[FFmpeg-devel] [PATCH] avformat/tta: only check for header and seek table crc if requested
James Almer
jamrial at gmail.com
Wed Feb 4 06:01:16 CET 2015
Signed-off-by: James Almer <jamrial at gmail.com>
---
I made it abort only if AV_EF_EXPLODE is also set like we do when decoding
audio frames, but maybe aborting if the header or seek table are damaged
should be the default behaviour. Chances are a file with a broken header is
unplayable after all.
Thoughts?
libavformat/tta.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 5789e5b..45dfee9 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -64,7 +64,8 @@ static int tta_read_header(AVFormatContext *s)
start_offset = avio_tell(s->pb);
if (start_offset < 0)
return start_offset;
- ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
+ if (s->error_recognition & AV_EF_CRCCHECK)
+ ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
if (avio_rl32(s->pb) != AV_RL32("TTA1"))
return AVERROR_INVALIDDATA;
@@ -83,10 +84,13 @@ static int tta_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
- if (crc != avio_rl32(s->pb)) {
- av_log(s, AV_LOG_ERROR, "Header CRC error\n");
- return AVERROR_INVALIDDATA;
+ if (s->error_recognition & AV_EF_CRCCHECK) {
+ crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
+ if (crc != avio_rl32(s->pb)) {
+ av_log(s, AV_LOG_ERROR, "Header CRC error\n");
+ if (s->error_recognition & AV_EF_EXPLODE)
+ return AVERROR_INVALIDDATA;
+ }
}
c->frame_size = samplerate * 256 / 245;
@@ -120,7 +124,8 @@ static int tta_read_header(AVFormatContext *s)
avio_seek(s->pb, start_offset, SEEK_SET);
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
- ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
+ if (s->error_recognition & AV_EF_CRCCHECK)
+ ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
for (i = 0; i < c->totalframes; i++) {
uint32_t size = avio_rl32(s->pb);
int r;
@@ -129,10 +134,13 @@ static int tta_read_header(AVFormatContext *s)
return r;
framepos += size;
}
- crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
- if (crc != avio_rl32(s->pb)) {
- av_log(s, AV_LOG_ERROR, "Seek table CRC error\n");
- return AVERROR_INVALIDDATA;
+ if (s->error_recognition & AV_EF_CRCCHECK) {
+ crc = ffio_get_checksum(s->pb) ^ UINT32_MAX;
+ if (crc != avio_rl32(s->pb)) {
+ av_log(s, AV_LOG_ERROR, "Seek table CRC error\n");
+ if (s->error_recognition & AV_EF_EXPLODE)
+ return AVERROR_INVALIDDATA;
+ }
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
--
2.2.2
More information about the ffmpeg-devel
mailing list