va: encoder: change reset_state() to a virtual function of base class.
authorHe Junyan <junyan.he@intel.com>
Wed, 25 May 2022 11:57:18 +0000 (19:57 +0800)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 25 May 2022 18:56:34 +0000 (18:56 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2489>

subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c
subprojects/gst-plugins-bad/sys/va/gstvabaseenc.h
subprojects/gst-plugins-bad/sys/va/gstvah264enc.c

index 09a949c..45f5909 100644 (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);
index e88446d..dd422ed 100644 (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,
index 9f3d4a4..35f3dca 100644 (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);
@@ -2829,26 +2831,6 @@ _encode_one_frame (GstVaH264Enc * self, GstVideoCodecFrame * gst_frame)
 }
 
 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)
 {
   GstVaH264Enc *self = GST_VA_H264_ENC (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 =