diff options
Diffstat (limited to 'ffmpeg/libavformat/idcin.c')
| -rw-r--r-- | ffmpeg/libavformat/idcin.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/ffmpeg/libavformat/idcin.c b/ffmpeg/libavformat/idcin.c index 2a8af40..cc25fb0 100644 --- a/ffmpeg/libavformat/idcin.c +++ b/ffmpeg/libavformat/idcin.c @@ -93,7 +93,9 @@ typedef struct IdcinDemuxContext { static int idcin_probe(AVProbeData *p) { - unsigned int number; + unsigned int number, sample_rate; + unsigned int w, h; + int i; /* * This is what you could call a "probabilistic" file check: id CIN @@ -108,36 +110,43 @@ static int idcin_probe(AVProbeData *p) /* check we have enough data to do all checks, otherwise the 0-padding may cause a wrong recognition */ - if (p->buf_size < 20) + if (p->buf_size < 20 + HUFFMAN_TABLE_SIZE + 12) return 0; /* check the video width */ - number = AV_RL32(&p->buf[0]); - if ((number == 0) || (number > 1024)) + w = AV_RL32(&p->buf[0]); + if ((w == 0) || (w > 1024)) return 0; /* check the video height */ - number = AV_RL32(&p->buf[4]); - if ((number == 0) || (number > 1024)) + h = AV_RL32(&p->buf[4]); + if ((h == 0) || (h > 1024)) return 0; /* check the audio sample rate */ - number = AV_RL32(&p->buf[8]); - if ((number != 0) && ((number < 8000) | (number > 48000))) + sample_rate = AV_RL32(&p->buf[8]); + if (sample_rate && (sample_rate < 8000 || sample_rate > 48000)) return 0; /* check the audio bytes/sample */ number = AV_RL32(&p->buf[12]); - if (number > 2) + if (number > 2 || sample_rate && !number) return 0; /* check the audio channels */ number = AV_RL32(&p->buf[16]); - if (number > 2) + if (number > 2 || sample_rate && !number) return 0; - /* return half certainly since this check is a bit sketchy */ - return AVPROBE_SCORE_MAX / 2; + i = 20 + HUFFMAN_TABLE_SIZE; + if (AV_RL32(&p->buf[i]) == 1) + i += 768; + + if (i+12 > p->buf_size || AV_RL32(&p->buf[i+8]) != w*h) + return 1; + + /* return half certainty since this check is a bit sketchy */ + return AVPROBE_SCORE_EXTENSION; } static int idcin_read_header(AVFormatContext *s) @@ -196,15 +205,8 @@ static int idcin_read_header(AVFormatContext *s) st->codec->height = height; /* load up the Huffman tables into extradata */ - st->codec->extradata_size = HUFFMAN_TABLE_SIZE; - st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE); - ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE); - if (ret < 0) { + if ((ret = ff_get_extradata(st->codec, pb, HUFFMAN_TABLE_SIZE)) < 0) return ret; - } else if (ret != HUFFMAN_TABLE_SIZE) { - av_log(s, AV_LOG_ERROR, "incomplete header\n"); - return AVERROR(EIO); - } if (idcin->audio_present) { idcin->audio_present = 1; |
