mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-21 14:26:59 +00:00
avformat/format: Weight the filename extension higher if there is nearly no data after an ID3 available
Fixes Ticket5205 Based-on-patch-by: Carl Eugen Hoyos Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
8619582bdf
commit
77864be44a
@ -175,6 +175,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
|
|||||||
const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
|
const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
|
||||||
enum nodat {
|
enum nodat {
|
||||||
NO_ID3,
|
NO_ID3,
|
||||||
|
ID3_ALMOST_GREATER_PROBE,
|
||||||
ID3_GREATER_PROBE,
|
ID3_GREATER_PROBE,
|
||||||
ID3_GREATER_MAX_PROBE,
|
ID3_GREATER_MAX_PROBE,
|
||||||
} nodat = NO_ID3;
|
} nodat = NO_ID3;
|
||||||
@ -185,6 +186,8 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
|
|||||||
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
|
if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
|
||||||
int id3len = ff_id3v2_tag_len(lpd.buf);
|
int id3len = ff_id3v2_tag_len(lpd.buf);
|
||||||
if (lpd.buf_size > id3len + 16) {
|
if (lpd.buf_size > id3len + 16) {
|
||||||
|
if (lpd.buf_size < 2LL*id3len + 16)
|
||||||
|
nodat = ID3_ALMOST_GREATER_PROBE;
|
||||||
lpd.buf += id3len;
|
lpd.buf += id3len;
|
||||||
lpd.buf_size -= id3len;
|
lpd.buf_size -= id3len;
|
||||||
} else if (id3len >= PROBE_BUF_MAX) {
|
} else if (id3len >= PROBE_BUF_MAX) {
|
||||||
@ -203,9 +206,18 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
|
|||||||
if (score)
|
if (score)
|
||||||
av_log(NULL, AV_LOG_TRACE, "Probing %s score:%d size:%d\n", fmt1->name, score, lpd.buf_size);
|
av_log(NULL, AV_LOG_TRACE, "Probing %s score:%d size:%d\n", fmt1->name, score, lpd.buf_size);
|
||||||
if (fmt1->extensions && av_match_ext(lpd.filename, fmt1->extensions)) {
|
if (fmt1->extensions && av_match_ext(lpd.filename, fmt1->extensions)) {
|
||||||
if (nodat == NO_ID3) score = FFMAX(score, 1);
|
switch (nodat) {
|
||||||
else if (nodat == ID3_GREATER_PROBE) score = FFMAX(score, AVPROBE_SCORE_EXTENSION / 2 - 1);
|
case NO_ID3:
|
||||||
else score = FFMAX(score, AVPROBE_SCORE_EXTENSION);
|
score = FFMAX(score, 1);
|
||||||
|
break;
|
||||||
|
case ID3_GREATER_PROBE:
|
||||||
|
case ID3_ALMOST_GREATER_PROBE:
|
||||||
|
score = FFMAX(score, AVPROBE_SCORE_EXTENSION / 2 - 1);
|
||||||
|
break;
|
||||||
|
case ID3_GREATER_MAX_PROBE:
|
||||||
|
score = FFMAX(score, AVPROBE_SCORE_EXTENSION);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (fmt1->extensions) {
|
} else if (fmt1->extensions) {
|
||||||
if (av_match_ext(lpd.filename, fmt1->extensions))
|
if (av_match_ext(lpd.filename, fmt1->extensions))
|
||||||
|
Loading…
Reference in New Issue
Block a user