hevc: Always consider VLC NALU type mismatch fatal
Sample-Id: 00001667-google
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit 521726ff57
)
This commit is contained in:
committed by
Reinhard Tartler
parent
4be1b68d52
commit
9b6ccf0f24
@@ -2521,9 +2521,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
|
||||||
s->nal_unit_type);
|
s->nal_unit_type);
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
goto fail;
|
||||||
return ret;
|
|
||||||
return 0;
|
|
||||||
} else if (!ret)
|
} else if (!ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -2531,23 +2529,23 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
case NAL_VPS:
|
case NAL_VPS:
|
||||||
ret = ff_hevc_decode_nal_vps(s);
|
ret = ff_hevc_decode_nal_vps(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_SPS:
|
case NAL_SPS:
|
||||||
ret = ff_hevc_decode_nal_sps(s);
|
ret = ff_hevc_decode_nal_sps(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_PPS:
|
case NAL_PPS:
|
||||||
ret = ff_hevc_decode_nal_pps(s);
|
ret = ff_hevc_decode_nal_pps(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_SEI_PREFIX:
|
case NAL_SEI_PREFIX:
|
||||||
case NAL_SEI_SUFFIX:
|
case NAL_SEI_SUFFIX:
|
||||||
ret = ff_hevc_decode_nal_sei(s);
|
ret = ff_hevc_decode_nal_sei(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case NAL_TRAIL_R:
|
case NAL_TRAIL_R:
|
||||||
case NAL_TRAIL_N:
|
case NAL_TRAIL_N:
|
||||||
@@ -2593,7 +2591,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
return ret;
|
return ret;
|
||||||
} else if (!s->ref) {
|
} else if (!s->ref) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
|
av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->nal_unit_type != s->first_nal_type) {
|
if (s->nal_unit_type != s->first_nal_type) {
|
||||||
@@ -2609,8 +2607,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_WARNING,
|
av_log(s->avctx, AV_LOG_WARNING,
|
||||||
"Error constructing the reference lists for the current slice.\n");
|
"Error constructing the reference lists for the current slice.\n");
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
goto fail;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2623,8 +2620,10 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
restore_tqb_pixels(s);
|
restore_tqb_pixels(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctb_addr_ts < 0)
|
if (ctb_addr_ts < 0) {
|
||||||
return ctb_addr_ts;
|
ret = ctb_addr_ts;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NAL_EOS_NUT:
|
case NAL_EOS_NUT:
|
||||||
case NAL_EOB_NUT:
|
case NAL_EOB_NUT:
|
||||||
@@ -2640,6 +2639,10 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
fail:
|
||||||
|
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
|
return ret;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
|
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
|
||||||
@@ -2820,8 +2823,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_WARNING,
|
av_log(s->avctx, AV_LOG_WARNING,
|
||||||
"Error parsing NAL unit #%d.\n", i);
|
"Error parsing NAL unit #%d.\n", i);
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
goto fail;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user