diff mbox

[FFmpeg-devel,FFmpeg-cvslog] lavf/amr: Make the heuristic for auto-detection even stricter.

Message ID CAB0OVGpqqCoeNdeW4j4spAyMbUTKUMc0fQrp690TyFqJqmh-vQ@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos June 25, 2018, 9:22 p.m. UTC
2018-06-23 14:43 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
> On Thu, Jun 21, 2018 at 10:09:14PM +0000, Carl Eugen Hoyos wrote:
>> ffmpeg | branch: master | Carl Eugen Hoyos <ceffmpeg@gmail.com> | Fri Jun
>> 22 00:08:13 2018 +0200| [40b7e6071815fc416a4efc5dc1616f5460a3aacb] |
>> committer: Carl Eugen Hoyos
>>
>> lavf/amr: Make the heuristic for auto-detection even stricter.
>>
>> Fixes ticket #7270.
>>
>> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40b7e6071815fc416a4efc5dc1616f5460a3aacb
>> ---
>>
>>  libavformat/amr.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavformat/amr.c b/libavformat/amr.c
>> index f954803d46..6cc06bceac 100644
>> --- a/libavformat/amr.c
>> +++ b/libavformat/amr.c
>> @@ -201,7 +201,7 @@ static int amrnb_probe(AVProbeData *p)
>>              i++;
>>          }
>>      }
>> -    if (valid > 100 && valid > invalid)
>> +    if (valid > 100 && valid >> 4 > invalid)
>>          return AVPROBE_SCORE_EXTENSION / 2 + 1;
>>      return 0;
>>  }
>> @@ -258,8 +258,8 @@ static int amrwb_probe(AVProbeData *p)
>>              i++;
>>          }
>>      }
>> -    if (valid > 100 && valid > invalid)
>> -        return AVPROBE_SCORE_EXTENSION / 2 - 1;
>> +    if (valid > 100 && valid >> 4 > invalid)
>> +        return AVPROBE_SCORE_EXTENSION / 2 + 1;
>
> This breaks detecting the h263 file:
>
> https://samples.ffmpeg.org/V-codecs/h263/h263-raw/messenger.h263

Attached patch fixes the existing heuristic to avoid detection of files
like this one.

Sorry, Carl Eugen

Comments

Michael Niedermayer June 25, 2018, 11:45 p.m. UTC | #1
On Mon, Jun 25, 2018 at 11:22:31PM +0200, Carl Eugen Hoyos wrote:
> 2018-06-23 14:43 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
> > On Thu, Jun 21, 2018 at 10:09:14PM +0000, Carl Eugen Hoyos wrote:
> >> ffmpeg | branch: master | Carl Eugen Hoyos <ceffmpeg@gmail.com> | Fri Jun
> >> 22 00:08:13 2018 +0200| [40b7e6071815fc416a4efc5dc1616f5460a3aacb] |
> >> committer: Carl Eugen Hoyos
> >>
> >> lavf/amr: Make the heuristic for auto-detection even stricter.
> >>
> >> Fixes ticket #7270.
> >>
> >> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40b7e6071815fc416a4efc5dc1616f5460a3aacb
> >> ---
> >>
> >>  libavformat/amr.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/libavformat/amr.c b/libavformat/amr.c
> >> index f954803d46..6cc06bceac 100644
> >> --- a/libavformat/amr.c
> >> +++ b/libavformat/amr.c
> >> @@ -201,7 +201,7 @@ static int amrnb_probe(AVProbeData *p)
> >>              i++;
> >>          }
> >>      }
> >> -    if (valid > 100 && valid > invalid)
> >> +    if (valid > 100 && valid >> 4 > invalid)
> >>          return AVPROBE_SCORE_EXTENSION / 2 + 1;
> >>      return 0;
> >>  }
> >> @@ -258,8 +258,8 @@ static int amrwb_probe(AVProbeData *p)
> >>              i++;
> >>          }
> >>      }
> >> -    if (valid > 100 && valid > invalid)
> >> -        return AVPROBE_SCORE_EXTENSION / 2 - 1;
> >> +    if (valid > 100 && valid >> 4 > invalid)
> >> +        return AVPROBE_SCORE_EXTENSION / 2 + 1;
> >
> > This breaks detecting the h263 file:
> >
> > https://samples.ffmpeg.org/V-codecs/h263/h263-raw/messenger.h263
> 
> Attached patch fixes the existing heuristic to avoid detection of files
> like this one.
> 
> Sorry, Carl Eugen

>  amr.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 4b51c43bba3a8a286dc8d8239936d615ab733ec5  0001-lavf-amr-Fix-heuristic-to-avoid-detection-of-repeate.patch
> From 3bfac3c9a525e8ce92c025ee2853a600d71e64d5 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Mon, 25 Jun 2018 23:20:09 +0200
> Subject: [PATCH] lavf/amr: Fix heuristic to avoid detection of repeated
>  bytes.

LGTM

thx

[...]
Carl Eugen Hoyos June 26, 2018, 9:05 p.m. UTC | #2
2018-06-26 1:45 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
> On Mon, Jun 25, 2018 at 11:22:31PM +0200, Carl Eugen Hoyos wrote:
>> 2018-06-23 14:43 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
>> > On Thu, Jun 21, 2018 at 10:09:14PM +0000, Carl Eugen Hoyos wrote:
>> >> ffmpeg | branch: master | Carl Eugen Hoyos <ceffmpeg@gmail.com> | Fri
>> >> Jun
>> >> 22 00:08:13 2018 +0200| [40b7e6071815fc416a4efc5dc1616f5460a3aacb] |
>> >> committer: Carl Eugen Hoyos
>> >>
>> >> lavf/amr: Make the heuristic for auto-detection even stricter.
>> >>
>> >> Fixes ticket #7270.
>> >>
>> >> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40b7e6071815fc416a4efc5dc1616f5460a3aacb
>> >> ---
>> >>
>> >>  libavformat/amr.c | 6 +++---
>> >>  1 file changed, 3 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/libavformat/amr.c b/libavformat/amr.c
>> >> index f954803d46..6cc06bceac 100644
>> >> --- a/libavformat/amr.c
>> >> +++ b/libavformat/amr.c
>> >> @@ -201,7 +201,7 @@ static int amrnb_probe(AVProbeData *p)
>> >>              i++;
>> >>          }
>> >>      }
>> >> -    if (valid > 100 && valid > invalid)
>> >> +    if (valid > 100 && valid >> 4 > invalid)
>> >>          return AVPROBE_SCORE_EXTENSION / 2 + 1;
>> >>      return 0;
>> >>  }
>> >> @@ -258,8 +258,8 @@ static int amrwb_probe(AVProbeData *p)
>> >>              i++;
>> >>          }
>> >>      }
>> >> -    if (valid > 100 && valid > invalid)
>> >> -        return AVPROBE_SCORE_EXTENSION / 2 - 1;
>> >> +    if (valid > 100 && valid >> 4 > invalid)
>> >> +        return AVPROBE_SCORE_EXTENSION / 2 + 1;
>> >
>> > This breaks detecting the h263 file:
>> >
>> > https://samples.ffmpeg.org/V-codecs/h263/h263-raw/messenger.h263
>>
>> Attached patch fixes the existing heuristic to avoid detection of files
>> like this one.
>>
>> Sorry, Carl Eugen
>
>>  amr.c |    6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>> 4b51c43bba3a8a286dc8d8239936d615ab733ec5
>> 0001-lavf-amr-Fix-heuristic-to-avoid-detection-of-repeate.patch
>> From 3bfac3c9a525e8ce92c025ee2853a600d71e64d5 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Mon, 25 Jun 2018 23:20:09 +0200
>> Subject: [PATCH] lavf/amr: Fix heuristic to avoid detection of repeated
>>  bytes.
>
> LGTM

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From 3bfac3c9a525e8ce92c025ee2853a600d71e64d5 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Mon, 25 Jun 2018 23:20:09 +0200
Subject: [PATCH] lavf/amr: Fix heuristic to avoid detection of repeated
 bytes.

---
 libavformat/amr.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index 6cc06bc..de34705 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -184,12 +184,11 @@  static int amrnb_probe(AVProbeData *p)
     while (i < p->buf_size) {
         mode = b[i] >> 3 & 0x0F;
         if (mode < 9 && (b[i] & 0x4) == 0x4) {
-            int last = mode;
+            int last = b[i];
             int size = amrnb_packed_size[mode];
             while (size--) {
                 if (b[++i] != last)
                     break;
-                last = b[i];
             }
             if (size > 0) {
                 valid++;
@@ -241,12 +240,11 @@  static int amrwb_probe(AVProbeData *p)
     while (i < p->buf_size) {
         mode = b[i] >> 3 & 0x0F;
         if (mode < 10 && (b[i] & 0x4) == 0x4) {
-            int last = mode;
+            int last = b[i];
             int size = amrwb_packed_size[mode];
             while (size--) {
                 if (b[++i] != last)
                     break;
-                last = b[i];
             }
             if (size > 0) {
                 valid++;
-- 
1.7.10.4