From a48eebefd63b37b842f45d2e8a040a0e2c57a36f Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Fri, 13 Nov 2015 19:23:05 +0200 Subject: [PATCH] decoder: vp9: Fix the context and surface pool reset for multi resolution video Unlike other decoders, vp9 decoder doesn't need to reset the whole context and surfaces for each resolution change. Context reset only needed if resolution of any frame is greater than what actullay configured. There are streams where a bigger resolution set in ivf header or webm header but actual resolution of all frames are less. Also it is possible to have inter-prediction between these multi resolution frames. --- gst-libs/gst/vaapi/gstvaapidecoder_vp9.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c b/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c index 39834eca89..508805e44a 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c @@ -504,14 +504,28 @@ parse_frame_header (GstVaapiDecoderVp9 * decoder, const guchar * buf, { GstVaapiDecoderVp9Private *const priv = &decoder->priv; GstVp9ParserResult result; + guint width, height; result = gst_vp9_parser_parse_frame_header (priv->parser, frame_hdr, buf, buf_size); if (result != GST_VP9_PARSER_OK) return get_status (result); - if ((frame_hdr->frame_type == GST_VP9_KEY_FRAME) && - (frame_hdr->width != priv->width || frame_hdr->height != priv->height)) { + /* Unlike other decoders, vp9 decoder doesn't need to reset the + * whole context and surfaces for each resolution change. context + * reset only needed if resolution of any frame is greater than + * what actullay configured. There are streams where a bigger + * resolution set in ivf header or webm header but actual resolution + * of all frames are less. Also it is possible to have inter-prediction + * between these multi resolution frames */ + width = GST_VAAPI_DECODER_WIDTH (decoder); + height = GST_VAAPI_DECODER_HEIGHT (decoder); + if (priv->width < width || priv->height < height) { + priv->width = GST_VAAPI_DECODER_WIDTH (decoder); + priv->height = GST_VAAPI_DECODER_HEIGHT (decoder); + priv->size_changed = TRUE; + } + if ((frame_hdr->width > priv->width || frame_hdr->height > priv->height)) { priv->width = frame_hdr->width; priv->height = frame_hdr->height; priv->size_changed = TRUE; -- 2.34.1