[FFmpeg-devel] lavf/mp3dec: increase probe score of buffers entirely composed of valid packets

Submitted by Rodger Combs on March 16, 2019, 10:24 a.m.

Details

Message ID 20190316102446.69900-1-rodger.combs@gmail.com
State New
Headers show

Commit Message

Rodger Combs March 16, 2019, 10:24 a.m.
Fixes some files misdetecting as MPEG PS
---
 libavformat/mp3dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Carl Eugen Hoyos March 16, 2019, 11:21 a.m.
Am Sa., 16. März 2019 um 11:25 Uhr schrieb Rodger Combs
<rodger.combs@gmail.com>:
>
> Fixes some files misdetecting as MPEG PS

Please provide such a sample.

Thank you, Carl Eugen
Michael Niedermayer March 16, 2019, 10:49 p.m.
On Sat, Mar 16, 2019 at 05:24:46AM -0500, Rodger Combs wrote:
> Fixes some files misdetecting as MPEG PS
> ---
>  libavformat/mp3dec.c | 4 ++--

If MPEG PS misdetects a file, i would first try to fix the mpeg ps
probe to not misdetect it and produce a lower score for whatever
makes this file not mpeg-ps.

But i have not seen the file so this is just the general direction
i would look into ...

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index ef884934e1..81da0c6090 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -100,13 +100,13 @@  static int mp3_read_probe(AVProbeData *p)
         max_framesizes = FFMAX(max_framesizes, framesizes);
         if(buf == buf0) {
             first_frames= frames;
-            if (buf2 == end + sizeof(uint32_t))
+            if (buf2 >= end + sizeof(uint32_t))
                 whole_used = 1;
         }
     }
     // keep this in sync with ac3 probe, both need to avoid
     // issues with MPEG-files!
-    if   (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1;
+    if   (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1 + whole_used * FFMIN(first_frames / 2, 5);
     else if(max_frames>200 && p->buf_size < 2*max_framesizes)return AVPROBE_SCORE_EXTENSION;
     else if(max_frames>=4 && p->buf_size < 2*max_framesizes) return AVPROBE_SCORE_EXTENSION / 2;
     else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size)