From 410938a0693d53e55022f4905e38eeabd2625801 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Mon, 21 Sep 2020 12:51:53 +0800 Subject: [PATCH] va: util: make the _format_changed a common decoder function. Part-of: --- sys/va/gstvadecoder.c | 11 +++++++++++ sys/va/gstvadecoder.h | 6 ++++++ sys/va/gstvah264dec.c | 20 ++------------------ sys/va/gstvautils.h | 1 - 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/va/gstvadecoder.c b/sys/va/gstvadecoder.c index 8e17fde..4d5e6b0 100644 --- a/sys/va/gstvadecoder.c +++ b/sys/va/gstvadecoder.c @@ -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); +} diff --git a/sys/va/gstvadecoder.h b/sys/va/gstvadecoder.h index 53ed36b..6829689 100644 --- a/sys/va/gstvadecoder.h +++ b/sys/va/gstvadecoder.h @@ -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 diff --git a/sys/va/gstvah264dec.c b/sys/va/gstvah264dec.c index f148214..3b15104 100644 --- a/sys/va/gstvah264dec.c +++ b/sys/va/gstvah264dec.c @@ -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; diff --git a/sys/va/gstvautils.h b/sys/va/gstvautils.h index ed0dd47..7c6f114 100644 --- a/sys/va/gstvautils.h +++ b/sys/va/gstvautils.h @@ -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 -- 2.7.4