From 97e3f88c2083182ae176f51056c05930c9fc4eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 26 Oct 2021 09:28:10 +0200 Subject: [PATCH] va: Move common variable need_negotiation to GstBaseDec. This is a common variable to all decoders, so it's sound to move it to the base helper. Part-of: --- subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c | 12 +++++------- subprojects/gst-plugins-bad/sys/va/gstvabasedec.h | 2 ++ subprojects/gst-plugins-bad/sys/va/gstvah264dec.c | 7 +++---- subprojects/gst-plugins-bad/sys/va/gstvah265dec.c | 8 +++----- subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c | 8 +++----- subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c | 8 +++----- subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c | 10 ++++------ 7 files changed, 23 insertions(+), 32 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c index 790c69cfa1..a3dc527eff 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c @@ -76,8 +76,6 @@ struct _GstVaAV1Dec GstAV1SequenceHeaderOBU seq; gint max_width; gint max_height; - - gboolean need_negotiation; }; static GstElementClass *parent_class = NULL; @@ -101,10 +99,10 @@ gst_va_av1_dec_negotiate (GstVideoDecoder * decoder) GstCapsFeatures *capsfeatures = NULL; /* Ignore downstream renegotiation request. */ - if (!self->need_negotiation) + if (!base->need_negotiation) return TRUE; - self->need_negotiation = FALSE; + base->need_negotiation = FALSE; /* Do not re-create the context if only the frame size changes */ if (!gst_va_decoder_config_is_equal (base->decoder, base->profile, @@ -275,7 +273,7 @@ gst_va_av1_dec_new_sequence (GstAV1Decoder * decoder, base->rt_format = rt_format; self->max_width = seq_hdr->max_frame_width_minus_1 + 1; self->max_height = seq_hdr->max_frame_height_minus_1 + 1; - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; base->min_buffers = 7 + 4; /* dpb size + scratch surfaces */ @@ -313,10 +311,10 @@ gst_va_av1_dec_new_picture (GstAV1Decoder * decoder, /* *INDENT-ON* */ } - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; } - if (self->need_negotiation) { + if (base->need_negotiation) { if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); return GST_FLOW_NOT_NEGOTIATED; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h index 4d855cb3f3..8e84e5c6c8 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h @@ -76,6 +76,8 @@ struct _GstVaBaseDec gboolean apply_video_crop; GstVideoConverter *convert; + + gboolean need_negotiation; }; struct _GstVaBaseDecClass diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c index a41bdd3900..617aabc5e3 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264dec.c @@ -84,7 +84,6 @@ struct _GstVaH264Dec /* Used to fill VAPictureParameterBufferH264.ReferenceFrames */ GArray *ref_list; - gboolean need_negotiation; gboolean interlaced; }; @@ -748,7 +747,7 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps, base->min_buffers = self->dpb_size + 4; /* dpb size + scratch surfaces */ if (negotiation_needed) { - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); return GST_FLOW_NOT_NEGOTIATED; @@ -824,10 +823,10 @@ gst_va_h264_dec_negotiate (GstVideoDecoder * decoder) GstH264Decoder *h264dec = GST_H264_DECODER (decoder); /* Ignore downstream renegotiation request. */ - if (!self->need_negotiation) + if (!base->need_negotiation) return TRUE; - self->need_negotiation = FALSE; + base->need_negotiation = FALSE; if (gst_va_decoder_is_open (base->decoder) && !gst_va_decoder_close (base->decoder)) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c b/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c index cecc512a6a..8f0c7edc1c 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah265dec.c @@ -99,8 +99,6 @@ struct _GstVaH265Dec gint32 WpOffsetHalfRangeC; struct slice prev_slice; - - gboolean need_negotiation; }; static GstElementClass *parent_class = NULL; @@ -1121,7 +1119,7 @@ gst_va_h265_dec_new_sequence (GstH265Decoder * decoder, const GstH265SPS * sps, base->min_buffers = self->dpb_size + 4; /* dpb size + scratch surfaces */ if (negotiation_needed) { - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); return GST_FLOW_NOT_NEGOTIATED; @@ -1208,10 +1206,10 @@ gst_va_h265_dec_negotiate (GstVideoDecoder * decoder) GstH265Decoder *h265dec = GST_H265_DECODER (decoder); /* Ignore downstream renegotiation request. */ - if (!self->need_negotiation) + if (!base->need_negotiation) return TRUE; - self->need_negotiation = FALSE; + base->need_negotiation = FALSE; if (gst_va_decoder_is_open (base->decoder) && !gst_va_decoder_close (base->decoder)) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c index 16c5e560d8..78e6d9007e 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c @@ -71,8 +71,6 @@ struct _GstVaMpeg2Dec GstVaBaseDec parent; gboolean progressive; - gboolean need_negotiation; - GstMpegVideoSequenceHdr seq; }; @@ -97,10 +95,10 @@ gst_va_mpeg2_dec_negotiate (GstVideoDecoder * decoder) GstMpeg2Decoder *mpeg2dec = GST_MPEG2_DECODER (decoder); /* Ignore downstream renegotiation request. */ - if (!self->need_negotiation) + if (!base->need_negotiation) return TRUE; - self->need_negotiation = FALSE; + base->need_negotiation = FALSE; if (gst_va_decoder_is_open (base->decoder) && !gst_va_decoder_close (base->decoder)) @@ -281,7 +279,7 @@ gst_va_mpeg2_dec_new_sequence (GstMpeg2Decoder * decoder, base->min_buffers = 2 + 4; /* max num pic references + scratch surfaces */ if (negotiation_needed) { - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); return GST_FLOW_NOT_NEGOTIATED; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c b/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c index a23d101e51..2df289c47a 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c @@ -71,8 +71,6 @@ struct _GstVaVp8Dec GstVaBaseDec parent; GstFlowReturn last_ret; - - gboolean need_negotiation; }; static GstElementClass *parent_class = NULL; @@ -96,10 +94,10 @@ gst_va_vp8_dec_negotiate (GstVideoDecoder * decoder) GstVp8Decoder *vp8dec = GST_VP8_DECODER (decoder); /* Ignore downstream renegotiation request. */ - if (!self->need_negotiation) + if (!base->need_negotiation) return TRUE; - self->need_negotiation = FALSE; + base->need_negotiation = FALSE; if (gst_va_decoder_is_open (base->decoder) && !gst_va_decoder_close (base->decoder)) @@ -180,7 +178,7 @@ gst_va_vp8_dec_new_sequence (GstVp8Decoder * decoder, base->min_buffers = 3 + 4; /* max num pic references + scratch surfaces */ if (negotiation_needed) { - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); return GST_FLOW_NOT_NEGOTIATED; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c b/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c index be88f2816f..f713382aae 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c @@ -70,8 +70,6 @@ struct _GstVaVp9Dec { GstVaBaseDec parent; GstVp9Segmentation segmentation[GST_VP9_MAX_SEGMENTS]; - - gboolean need_negotiation; }; static GstElementClass *parent_class = NULL; @@ -182,7 +180,7 @@ gst_va_vp9_new_sequence (GstVp9Decoder * decoder, base->min_buffers = GST_VP9_REF_FRAMES; if (negotiation_needed) { - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Failed to negotiate with downstream"); return GST_FLOW_NOT_NEGOTIATED; @@ -202,7 +200,7 @@ _check_resolution_change (GstVaVp9Dec * self, GstVp9Picture * picture) base->width = frame_hdr->width; base->height = frame_hdr->height; - self->need_negotiation = TRUE; + base->need_negotiation = TRUE; if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) { GST_ERROR_OBJECT (self, "Resolution changed, but failed to" " negotiate with downstream"); @@ -555,10 +553,10 @@ gst_va_vp9_dec_negotiate (GstVideoDecoder * decoder) gboolean need_open; /* Ignore downstream renegotiation request. */ - if (!self->need_negotiation) + if (!base->need_negotiation) return TRUE; - self->need_negotiation = FALSE; + base->need_negotiation = FALSE; need_open = TRUE; /* VP9 profile entry should have the ability to handle dynamical