[FFmpeg-cvslog] r13888 - in trunk/libavcodec: cook.c dsputil.h imc.c mdct.c nellymoserdec.c

superdump subversion
Sun Jun 22 17:12:27 CEST 2008


Author: superdump
Date: Sun Jun 22 17:12:27 2008
New Revision: 13888

Log:
Add generic ff_sine_window_init function and implement in codecs appropriately


Modified:
   trunk/libavcodec/cook.c
   trunk/libavcodec/dsputil.h
   trunk/libavcodec/imc.c
   trunk/libavcodec/mdct.c
   trunk/libavcodec/nellymoserdec.c

Modified: trunk/libavcodec/cook.c
==============================================================================
--- trunk/libavcodec/cook.c	(original)
+++ trunk/libavcodec/cook.c	Sun Jun 22 17:12:27 2008
@@ -239,9 +239,9 @@ static int init_cook_mlt(COOKContext *q)
       return -1;
 
     /* Initialize the MLT window: simple sine window. */
-    alpha = M_PI / (2.0 * (float)mlt_size);
+    ff_sine_window_init(q->mlt_window, mlt_size);
     for(j=0 ; j<mlt_size ; j++)
-        q->mlt_window[j] = sin((j + 0.5) * alpha) * sqrt(2.0 / q->samples_per_channel);
+        q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel);
 
     /* Initialize the MDCT. */
     if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1)) {

Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h	(original)
+++ trunk/libavcodec/dsputil.h	Sun Jun 22 17:12:27 2008
@@ -649,6 +649,13 @@ typedef struct MDCTContext {
  */
 void ff_kbd_window_init(float *window, float alpha, int n);
 
+/**
+ * Generate a sine window.
+ * @param   window  pointer to half window
+ * @param   n       size of half window
+ */
+void ff_sine_window_init(float *window, int n);
+
 int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
 void ff_imdct_calc(MDCTContext *s, FFTSample *output,
                 const FFTSample *input, FFTSample *tmp);

Modified: trunk/libavcodec/imc.c
==============================================================================
--- trunk/libavcodec/imc.c	(original)
+++ trunk/libavcodec/imc.c	Sun Jun 22 17:12:27 2008
@@ -102,8 +102,9 @@ static av_cold int imc_decode_init(AVCod
         q->old_floor[i] = 1.0;
 
     /* Build mdct window, a simple sine window normalized with sqrt(2) */
+    ff_sine_window_init(q->mdct_sine_window, COEFFS);
     for(i = 0; i < COEFFS; i++)
-        q->mdct_sine_window[i] = sin((i + 0.5) / 512.0 * M_PI) * sqrt(2.0);
+        q->mdct_sine_window[i] *= sqrt(2.0);
     for(i = 0; i < COEFFS/2; i++){
         q->post_cos[i] = cos(i / 256.0 * M_PI);
         q->post_sin[i] = sin(i / 256.0 * M_PI);

Modified: trunk/libavcodec/mdct.c
==============================================================================
--- trunk/libavcodec/mdct.c	(original)
+++ trunk/libavcodec/mdct.c	Sun Jun 22 17:12:27 2008
@@ -48,6 +48,13 @@ void ff_kbd_window_init(float *window, f
        window[i] = sqrt(local_window[i] / sum);
 }
 
+// Generate a sine window.
+void ff_sine_window_init(float *window, int n) {
+    int i;
+    for(i = 0; i < n; i++)
+        window[i] = sin((i + 0.5) / (2 * n) * M_PI);
+}
+
 /**
  * init MDCT or IMDCT computation.
  */

Modified: trunk/libavcodec/nellymoserdec.c
==============================================================================
--- trunk/libavcodec/nellymoserdec.c	(original)
+++ trunk/libavcodec/nellymoserdec.c	Sun Jun 22 17:12:27 2008
@@ -148,9 +148,7 @@ static av_cold int decode_init(AVCodecCo
 
     /* Generate overlap window */
     if (!sine_window[0])
-        for (i=0 ; i<128; i++) {
-            sine_window[i] = sin((i + 0.5) / 256.0 * M_PI);
-        }
+        ff_sine_window_init(sine_window, 128);
 
     return 0;
 }




More information about the ffmpeg-cvslog mailing list