]> git.sesse.net Git - vlc/commitdiff
travail sur l'ac3_decoder : debut de separation de ce qui est specifique a
authorMichel Lespinasse <walken@videolan.org>
Tue, 22 Feb 2000 22:54:22 +0000 (22:54 +0000)
committerMichel Lespinasse <walken@videolan.org>
Tue, 22 Feb 2000 22:54:22 +0000 (22:54 +0000)
videolan (ac3_decoder_thread) et de ce qui ne l'est pas. Ce n'est pas encore
ideal, la partie "videolan" fait des inits a l'interieur de la partie
"ac3"... il faudra que je fasse une belle interface pour ca.

Le probleme des includes n'est pas non plus regle, mais c'est a cause des
bit_streams :) patience.

20 files changed:
Makefile
include/ac3_decoder.h
include/ac3_decoder_thread.h [new file with mode: 0644]
src/ac3_decoder/ac3_bit_allocate.c
src/ac3_decoder/ac3_bit_allocate.h
src/ac3_decoder/ac3_decoder.c
src/ac3_decoder/ac3_downmix.c
src/ac3_decoder/ac3_downmix.h
src/ac3_decoder/ac3_exponent.c
src/ac3_decoder/ac3_exponent.h
src/ac3_decoder/ac3_imdct.c
src/ac3_decoder/ac3_imdct.h
src/ac3_decoder/ac3_mantissa.c
src/ac3_decoder/ac3_mantissa.h
src/ac3_decoder/ac3_parse.c
src/ac3_decoder/ac3_parse.h
src/ac3_decoder/ac3_rematrix.c
src/ac3_decoder/ac3_rematrix.h
src/input/input.c
src/input/input_ctrl.c

index 7bf3c0846179e38281ca2d173413830bca275662..929d9266ad06b7268e78b242750c9f2adb30399f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -201,7 +201,8 @@ video_output_obj =          video_output/video_output.o \
                                                video_output/video_text.o \
                                                video_output/video_yuv.o
 
-ac3_decoder_obj =              ac3_decoder/ac3_decoder.o \
+ac3_decoder_obj =              ac3_decoder/ac3_decoder_thread.o \
+                                               ac3_decoder/ac3_decoder.o \
                                                ac3_decoder/ac3_parse.o \
                                                ac3_decoder/ac3_exponent.o \
                                                ac3_decoder/ac3_bit_allocate.o \
index 269f123b865b7af4a38cb4c09f4d706b967bccd1..92b05196bbe9868f7640df0b9539063a6128a64b 100644 (file)
@@ -325,22 +325,16 @@ typedef struct stream_samples_s
 typedef s16 ac3dec_frame_t[ AC3DEC_FRAME_SIZE ];
 
 /*****************************************************************************
- * ac3dec_thread_t : ac3 decoder thread descriptor
+ * ac3dec_t : ac3 decoder descriptor
  *****************************************************************************/
-typedef struct ac3dec_thread_s
+typedef struct ac3dec_s
 {
-    /*
-     * Thread properties
-     */
-    vlc_thread_t        thread_id;                /* id for thread functions */
-    boolean_t           b_die;                                 /* `die' flag */
-    boolean_t           b_error;                             /* `error' flag */
     boolean_t           b_invalid;                         /* `invalid' flag */
 
     /*
      * Input properties
      */
-    decoder_fifo_t      fifo;                  /* stores the PES stream data */
+
     /* The bit stream structure handles the PES stream at the bit level */
     bit_stream_t        bit_stream;
 
@@ -356,16 +350,6 @@ typedef struct ac3dec_thread_s
     stream_coeffs_t     coeffs;
     stream_samples_t    samples;
 
-    /*
-     * Output properties
-     */
-    aout_fifo_t *       p_aout_fifo; /* stores the decompressed audio frames */
-    aout_thread_t *     p_aout;           /* needed to create the audio fifo */
-
-} ac3dec_thread_t;
+} ac3dec_t;
 
-/*****************************************************************************
- * Prototypes
- *****************************************************************************/
-ac3dec_thread_t *       ac3dec_CreateThread( input_thread_t * p_input );
-void                    ac3dec_DestroyThread( ac3dec_thread_t * p_ac3dec );
+int ac3_audio_block (ac3dec_t * p_ac3dec, s16 * buffer);
diff --git a/include/ac3_decoder_thread.h b/include/ac3_decoder_thread.h
new file mode 100644 (file)
index 0000000..03894a2
--- /dev/null
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * ac3_decoder.h : ac3 decoder thread interface
+ * (c)1999 VideoLAN
+ *****************************************************************************/
+
+/*****************************************************************************
+ * ac3dec_thread_t : ac3 decoder thread descriptor
+ *****************************************************************************/
+typedef struct ac3dec_thread_s
+{
+    /*
+     * Thread properties
+     */
+    vlc_thread_t        thread_id;                /* id for thread functions */
+    boolean_t           b_die;                                 /* `die' flag */
+    boolean_t           b_error;                             /* `error' flag */
+
+    /*
+     * Input properties
+     */
+    decoder_fifo_t      fifo;                  /* stores the PES stream data */
+
+    /*
+     * Decoder properties
+     */
+
+    ac3dec_t            ac3_decoder;
+
+    /*
+     * Output properties
+     */
+    aout_fifo_t *       p_aout_fifo; /* stores the decompressed audio frames */
+    aout_thread_t *     p_aout;           /* needed to create the audio fifo */
+
+} ac3dec_thread_t;
+
+/*****************************************************************************
+ * Prototypes
+ *****************************************************************************/
+ac3dec_thread_t *       ac3dec_CreateThread( input_thread_t * p_input );
+void                    ac3dec_DestroyThread( ac3dec_thread_t * p_ac3dec );
index 526171a2333f99d13453d059a51ee64806a42ffc..167734735fbf29af3da2f294094bc31ae9e160fe 100644 (file)
@@ -202,7 +202,7 @@ static __inline__ s16 calc_lowcomp( s16 a, s16 b0, s16 b1, s16 bin )
        return(a);
 }
 
-void bit_allocate( ac3dec_thread_t * p_ac3dec )
+void bit_allocate( ac3dec_t * p_ac3dec )
 {
        u16 i;
        s16 fgain;
index 9332be6b32bfb8bb68ad2f77e3457a30b7369773..d5bd8e9e779f911564bdebd99171882ddf72cb81 100644 (file)
@@ -1 +1 @@
-void bit_allocate( ac3dec_thread_t * );
+void bit_allocate( ac3dec_t * );
index 483bfc18b230f20a10b22271dcd331ef69b40ea6..8a74b68ce02f1e44dfb0b0027f7e272f977cd644 100644 (file)
-/*****************************************************************************
- * ac3_decoder.c: ac3 decoder thread
- * (c)1999 VideoLAN
- *****************************************************************************/
-
-/*
- * TODO :
- *
- * - vérifier l'état de la fifo de sortie avant d'y stocker les samples
- *   décodés ;
- * - vlc_cond_signal() / vlc_cond_wait()
- *
- */
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <unistd.h>                                              /* getpid() */
-
-#include <stdio.h>                                           /* "intf_msg.h" */
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <sys/soundcard.h>                               /* "audio_output.h" */
-#include <sys/uio.h>                                            /* "input.h" */
-
-#include "common.h"
-#include "config.h"
-#include "mtime.h"
-#include "vlc_thread.h"
-#include "debug.h"                                      /* "input_netlist.h" */
-
-#include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
-
-#include "input.h"                                           /* pes_packet_t */
-#include "input_netlist.h"                         /* input_NetlistFreePES() */
-#include "decoder_fifo.h"         /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
-
-#include "audio_output.h"
-
-#include "ac3_decoder.h"
-#include "ac3_parse.h"
-#include "ac3_exponent.h"
-#include "ac3_bit_allocate.h"
-#include "ac3_mantissa.h"
-#include "ac3_rematrix.h"
-#include "ac3_imdct.h"
-#include "ac3_downmix.h"
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int      InitThread              ( ac3dec_thread_t * p_adec );
-static void     RunThread               ( ac3dec_thread_t * p_adec );
-static void     ErrorThread             ( ac3dec_thread_t * p_adec );
-static void     EndThread               ( ac3dec_thread_t * p_adec );
-
-/*****************************************************************************
- * ac3dec_CreateThread: creates an ac3 decoder thread
- *****************************************************************************/
-ac3dec_thread_t * ac3dec_CreateThread( input_thread_t * p_input )
-{
-    ac3dec_thread_t *   p_ac3dec;
-
-    intf_DbgMsg("ac3dec debug: creating ac3 decoder thread\n");
-
-    /* Allocate the memory needed to store the thread's structure */
-    if ( (p_ac3dec = (ac3dec_thread_t *)malloc( sizeof(ac3dec_thread_t) )) == NULL )
-    {
-        intf_ErrMsg("ac3dec error: not enough memory for ac3dec_CreateThread() to create the new thread\n");
-        return( NULL );
-    }
-
-    /*
-     * Initialize the thread properties
-     */
-    p_ac3dec->b_die = 0;
-    p_ac3dec->b_error = 0;
-
-    /*
-     * Initialize the input properties
-     */
-    /* Initialize the decoder fifo's data lock and conditional variable and set
-     * its buffer as empty */
-    vlc_mutex_init( &p_ac3dec->fifo.data_lock );
-    vlc_cond_init( &p_ac3dec->fifo.data_wait );
-    p_ac3dec->fifo.i_start = 0;
-    p_ac3dec->fifo.i_end = 0;
-    /* Initialize the bit stream structure */
-    p_ac3dec->bit_stream.p_input = p_input;
-    p_ac3dec->bit_stream.p_decoder_fifo = &p_ac3dec->fifo;
-    p_ac3dec->bit_stream.fifo.buffer = 0;
-    p_ac3dec->bit_stream.fifo.i_available = 0;
-
-    /*
-     * Initialize the output properties
-     */
-    p_ac3dec->p_aout = p_input->p_aout;
-    p_ac3dec->p_aout_fifo = NULL;
-
-    imdct_init();
-
-    /* Spawn the ac3 decoder thread */
-    if ( vlc_thread_create(&p_ac3dec->thread_id, "ac3 decoder", (vlc_thread_func_t)RunThread, (void *)p_ac3dec) )
-    {
-        intf_ErrMsg( "ac3dec error: can't spawn ac3 decoder thread\n" );
-        free( p_ac3dec );
-        return( NULL );
-    }
-
-    intf_DbgMsg( "ac3dec debug: ac3 decoder thread (%p) created\n", p_ac3dec );
-    return( p_ac3dec );
-}
-
-/*****************************************************************************
- * ac3dec_DestroyThread: destroys an ac3 decoder thread
- *****************************************************************************/
-void ac3dec_DestroyThread( ac3dec_thread_t * p_ac3dec )
-{
-    intf_DbgMsg( "ac3dec debug: requesting termination of ac3 decoder thread %p\n", p_ac3dec );
-
-    /* Ask thread to kill itself */
-    p_ac3dec->b_die = 1;
-
-    /* Make sure the decoder thread leaves the GetByte() function */
-    vlc_mutex_lock( &(p_ac3dec->fifo.data_lock) );
-    vlc_cond_signal( &(p_ac3dec->fifo.data_wait) );
-    vlc_mutex_unlock( &(p_ac3dec->fifo.data_lock) );
-
-    /* Waiting for the decoder thread to exit */
-    /* Remove this as soon as the "status" flag is implemented */
-    vlc_thread_join( p_ac3dec->thread_id );
-}
-
-/* Following functions are local */
-
-/*****************************************************************************
- * decode_find_sync()
- *****************************************************************************/
-static __inline__ int decode_find_sync( ac3dec_thread_t * p_ac3dec )
-{
-    while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) )
-    {
-        NeedBits( &(p_ac3dec->bit_stream), 16 );
-        if ( (p_ac3dec->bit_stream.fifo.buffer >> (32 - 16)) == 0x0b77 )
-        {
-            DumpBits( &(p_ac3dec->bit_stream), 16 );
-            p_ac3dec->total_bits_read = 16;
-            return( 0 );
-        }
-        DumpBits( &(p_ac3dec->bit_stream), 1 ); /* XXX */
-    }
-    return( -1 );
-}
-
-/*****************************************************************************
- * InitThread : initialize an ac3 decoder thread
- *****************************************************************************/
-static int InitThread( ac3dec_thread_t * p_ac3dec )
-{
-    aout_fifo_t         aout_fifo;
-
-    intf_DbgMsg( "ac3dec debug: initializing ac3 decoder thread %p\n", p_ac3dec );
-
-    /* Our first job is to initialize the bit stream structure with the
-     * beginning of the input stream */
-    vlc_mutex_lock( &p_ac3dec->fifo.data_lock );
-    while ( DECODER_FIFO_ISEMPTY(p_ac3dec->fifo) )
-    {
-        if ( p_ac3dec->b_die )
-        {
-            vlc_mutex_unlock( &p_ac3dec->fifo.data_lock );
-            return( -1 );
-        }
-        vlc_cond_wait( &p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock );
-    }
-    p_ac3dec->bit_stream.p_ts = DECODER_FIFO_START( p_ac3dec->fifo )->p_first_ts;
-    p_ac3dec->bit_stream.p_byte = p_ac3dec->bit_stream.p_ts->buffer + p_ac3dec->bit_stream.p_ts->i_payload_start;
-    p_ac3dec->bit_stream.p_end = p_ac3dec->bit_stream.p_ts->buffer + p_ac3dec->bit_stream.p_ts->i_payload_end;
-    vlc_mutex_unlock( &p_ac3dec->fifo.data_lock );
-
-    aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO;
-    aout_fifo.i_channels = 2;
-    aout_fifo.b_stereo = 1;
-
-    aout_fifo.l_frame_size = AC3DEC_FRAME_SIZE;
-
-    /* Creating the audio output fifo */
-    if ( (p_ac3dec->p_aout_fifo = aout_CreateFifo(p_ac3dec->p_aout, &aout_fifo)) == NULL )
-    {
-        return( -1 );
+#include <math.h> 
+#include <sys/uio.h>                                            /* "input.h" */ 
+#include "common.h" 
+#include "config.h" 
+#include "vlc_thread.h" 
+#include "mtime.h" 
+#include "input.h" 
+#include "decoder_fifo.h" 
+#include "audio_output.h" 
+
+#include "ac3_decoder.h" 
+#include "ac3_parse.h" 
+#include "ac3_exponent.h" 
+#include "ac3_bit_allocate.h" 
+#include "ac3_mantissa.h" 
+#include "ac3_rematrix.h" 
+#include "ac3_imdct.h" 
+#include "ac3_downmix.h" 
+
+int ac3_audio_block (ac3dec_t * p_ac3dec, s16 * buffer)
+    {
+    parse_audblk( p_ac3dec );
+    exponent_unpack( p_ac3dec );
+    if ( p_ac3dec->b_invalid )
+       return 1;
+    bit_allocate( p_ac3dec );
+    mantissa_unpack( p_ac3dec );
+    if ( p_ac3dec->b_invalid )
+       return 1;
+    if ( p_ac3dec->bsi.acmod == 0x2 )
+       rematrix( p_ac3dec );
+    imdct( p_ac3dec );
+    downmix( p_ac3dec, buffer );
+    return 0;
     }
-
-    intf_DbgMsg( "ac3dec debug: ac3 decoder thread %p initialized\n", p_ac3dec );
-    return( 0 );
-}
-
-/*****************************************************************************
- * RunThread : ac3 decoder thread
- *****************************************************************************/
-static void RunThread( ac3dec_thread_t * p_ac3dec )
-{
-    intf_DbgMsg( "ac3dec debug: running ac3 decoder thread (%p) (pid == %i)\n", p_ac3dec, getpid() );
-
-    msleep( INPUT_PTS_DELAY );
-
-    /* Initializing the ac3 decoder thread */
-    if ( InitThread(p_ac3dec) ) /* XXX */
-    {
-        p_ac3dec->b_error = 1;
-    }
-
-    /* ac3 decoder thread's main loop */
-    /* FIXME : do we have enough room to store the decoded frames ? */
-    while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) )
-    {
-        p_ac3dec->b_invalid = 0;
-
-       decode_find_sync( p_ac3dec );
-
-       if ( DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts )
-       {
-               p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts;
-               DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts = 0;
-       }
-       else
-       {
-               p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       }
-
-       parse_syncinfo( p_ac3dec );
-       switch ( p_ac3dec->syncinfo.fscod )
-       {
-               case 0:
-                       p_ac3dec->p_aout_fifo->l_rate = 48000;
-                       break;
-
-               case 1:
-                       p_ac3dec->p_aout_fifo->l_rate = 44100;
-                       break;
-
-               case 2:
-                       p_ac3dec->p_aout_fifo->l_rate = 32000;
-                       break;
-
-               default: /* XXX */
-                       fprintf( stderr, "ac3dec debug: invalid fscod\n" );
-                       p_ac3dec->b_invalid = 1;
-                       break;
-       }
-       if ( p_ac3dec->b_invalid ) /* XXX */
-       {
-               continue;
-       }
-
-       parse_bsi( p_ac3dec );
-
-       /* frame 1 */
-       parse_audblk( p_ac3dec );
-       exponent_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       bit_allocate( p_ac3dec );
-       mantissa_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       if ( p_ac3dec->bsi.acmod == 0x2 )
-       {
-               rematrix( p_ac3dec );
-       }
-       imdct( p_ac3dec );
-       downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
-       vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal( &p_ac3dec->p_aout_fifo->data_wait );
-       vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
-
-       /* frame 2 */
-       parse_audblk( p_ac3dec );
-       exponent_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       bit_allocate( p_ac3dec );
-       mantissa_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       if ( p_ac3dec->bsi.acmod == 0x2 )
-       {
-               rematrix( p_ac3dec );
-       }
-       imdct( p_ac3dec );
-       downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
-       p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal( &p_ac3dec->p_aout_fifo->data_wait );
-       vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
-
-       /* frame 3 */
-       parse_audblk( p_ac3dec );
-       exponent_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       bit_allocate( p_ac3dec );
-       mantissa_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       if ( p_ac3dec->bsi.acmod == 0x2 )
-       {
-               rematrix( p_ac3dec );
-       }
-       imdct( p_ac3dec );
-       downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
-       p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal( &p_ac3dec->p_aout_fifo->data_wait );
-       vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
-
-       /* frame 4 */
-       parse_audblk( p_ac3dec );
-       exponent_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       bit_allocate( p_ac3dec );
-       mantissa_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       if ( p_ac3dec->bsi.acmod == 0x2 )
-       {
-               rematrix( p_ac3dec );
-       }
-       imdct( p_ac3dec );
-       downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
-       p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal( &p_ac3dec->p_aout_fifo->data_wait );
-       vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
-
-       /* frame 5 */
-       parse_audblk( p_ac3dec );
-       exponent_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       bit_allocate( p_ac3dec );
-       mantissa_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       if ( p_ac3dec->bsi.acmod == 0x2 )
-       {
-               rematrix( p_ac3dec );
-       }
-       imdct( p_ac3dec );
-       downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
-       p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal( &p_ac3dec->p_aout_fifo->data_wait );
-       vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
-
-       /* frame 6 */
-       parse_audblk( p_ac3dec );
-       exponent_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       bit_allocate( p_ac3dec );
-       mantissa_unpack( p_ac3dec );
-       if ( p_ac3dec->b_invalid )
-       {
-               continue;
-       }
-       if ( p_ac3dec->bsi.acmod == 0x2 )
-       {
-               rematrix( p_ac3dec );
-       }
-       imdct( p_ac3dec );
-       downmix( p_ac3dec, ((ac3dec_frame_t *)p_ac3dec->p_aout_fifo->buffer)[ p_ac3dec->p_aout_fifo->l_end_frame ] );
-       p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       vlc_mutex_lock( &p_ac3dec->p_aout_fifo->data_lock );
-       p_ac3dec->p_aout_fifo->l_end_frame = (p_ac3dec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal( &p_ac3dec->p_aout_fifo->data_wait );
-       vlc_mutex_unlock( &p_ac3dec->p_aout_fifo->data_lock );
-
-       parse_auxdata( p_ac3dec );
-    }
-
-    /* If b_error is set, the ac3 decoder thread enters the error loop */
-    if ( p_ac3dec->b_error )
-    {
-        ErrorThread( p_ac3dec );
-    }
-
-    /* End of the ac3 decoder thread */
-    EndThread( p_ac3dec );
-}
-
-/*****************************************************************************
- * ErrorThread : ac3 decoder's RunThread() error loop
- *****************************************************************************/
-static void ErrorThread( ac3dec_thread_t * p_ac3dec )
-{
-    /* We take the lock, because we are going to read/write the start/end
-     * indexes of the decoder fifo */
-    vlc_mutex_lock( &p_ac3dec->fifo.data_lock );
-
-    /* Wait until a `die' order is sent */
-    while( !p_ac3dec->b_die )
-    {
-        /* Trash all received PES packets */
-        while( !DECODER_FIFO_ISEMPTY(p_ac3dec->fifo) )
-        {
-            input_NetlistFreePES( p_ac3dec->bit_stream.p_input, DECODER_FIFO_START(p_ac3dec->fifo) );
-           DECODER_FIFO_INCSTART( p_ac3dec->fifo );
-        }
-
-        /* Waiting for the input thread to put new PES packets in the fifo */
-        vlc_cond_wait( &p_ac3dec->fifo.data_wait, &p_ac3dec->fifo.data_lock );
-    }
-
-    /* We can release the lock before leaving */
-    vlc_mutex_unlock( &p_ac3dec->fifo.data_lock );
-}
-
-/*****************************************************************************
- * EndThread : ac3 decoder thread destruction
- *****************************************************************************/
-static void EndThread( ac3dec_thread_t * p_ac3dec )
-{
-    intf_DbgMsg( "ac3dec debug: destroying ac3 decoder thread %p\n", p_ac3dec );
-
-    /* If the audio output fifo was created, we destroy it */
-    if ( p_ac3dec->p_aout_fifo != NULL )
-    {
-        aout_DestroyFifo( p_ac3dec->p_aout_fifo );
-
-        /* Make sure the output thread leaves the NextFrame() function */
-        vlc_mutex_lock( &(p_ac3dec->p_aout_fifo->data_lock) );
-        vlc_cond_signal( &(p_ac3dec->p_aout_fifo->data_wait) );
-        vlc_mutex_unlock( &(p_ac3dec->p_aout_fifo->data_lock) );
-    }
-
-    /* Destroy descriptor */
-    free( p_ac3dec );
-
-    intf_DbgMsg( "ac3dec debug: ac3 decoder thread %p destroyed\n", p_ac3dec );
-}
index 3a8fb8772f16eb04506fa94cf79b8f24904770fb..071f2fc86eaa29ea570530f0fba901c754c5dd19 100644 (file)
@@ -42,7 +42,7 @@ static float smixlev_lut[4] = { 0.2928, 0.2071, 0.0   , 0.2071 };
  * to reduce complexity. Realistically, there aren't many machines around
  * with > 2 channel output anyways */
 
-void downmix( ac3dec_thread_t * p_ac3dec, s16 * out_buf )
+void downmix( ac3dec_t * p_ac3dec, s16 * out_buf )
 {
        int j;
        float right_tmp;
index 41e135a7d609e95ca74151c94b2d06f8db129fcf..cef2bef038f988726582f1ccd00220a51c4c5975 100644 (file)
@@ -1 +1 @@
-void downmix( ac3dec_thread_t *, s16 * );
+void downmix( ac3dec_t *, s16 * );
index 290d764ca8cad36eee413d62d676e66c90eefa05..2216eac81f7050dabbeef9810741806dd8cb5721 100644 (file)
@@ -29,7 +29,7 @@ static const s16 exps_2[128] = { -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0
 
 static const s16 exps_3[128] = { -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0 };
 
-static __inline__ void exp_unpack_ch( ac3dec_thread_t * p_ac3dec, u16 type, u16 expstr, u16 ngrps, u16 initial_exp, u16 exps[], u16 * dest )
+static __inline__ void exp_unpack_ch( ac3dec_t * p_ac3dec, u16 type, u16 expstr, u16 ngrps, u16 initial_exp, u16 exps[], u16 * dest )
 {
        u16 i,j;
        s16 exp_acc;
@@ -118,7 +118,7 @@ static __inline__ void exp_unpack_ch( ac3dec_thread_t * p_ac3dec, u16 type, u16
        }
 }
 
-void exponent_unpack( ac3dec_thread_t * p_ac3dec )
+void exponent_unpack( ac3dec_t * p_ac3dec )
 {
        u16 i;
 
index 0ff520f5e6eee002c8bf4dab5b45f5ef8ed3ba1c..5932661051dbaf5b70a4693f2f0689b1468a9b54 100644 (file)
@@ -2,4 +2,4 @@
 #define UNPACK_CPL  2
 #define UNPACK_LFE  4
 
-void exponent_unpack( ac3dec_thread_t * );
+void exponent_unpack( ac3dec_t * );
index e2972dc3066486e9815bb622c9d9b7878e975f63..e4419d737c3f971e81575aa138a3f1be5b21d22d 100644 (file)
@@ -1,27 +1,13 @@
-#include <unistd.h>                                              /* getpid() */
-
 #include <math.h>
-
-#include <stdio.h>                                           /* "intf_msg.h" */
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <sys/soundcard.h>                               /* "audio_output.h" */
-#include <sys/types.h>
 #include <sys/uio.h>                                            /* "input.h" */
 
 #include "common.h"
 #include "config.h"
-#include "mtime.h"
 #include "vlc_thread.h"
-#include "debug.h"                                      /* "input_netlist.h" */
-
-#include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
-
-#include "input.h"                                           /* pes_packet_t */
-#include "input_netlist.h"                         /* input_NetlistFreePES() */
-#include "decoder_fifo.h"         /* DECODER_FIFO_(ISEMPTY|START|INCSTART)() */
-
+#include "mtime.h"
+#include "input.h"
+#include "decoder_fifo.h"
 #include "audio_output.h"
-
 #include "ac3_decoder.h"
 #include "ac3_imdct.h"
 
@@ -185,7 +171,7 @@ void imdct_init(void)
        }
 }
 
-void imdct( ac3dec_thread_t * p_ac3dec )
+void imdct( ac3dec_t * p_ac3dec )
 {
        int i;
 
index c2c11d80f5e155ed56a4210442cf6e3b37c5be66..00d40ab926574c165e760cb95dc8113cde9b594f 100644 (file)
@@ -1,2 +1,2 @@
-void imdct( ac3dec_thread_t * p_ac3dec );
+void imdct( ac3dec_t * p_ac3dec );
 void imdct_init( void );
index 318275b8726a8c7990786b1b729cb2e37c21ed40..f3ace1a74d9dd6782a027be1de449a5a0c0df357 100644 (file)
@@ -101,7 +101,7 @@ static float exp_lut[ 25 ] =
 };
 
 /* Fetch an unpacked, left justified, and properly biased/dithered mantissa value */
-static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp )
+static __inline__ float float_get( ac3dec_t * p_ac3dec, u16 bap, u16 exp )
 {
        u32 group_code;
 
@@ -217,7 +217,7 @@ static __inline__ float float_get( ac3dec_thread_t * p_ac3dec, u16 bap, u16 exp
        }
 }
 
-static __inline__ void uncouple_channel( ac3dec_thread_t * p_ac3dec, u32 ch )
+static __inline__ void uncouple_channel( ac3dec_t * p_ac3dec, u32 ch )
 {
        u32 bnd = 0;
        u32 i,j;
@@ -247,7 +247,7 @@ static __inline__ void uncouple_channel( ac3dec_thread_t * p_ac3dec, u32 ch )
        }
 }
 
-void mantissa_unpack( ac3dec_thread_t * p_ac3dec )
+void mantissa_unpack( ac3dec_t * p_ac3dec )
 {
        int i, j;
 
index fa93fe46ce84321d319575887886d74a16ff757d..abf57ca78778041387822633e6f14e51bc80767d 100644 (file)
@@ -1 +1 @@
-void mantissa_unpack( ac3dec_thread_t * );
+void mantissa_unpack( ac3dec_t * );
index 78e280e61433377bd45fe58232f2bd493885b040..10730f35d3a917a021df28589745a58cd4e28a49 100644 (file)
@@ -70,7 +70,7 @@ static struct frmsize_s frmsizecod_tbl[] = {
       { 640 ,{1280 ,1394 ,1920 } }};
 
 /* Parse a syncinfo structure, minus the sync word */
-void parse_syncinfo( ac3dec_thread_t * p_ac3dec )
+void parse_syncinfo( ac3dec_t * p_ac3dec )
 {
         /* Get crc1 - we don't actually use this data though */
        NeedBits( &(p_ac3dec->bit_stream), 16 );
@@ -100,7 +100,7 @@ void parse_syncinfo( ac3dec_thread_t * p_ac3dec )
 /*
  * This routine fills a bsi struct from the AC3 stream
  */
-void parse_bsi( ac3dec_thread_t * p_ac3dec )
+void parse_bsi( ac3dec_t * p_ac3dec )
 {
        u32 i;
 
@@ -336,7 +336,7 @@ void parse_bsi( ac3dec_thread_t * p_ac3dec )
 }
 
 /* More pain inducing parsing */
-void parse_audblk( ac3dec_thread_t * p_ac3dec )
+void parse_audblk( ac3dec_t * p_ac3dec )
 {
        int i, j;
 
@@ -861,7 +861,7 @@ void parse_audblk( ac3dec_thread_t * p_ac3dec )
        }
 }
 
-void parse_auxdata( ac3dec_thread_t * p_ac3dec )
+void parse_auxdata( ac3dec_t * p_ac3dec )
 {
        int i;
        int skip_length;
index 00d0f57fcf01f696974950f06a4f902b1c5dd105..fe34da3f54f50be4d4b7dfe41b367a9c0f870030 100644 (file)
@@ -1,4 +1,4 @@
-void parse_syncinfo( ac3dec_thread_t * );
-void parse_bsi( ac3dec_thread_t * );
-void parse_audblk( ac3dec_thread_t * );
-void parse_auxdata( ac3dec_thread_t * );
+void parse_syncinfo( ac3dec_t * );
+void parse_bsi( ac3dec_t * );
+void parse_audblk( ac3dec_t * );
+void parse_auxdata( ac3dec_t * );
index cd40173ae41db48d99003c2ba8ea8dc1362b5528..f7105b1a7ac0e23bd99c2fa79a3597e277dec243 100644 (file)
@@ -42,7 +42,7 @@ static __inline__ u32 min( u32 a, u32 b )
 
 /* This routine simply does stereo rematixing for the 2 channel
  * stereo mode */
-void rematrix( ac3dec_thread_t * p_ac3dec )
+void rematrix( ac3dec_t * p_ac3dec )
 {
        u32 num_bands;
        u32 start;
index 7d493006c0b52a63c74c05453a79a727a3dc237a..69a1404b3dda5eedab6f8508de1e3eed7659d990 100644 (file)
@@ -1 +1 @@
-void rematrix( ac3dec_thread_t * );
+void rematrix( ac3dec_t * );
index a30b51e707fca682ad9feef13d2786c0439d92a8..602d39d338ee26f0335b0ac1df341bb2323d45f0 100644 (file)
@@ -48,6 +48,7 @@
 #include "video_parser.h"
 
 #include "ac3_decoder.h"
+#include "ac3_decoder_thread.h"
 #include "spu_decoder.h"
 
 #include "main.h"
index b80179c123fe1f5a868fe6e748d24ae3d7c9aad1..c16c40baae0c86eeed351464a084fc6b11696f72 100644 (file)
@@ -34,6 +34,7 @@
 #include "audio_output.h"
 #include "audio_decoder.h"
 #include "ac3_decoder.h"
+#include "ac3_decoder_thread.h"
 
 #include "video.h"
 #include "video_output.h"