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 8afd91c70a81722371b2b8715379ffad0394df1a..5b02cbc488f4e6e20ef534f4bd249e0a6a5fb430 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 44d4e6dbfa1b2c5960034b64380b25a9348e4dd7..0f9723252088c9598ef7f2531b11b304ead1f9e6 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)
 {
@@ -807,17 +825,6 @@ gst_va_decode_picture_dup (GstVaDecodePicture * pic)
   return dup;
 }
 
-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 60bb63d0c2dc2d9e837b2fb2c83d901308f0f924..204721cd7ac33e9103c337d847a04a7c18fb4c00 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 bb4b2c77a3f1533127dc5b235c8401cc98b3685d..4f1d08c9db011e1b0bf7b9cb9aadb8937fee1058 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 63f50be6a1bbbf23029fd26d894f5343d3ff7b59..304f4fd5f61f3d802a92b7c41b7f6031ecbb94f7 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 6fe0169f03446aea2b824dcb8022704dabd6ac33..c282c25894cd8a3a713211cc1473ddde08d9e599 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 d9b266b6599ed4cb75be95856683b9396b8db39f..c3a63942441d6c1670d19e320256a15edcb433ec 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 dcecd8daedea7744980982bbc7c3582fa772d250..0340e1e4de6a13d05bfcdf9e919c03b7694ffe73 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;