libs: decoder: jpeg: support dynamic resolution change decode.

Add size_changed flag to watch out resolution. if change, reset
jpeg decoder's context.
This commit is contained in:
Wangfei 2019-03-26 14:20:34 +08:00 committed by Víctor Manuel Jáquez Leal
parent 49f363bca2
commit 871aecb0d4

View file

@ -70,6 +70,7 @@ struct _GstVaapiDecoderJpegPrivate
guint decoder_state; guint decoder_state;
guint is_opened:1; guint is_opened:1;
guint profile_changed:1; guint profile_changed:1;
guint size_changed:1;
}; };
/** /**
@ -123,6 +124,7 @@ gst_vaapi_decoder_jpeg_close (GstVaapiDecoderJpeg * decoder)
priv->height = 0; priv->height = 0;
priv->is_opened = FALSE; priv->is_opened = FALSE;
priv->profile_changed = TRUE; priv->profile_changed = TRUE;
priv->size_changed = TRUE;
} }
static gboolean static gboolean
@ -155,6 +157,7 @@ gst_vaapi_decoder_jpeg_create (GstVaapiDecoder * base_decoder)
priv->profile = GST_VAAPI_PROFILE_JPEG_BASELINE; priv->profile = GST_VAAPI_PROFILE_JPEG_BASELINE;
priv->profile_changed = TRUE; priv->profile_changed = TRUE;
priv->size_changed = TRUE;
return TRUE; return TRUE;
} }
@ -194,6 +197,12 @@ ensure_context (GstVaapiDecoderJpeg * decoder)
priv->profile = profiles[i]; priv->profile = profiles[i];
} }
if (priv->size_changed) {
GST_DEBUG ("size changed");
priv->size_changed = FALSE;
reset_context = TRUE;
}
if (reset_context) { if (reset_context) {
GstVaapiContextInfo info; GstVaapiContextInfo info;
@ -439,6 +448,10 @@ decode_picture (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
GST_ERROR ("failed to parse image"); GST_ERROR ("failed to parse image");
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
} }
if (priv->height != frame_hdr->height || priv->width != frame_hdr->width)
priv->size_changed = TRUE;
priv->height = frame_hdr->height; priv->height = frame_hdr->height;
priv->width = frame_hdr->width; priv->width = frame_hdr->width;