avformat/aea: improve probe function
This commit is contained in:
@@ -29,32 +29,28 @@
|
|||||||
|
|
||||||
static int aea_read_probe(const AVProbeData *p)
|
static int aea_read_probe(const AVProbeData *p)
|
||||||
{
|
{
|
||||||
if (p->buf_size <= 2048+212)
|
if (p->buf_size <= 2048+AT1_SU_SIZE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Magic is '00 08 00 00' in little-endian*/
|
/* Magic is '00 08 00 00' in little-endian*/
|
||||||
if (AV_RL32(p->buf)==0x800) {
|
if (AV_RL32(p->buf)==0x800) {
|
||||||
int ch, i;
|
int ch, block_size, score = 0;
|
||||||
ch = p->buf[264];
|
ch = p->buf[264];
|
||||||
|
|
||||||
if (ch != 1 && ch != 2)
|
if (ch != 1 && ch != 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
block_size = ch * AT1_SU_SIZE;
|
||||||
/* Check so that the redundant bsm bytes and info bytes are valid
|
/* Check so that the redundant bsm bytes and info bytes are valid
|
||||||
* the block size mode bytes have to be the same
|
* the block size mode bytes have to be the same
|
||||||
* the info bytes have to be the same
|
* the info bytes have to be the same
|
||||||
*/
|
*/
|
||||||
for (i = 2048; i + 211 < p->buf_size; i+= 212) {
|
for (int i = 2048 + block_size; i + block_size <= p->buf_size; i += block_size) {
|
||||||
int bsm_s, bsm_e, inb_s, inb_e;
|
if (AV_RN16(p->buf+i) != AV_RN16(p->buf+i+AT1_SU_SIZE))
|
||||||
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)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
score++;
|
||||||
}
|
}
|
||||||
return AVPROBE_SCORE_MAX / 4 + 1;
|
return FFMIN(AVPROBE_SCORE_MAX / 4 + score, AVPROBE_SCORE_MAX);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user