Commit ea8b372c authored by Víctor Manuel Jáquez Leal's avatar Víctor Manuel Jáquez Leal
Browse files

va: Refactor _format_changed() to _config_is_equal().

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: <!2417>
parent d2d7ce71
......@@ -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;
......
......@@ -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)
......
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment