va: util: make the _format_changed a common decoder function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1587>
This commit is contained in:
He Junyan 2020-09-21 12:51:53 +08:00
parent 00b73cfddd
commit 410938a069
4 changed files with 19 additions and 19 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -679,23 +679,6 @@ _get_profile (GstVaH264Dec * self, const GstH264SPS * sps, gint max_dpb_size)
return VAProfileNone;
}
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;

View file

@ -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