[vlc-devel] [PATCH 4/4] avcodec: drop frames from old vouts
Thomas Guillem
thomas at gllm.fr
Sun Sep 24 11:34:59 CEST 2017
This fixes a crash in indirect rendering when the decoder requested a lower
video resultion.
---
modules/codec/avcodec/video.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 022fc0d884..316222d331 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -342,13 +342,20 @@ static int lavc_CopyPicture(decoder_t *dec, picture_t *pic, AVFrame *frame)
{
decoder_sys_t *sys = dec->p_sys;
- if (!FindVlcChroma(sys->p_context->pix_fmt))
+ vlc_fourcc_t fourcc = FindVlcChroma(frame->format);
+ if (!fourcc)
{
- const char *name = av_get_pix_fmt_name(sys->p_context->pix_fmt);
+ const char *name = av_get_pix_fmt_name(frame->format);
msg_Err(dec, "Unsupported decoded output format %d (%s)",
sys->p_context->pix_fmt, (name != NULL) ? name : "unknown");
return VLC_EGENERIC;
+ } else if (fourcc != pic->format.i_chroma
+ || frame->width != (int) pic->format.i_visible_width
+ || frame->height != (int) pic->format.i_visible_height)
+ {
+ msg_Warn(dec, "dropping frame because the vout changed");
+ return VLC_EGENERIC;
}
for (int plane = 0; plane < pic->i_planes; plane++)
@@ -1149,7 +1156,6 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
/* Fill picture_t from AVFrame */
if( lavc_CopyPicture( p_dec, p_pic, frame ) != VLC_SUCCESS )
{
- *error = true;
av_frame_free(&frame);
picture_Release( p_pic );
break;
--
2.11.0
More information about the vlc-devel
mailing list