va: util: make the _format_changed a common decoder function.
authorHe Junyan <junyan.he@intel.com>
Mon, 21 Sep 2020 04:51:53 +0000 (12:51 +0800)
committerHe Junyan <junyan.he@intel.com>
Fri, 25 Sep 2020 09:07:05 +0000 (17:07 +0800)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1587>

sys/va/gstvadecoder.c
sys/va/gstvadecoder.h
sys/va/gstvah264dec.c
sys/va/gstvautils.h

index 8e17fde..4d5e6b0 100644 (file)
@@ -731,3 +731,14 @@ gst_va_decode_picture_free (GstVaDecodePicture * pic)
 
   g_slice_free (GstVaDecodePicture, pic);
 }
+
+gboolean
+gst_va_decoder_format_changed (GstVaDecoder * decoder, VAProfile new_profile,
+    guint new_rtformat, gint new_width, gint new_height)
+{
+  /* @TODO: Check if current buffers are large enough, and reuse
+   * them */
+  return !(decoder->profile == new_profile &&
+      decoder->rt_format == new_rtformat &&
+      decoder->coded_width == new_width && decoder->coded_height == new_height);
+}
index 53ed36b..6829689 100644 (file)
@@ -73,4 +73,10 @@ GstVaDecodePicture *  gst_va_decode_picture_new           (GstBuffer * buffer);
 VASurfaceID           gst_va_decode_picture_get_surface   (GstVaDecodePicture * pic);
 void                  gst_va_decode_picture_free          (GstVaDecodePicture * pic);
 
+gboolean              gst_va_decoder_format_changed       (GstVaDecoder * decoder,
+                                                           VAProfile new_profile,
+                                                           guint new_rtformat,
+                                                           gint new_width,
+                                                           gint new_height);
+
 G_END_DECLS
index f148214..3b15104 100644 (file)
@@ -680,23 +680,6 @@ _get_profile (GstVaH264Dec * self, const GstH264SPS * sps, gint max_dpb_size)
 }
 
 static gboolean
-_format_changed (GstVaH264Dec * self, VAProfile new_profile, guint new_rtformat,
-    gint new_width, gint new_height)
-{
-  VAProfile profile = VAProfileNone;
-  guint rt_format = VA_RT_FORMAT_YUV420;
-  gint width = 0, height = 0;
-
-  g_object_get (self->decoder, "va-profile", &profile, "va-rt-format",
-      &rt_format, "coded-width", &width, "coded-height", &height, NULL);
-
-  /* @TODO: Check if current buffers are large enough, and reuse
-   * them */
-  return !(profile == new_profile && rt_format == new_rtformat
-      && width == new_width && height == new_height);
-}
-
-static gboolean
 gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
     gint max_dpb_size)
 {
@@ -727,7 +710,8 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
   if (rt_format == 0)
     return FALSE;
 
-  if (_format_changed (self, profile, rt_format, sps->width, sps->height)) {
+  if (gst_va_decoder_format_changed (self->decoder, profile,
+          rt_format, sps->width, sps->height)) {
     self->profile = profile;
     self->rt_format = rt_format;
     self->coded_width = sps->width;
index ed0dd47..7c6f114 100644 (file)
@@ -44,5 +44,4 @@ gboolean              gst_context_get_va_display          (GstContext * context,
 void                  gst_context_set_va_display          (GstContext * context,
                                                           GstVaDisplay * display);
 
-
 G_END_DECLS