]> git.sesse.net Git - vlc/commitdiff
* Fixed heap corruption issues in ac3dec (thanks reno).
authorSam Hocevar <sam@videolan.org>
Tue, 13 Nov 2001 18:10:39 +0000 (18:10 +0000)
committerSam Hocevar <sam@videolan.org>
Tue, 13 Nov 2001 18:10:39 +0000 (18:10 +0000)
include/modules.h
plugins/ac3_adec/.cvsignore [new file with mode: 0644]
plugins/ac3_adec/ac3_adec.c
plugins/ac3_adec/ac3_imdct.c
plugins/ac3_spdif/.cvsignore [new file with mode: 0644]
plugins/imdct/ac3_imdct_sse.c
plugins/lpcm_adec/.cvsignore [new file with mode: 0644]
plugins/mpeg_adec/.cvsignore [new file with mode: 0644]
plugins/mpeg_vdec/.cvsignore [new file with mode: 0644]
plugins/spu_dec/.cvsignore [new file with mode: 0644]

index 1dc79dadf0f829f57a319e2002b9e99a41b89eb0..c44e3d3152483d672d6f0fe8fbe903d359d3d5f4 100644 (file)
@@ -2,7 +2,7 @@
  * modules.h : Module management functions.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules.h,v 1.31 2001/11/13 12:09:17 henri Exp $
+ * $Id: modules.h,v 1.32 2001/11/13 18:10:38 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -41,7 +41,7 @@ extern module_bank_t *p_module_bank;
  *****************************************************************************/
 
 /* Number of tries before we unload an unused module */
-#define MODULE_HIDE_DELAY 100
+#define MODULE_HIDE_DELAY 10000
 
 /* The module handle type. */
 #ifdef SYS_BEOS
diff --git a/plugins/ac3_adec/.cvsignore b/plugins/ac3_adec/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep
index 1559b04e3a8e0a6946acf857dc81b63596b57483..b790e3083c3df960d127ebc104254215dcdae0f9 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_adec.c: ac3 decoder module main file
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: ac3_adec.c,v 1.1 2001/11/13 12:09:17 henri Exp $
+ * $Id: ac3_adec.c,v 1.2 2001/11/13 18:10:38 sam Exp $
  *
  * Authors: Michel Lespinasse <walken@zoy.org>
  *
@@ -115,10 +115,7 @@ MODULE_DEACTIVATE_STOP
  *****************************************************************************/
 static int ac3_adec_Probe( probedata_t *p_data )
 {
-    if( p_data->i_type == AC3_AUDIO_ES )
-        return( 50 );
-    else
-        return( 0 );
+    return ( p_data->i_type == AC3_AUDIO_ES ) ? 50 : 0;
 }
 
 /*****************************************************************************
@@ -134,10 +131,11 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
     /* Allocate the memory needed to store the thread's structure */
     p_ac3thread = (ac3dec_thread_t *)memalign(16, sizeof(ac3dec_thread_t));
 
-    if(p_ac3thread == NULL)
+    if( p_ac3thread == NULL )
     {
         intf_ErrMsg ( "ac3dec error: not enough memory "
                       "for ac3_adec_Run() to allocate p_ac3thread" );
+        free( p_ac3thread->p_config );
         return( -1 );
     }
    
@@ -148,6 +146,8 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
     if( ac3_adec_Init( p_ac3thread ) )
     {
         intf_ErrMsg( "ac3_adec error : could not initialize thread" );
+        free( p_ac3thread->p_config );
+        free( p_ac3thread );
         return( -1 );
     }
 
@@ -227,7 +227,10 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
 
     /* End of the ac3 decoder thread */
     ac3_adec_EndThread (p_ac3thread);
-    
+
+    free( p_ac3thread->p_config );
+    free( p_ac3thread );
+
     return( 0 );
 }
 
@@ -253,7 +256,6 @@ static int ac3_adec_Init( ac3dec_thread_t * p_ac3thread )
     {
         intf_ErrMsg( "ac3dec error: no suitable downmix module" );
         free( p_ac3thread->ac3_decoder );
-        free( p_ac3thread );
         return( -1 );
     }
 
@@ -282,7 +284,6 @@ static int ac3_adec_Init( ac3dec_thread_t * p_ac3thread )
         module_Unneed( p_ac3thread->ac3_decoder->downmix.p_module );
         free( p_ac3thread->ac3_decoder->imdct );
         free( p_ac3thread->ac3_decoder );
-        free( p_ac3thread );
         return( -1 );
     }
 
@@ -293,34 +294,35 @@ static int ac3_adec_Init( ac3dec_thread_t * p_ac3thread )
     IMDCT->pf_imdct_512     = F.pf_imdct_512;
     IMDCT->pf_imdct_512_nol = F.pf_imdct_512_nol;
 #undef F
-#undef IMDCT
 
     /* Initialize the ac3 decoder structures */
+#define p_dec p_ac3thread->ac3_decoder
 #if defined( __MINGW32__ )
-    p_ac3thread->ac3_decoder->samples_back = memalign(16, 6 * 256 *
-        sizeof(float) + 15);
-    p_ac3thread->ac3_decoder->samples = (float *) (((unsigned long)
-        p_ac3thread->ac3_decoder->samples_back+15) & ~0xFUL);
+    p_dec->samples_back = memalign( 16, 6 * 256 * sizeof(float) + 15 );
+    p_dec->samples = (float *)
+                     (((unsigned long) p_dec->samples_back + 15 ) & ~0xFUL);
 #else
-     p_ac3thread->ac3_decoder->samples = memalign(16, 6 * 256 * sizeof(float));
+    p_dec->samples = memalign( 16, 6 * 256 * sizeof(float) );
 #endif
-    p_ac3thread->ac3_decoder->imdct->buf = memalign(16, N/4 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->delay = memalign(16, 6 * 256 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->delay1 = memalign(16, 6 * 256 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->xcos1 = memalign(16, N/4 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->xsin1 = memalign(16, N/4 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->xcos2 = memalign(16, N/8 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->xsin2 = memalign(16, N/8 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->xcos_sin_sse = memalign(16, 128 * 4 * sizeof(float));
-    p_ac3thread->ac3_decoder->imdct->w_2 = memalign(16, 2 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->w_4 = memalign(16, 4 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->w_8 = memalign(16, 8 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->w_16 = memalign(16, 16 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->w_32 = memalign(16, 32 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->w_64 = memalign(16, 64 * sizeof(complex_t));
-    p_ac3thread->ac3_decoder->imdct->w_1 = memalign(16, sizeof(complex_t));
-
-    ac3_init (p_ac3thread->ac3_decoder);
+#undef p_dec
+
+    IMDCT->buf    = memalign( 16, N/4 * sizeof(complex_t) );
+    IMDCT->delay  = memalign( 16, 6 * 256 * sizeof(float) );
+    IMDCT->delay1 = memalign( 16, 6 * 256 * sizeof(float) );
+    IMDCT->xcos1  = memalign( 16, N/4 * sizeof(float) );
+    IMDCT->xsin1  = memalign( 16, N/4 * sizeof(float) );
+    IMDCT->xcos2  = memalign( 16, N/8 * sizeof(float) );
+    IMDCT->xsin2  = memalign( 16, N/8 * sizeof(float) );
+    IMDCT->xcos_sin_sse = memalign( 16, 128 * 4 * sizeof(float) );
+    IMDCT->w_1    = memalign( 16, 1  * sizeof(complex_t) );
+    IMDCT->w_2    = memalign( 16, 2  * sizeof(complex_t) );
+    IMDCT->w_4    = memalign( 16, 4  * sizeof(complex_t) );
+    IMDCT->w_8    = memalign( 16, 8  * sizeof(complex_t) );
+    IMDCT->w_16   = memalign( 16, 16 * sizeof(complex_t) );
+    IMDCT->w_32   = memalign( 16, 32 * sizeof(complex_t) );
+    IMDCT->w_64   = memalign( 16, 64 * sizeof(complex_t) );
+
+    ac3_init( p_ac3thread->ac3_decoder );
 
     /*
      * Initialize the output properties
@@ -343,6 +345,30 @@ static int ac3_adec_Init( ac3dec_thread_t * p_ac3thread )
                                                AC3DEC_FRAME_SIZE, NULL  );
     if ( p_ac3thread->p_aout_fifo == NULL )
     {
+        free( IMDCT->w_1 );
+        free( IMDCT->w_64 );
+        free( IMDCT->w_32 );
+        free( IMDCT->w_16 );
+        free( IMDCT->w_8 );
+        free( IMDCT->w_4 );
+        free( IMDCT->w_2 );
+        free( IMDCT->xcos_sin_sse );
+        free( IMDCT->xsin2 );
+        free( IMDCT->xcos2 );
+        free( IMDCT->xsin1 );
+        free( IMDCT->xcos1 );
+        free( IMDCT->delay1 );
+        free( IMDCT->delay );
+        free( IMDCT->buf );
+#undef IMDCT
+
+#if defined( __MINGW32__ )
+        free( p_ac3thread->ac3_decoder->samples_back );
+#else
+        free( p_ac3thread->ac3_decoder->samples );
+#endif
+        free( p_ac3thread->ac3_decoder->imdct );
+        free( p_ac3thread->ac3_decoder );
         return( -1 );
     }
 
@@ -405,21 +431,24 @@ static void ac3_adec_EndThread (ac3dec_thread_t * p_ac3thread)
     module_Unneed( p_ac3thread->ac3_decoder->imdct->p_module );
 
     /* Destroy descriptor */
-    free( p_ac3thread->ac3_decoder->imdct->w_1 );
-    free( p_ac3thread->ac3_decoder->imdct->w_64 );
-    free( p_ac3thread->ac3_decoder->imdct->w_32 );
-    free( p_ac3thread->ac3_decoder->imdct->w_16 );
-    free( p_ac3thread->ac3_decoder->imdct->w_8 );
-    free( p_ac3thread->ac3_decoder->imdct->w_4 );
-    free( p_ac3thread->ac3_decoder->imdct->w_2 );
-    free( p_ac3thread->ac3_decoder->imdct->xcos_sin_sse );
-    free( p_ac3thread->ac3_decoder->imdct->xsin2 );
-    free( p_ac3thread->ac3_decoder->imdct->xcos2 );
-    free( p_ac3thread->ac3_decoder->imdct->xsin1 );
-    free( p_ac3thread->ac3_decoder->imdct->xcos1 );
-    free( p_ac3thread->ac3_decoder->imdct->delay1 );
-    free( p_ac3thread->ac3_decoder->imdct->delay );
-    free( p_ac3thread->ac3_decoder->imdct->buf );
+#define IMDCT p_ac3thread->ac3_decoder->imdct
+    free( IMDCT->w_1 );
+    free( IMDCT->w_64 );
+    free( IMDCT->w_32 );
+    free( IMDCT->w_16 );
+    free( IMDCT->w_8 );
+    free( IMDCT->w_4 );
+    free( IMDCT->w_2 );
+    free( IMDCT->xcos_sin_sse );
+    free( IMDCT->xsin2 );
+    free( IMDCT->xcos2 );
+    free( IMDCT->xsin1 );
+    free( IMDCT->xcos1 );
+    free( IMDCT->delay1 );
+    free( IMDCT->delay );
+    free( IMDCT->buf );
+#undef IMDCT
+
 #if defined( __MINGW32__ )
     free( p_ac3thread->ac3_decoder->samples_back );
 #else
@@ -427,17 +456,15 @@ static void ac3_adec_EndThread (ac3dec_thread_t * p_ac3thread)
 #endif
     free( p_ac3thread->ac3_decoder->imdct );
     free( p_ac3thread->ac3_decoder );
-    free( p_ac3thread->p_config );
-    free( p_ac3thread );
 
-    intf_DbgMsg ("ac3dec debug: ac3 decoder thread %p destroyed", p_ac3thread);
+    intf_DbgMsg( "ac3dec debug: ac3 decoder thread %p destroyed", p_ac3thread );
 }
 
 /*****************************************************************************
-* BitstreamCallback: Import parameters from the new data/PES packet
-*****************************************************************************
-* This function is called by input's NextDataPacket.
-*****************************************************************************/
+ * BitstreamCallback: Import parameters from the new data/PES packet
+ *****************************************************************************
+ * This function is called by input's NextDataPacket.
+ *****************************************************************************/
 static void BitstreamCallback ( bit_stream_t * p_bit_stream,
                                         boolean_t b_new_pes)
 {
index 7b30b0812ac47f44fc4de3ac21bd9eefae832a43..cb216ece8b17fdf4c07814cd535796c4ac8a5281 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_imdct.c: ac3 DCT
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: ac3_imdct.c,v 1.1 2001/11/13 12:09:17 henri Exp $
+ * $Id: ac3_imdct.c,v 1.2 2001/11/13 18:10:38 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Aaron Holtzman <aholtzma@engr.uvic.ca>
@@ -140,10 +140,16 @@ void imdct (ac3dec_t * p_ac3dec, s16 * buffer)
         for (i=0; i<p_ac3dec->bsi.nfchans; i++)
         {
             if (p_ac3dec->audblk.blksw[i])
+            {
                 /* There is only a C function */
-                p_ac3dec->imdct->pf_imdct_256_nol (p_ac3dec->imdct, p_ac3dec->samples+256*i, p_ac3dec->imdct->delay1+256*i);
+                p_ac3dec->imdct->pf_imdct_256_nol( p_ac3dec->imdct,
+                     p_ac3dec->samples+256*i, p_ac3dec->imdct->delay1+256*i );
+            }
             else
-                p_ac3dec->imdct->pf_imdct_512_nol (p_ac3dec->imdct, p_ac3dec->samples+256*i, p_ac3dec->imdct->delay1+256*i);
+            {
+                p_ac3dec->imdct->pf_imdct_512_nol( p_ac3dec->imdct,
+                     p_ac3dec->samples+256*i, p_ac3dec->imdct->delay1+256*i );
+            }
         }
 
         /* mix the sample, overlap */
diff --git a/plugins/ac3_spdif/.cvsignore b/plugins/ac3_spdif/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep
index fe155204290be12297b9006737aefbad369ff072..c397193d5a6afcbd284e54d0427bf7d6b76cd42a 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_imdct_sse.c: accelerated SSE ac3 DCT
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: ac3_imdct_sse.c,v 1.6 2001/10/30 19:34:53 reno Exp $
+ * $Id: ac3_imdct_sse.c,v 1.7 2001/11/13 18:10:38 sam Exp $
  *
  * Authors: Renaud Dartus <reno@videolan.org>
  *          Aaron Holtzman <aholtzma@engr.uvic.ca>
 void _M( fft_64p )  ( complex_t *x );
 void _M( fft_128p ) ( complex_t *a );
 
-static void imdct512_pre_ifft_twiddle_sse (const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse);
-static void imdct512_post_ifft_twiddle_sse (complex_t *buf, float *xcos_sin_sse);
-static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt);
-static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt);
-
+static void imdct512_pre_ifft_twiddle_sse  ( const int *, complex_t *,
+                                             float *, float * );
+static void imdct512_post_ifft_twiddle_sse ( complex_t *, float * );
+static void imdct512_window_delay_sse      ( complex_t *, float *,
+                                             float *, float * );
+static void imdct512_window_delay_nol_sse  ( complex_t *, float *,
+                                             float *, float * );
 
 void _M( imdct_init ) (imdct_t * p_imdct)
 {
@@ -73,19 +75,21 @@ void _M( imdct_init ) (imdct_t * p_imdct)
 
 void _M( imdct_do_512 ) (imdct_t * p_imdct, float data[], float delay[])
 {
-    imdct512_pre_ifft_twiddle_sse (pm128, p_imdct->buf, data, p_imdct->xcos_sin_sse);
+    imdct512_pre_ifft_twiddle_sse( pm128, p_imdct->buf, data,
+                                   p_imdct->xcos_sin_sse );
     _M( fft_128p ) ( p_imdct->buf );
-    imdct512_post_ifft_twiddle_sse (p_imdct->buf, p_imdct->xcos_sin_sse);
-    imdct512_window_delay_sse (p_imdct->buf, data, window, delay);
+    imdct512_post_ifft_twiddle_sse( p_imdct->buf, p_imdct->xcos_sin_sse );
+    imdct512_window_delay_sse( p_imdct->buf, data, window, delay );
 }
 
 
 void _M( imdct_do_512_nol ) (imdct_t * p_imdct, float data[], float delay[])
 {
-    imdct512_pre_ifft_twiddle_sse (pm128, p_imdct->buf, data, p_imdct->xcos_sin_sse);  
+    imdct512_pre_ifft_twiddle_sse( pm128, p_imdct->buf, data,
+                                   p_imdct->xcos_sin_sse );
     _M( fft_128p ) ( p_imdct->buf );
-    imdct512_post_ifft_twiddle_sse (p_imdct->buf, p_imdct->xcos_sin_sse);
-    imdct512_window_delay_nol_sse (p_imdct->buf, data, window, delay);
+    imdct512_post_ifft_twiddle_sse( p_imdct->buf, p_imdct->xcos_sin_sse );
+    imdct512_window_delay_nol_sse( p_imdct->buf, data, window, delay );
 }
 
 static void imdct512_pre_ifft_twiddle_sse (const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse)
@@ -408,7 +412,8 @@ static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, float *w
     
 }
 
-static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt)
+static void imdct512_window_delay_nol_sse( complex_t *buf, float *data_ptr,
+                                           float *window_prt, float *delay_prt )
 {
     __asm__ __volatile__ (
     ".align 16\n"
@@ -501,7 +506,6 @@ static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, floa
     "leal 512(%%ebp), %%esi\n"  /* buf[64].re */
     "leal 508(%%ebp), %%edi\n"  /* buf[63].im */
     "movl $16, %%ebx\n"         /* loop count */
-    "addl  $-1024, %%ecx\n"  /* delay */
     
     ".align 16\n"
 ".first_128_delays:\n"
diff --git a/plugins/lpcm_adec/.cvsignore b/plugins/lpcm_adec/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep
diff --git a/plugins/mpeg_adec/.cvsignore b/plugins/mpeg_adec/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep
diff --git a/plugins/mpeg_vdec/.cvsignore b/plugins/mpeg_vdec/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep
diff --git a/plugins/spu_dec/.cvsignore b/plugins/spu_dec/.cvsignore
new file mode 100644 (file)
index 0000000..63e7180
--- /dev/null
@@ -0,0 +1 @@
+.dep