mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
Merge commit '23a211cbba0b7c9ee694040031b2e5da1be54a00'
* commit '23a211cbba0b7c9ee694040031b2e5da1be54a00': lavc: change all decoders to behave consistently with AV_EF_CRCCHECK. Conflicts: libavcodec/avcodec.h libavcodec/tta.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
84f972f994
@ -1330,6 +1330,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
|||||||
if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],
|
if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],
|
||||||
s->frame_size - 2)) {
|
s->frame_size - 2)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
|
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
|
||||||
|
if (avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
err = AAC_AC3_PARSE_ERROR_CRC;
|
err = AAC_AC3_PARSE_ERROR_CRC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1565,6 +1565,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
|
|||||||
if (ctx->cur_frame_length != sconf->frame_length &&
|
if (ctx->cur_frame_length != sconf->frame_length &&
|
||||||
ctx->crc_org != ctx->crc) {
|
ctx->crc_org != ctx->crc) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "CRC error.\n");
|
av_log(avctx, AV_LOG_ERROR, "CRC error.\n");
|
||||||
|
if (avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2474,7 +2474,14 @@ typedef struct AVCodecContext {
|
|||||||
* - decoding: Set by user.
|
* - decoding: Set by user.
|
||||||
*/
|
*/
|
||||||
int err_recognition;
|
int err_recognition;
|
||||||
#define AV_EF_CRCCHECK (1<<0) ///< verify embedded CRCs
|
|
||||||
|
/**
|
||||||
|
* Verify checksums embedded in the bitstream (could be of either encoded or
|
||||||
|
* decoded data, depending on the codec) and print an error message on mismatch.
|
||||||
|
* If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
|
||||||
|
* decoder returning an error.
|
||||||
|
*/
|
||||||
|
#define AV_EF_CRCCHECK (1<<0)
|
||||||
#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
|
#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
|
||||||
#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
|
#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
|
||||||
#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
|
#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
|
||||||
|
@ -690,6 +690,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
hsize = get_bits_count(gb) / 8;
|
hsize = get_bits_count(gb) / 8;
|
||||||
if (ff_tak_check_crc(pkt->data, hsize)) {
|
if (ff_tak_check_crc(pkt->data, hsize)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "CRC error\n");
|
av_log(avctx, AV_LOG_ERROR, "CRC error\n");
|
||||||
|
if (avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -865,6 +866,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
if (ff_tak_check_crc(pkt->data + hsize,
|
if (ff_tak_check_crc(pkt->data + hsize,
|
||||||
get_bits_count(gb) / 8 - hsize)) {
|
get_bits_count(gb) / 8 - hsize)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "CRC error\n");
|
av_log(avctx, AV_LOG_ERROR, "CRC error\n");
|
||||||
|
if (avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,8 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
int32_t *p;
|
int32_t *p;
|
||||||
|
|
||||||
if (avctx->err_recognition & AV_EF_CRCCHECK) {
|
if (avctx->err_recognition & AV_EF_CRCCHECK) {
|
||||||
if (buf_size < 4 || tta_check_crc(s, buf, buf_size - 4))
|
if (buf_size < 4 ||
|
||||||
|
(tta_check_crc(s, buf, buf_size - 4) && avctx->err_recognition & AV_EF_EXPLODE))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,9 +548,11 @@ static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb,
|
|||||||
} while (!last && count < s->samples);
|
} while (!last && count < s->samples);
|
||||||
|
|
||||||
wv_reset_saved_context(s);
|
wv_reset_saved_context(s);
|
||||||
if ((s->avctx->err_recognition & AV_EF_CRCCHECK) &&
|
if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
|
||||||
wv_check_crc(s, crc, crc_extra_bits))
|
int ret = wv_check_crc(s, crc, crc_extra_bits);
|
||||||
return AVERROR_INVALIDDATA;
|
if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user