va: encoder: change reset_state() to a virtual function of base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2489>
This commit is contained in:
He Junyan 2022-05-25 19:57:18 +08:00 committed by GStreamer Marge Bot
parent b91093a2e6
commit 994f2c56e2
3 changed files with 13 additions and 27 deletions

View file

@ -58,7 +58,7 @@ G_DEFINE_TYPE_WITH_CODE (GstVaBaseEnc, gst_va_base_enc,
"vabaseenc", 0, "vabaseenc element"););
/* *INDENT-ON* */
void
static void
gst_va_base_enc_reset_state (GstVaBaseEnc * base)
{
base->frame_duration = GST_CLOCK_TIME_NONE;
@ -118,6 +118,9 @@ static gboolean
gst_va_base_enc_start (GstVideoEncoder * venc)
{
GstVaBaseEnc *base = GST_VA_BASE_ENC (venc);
GstVaBaseEncClass *klass = GST_VA_BASE_ENC_GET_CLASS (base);
klass->reset_state (base);
base->input_state = NULL;
@ -891,6 +894,8 @@ gst_va_base_enc_class_init (GstVaBaseEncClass * klass)
encoder_class->finish = GST_DEBUG_FUNCPTR (gst_va_base_enc_finish);
encoder_class->flush = GST_DEBUG_FUNCPTR (gst_va_base_enc_flush);
klass->reset_state = GST_DEBUG_FUNCPTR (gst_va_base_enc_reset_state);
properties[PROP_DEVICE_PATH] = g_param_spec_string ("device-path",
"Device Path", "DRM device path", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);

View file

@ -73,6 +73,7 @@ struct _GstVaBaseEncClass
{
GstVideoEncoderClass parent_class;
void (*reset_state) (GstVaBaseEnc * encoder);
gboolean (*reconfig) (GstVaBaseEnc * encoder);
gboolean (*new_frame) (GstVaBaseEnc * encoder,
GstVideoCodecFrame * frame);
@ -101,7 +102,6 @@ struct CData
};
GType gst_va_base_enc_get_type (void);
void gst_va_base_enc_reset_state (GstVaBaseEnc * base);
gboolean gst_va_base_enc_add_rate_control_parameter (GstVaBaseEnc * base,
GstVaEncodePicture * picture,

View file

@ -1454,9 +1454,11 @@ out:
* property. The reconfig may change these fields because of the
* profile/level and HW limitation. */
static void
gst_va_h264_enc_reset_state (GstVaH264Enc * self)
gst_va_h264_enc_reset_state (GstVaBaseEnc * base)
{
gst_va_base_enc_reset_state (GST_VA_BASE_ENC (self));
GstVaH264Enc *self = GST_VA_H264_ENC (base);
GST_VA_BASE_ENC_CLASS (parent_class)->reset_state (base);
self->level_idc = 0;
self->level_str = NULL;
@ -1515,7 +1517,7 @@ gst_va_h264_enc_reconfig (GstVaBaseEnc * base)
guint max_ref_frames;
GstVideoCodecState *output_state;
gst_va_h264_enc_reset_state (self);
gst_va_h264_enc_reset_state (base);
base->width = GST_VIDEO_INFO_WIDTH (&base->input_state->info);
base->height = GST_VIDEO_INFO_HEIGHT (&base->input_state->info);
@ -2828,26 +2830,6 @@ _encode_one_frame (GstVaH264Enc * self, GstVideoCodecFrame * gst_frame)
return TRUE;
}
static gboolean
gst_va_h264_enc_start (GstVideoEncoder * venc)
{
GstVaH264Enc *self = GST_VA_H264_ENC (venc);
gst_va_h264_enc_reset_state (self);
return GST_VIDEO_ENCODER_CLASS (parent_class)->start (venc);
}
static gboolean
gst_va_h264_enc_stop (GstVideoEncoder * venc)
{
GstVaH264Enc *self = GST_VA_H264_ENC (venc);
gst_va_h264_enc_reset_state (self);
return GST_VIDEO_ENCODER_CLASS (parent_class)->stop (venc);
}
static gboolean
gst_va_h264_enc_flush (GstVideoEncoder * venc)
{
@ -3294,10 +3276,9 @@ gst_va_h264_enc_class_init (gpointer g_klass, gpointer class_data)
object_class->set_property = gst_va_h264_enc_set_property;
object_class->get_property = gst_va_h264_enc_get_property;
venc_class->start = GST_DEBUG_FUNCPTR (gst_va_h264_enc_start);
venc_class->stop = GST_DEBUG_FUNCPTR (gst_va_h264_enc_stop);
venc_class->flush = GST_DEBUG_FUNCPTR (gst_va_h264_enc_flush);
va_enc_class->reset_state = GST_DEBUG_FUNCPTR (gst_va_h264_enc_reset_state);
va_enc_class->reconfig = GST_DEBUG_FUNCPTR (gst_va_h264_enc_reconfig);
va_enc_class->new_frame = GST_DEBUG_FUNCPTR (gst_va_h264_enc_new_frame);
va_enc_class->reorder_frame =