diff ac3.c @ 4645:056127e5df89 libavcodec

remove redundancy in AC-3 parser by using common tables from ac3tab.h
author jbr
date Sun, 11 Mar 2007 02:13:05 +0000
parents 7e140e4cd8cb
children 5683b496ffbc
line wrap: on
line diff
--- a/ac3.c	Sat Mar 10 09:20:07 2007 +0000
+++ b/ac3.c	Sun Mar 11 02:13:05 2007 +0000
@@ -181,6 +181,11 @@
     } while (end > bndtab[j++]);
 }
 
+/**
+ * Initializes some tables.
+ * note: This function must remain thread safe because it is called by the
+ *       AVParser init code.
+ */
 void ac3_common_init(void)
 {
     int i, j, k, l, v;
@@ -194,4 +199,12 @@
         l += v;
     }
     bndtab[50] = l;
+
+    /* generate ff_ac3_frame_sizes table */
+    for(i=0; i<38; i++) {
+        int br = ff_ac3_bitratetab[i >> 1];
+        ff_ac3_frame_sizes[i][0] = (  2*br      );
+        ff_ac3_frame_sizes[i][1] = (320*br / 147) + (i & 1);
+        ff_ac3_frame_sizes[i][2] = (  3*br      );
+    }
 }