|
|
@ -2121,7 +2121,7 @@ static int decode_chunks(AVCodecContext *avctx, |
|
|
|
const uint8_t *buf_ptr = buf; |
|
|
|
const uint8_t *buf_ptr = buf; |
|
|
|
const uint8_t *buf_end = buf + buf_size; |
|
|
|
const uint8_t *buf_end = buf + buf_size; |
|
|
|
int ret, input_size; |
|
|
|
int ret, input_size; |
|
|
|
int last_code = 0; |
|
|
|
int last_code = 0, skip_frame = 0; |
|
|
|
int picture_start_code_seen = 0; |
|
|
|
int picture_start_code_seen = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (;;) { |
|
|
|
for (;;) { |
|
|
@ -2129,7 +2129,7 @@ static int decode_chunks(AVCodecContext *avctx, |
|
|
|
uint32_t start_code = -1; |
|
|
|
uint32_t start_code = -1; |
|
|
|
buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &start_code); |
|
|
|
buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &start_code); |
|
|
|
if (start_code > 0x1ff) { |
|
|
|
if (start_code > 0x1ff) { |
|
|
|
if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT) { |
|
|
|
if (!skip_frame) { |
|
|
|
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) { |
|
|
|
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) { |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
av_assert0(avctx->thread_count > 1); |
|
|
|
av_assert0(avctx->thread_count > 1); |
|
|
@ -2316,20 +2316,27 @@ static int decode_chunks(AVCodecContext *avctx, |
|
|
|
if (s2->last_picture_ptr == NULL) { |
|
|
|
if (s2->last_picture_ptr == NULL) { |
|
|
|
/* Skip B-frames if we do not have reference frames and gop is not closed */ |
|
|
|
/* Skip B-frames if we do not have reference frames and gop is not closed */ |
|
|
|
if (s2->pict_type == AV_PICTURE_TYPE_B) { |
|
|
|
if (s2->pict_type == AV_PICTURE_TYPE_B) { |
|
|
|
if (!s2->closed_gop) |
|
|
|
if (!s2->closed_gop) { |
|
|
|
|
|
|
|
skip_frame = 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->flags2 & CODEC_FLAG2_SHOW_ALL)) |
|
|
|
if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->flags2 & CODEC_FLAG2_SHOW_ALL)) |
|
|
|
s->sync=1; |
|
|
|
s->sync=1; |
|
|
|
if (s2->next_picture_ptr == NULL) { |
|
|
|
if (s2->next_picture_ptr == NULL) { |
|
|
|
/* Skip P-frames if we do not have a reference frame or we have an invalid header. */ |
|
|
|
/* Skip P-frames if we do not have a reference frame or we have an invalid header. */ |
|
|
|
if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) break; |
|
|
|
if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) { |
|
|
|
|
|
|
|
skip_frame = 1; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ((avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type == AV_PICTURE_TYPE_B) || |
|
|
|
if ((avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type == AV_PICTURE_TYPE_B) || |
|
|
|
(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type != AV_PICTURE_TYPE_I) || |
|
|
|
(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type != AV_PICTURE_TYPE_I) || |
|
|
|
avctx->skip_frame >= AVDISCARD_ALL) |
|
|
|
avctx->skip_frame >= AVDISCARD_ALL) { |
|
|
|
|
|
|
|
skip_frame = 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!s->mpeg_enc_ctx_allocated) |
|
|
|
if (!s->mpeg_enc_ctx_allocated) |
|
|
|
break; |
|
|
|
break; |
|
|
@ -2347,6 +2354,7 @@ static int decode_chunks(AVCodecContext *avctx, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (s2->first_slice) { |
|
|
|
if (s2->first_slice) { |
|
|
|
|
|
|
|
skip_frame = 0; |
|
|
|
s2->first_slice = 0; |
|
|
|
s2->first_slice = 0; |
|
|
|
if (mpeg_field_start(s2, buf, buf_size) < 0) |
|
|
|
if (mpeg_field_start(s2, buf, buf_size) < 0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|