1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
From: Zhao Zhili <quinkblack@foxmail.com>
Date: Fri, 11 Jun 2021 18:02:34 +0800
Subject: codec: avcodec: check open codec return value
(cherry picked from commit 21ab6be22e7c1831cebf023fd53bd7ffbfad22f6) (edited)
edited:
- on 3.0 DecodeBlock returns a picture_t, not an error code
---
modules/codec/avcodec/audio.c | 7 ++++++-
modules/codec/avcodec/video.c | 11 +++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index a3f67f7..e843675 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -309,7 +309,12 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
&& !avcodec_is_open( ctx ) )
{
InitDecoderConfig( p_dec, ctx );
- OpenAudioCodec( p_dec );
+ if( OpenAudioCodec( p_dec ) < 0 )
+ {
+ if( pp_block != NULL && *pp_block != NULL )
+ block_Release( *pp_block );
+ return VLCDEC_ECRITICAL;
+ }
}
if( !avcodec_is_open( ctx ) )
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index c306e91..096a0b7 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1114,17 +1114,20 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
bool eos_spotted = false;
- block_t *p_block;
+ block_t *p_block = pp_block ? *pp_block : NULL;
vlc_tick_t current_time;
if( !p_context->extradata_size && p_dec->fmt_in.i_extra )
{
ffmpeg_InitCodec( p_dec );
- if( !avcodec_is_open( p_context ) )
- OpenVideoCodec( p_dec );
+ if( !avcodec_is_open( p_context ) && OpenVideoCodec(p_dec) < 0 )
+ {
+ if( p_block != NULL )
+ block_Release( p_block );
+ return NULL;
+ }
}
- p_block = pp_block ? *pp_block : NULL;
if(!p_block && !(p_sys->p_codec->capabilities & AV_CODEC_CAP_DELAY) )
return NULL;
|