2024-02-01 19:43:04 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2023 Igalia, S.L.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gst/vulkan/vulkan.h>
|
|
|
|
|
|
|
|
#define GST_TYPE_VULKAN_ENCODER (gst_vulkan_encoder_get_type())
|
|
|
|
#define GST_VULKAN_ENCODER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_ENCODER, GstVulkanEncoder))
|
|
|
|
#define GST_VULKAN_ENCODER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_ENCODER, GstVulkanEncoderClass))
|
|
|
|
#define GST_IS_VULKAN_ENCODER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_ENCODER))
|
|
|
|
#define GST_IS_VULKAN_ENCODER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_ENCODER))
|
|
|
|
#define GST_VULKAN_ENCODER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_ENCODER, GstVulkanEncoderClass))
|
|
|
|
GST_VULKAN_API
|
|
|
|
GType gst_vulkan_encoder_get_type (void);
|
|
|
|
|
2024-11-15 11:41:15 +00:00
|
|
|
#define GST_TYPE_VULKAN_ENCODER_RATE_CONTROL_MODE (gst_vulkan_encoder_rate_control_mode_get_type())
|
|
|
|
GST_VULKAN_API
|
|
|
|
GType gst_vulkan_encoder_rate_control_mode_get_type (void);
|
|
|
|
|
2024-02-01 19:43:04 +00:00
|
|
|
typedef struct _GstVulkanEncoder GstVulkanEncoder;
|
|
|
|
typedef struct _GstVulkanEncoderClass GstVulkanEncoderClass;
|
2024-09-19 14:43:09 +00:00
|
|
|
typedef struct _GstVulkanEncoderQualityPoperties GstVulkanEncoderQualityProperties;
|
2024-02-01 19:43:04 +00:00
|
|
|
typedef union _GstVulkanEncoderParameters GstVulkanEncoderParameters;
|
|
|
|
typedef union _GstVulkanEncoderParametersOverrides GstVulkanEncoderParametersOverrides;
|
|
|
|
typedef union _GstVulkanEncoderParametersFeedback GstVulkanEncoderParametersFeedback;
|
2024-11-27 09:51:38 +00:00
|
|
|
typedef struct _GstVulkanEncoderPicture GstVulkanEncoderPicture;
|
2024-11-08 10:44:40 +00:00
|
|
|
typedef struct _GstVulkaneEncoderCallbacks GstVulkanEncoderCallbacks;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVulkaneEncoderCallbacks:
|
|
|
|
* @setup_codec_pic: Called after VkVideoEncodeInfoKHR and
|
|
|
|
* VkVideoReferenceSlotInfoKHR are filled so they can be chained with the
|
|
|
|
* specific codec structures. Called in gst_vulkan_encoder_encode().
|
2024-11-08 17:05:55 +00:00
|
|
|
* @setup_rc_pic: Called after VkVideoEncodeRateControlInfoKHR and
|
|
|
|
* VkVideoEncodeRateControlLayerInfoKHR are filled so they can be chained
|
|
|
|
* with the specific codec structures. Called in
|
|
|
|
* gst_vulkan_encoder_encode().
|
2024-11-08 10:44:40 +00:00
|
|
|
*
|
|
|
|
* See gst_vulkan_encoder_set_callbacks()
|
|
|
|
*/
|
|
|
|
struct _GstVulkaneEncoderCallbacks
|
|
|
|
{
|
|
|
|
void (*setup_codec_pic) (GstVulkanEncoderPicture * pic,
|
|
|
|
VkVideoEncodeInfoKHR * info, gpointer data);
|
2024-11-08 17:05:55 +00:00
|
|
|
void (*setup_rc_pic) (GstVulkanEncoderPicture * pic,
|
|
|
|
VkVideoEncodeRateControlInfoKHR * info,
|
|
|
|
VkVideoEncodeRateControlLayerInfoKHR * layer, gpointer data);
|
2024-11-08 10:44:40 +00:00
|
|
|
};
|
2024-02-01 19:43:04 +00:00
|
|
|
|
|
|
|
/**
|
2024-11-27 09:51:38 +00:00
|
|
|
* GstVulkanEncoderPicture:
|
2024-02-01 19:43:04 +00:00
|
|
|
* @slotIndex: slot index
|
2024-11-26 19:10:15 +00:00
|
|
|
* @offset: headers offset
|
2024-02-01 19:43:04 +00:00
|
|
|
* @in_buffer: input buffer
|
|
|
|
* @out_buffer: output buffer
|
|
|
|
*
|
|
|
|
* It contains the whole state for encoding a single picture.
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
2024-11-27 09:51:38 +00:00
|
|
|
struct _GstVulkanEncoderPicture
|
2024-02-01 19:43:04 +00:00
|
|
|
{
|
2024-11-26 19:10:15 +00:00
|
|
|
guint64 offset;
|
2024-02-01 19:43:04 +00:00
|
|
|
|
|
|
|
GstBuffer *in_buffer;
|
|
|
|
GstBuffer *dpb_buffer;
|
|
|
|
GstBuffer *out_buffer;
|
|
|
|
|
|
|
|
/* Input frame */
|
|
|
|
GstVulkanImageView *img_view;
|
|
|
|
GstVulkanImageView *dpb_view;
|
|
|
|
|
|
|
|
VkVideoPictureResourceInfoKHR dpb;
|
2024-09-19 10:21:04 +00:00
|
|
|
VkVideoReferenceSlotInfoKHR dpb_slot;
|
2024-02-01 19:43:04 +00:00
|
|
|
|
2024-09-06 09:22:54 +00:00
|
|
|
gpointer codec_rc_info;
|
2024-02-01 19:43:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVulkanEncoder:
|
|
|
|
* @parent: the parent #GstObject
|
|
|
|
* @queue: the #GstVulkanQueue to command buffers will be allocated from
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
**/
|
|
|
|
struct _GstVulkanEncoder
|
|
|
|
{
|
|
|
|
GstObject parent;
|
|
|
|
|
|
|
|
GstVulkanQueue *queue;
|
|
|
|
|
|
|
|
guint codec;
|
|
|
|
|
|
|
|
/* <private> */
|
|
|
|
gpointer _reserved [GST_PADDING];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVulkanEncoderClass:
|
|
|
|
* @parent_class: the parent #GstObjectClass
|
|
|
|
*
|
|
|
|
* Since: 1.24
|
|
|
|
*/
|
|
|
|
struct _GstVulkanEncoderClass
|
|
|
|
{
|
|
|
|
GstObjectClass parent;
|
|
|
|
/* <private> */
|
|
|
|
gpointer _reserved [GST_PADDING];
|
|
|
|
};
|
|
|
|
|
|
|
|
union _GstVulkanEncoderParameters
|
|
|
|
{
|
|
|
|
/*< private >*/
|
|
|
|
VkVideoEncodeH264SessionParametersCreateInfoKHR h264;
|
|
|
|
VkVideoEncodeH265SessionParametersCreateInfoKHR h265;
|
|
|
|
};
|
|
|
|
|
|
|
|
union _GstVulkanEncoderParametersOverrides
|
|
|
|
{
|
|
|
|
/*< private >*/
|
|
|
|
VkVideoEncodeH264SessionParametersGetInfoKHR h264;
|
|
|
|
VkVideoEncodeH265SessionParametersGetInfoKHR h265;
|
|
|
|
};
|
|
|
|
|
|
|
|
union _GstVulkanEncoderParametersFeedback
|
|
|
|
{
|
|
|
|
VkVideoEncodeH264SessionParametersFeedbackInfoKHR h264;
|
|
|
|
VkVideoEncodeH265SessionParametersFeedbackInfoKHR h265;
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:43:09 +00:00
|
|
|
struct _GstVulkanEncoderQualityPoperties
|
|
|
|
{
|
|
|
|
gint32 quality_level;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
VkVideoEncodeH264QualityLevelPropertiesKHR h264;
|
|
|
|
VkVideoEncodeH265QualityLevelPropertiesKHR h265;
|
|
|
|
} codec;
|
|
|
|
};
|
|
|
|
|
2024-02-01 19:43:04 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanEncoder, gst_object_unref)
|
|
|
|
|
|
|
|
GST_VULKAN_API
|
|
|
|
GstVulkanEncoder * gst_vulkan_encoder_create_from_queue (GstVulkanQueue * queue,
|
|
|
|
guint codec);
|
|
|
|
|
2024-11-08 10:44:40 +00:00
|
|
|
GST_VULKAN_API
|
|
|
|
void gst_vulkan_encoder_set_callbacks (GstVulkanEncoder * self,
|
|
|
|
GstVulkanEncoderCallbacks * callbacks,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify);
|
2024-11-08 17:05:55 +00:00
|
|
|
GST_VULKAN_API
|
|
|
|
void gst_vulkan_encoder_set_rc_mode (GstVulkanEncoder * self,
|
|
|
|
VkVideoEncodeRateControlModeFlagBitsKHR rc_mode);
|
2024-11-08 10:44:40 +00:00
|
|
|
|
2024-02-01 19:43:04 +00:00
|
|
|
GST_VULKAN_API
|
|
|
|
gboolean gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
|
|
|
GstVulkanVideoProfile * profile,
|
2024-09-19 14:43:09 +00:00
|
|
|
GstVulkanEncoderQualityProperties * codec_quality_props,
|
2024-02-01 19:43:04 +00:00
|
|
|
GError ** error);
|
|
|
|
GST_VULKAN_API
|
|
|
|
gboolean gst_vulkan_encoder_stop (GstVulkanEncoder * self);
|
|
|
|
GST_VULKAN_API
|
|
|
|
gboolean gst_vulkan_encoder_update_video_session_parameters
|
|
|
|
(GstVulkanEncoder * self,
|
|
|
|
GstVulkanEncoderParameters *enc_params,
|
|
|
|
GError ** error);
|
|
|
|
GST_VULKAN_API
|
|
|
|
gboolean gst_vulkan_encoder_video_session_parameters_overrides
|
|
|
|
(GstVulkanEncoder * self,
|
|
|
|
GstVulkanEncoderParametersOverrides * params,
|
|
|
|
GstVulkanEncoderParametersFeedback * feedback,
|
|
|
|
gsize * data_size,
|
|
|
|
gpointer * data,
|
|
|
|
GError ** error);
|
|
|
|
GST_VULKAN_API
|
|
|
|
gboolean gst_vulkan_encoder_create_dpb_pool (GstVulkanEncoder * self,
|
|
|
|
GstCaps * caps);
|
|
|
|
GST_VULKAN_API
|
|
|
|
gboolean gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
2024-09-04 12:14:04 +00:00
|
|
|
GstVideoInfo * info,
|
2024-11-27 09:51:38 +00:00
|
|
|
GstVulkanEncoderPicture * pic,
|
2024-09-04 11:17:01 +00:00
|
|
|
guint nb_refs,
|
2024-11-27 09:51:38 +00:00
|
|
|
GstVulkanEncoderPicture ** ref_pics);
|
2024-02-01 19:43:04 +00:00
|
|
|
GST_VULKAN_API
|
2024-08-12 14:57:59 +00:00
|
|
|
gboolean gst_vulkan_encoder_caps (GstVulkanEncoder * self,
|
2024-02-01 19:43:04 +00:00
|
|
|
GstVulkanVideoCapabilities * caps);
|
|
|
|
GST_VULKAN_API
|
2024-08-20 18:43:42 +00:00
|
|
|
gboolean gst_vulkan_encoder_is_started (GstVulkanEncoder * self);
|
|
|
|
GST_VULKAN_API
|
2024-02-01 19:43:04 +00:00
|
|
|
GstCaps * gst_vulkan_encoder_profile_caps (GstVulkanEncoder * self);
|
2024-09-19 14:43:09 +00:00
|
|
|
GST_VULKAN_API
|
|
|
|
gint32 gst_vulkan_encoder_quality_level (GstVulkanEncoder * self);
|
|
|
|
|
2024-02-01 19:43:04 +00:00
|
|
|
GST_VULKAN_API
|
2024-09-06 09:23:40 +00:00
|
|
|
gboolean gst_vulkan_encoder_picture_init (GstVulkanEncoderPicture * pic,
|
|
|
|
GstVulkanEncoder * self,
|
2024-02-01 19:43:04 +00:00
|
|
|
GstBuffer * in_buffer,
|
2024-09-04 11:17:01 +00:00
|
|
|
gsize size);
|
2024-02-01 19:43:04 +00:00
|
|
|
GST_VULKAN_API
|
2024-09-19 11:28:15 +00:00
|
|
|
void gst_vulkan_encoder_picture_clear (GstVulkanEncoderPicture * pic,
|
|
|
|
GstVulkanEncoder * self);
|