[Ffmpeg-cvslog] CVS: ffmpeg/libavcodec ac3enc.c, 1.31, 1.32 ac3tab.h, 1.7, 1.8
Benjamin Larsson CVS
banan
Sat Apr 22 23:21:19 CEST 2006
Update of /cvsroot/ffmpeg/ffmpeg/libavcodec
In directory mail:/var2/tmp/cvs-serv11932/libavcodec
Modified Files:
ac3enc.c ac3tab.h
Log Message:
Patch to generate the ac3 window, based on code by Justin Ruggles.
Index: ac3enc.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/ac3enc.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- ac3enc.c 10 Apr 2006 12:12:26 -0000 1.31
+++ ac3enc.c 22 Apr 2006 21:21:16 -0000 1.32
@@ -81,6 +81,51 @@
return v;
}
+
+/**
+ * Generate a Kaiser Window.
+ */
+static void k_window_init(int alpha, double *window, int n, int iter)
+{
+ int j, k;
+ double a, x;
+ a = alpha * M_PI / n;
+ a = a*a;
+ for(k=0; k<n; k++) {
+ x = k * (n - k) * a;
+ window[k] = 1.0;
+ for(j=iter; j>0; j--) {
+ window[k] = (window[k] * x / (j*j)) + 1.0;
+ }
+ }
+}
+
+/**
+ * Generate a Kaiser-Bessel Derived Window.
+ * @param alpha determines window shape
+ * @param window array to fill with window values
+ * @param iter number of iterations to use in BesselI0
+ */
+
+static void kbd_window_init(int alpha, int16_t *out_window, int iter)
+{
+ int k, n2;
+ double kwindow[256];
+ double window[256];
+
+ n2 = 256;
+ k_window_init(alpha, kwindow, n2, iter);
+ window[0] = kwindow[0];
+ for(k=1; k<n2; k++) {
+ window[k] = window[k-1] + kwindow[k];
+ }
+ for(k=0; k<n2; k++) {
+ window[k] = sqrt(window[k] / (window[n2-1]+1));
+ //out_window[k] = round(window[k]*((1<<15)-1)); //enable this for a rounded window
+ out_window[k] = fix15(window[k]);
+ }
+}
+
static inline int calc_lowcomp1(int a, int b0, int b1)
{
if ((b0 + 256) == b1) {
@@ -882,6 +927,8 @@
ac3_common_init();
/* mdct init */
+ kbd_window_init(5.0, ac3_window, 50);
+
fft_init(MDCT_NBITS - 2);
for(i=0;i<N/4;i++) {
alpha = 2 * M_PI * (i + 1.0 / 8.0) / (float)N;
Index: ac3tab.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/ac3tab.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ac3tab.h 6 Mar 2006 14:53:13 -0000 1.7
+++ ac3tab.h 22 Apr 2006 21:21:16 -0000 1.8
@@ -12,44 +12,6 @@
160, 192, 224, 256, 320, 384, 448, 512, 576, 640
};
-/* AC3 MDCT window */
-
-/* MDCT window */
-static const int16_t ac3_window[256] = {
- 4, 7, 12, 16, 21, 28, 34, 42,
- 51, 61, 72, 84, 97, 111, 127, 145,
- 164, 184, 207, 231, 257, 285, 315, 347,
- 382, 419, 458, 500, 544, 591, 641, 694,
- 750, 810, 872, 937, 1007, 1079, 1155, 1235,
- 1318, 1406, 1497, 1593, 1692, 1796, 1903, 2016,
- 2132, 2253, 2379, 2509, 2644, 2783, 2927, 3076,
- 3230, 3389, 3552, 3721, 3894, 4072, 4255, 4444,
- 4637, 4835, 5038, 5246, 5459, 5677, 5899, 6127,
- 6359, 6596, 6837, 7083, 7334, 7589, 7848, 8112,
- 8380, 8652, 8927, 9207, 9491, 9778,10069,10363,
-10660,10960,11264,11570,11879,12190,12504,12820,
-13138,13458,13780,14103,14427,14753,15079,15407,
-15735,16063,16392,16720,17049,17377,17705,18032,
-18358,18683,19007,19330,19651,19970,20287,20602,
-20914,21225,21532,21837,22139,22438,22733,23025,
-23314,23599,23880,24157,24430,24699,24964,25225,
-25481,25732,25979,26221,26459,26691,26919,27142,
-27359,27572,27780,27983,28180,28373,28560,28742,
-28919,29091,29258,29420,29577,29729,29876,30018,
-30155,30288,30415,30538,30657,30771,30880,30985,
-31086,31182,31274,31363,31447,31528,31605,31678,
-31747,31814,31877,31936,31993,32046,32097,32145,
-32190,32232,32272,32310,32345,32378,32409,32438,
-32465,32490,32513,32535,32556,32574,32592,32608,
-32623,32636,32649,32661,32671,32681,32690,32698,
-32705,32712,32718,32724,32729,32733,32737,32741,
-32744,32747,32750,32752,32754,32756,32757,32759,
-32760,32761,32762,32763,32764,32764,32765,32765,
-32766,32766,32766,32766,32767,32767,32767,32767,
-32767,32767,32767,32767,32767,32767,32767,32767,
-32767,32767,32767,32767,32767,32767,32767,32767,
-};
-
static uint8_t masktab[253];
static const uint8_t latab[260]= {
@@ -176,6 +138,9 @@
static uint8_t bndtab[51];
+/* AC3 MDCT window */
+static int16_t ac3_window[256];
+
/* fft & mdct sin cos tables */
static int16_t costab[64];
static int16_t sintab[64];
More information about the ffmpeg-cvslog
mailing list