[vlc-commits] avcodec: video: check return of avcodec_send_packet/avcodec_receive_frame
Thomas Guillem
git at videolan.org
Wed Sep 7 15:52:36 CEST 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep 7 12:32:37 2016 +0200| [61d7a6068b28da1fba6512e2c8b269a530c49755] | committer: Thomas Guillem
avcodec: video: check return of avcodec_send_packet/avcodec_receive_frame
Don't treat EAGAIN as an error
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=61d7a6068b28da1fba6512e2c8b269a530c49755
---
modules/codec/avcodec/video.c | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 6fcb2a2..42d9e89 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -793,13 +793,6 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
int i_used;
AVPacket pkt;
- AVFrame *frame = av_frame_alloc();
- if (unlikely(frame == NULL))
- {
- p_dec->b_error = true;
- break;
- }
-
post_mt( p_sys );
av_init_packet( &pkt );
@@ -833,11 +826,31 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
p_block->i_dts = VLC_TS_INVALID;
}
- int not_able_to_send_packet = avcodec_send_packet( p_context, &pkt );
- i_used = pkt.size;
+ int ret = avcodec_send_packet(p_context, &pkt);
+ if( ret != 0 && ret != AVERROR(EAGAIN) )
+ {
+ p_dec->b_error = true;
+ av_packet_unref( &pkt );
+ break;
+ }
+ i_used = ret != AVERROR(EAGAIN) ? pkt.size : 0;
av_packet_unref( &pkt );
- int not_received_frame = avcodec_receive_frame( p_context, frame);
+ AVFrame *frame = av_frame_alloc();
+ if (unlikely(frame == NULL))
+ {
+ p_dec->b_error = true;
+ break;
+ }
+
+ ret = avcodec_receive_frame(p_context, frame);
+ if( ret != 0 && ret != AVERROR(EAGAIN) )
+ {
+ p_dec->b_error = true;
+ av_frame_free(&frame);
+ break;
+ }
+ bool not_received_frame = ret;
wait_mt( p_sys );
@@ -850,8 +863,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
eos_spotted = false;
/* Consumed bytes */
- p_block->p_buffer += p_block->i_buffer;
- p_block->i_buffer = 0;
+ p_block->p_buffer += i_used;
+ p_block->i_buffer -= i_used;
}
/* Nothing to display */
More information about the vlc-commits
mailing list