va: Refactor _format_changed() to _config_is_equal().
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sat, 17 Jul 2021 18:45:48 +0000 (20:45 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sat, 17 Jul 2021 18:51:29 +0000 (20:51 +0200)
Change gst_va_decoder_format_changed() to
gst_va_decoder_config_is_equal(), which is more similar with other
GStreamer API.

The function call is replaced but it has to be negated because the
return value is the opposite.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2417>

sys/va/gstvaav1dec.c
sys/va/gstvadecoder.c
sys/va/gstvadecoder.h
sys/va/gstvah264dec.c
sys/va/gstvah265dec.c
sys/va/gstvampeg2dec.c
sys/va/gstvavp8dec.c
sys/va/gstvavp9dec.c

index 8afd91c..5b02cbc 100644 (file)
@@ -103,7 +103,7 @@ gst_va_av1_dec_negotiate (GstVideoDecoder * decoder)
   self->need_negotiation = FALSE;
 
   /* Do not re-create the context if only the frame size changes */
-  if (gst_va_decoder_format_changed (base->decoder, base->profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, base->profile,
           base->rt_format, self->max_width, self->max_height)) {
     if (gst_va_decoder_is_open (base->decoder)
         && !gst_va_decoder_close (base->decoder))
@@ -265,7 +265,7 @@ gst_va_av1_dec_new_sequence (GstAV1Decoder * decoder,
 
   self->seq = *seq_hdr;
 
-  if (gst_va_decoder_format_changed (base->decoder, profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, profile,
           rt_format, seq_hdr->max_frame_width_minus_1 + 1,
           seq_hdr->max_frame_height_minus_1 + 1)) {
     base->profile = profile;
index 44d4e6d..0f97232 100644 (file)
@@ -698,6 +698,24 @@ gst_va_decoder_decode (GstVaDecoder * self, GstVaDecodePicture * pic)
   return gst_va_decoder_decode_with_aux_surface (self, pic, FALSE);
 }
 
+gboolean
+gst_va_decoder_config_is_equal (GstVaDecoder * self, VAProfile new_profile,
+    guint new_rtformat, gint new_width, gint new_height)
+{
+  gboolean ret;
+
+  g_return_val_if_fail (GST_IS_VA_DECODER (self), FALSE);
+
+  /* @TODO: Check if current buffers are large enough, and reuse
+   * them */
+  GST_OBJECT_LOCK (self);
+  ret = (self->profile == new_profile && self->rt_format == new_rtformat
+      && self->coded_width == new_width && self->coded_height == new_height);
+  GST_OBJECT_UNLOCK (self);
+
+  return ret;
+}
+
 static gboolean
 _destroy_buffers (GstVaDecodePicture * pic)
 {
@@ -808,17 +826,6 @@ gst_va_decode_picture_dup (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);
-}
-
-gboolean
 gst_va_decoder_get_config (GstVaDecoder * decoder, VAProfile * profile,
     guint * rt_format, gint * width, gint * height)
 {
index 60bb63d..204721c 100644 (file)
@@ -86,6 +86,11 @@ gboolean              gst_va_decoder_decode               (GstVaDecoder * self,
 gboolean              gst_va_decoder_decode_with_aux_surface (GstVaDecoder * self,
                                                               GstVaDecodePicture * pic,
                                                               gboolean use_aux);
+gboolean              gst_va_decoder_config_is_equal      (GstVaDecoder * decoder,
+                                                           VAProfile new_profile,
+                                                           guint new_rtformat,
+                                                           gint new_width,
+                                                           gint new_height);
 
 GstVaDecodePicture *  gst_va_decode_picture_new           (GstVaDecoder * self,
                                                            GstBuffer * buffer);
@@ -94,11 +99,6 @@ VASurfaceID           gst_va_decode_picture_get_aux_surface (GstVaDecodePicture
 void                  gst_va_decode_picture_free          (GstVaDecodePicture * pic);
 GstVaDecodePicture *  gst_va_decode_picture_dup           (GstVaDecodePicture * pic);
 
-gboolean              gst_va_decoder_format_changed       (GstVaDecoder * decoder,
-                                                           VAProfile new_profile,
-                                                           guint new_rtformat,
-                                                           gint new_width,
-                                                           gint new_height);
 gboolean              gst_va_decoder_get_config           (GstVaDecoder * decoder,
                                                            VAProfile * profile,
                                                            guint * rt_format,
index bb4b2c7..4f1d08c 100644 (file)
@@ -673,7 +673,7 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
   if (rt_format == 0)
     return FALSE;
 
-  if (gst_va_decoder_format_changed (base->decoder, profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, profile,
           rt_format, sps->width, sps->height)) {
     base->profile = profile;
     base->rt_format = rt_format;
index 63f50be..304f4fd 100644 (file)
@@ -1053,7 +1053,7 @@ gst_va_h265_dec_new_sequence (GstH265Decoder * decoder, const GstH265SPS * sps,
   if (rt_format == 0)
     return FALSE;
 
-  if (gst_va_decoder_format_changed (base->decoder, profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, profile,
           rt_format, sps->width, sps->height)) {
     base->profile = profile;
     base->rt_format = rt_format;
index 6fe0169..c282c25 100644 (file)
@@ -252,7 +252,7 @@ gst_va_mpeg2_dec_new_sequence (GstMpeg2Decoder * decoder,
   if (rt_format == 0)
     return FALSE;
 
-  if (gst_va_decoder_format_changed (base->decoder, profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, profile,
           rt_format, width, height)) {
     base->profile = profile;
     base->rt_format = rt_format;
index d9b266b..c3a6394 100644 (file)
@@ -165,7 +165,7 @@ gst_va_vp8_dec_new_sequence (GstVp8Decoder * decoder,
   /* VP8 always use 8 bits 4:2:0 */
   rt_format = VA_RT_FORMAT_YUV420;
 
-  if (gst_va_decoder_format_changed (base->decoder, profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, profile,
           rt_format, frame_hdr->width, frame_hdr->height)) {
     base->profile = profile;
     base->width = frame_hdr->width;
index dcecd8d..0340e1e 100644 (file)
@@ -166,7 +166,7 @@ gst_va_vp9_new_sequence (GstVp9Decoder * decoder,
   if (rt_format == 0)
     return FALSE;
 
-  if (gst_va_decoder_format_changed (base->decoder, profile,
+  if (!gst_va_decoder_config_is_equal (base->decoder, profile,
           rt_format, frame_hdr->width, frame_hdr->height)) {
     base->profile = profile;
     base->width = frame_hdr->width;