mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
In h264 decoder, fix decoding when nal end sequence is present
Originally committed as revision 25809 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
8ee764b020
commit
9d252137e5
@ -2783,14 +2783,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
|||||||
nalsize = 0;
|
nalsize = 0;
|
||||||
for(i = 0; i < h->nal_length_size; i++)
|
for(i = 0; i < h->nal_length_size; i++)
|
||||||
nalsize = (nalsize << 8) | buf[buf_index++];
|
nalsize = (nalsize << 8) | buf[buf_index++];
|
||||||
if(nalsize <= 1 || nalsize > buf_size - buf_index){
|
if(nalsize <= 0 || nalsize > buf_size - buf_index){
|
||||||
if(nalsize == 1){
|
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
|
||||||
buf_index++;
|
break;
|
||||||
continue;
|
|
||||||
}else{
|
|
||||||
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
next_avc= buf_index + nalsize;
|
next_avc= buf_index + nalsize;
|
||||||
} else {
|
} else {
|
||||||
@ -2990,6 +2985,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
s->flags2= avctx->flags2;
|
s->flags2= avctx->flags2;
|
||||||
|
|
||||||
/* end of stream, output what is still in the buffers */
|
/* end of stream, output what is still in the buffers */
|
||||||
|
out:
|
||||||
if (buf_size == 0) {
|
if (buf_size == 0) {
|
||||||
Picture *out;
|
Picture *out;
|
||||||
int i, out_idx;
|
int i, out_idx;
|
||||||
@ -3018,6 +3014,11 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
if(buf_index < 0)
|
if(buf_index < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
|
||||||
|
buf_size = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
|
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
|
||||||
if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
|
if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
|
||||||
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
|
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user