[FFmpeg-cvslog] avformat/dtsdec: count LE and BE separately in dts_probe()

Michael Niedermayer git at videolan.org
Sat Aug 2 17:41:14 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Aug  2 17:21:03 2014 +0200| [dd551dc7ff510ef74d49ab920e1f4f221292d4db] | committer: Michael Niedermayer

avformat/dtsdec: count LE and BE separately in dts_probe()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dd551dc7ff510ef74d49ab920e1f4f221292d4db
---

 libavformat/dtsdec.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index 23cbe93..227a02b 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -32,8 +32,8 @@ static int dts_probe(AVProbeData *p)
 {
     const uint8_t *buf, *bufp;
     uint32_t state = -1;
-    int markers[3] = {0};
-    int sum, max;
+    int markers[4] = {0};
+    int sum, max, i;
     int64_t diff = 0;
 
     buf = p->buf;
@@ -43,25 +43,29 @@ static int dts_probe(AVProbeData *p)
         state = (state << 16) | bytestream_get_be16(&bufp);
 
         /* regular bitstream */
-        if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
+        if (state == DCA_MARKER_RAW_BE)
             markers[0]++;
+        if (state == DCA_MARKER_RAW_LE)
+            markers[1]++;
 
         /* 14 bits big-endian bitstream */
         if (state == DCA_MARKER_14B_BE)
             if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
-                markers[1]++;
+                markers[2]++;
 
         /* 14 bits little-endian bitstream */
         if (state == DCA_MARKER_14B_LE)
             if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
-                markers[2]++;
+                markers[3]++;
 
         if (buf - p->buf >= 4)
             diff += FFABS(AV_RL16(buf) - AV_RL16(buf-4));
     }
-    sum = markers[0] + markers[1] + markers[2];
-    max = markers[1] > markers[0];
-    max = markers[2] > markers[max] ? 2 : max;
+    sum = markers[0] + markers[1] + markers[2] + markers[3];
+    max = 0;
+    for (i=1; i<4; i++)
+        if (markers[max] < markers[i])
+            max = i;
     if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 &&
         markers[max] * 4 > sum * 3 &&
         diff / p->buf_size > 200)



More information about the ffmpeg-cvslog mailing list