2022-03-25 13:48:05 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2022 Intel Corporation
|
|
|
|
* Author: He Junyan <junyan.he@intel.com>
|
|
|
|
*
|
|
|
|
* 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 the0
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "gstvadevice.h"
|
|
|
|
#include "gstvaencoder.h"
|
|
|
|
#include "gstvaprofile.h"
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GST_TYPE_VA_BASE_ENC (gst_va_base_enc_get_type())
|
|
|
|
#define GST_VA_BASE_ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VA_BASE_ENC, GstVaBaseEnc))
|
|
|
|
#define GST_IS_VA_BASE_ENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VA_BASE_ENC))
|
|
|
|
#define GST_VA_BASE_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VA_BASE_ENC, GstVaBaseEncClass))
|
|
|
|
#define GST_IS_VA_BASE_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VA_BASE_ENC))
|
|
|
|
#define GST_VA_BASE_ENC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VA_BASE_ENC, GstVaBaseEncClass))
|
|
|
|
|
2022-09-20 13:00:15 +00:00
|
|
|
#define GST_VA_BASE_ENC_ENTRYPOINT(obj) (GST_VA_BASE_ENC_GET_CLASS(obj)->entrypoint)
|
|
|
|
|
2022-03-25 13:48:05 +00:00
|
|
|
typedef struct _GstVaBaseEnc GstVaBaseEnc;
|
|
|
|
typedef struct _GstVaBaseEncClass GstVaBaseEncClass;
|
|
|
|
typedef struct _GstVaBaseEncPrivate GstVaBaseEncPrivate;
|
|
|
|
|
|
|
|
struct _GstVaBaseEnc
|
|
|
|
{
|
|
|
|
GstVideoEncoder parent_instance;
|
|
|
|
|
|
|
|
GstVaDisplay *display;
|
|
|
|
GstVaEncoder *encoder;
|
|
|
|
|
2022-10-20 09:13:19 +00:00
|
|
|
gboolean reconf;
|
|
|
|
|
2022-03-25 13:48:05 +00:00
|
|
|
VAProfile profile;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
guint rt_format;
|
|
|
|
guint codedbuf_size;
|
|
|
|
|
|
|
|
GstClockTime start_pts;
|
|
|
|
GstClockTime frame_duration;
|
|
|
|
/* Total frames we handled since reconfig. */
|
|
|
|
guint input_frame_count;
|
|
|
|
guint output_frame_count;
|
|
|
|
|
|
|
|
GQueue reorder_list;
|
|
|
|
GQueue ref_list;
|
|
|
|
GQueue output_list;
|
|
|
|
|
|
|
|
GstVideoCodecState *input_state;
|
|
|
|
|
|
|
|
/*< private >*/
|
|
|
|
GstVaBaseEncPrivate *priv;
|
|
|
|
|
|
|
|
gpointer _padding[GST_PADDING];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstVaBaseEncClass
|
|
|
|
{
|
|
|
|
GstVideoEncoderClass parent_class;
|
|
|
|
|
2022-05-25 11:57:18 +00:00
|
|
|
void (*reset_state) (GstVaBaseEnc * encoder);
|
2022-03-25 13:48:05 +00:00
|
|
|
gboolean (*reconfig) (GstVaBaseEnc * encoder);
|
|
|
|
gboolean (*new_frame) (GstVaBaseEnc * encoder,
|
|
|
|
GstVideoCodecFrame * frame);
|
|
|
|
gboolean (*reorder_frame) (GstVaBaseEnc * base,
|
|
|
|
GstVideoCodecFrame * frame,
|
|
|
|
gboolean bump_all,
|
|
|
|
GstVideoCodecFrame ** out_frame);
|
|
|
|
gboolean (*encode_frame) (GstVaBaseEnc * encoder,
|
|
|
|
GstVideoCodecFrame * frame,
|
|
|
|
gboolean is_last);
|
|
|
|
void (*prepare_output) (GstVaBaseEnc * encoder,
|
|
|
|
GstVideoCodecFrame * frame);
|
|
|
|
|
|
|
|
GstVaCodecs codec;
|
2022-05-23 12:58:47 +00:00
|
|
|
VAEntrypoint entrypoint;
|
2022-03-25 13:48:05 +00:00
|
|
|
gchar *render_device_path;
|
|
|
|
|
|
|
|
gpointer _padding[GST_PADDING];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CData
|
|
|
|
{
|
2022-05-23 12:58:47 +00:00
|
|
|
VAEntrypoint entrypoint;
|
2022-03-25 13:48:05 +00:00
|
|
|
gchar *render_device_path;
|
|
|
|
gchar *description;
|
|
|
|
GstCaps *sink_caps;
|
|
|
|
GstCaps *src_caps;
|
|
|
|
};
|
|
|
|
|
2022-08-04 10:00:58 +00:00
|
|
|
GType gst_va_base_enc_get_type (void);
|
2022-03-25 13:48:05 +00:00
|
|
|
|
|
|
|
gboolean gst_va_base_enc_add_rate_control_parameter (GstVaBaseEnc * base,
|
|
|
|
GstVaEncodePicture * picture,
|
|
|
|
guint32 rc_mode,
|
|
|
|
guint max_bitrate_bits,
|
|
|
|
guint target_percentage,
|
|
|
|
guint32 qp_i,
|
|
|
|
guint32 min_qp,
|
|
|
|
guint32 max_qp,
|
|
|
|
guint32 mbbrc);
|
|
|
|
gboolean gst_va_base_enc_add_quality_level_parameter (GstVaBaseEnc * base,
|
|
|
|
GstVaEncodePicture * picture,
|
2022-08-04 10:00:58 +00:00
|
|
|
guint target_usage);
|
2022-03-25 13:48:05 +00:00
|
|
|
gboolean gst_va_base_enc_add_frame_rate_parameter (GstVaBaseEnc * base,
|
|
|
|
GstVaEncodePicture * picture);
|
2022-08-04 10:00:58 +00:00
|
|
|
gboolean gst_va_base_enc_add_hrd_parameter (GstVaBaseEnc * base,
|
|
|
|
GstVaEncodePicture * picture,
|
|
|
|
guint32 rc_mode,
|
|
|
|
guint cpb_length_bits);
|
2022-03-25 13:48:05 +00:00
|
|
|
gboolean gst_va_base_enc_add_trellis_parameter (GstVaBaseEnc * base,
|
|
|
|
GstVaEncodePicture * picture,
|
|
|
|
gboolean use_trellis);
|
2022-08-04 10:00:58 +00:00
|
|
|
void gst_va_base_enc_add_codec_tag (GstVaBaseEnc * base,
|
|
|
|
const gchar * codec_name);
|
2022-09-16 10:50:33 +00:00
|
|
|
void gst_va_base_enc_reset_state (GstVaBaseEnc * base);
|
2022-03-25 13:48:05 +00:00
|
|
|
|
2022-08-03 15:52:25 +00:00
|
|
|
void gst_va_base_enc_update_property_uint (GstVaBaseEnc * base,
|
|
|
|
guint32 * old_val,
|
|
|
|
guint32 new_val,
|
|
|
|
GParamSpec * pspec);
|
|
|
|
void gst_va_base_enc_update_property_bool (GstVaBaseEnc * base,
|
|
|
|
gboolean * old_val,
|
|
|
|
gboolean new_val,
|
|
|
|
GParamSpec * pspec);
|
|
|
|
|
2022-03-25 13:48:05 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaBaseEnc, gst_object_unref)
|
|
|
|
|
|
|
|
G_END_DECLS
|