]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix error in AC3 parser
authorAndreas Öman <andreas@lonelycoder.com>
Wed, 30 Jun 2010 18:39:57 +0000 (18:39 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Wed, 30 Jun 2010 18:39:57 +0000 (18:39 +0000)
src/parsers.c

index 50608684bb1cae29d4c6dc9f6f0773ded9ec5d36..7e2f62117fb63f396320f6d32862caaf5daae70b 100644 (file)
@@ -606,14 +606,14 @@ parse_ac3(th_transport_t *t, th_stream_t *st, size_t ilen,
   len = st->st_buffer3_ptr;
 
   for(i = 0; i < len - 6; i++) {
-    if(ac3_valid_frame(buf + i)) {
-      int bsid      = buf[5] & 0xf;
+    const uint8_t *p = buf + i;
+    if(ac3_valid_frame(p)) {
+      int bsid      = p[5] & 0xf;
       int fsize, sr;
 
       if(bsid <= 10) {
-       int fscod     = buf[4] >> 6;
-       int frmsizcod = buf[4] & 0x3f;
-
+       int fscod     = p[4] >> 6;
+       int frmsizcod = p[4] & 0x3f;
        fsize  = ac3_frame_size_tab[frmsizcod][fscod] * 2;
 
        bsid -= 8;
@@ -623,13 +623,13 @@ parse_ac3(th_transport_t *t, th_stream_t *st, size_t ilen,
        
       } else {
 
-       fsize = ((((buf[2] & 0x7) << 8) | buf[3]) + 1) * 2;
+       fsize = ((((p[2] & 0x7) << 8) | p[3]) + 1) * 2;
        
        
-       if((buf[4] & 0xc0) == 0xc0) {
-         sr = ac3_freq_tab[(buf[4] >> 4) & 3] / 2;
+       if((p[4] & 0xc0) == 0xc0) {
+         sr = ac3_freq_tab[(p[4] >> 4) & 3] / 2;
        } else {
-         sr = ac3_freq_tab[(buf[4] >> 6) & 3];
+         sr = ac3_freq_tab[(p[4] >> 6) & 3];
        }
       }
 
@@ -640,10 +640,9 @@ parse_ac3(th_transport_t *t, th_stream_t *st, size_t ilen,
        if(dts == PTS_UNSET)
          dts = st->st_nextdts;
 
-       if(dts != PTS_UNSET && 
-          len >= i + fsize + 6 &&
-          ac3_valid_frame(buf + i + fsize)) {
-         makeapkt(t, st, buf + i, fsize, dts, duration);
+       if(dts != PTS_UNSET && len >= i + fsize + 6 &&
+          ac3_valid_frame(p + fsize)) {
+         makeapkt(t, st, p, fsize, dts, duration);
          buffer3_cut(st, i + fsize);
          goto again;
        }