[FFmpeg-devel] lavf/amr: Stricter heuristic for auto-detection.

Submitted by Carl Eugen Hoyos on April 4, 2018, 10:45 p.m.

Details

Message ID CAB0OVGrFmktL3nkDN_eNsJq16yb-+jKHXtrEP9_mqGHafu5HWg@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos April 4, 2018, 10:45 p.m.
Hi!

Attached patch fixes ticket #7125, the jpg file in question contains a
repeated pattern up to PROBE_SIZE that plays as amr_nb:
000d3290  05 14 51 40 05 14 51 40  05 14 51 40 05 14 51 40  |..Q@..Q@..Q@..Q@|
*
00112900  1f ff d9                                          |...|

Please comment, Carl Eugen

Comments

Michael Niedermayer April 5, 2018, 6:08 p.m.
On Thu, Apr 05, 2018 at 12:45:18AM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #7125, the jpg file in question contains a
> repeated pattern up to PROBE_SIZE that plays as amr_nb:
> 000d3290  05 14 51 40 05 14 51 40  05 14 51 40 05 14 51 40  |..Q@..Q@..Q@..Q@|
> *
> 00112900  1f ff d9                                          |...|
> 
> Please comment, Carl Eugen

>  amr.c |   10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 64ad2690251aff3bf4ce981e2b09e5102df0ba44  0001-lavf-amr-Stricter-heuristic-for-auto-detection.patch
> From 26712381d7dc3d3dfc623a77a80a697ffcd54124 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Thu, 5 Apr 2018 00:41:55 +0200
> Subject: [PATCH] lavf/amr: Stricter heuristic for auto-detection.
> 
> Fixes ticket #7125.

probably ok

thx

[...]
Carl Eugen Hoyos April 5, 2018, 10:24 p.m.
2018-04-05 20:08 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
> On Thu, Apr 05, 2018 at 12:45:18AM +0200, Carl Eugen Hoyos wrote:

>>  amr.c |   10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>> 64ad2690251aff3bf4ce981e2b09e5102df0ba44
>> 0001-lavf-amr-Stricter-heuristic-for-auto-detection.patch
>> From 26712381d7dc3d3dfc623a77a80a697ffcd54124 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Thu, 5 Apr 2018 00:41:55 +0200
>> Subject: [PATCH] lavf/amr: Stricter heuristic for auto-detection.
>>
>> Fixes ticket #7125.
>
> probably ok

Patch applied.

Thank you, Carl Eugen

Patch hide | download patch | download mbox

From 26712381d7dc3d3dfc623a77a80a697ffcd54124 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 5 Apr 2018 00:41:55 +0200
Subject: [PATCH] lavf/amr: Stricter heuristic for auto-detection.

Fixes ticket #7125.
---
 libavformat/amr.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 8b4d736..f954803 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -178,7 +178,7 @@  AVInputFormat ff_amr_demuxer = {
 #if CONFIG_AMRNB_DEMUXER
 static int amrnb_probe(AVProbeData *p)
 {
-    int mode, i = 0, valid = 0;
+    int mode, i = 0, valid = 0, invalid = 0;
     const uint8_t *b = p->buf;
 
     while (i < p->buf_size) {
@@ -197,10 +197,11 @@  static int amrnb_probe(AVProbeData *p)
             }
         } else {
             valid = 0;
+            invalid++;
             i++;
         }
     }
-    if (valid > 100)
+    if (valid > 100 && valid > invalid)
         return AVPROBE_SCORE_EXTENSION / 2 + 1;
     return 0;
 }
@@ -234,7 +235,7 @@  AVInputFormat ff_amrnb_demuxer = {
 #if CONFIG_AMRWB_DEMUXER
 static int amrwb_probe(AVProbeData *p)
 {
-    int mode, i = 0, valid = 0;
+    int mode, i = 0, valid = 0, invalid = 0;
     const uint8_t *b = p->buf;
 
     while (i < p->buf_size) {
@@ -253,10 +254,11 @@  static int amrwb_probe(AVProbeData *p)
             }
         } else {
             valid = 0;
+            invalid++;
             i++;
         }
     }
-    if (valid > 100)
+    if (valid > 100 && valid > invalid)
         return AVPROBE_SCORE_EXTENSION / 2 - 1;
     return 0;
 }
-- 
1.7.10.4