[FFmpeg-cvslog] avformat/dtsdec: switch to common frame header parsing function

foo86 git at videolan.org
Wed Jul 19 03:08:04 EEST 2017


ffmpeg | branch: master | foo86 <foobaz86 at gmail.com> | Mon Jul 10 17:11:36 2017 +0300| [3b7ec920af42f1dc3676b72db9e617227c220436] | committer: James Almer

avformat/dtsdec: switch to common frame header parsing function

This makes probing for regular DTS more strict because more header
fields are checked and values not supported by decoder are now rejected.

Also fixes an issue original code had with 14-bit streams: 96 bits of
header were expected, however only 84 bits were converted, which was not
enough to parse LFE flag.

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavformat/dtsdec.c | 39 +++++++++------------------------------
 1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index 8c985b8877..6e0048f9bc 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -35,13 +35,13 @@ static int dts_probe(AVProbeData *p)
     uint32_t state = -1;
     int markers[4*16] = {0};
     int exss_markers = 0, exss_nextpos = 0;
-    int sum, max, pos, i;
+    int sum, max, pos, ret, i;
     int64_t diff = 0;
-    uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
+    uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
 
     for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {
-        int marker, sample_blocks, sample_rate, sr_code, framesize;
-        int lfe, wide_hdr, hdr_size;
+        int marker, wide_hdr, hdr_size, framesize;
+        DCACoreFrameHeader h;
         GetBitContext gb;
 
         bufp = buf = p->buf + pos;
@@ -98,36 +98,15 @@ static int dts_probe(AVProbeData *p)
         else
             continue;
 
-        if (avpriv_dca_convert_bitstream(buf-2, 12, hdr, 12) < 0)
+        if ((ret = avpriv_dca_convert_bitstream(buf - 2, DCA_CORE_FRAME_HEADER_SIZE,
+                                                hdr,     DCA_CORE_FRAME_HEADER_SIZE)) < 0)
             continue;
-
-        init_get_bits(&gb, hdr, 96);
-        skip_bits_long(&gb, 39);
-
-        sample_blocks = get_bits(&gb, 7) + 1;
-        if (sample_blocks < 8)
+        if (init_get_bits8(&gb, hdr, ret) < 0)
             continue;
-
-        framesize = get_bits(&gb, 14) + 1;
-        if (framesize < 95)
-            continue;
-
-        skip_bits(&gb, 6);
-        sr_code = get_bits(&gb, 4);
-        sample_rate = avpriv_dca_sample_rates[sr_code];
-        if (sample_rate == 0)
-            continue;
-
-        get_bits(&gb, 5);
-        if (get_bits(&gb, 1))
-            continue;
-
-        skip_bits_long(&gb, 9);
-        lfe = get_bits(&gb, 2);
-        if (lfe > 2)
+        if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
             continue;
 
-        marker += 4* sr_code;
+        marker += 4 * h.sr_code;
 
         markers[marker] ++;
     }



More information about the ffmpeg-cvslog mailing list