}
}
- assert(h->mb_num == h->mb_width * h->mb_height);
+ if (h->picture_idr && nal->type != H264_NAL_IDR_SLICE) {
+ av_log(h->avctx, AV_LOG_ERROR, "Invalid mix of IDR and non-IDR slices\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ av_assert1(h->mb_num == h->mb_width * h->mb_height);
if (sl->first_mb_addr << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
sl->first_mb_addr >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
err = 0;
switch (nal->type) {
case H264_NAL_IDR_SLICE:
- idr(h); // FIXME ensure we don't lose some frames if there is reordering
+ if ((nal->data[1] & 0xFC) == 0x98) {
+ av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
+ h->next_outputed_poc = INT_MIN;
+ ret = -1;
+ goto end;
+ }
- if (nal->type != H264_NAL_IDR_SLICE) {
- av_log(h->avctx, AV_LOG_ERROR,
- "Invalid mix of idr and non-idr slices\n");
- ret = -1;
- goto end;
- }
+ if(!idr_cleared) {
+ if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
+ av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
+ idr(h); // FIXME ensure we don't lose some frames if there is reordering
+ }
+ idr_cleared = 1;
+ h->has_recovery_point = 1;
case H264_NAL_SLICE:
sl->gb = nal->gb;