]> git.sesse.net Git - vlc/blob - include/audio_decoder.h
f2b3a39f3e5c053159a831f467535741e9241043
[vlc] / include / audio_decoder.h
1 /******************************************************************************
2  * audio_decoder.h : audio decoder thread interface
3  * (c)1999 VideoLAN
4  ******************************************************************************
5  * = Prototyped functions are implemented in audio_decoder/audio_decoder.c
6  *
7  * = Required headers :
8  *   - <pthread.h>                                                ( pthread_t )
9  *   - "common.h"                                    ( u32, byte_t, boolean_t )
10  *   - "input.h"                                ( ts_packet_t, input_thread_t )
11  *   - "decoder_fifo.h"                                      ( decoder_fifo_t )
12  *   - "audio_output.h"                          ( aout_fifo_t, aout_thread_t )
13  *
14  * = - LSb = Least Significant bit
15  *   - LSB = Least Significant Byte
16  *
17  * = - MSb = Most Significant bit
18  *   - MSB = Most Significant Byte
19  ******************************************************************************/
20
21 /*
22  * TODO :
23  * - Etudier /usr/include/asm/bitops.h d'un peu plus près, bien qu'il ne me
24  *   semble pas être possible d'utiliser ces fonctions ici
25  * - N'y aurait-t-il pas moyen de se passer d'un buffer de bits, en travaillant
26  *   directement sur le flux PES ?
27  */
28
29 /******************************************************************************
30  * bit_fifo_t : bit fifo descriptor
31  ******************************************************************************
32  * This type describes a bit fifo used to store bits while working with the
33  * input stream at the bit level.
34  ******************************************************************************/
35 typedef struct bit_fifo_s
36 {
37     /* This unsigned integer allows us to work at the bit level. This buffer
38      * can contain 32 bits, and the used space can be found on the MSb's side
39      * and the available space on the LSb's side. */
40     u32                 buffer;
41
42     /* Number of bits available in the bit buffer */
43     int                 i_available;
44
45 } bit_fifo_t;
46
47 /******************************************************************************
48  * bit_stream_t : bit stream descriptor
49  ******************************************************************************
50  * This type, based on a PES stream, includes all the structures needed to
51  * handle the input stream like a bit stream.
52  ******************************************************************************/
53 typedef struct bit_stream_s
54 {
55     /*
56      * Input structures
57      */
58     /* The input thread feeds the stream with fresh PES packets */
59     input_thread_t *    p_input;
60     /* The decoder fifo contains the data of the PES stream */
61     decoder_fifo_t *    p_decoder_fifo;
62
63     /*
64      * Byte structures
65      */
66     /* Current TS packet (in the current PES packet of the PES stream) */
67     ts_packet_t *       p_ts;
68     /* Index of the next byte that is to be read (in the current TS packet) */
69     unsigned int        i_byte;
70
71     /*
72      * Bit structures
73      */
74     bit_fifo_t          fifo;
75
76 } bit_stream_t;
77
78 /******************************************************************************
79  * adec_bank_t
80  ******************************************************************************/
81 typedef struct adec_bank_s
82 {
83     float               v1[512];
84     float               v2[512];
85     float *             actual;
86     int                 pos;
87
88 } adec_bank_t;
89
90 /******************************************************************************
91  * adec_thread_t : audio decoder thread descriptor
92  ******************************************************************************
93  * This type describes an audio decoder thread
94  ******************************************************************************/
95 typedef struct adec_thread_s
96 {
97     /*
98      * Thread properties
99      */
100     pthread_t           thread_id;                /* id for pthread functions */
101     boolean_t           b_die;                                  /* `die' flag */
102     boolean_t           b_error;                              /* `error' flag */
103
104     /*
105      * Input properties
106      */
107     decoder_fifo_t      fifo;                   /* stores the PES stream data */
108     /* The bit stream structure handles the PES stream at the bit level */
109     bit_stream_t        bit_stream;
110
111     /*
112      * Decoder properties
113      */
114     adec_bank_t         bank_0;
115     adec_bank_t         bank_1;
116
117     /*
118      * Output properties
119      */
120     aout_fifo_t *       p_aout_fifo;  /* stores the decompressed audio frames */
121     aout_thread_t *     p_aout;            /* needed to create the audio fifo */
122
123 } adec_thread_t;
124
125 /******************************************************************************
126  * Prototypes
127  ******************************************************************************/
128 adec_thread_t * adec_CreateThread       ( input_thread_t * p_input /* !! , aout_thread_t * p_aout !! */ );
129 void            adec_DestroyThread      ( adec_thread_t * p_adec );