forked from FFmpeg/FFmpeg
avformat/aea: improve probe function
This commit is contained in:
parent
7a444501d5
commit
edb6d6d536
1 changed files with 8 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue