mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-09 19:09:41 +00:00
mpeg2: fix crash when there is no free surface to decode into.
This commit is contained in:
parent
d46e8d9961
commit
d75d70d395
3 changed files with 21 additions and 4 deletions
|
@ -99,14 +99,13 @@ pop_buffer(GstVaapiDecoder *decoder)
|
|||
static GstVaapiDecoderStatus
|
||||
decode_step(GstVaapiDecoder *decoder)
|
||||
{
|
||||
GstVaapiDecoderPrivate * const priv = decoder->priv;
|
||||
GstVaapiDecoderStatus status;
|
||||
GstBuffer *buffer;
|
||||
|
||||
/* Decoding will fail if there is no surface left */
|
||||
if (priv->context &&
|
||||
gst_vaapi_context_get_surface_count(priv->context) == 0)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
|
||||
status = gst_vaapi_decoder_check_status(decoder);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
do {
|
||||
buffer = pop_buffer(decoder);
|
||||
|
@ -561,3 +560,13 @@ gst_vaapi_decoder_push_surface_proxy(
|
|||
{
|
||||
return push_surface(decoder, proxy);
|
||||
}
|
||||
|
||||
GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_check_status(GstVaapiDecoder *decoder)
|
||||
{
|
||||
GstVaapiDecoderPrivate * const priv = decoder->priv;
|
||||
|
||||
if (priv->context && gst_vaapi_context_get_surface_count(priv->context) < 1)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -685,6 +685,10 @@ decode_buffer(GstVaapiDecoderMpeg2 *decoder, GstBuffer *buffer)
|
|||
gst_adapter_flush(priv->adapter, ofs);
|
||||
size -= ofs;
|
||||
|
||||
status = gst_vaapi_decoder_check_status(decoder);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
break;
|
||||
|
||||
if (size < 8)
|
||||
break;
|
||||
ofs = scan_for_start_code(priv->adapter, 4, size - 4, NULL);
|
||||
|
|
|
@ -171,6 +171,10 @@ gst_vaapi_decoder_push_surface_proxy(
|
|||
GstVaapiSurfaceProxy *proxy
|
||||
) attribute_hidden;
|
||||
|
||||
GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_check_status(GstVaapiDecoder *decoder)
|
||||
attribute_hidden;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_DECODER_PRIV_H */
|
||||
|
|
Loading…
Reference in a new issue