diff options
author | Paul B Mahol <onemda@gmail.com> | 2023-10-02 00:53:16 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2023-10-02 01:28:11 +0200 |
commit | edb6d6d5361ad6c58af32d3c1ba9a6569988380d (patch) | |
tree | 3b50fcfbfa8a20ba78d8d8a6763a4dc7ee3454c6 | |
parent | 7a444501d5dee96e7692a4339f4ab038753ca43c (diff) | |
download | ffmpeg-edb6d6d5361ad6c58af32d3c1ba9a6569988380d.tar.gz |
avformat/aea: improve probe function
-rw-r--r-- | libavformat/aea.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/libavformat/aea.c b/libavformat/aea.c index d16217381b..684217a2a3 100644 --- a/libavformat/aea.c +++ b/libavformat/aea.c @@ -25,36 +25,32 @@ #include "avformat.h" #include "pcm.h" -#define AT1_SU_SIZE 212 +#define AT1_SU_SIZE 212 static int aea_read_probe(const AVProbeData *p) { - if (p->buf_size <= 2048+212) + if (p->buf_size <= 2048+AT1_SU_SIZE) return 0; /* Magic is '00 08 00 00' in little-endian*/ if (AV_RL32(p->buf)==0x800) { - int ch, i; + int ch, block_size, score = 0; ch = p->buf[264]; if (ch != 1 && ch != 2) return 0; + block_size = ch * AT1_SU_SIZE; /* Check so that the redundant bsm bytes and info bytes are valid * the block size mode bytes have to be the same * the info bytes have to be the same */ - for (i = 2048; i + 211 < p->buf_size; i+= 212) { - int bsm_s, bsm_e, inb_s, inb_e; - bsm_s = p->buf[0]; - inb_s = p->buf[1]; - inb_e = p->buf[210]; - bsm_e = p->buf[211]; - - if (bsm_s != bsm_e || inb_s != inb_e) + for (int i = 2048 + block_size; i + block_size <= p->buf_size; i += block_size) { + if (AV_RN16(p->buf+i) != AV_RN16(p->buf+i+AT1_SU_SIZE)) return 0; + score++; } - return AVPROBE_SCORE_MAX / 4 + 1; + return FFMIN(AVPROBE_SCORE_MAX / 4 + score, AVPROBE_SCORE_MAX); } return 0; } |