Changeset 15f3b0f6fa0eac7207eec34e80e1f65506d4f599
- Timestamp:
- 27/08/02 01:00:23
(6 years ago)
- Author:
- Christophe Massiot <massiot@videolan.org>
- git-committer:
- Christophe Massiot <massiot@videolan.org> 1030402823 +0000
- git-parent:
[44fc8c8927a693b57b9e525341167620a9915ac4]
- git-author:
- Christophe Massiot <massiot@videolan.org> 1030402823 +0000
- Message:
* Miscellaneous S/PDIF fixes.
* New NextPTS() function, to replace CurrentPTS() (gives the PTS which will
be valid for NEXT byte).
* Fixed mono mode in the builtin mpeg audio decoder.
* Various fixes related to PTS calculation in audio decoders.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r8d5c85f |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1999-2001 VideoLAN |
|---|
| 5 | | * $Id: input_ext-dec.h,v 1.69 2002/08/12 22:12:50 massiot Exp $ |
|---|
| | 5 | * $Id: input_ext-dec.h,v 1.70 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Christophe Massiot <massiot@via.ecp.fr> |
|---|
| … | … | |
| 227 | 227 | VLC_EXPORT( u32, UnalignedGetBits, ( bit_stream_t *, unsigned int ) ); |
|---|
| 228 | 228 | VLC_EXPORT( void, CurrentPTS, ( bit_stream_t *, mtime_t *, mtime_t * ) ); |
|---|
| | 229 | VLC_EXPORT( void, NextPTS, ( bit_stream_t *, mtime_t *, mtime_t * ) ); |
|---|
| 229 | 230 | |
|---|
| 230 | 231 | /***************************************************************************** |
|---|
| r51e9975 |
r15f3b0f |
|
| 79 | 79 | void (* DecoderError_inner) ( decoder_fifo_t * p_fifo ) ; |
|---|
| 80 | 80 | void (* InitBitstream_inner) ( bit_stream_t *, decoder_fifo_t *, void ( * )( bit_stream_t *, vlc_bool_t ), void * p_callback_arg ) ; |
|---|
| | 81 | void (* NextPTS_inner) ( bit_stream_t *, mtime_t *, mtime_t * ) ; |
|---|
| 81 | 82 | void (* UnalignedRemoveBits_inner) ( bit_stream_t * ) ; |
|---|
| 82 | 83 | void (* __config_PutFloat_inner) (vlc_object_t *, const char *, float) ; |
|---|
| … | … | |
| 160 | 161 | # define InitBitstream p_symbols->InitBitstream_inner |
|---|
| 161 | 162 | # define NextDataPacket p_symbols->NextDataPacket_inner |
|---|
| | 163 | # define NextPTS p_symbols->NextPTS_inner |
|---|
| 162 | 164 | # define UnalignedGetBits p_symbols->UnalignedGetBits_inner |
|---|
| 163 | 165 | # define UnalignedRemoveBits p_symbols->UnalignedRemoveBits_inner |
|---|
| r1c13a98 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: a52tospdif.c,v 1.9 2002/08/21 22:41:59 massiot Exp $ |
|---|
| | 5 | * $Id: a52tospdif.c,v 1.10 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Christophe Massiot <massiot@via.ecp.fr> |
|---|
| … | … | |
| 99 | 99 | memcpy( p_out, p_sync, 6 ); |
|---|
| 100 | 100 | pi_length = (u16 *)(p_out + 6); |
|---|
| 101 | | *pi_length = i_length; |
|---|
| | 101 | *pi_length = i_length * 8; |
|---|
| 102 | 102 | |
|---|
| 103 | 103 | /* FIXME : if i_length is odd, the following code sucks. What should |
|---|
| … | … | |
| 106 | 106 | #ifndef WORDS_BIGENDIAN |
|---|
| 107 | 107 | # ifdef HAVE_SWAB |
|---|
| 108 | | swab( p_out + 8, p_in, i_length ); |
|---|
| | 108 | swab( p_in, p_out + 8, i_length ); |
|---|
| 109 | 109 | # else |
|---|
| 110 | 110 | p_out += 8; |
|---|
| r1c13a98 |
r15f3b0f |
|
| 5 | 5 | ***************************************************************************** |
|---|
| 6 | 6 | * Copyright (C) 2001, 2002 VideoLAN |
|---|
| 7 | | * $Id: a52.c,v 1.6 2002/08/21 22:41:59 massiot Exp $ |
|---|
| | 7 | * $Id: a52.c,v 1.7 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 8 | 8 | * |
|---|
| 9 | 9 | * Authors: Gildas Bazin <gbazin@netcourrier.com> |
|---|
| … | … | |
| 168 | 168 | } |
|---|
| 169 | 169 | |
|---|
| | 170 | /* Set the Presentation Time Stamp */ |
|---|
| | 171 | NextPTS( &p_dec->bit_stream, &pts, NULL ); |
|---|
| | 172 | if ( pts != 0 && pts != aout_DateGet( &p_dec->end_date ) ) |
|---|
| | 173 | { |
|---|
| | 174 | aout_DateSet( &p_dec->end_date, pts ); |
|---|
| | 175 | } |
|---|
| | 176 | |
|---|
| 170 | 177 | /* Get A/52 frame header */ |
|---|
| 171 | 178 | GetChunk( &p_dec->bit_stream, p_frame_buffer, 7 ); |
|---|
| … | … | |
| 208 | 215 | } |
|---|
| 209 | 216 | |
|---|
| 210 | | /* Set the Presentation Time Stamp */ |
|---|
| 211 | | CurrentPTS( &p_dec->bit_stream, &pts, NULL ); |
|---|
| 212 | | if ( pts != 0 && pts != aout_DateGet( &p_dec->end_date ) ) |
|---|
| 213 | | { |
|---|
| 214 | | aout_DateSet( &p_dec->end_date, pts ); |
|---|
| 215 | | } |
|---|
| 216 | | |
|---|
| 217 | 217 | /* Get the complete frame */ |
|---|
| 218 | 218 | GetChunk( &p_dec->bit_stream, p_frame_buffer + 7, |
|---|
| rf7934b1 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1999-2001 VideoLAN |
|---|
| 5 | | * $Id: a52old.c,v 1.4 2002/08/23 14:05:22 sam Exp $ |
|---|
| | 5 | * $Id: a52old.c,v 1.5 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Michel Lespinasse <walken@zoy.org> |
|---|
| … | … | |
| 187 | 187 | } |
|---|
| 188 | 188 | |
|---|
| 189 | | CurrentPTS( &p_a52dec->bit_stream, &i_pts, NULL ); |
|---|
| | 189 | NextPTS( &p_a52dec->bit_stream, &i_pts, NULL ); |
|---|
| 190 | 190 | if( i_pts != 0 && i_pts != aout_DateGet( &end_date ) ) |
|---|
| 191 | 191 | { |
|---|
| r764fd89 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1999-2001 VideoLAN |
|---|
| 5 | | * $Id: decoder.c,v 1.2 2002/08/17 15:35:10 fenrir Exp $ |
|---|
| | 5 | * $Id: decoder.c,v 1.3 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Michel Kaempf <maxx@via.ecp.fr> |
|---|
| … | … | |
| 38 | 38 | #include "decoder.h" |
|---|
| 39 | 39 | |
|---|
| 40 | | #define ADEC_FRAME_SIZE 1152 /* XXX Frame size for only one channel */ |
|---|
| | 40 | #define ADEC_FRAME_NB 1152 |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | /***************************************************************************** |
|---|
| … | … | |
| 84 | 84 | static int RunDecoder( decoder_fifo_t *p_fifo ) |
|---|
| 85 | 85 | { |
|---|
| 86 | | adec_thread_t * p_adec; |
|---|
| | 86 | adec_thread_t * p_dec; |
|---|
| 87 | 87 | |
|---|
| 88 | 88 | /* Allocate the memory needed to store the thread's structure */ |
|---|
| 89 | | if ( (p_adec = (adec_thread_t *)malloc (sizeof(adec_thread_t))) == NULL ) |
|---|
| | 89 | if ( (p_dec = (adec_thread_t *)malloc (sizeof(adec_thread_t))) == NULL ) |
|---|
| 90 | 90 | { |
|---|
| 91 | 91 | msg_Err( p_fifo, "out of memory" ); |
|---|
| … | … | |
| 97 | 97 | * Initialize the thread properties |
|---|
| 98 | 98 | */ |
|---|
| 99 | | p_adec->p_fifo = p_fifo; |
|---|
| | 99 | p_dec->p_fifo = p_fifo; |
|---|
| 100 | 100 | |
|---|
| 101 | 101 | /* |
|---|
| 102 | 102 | * Initilize the banks |
|---|
| 103 | 103 | */ |
|---|
| 104 | | p_adec->bank_0.actual = p_adec->bank_0.v1; |
|---|
| 105 | | p_adec->bank_0.pos = 0; |
|---|
| 106 | | p_adec->bank_1.actual = p_adec->bank_1.v1; |
|---|
| 107 | | p_adec->bank_1.pos = 0; |
|---|
| | 104 | p_dec->bank_0.actual = p_dec->bank_0.v1; |
|---|
| | 105 | p_dec->bank_0.pos = 0; |
|---|
| | 106 | p_dec->bank_1.actual = p_dec->bank_1.v1; |
|---|
| | 107 | p_dec->bank_1.pos = 0; |
|---|
| 108 | 108 | |
|---|
| 109 | 109 | /* |
|---|
| 110 | 110 | * Initialize bit stream |
|---|
| 111 | 111 | */ |
|---|
| 112 | | InitBitstream( &p_adec->bit_stream, p_adec->p_fifo, NULL, NULL ); |
|---|
| | 112 | InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, NULL, NULL ); |
|---|
| 113 | 113 | |
|---|
| 114 | 114 | /* We do not create the audio output fifo now, but |
|---|
| 115 | 115 | it will be created when the first frame is received */ |
|---|
| 116 | | p_adec->p_aout = NULL; |
|---|
| 117 | | p_adec->p_aout_input = NULL; |
|---|
| 118 | | p_adec->i_pts = 0; |
|---|
| 119 | | |
|---|
| 120 | | p_adec->i_sync = 0; |
|---|
| | 116 | p_dec->p_aout = NULL; |
|---|
| | 117 | p_dec->p_aout_input = NULL; |
|---|
| 121 | 118 | |
|---|
| 122 | 119 | /* Audio decoder thread's main loop */ |
|---|
| 123 | | while( (!p_adec->p_fifo->b_die) && (!p_adec->p_fifo->b_error) ) |
|---|
| 124 | | { |
|---|
| 125 | | DecodeThread( p_adec ); |
|---|
| | 120 | while( (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error) ) |
|---|
| | 121 | { |
|---|
| | 122 | DecodeThread( p_dec ); |
|---|
| 126 | 123 | } |
|---|
| 127 | 124 | |
|---|
| 128 | 125 | /* If b_error is set, the audio decoder thread enters the error loop */ |
|---|
| 129 | | if( p_adec->p_fifo->b_error ) |
|---|
| 130 | | { |
|---|
| 131 | | DecoderError( p_adec->p_fifo ); |
|---|
| | 126 | if( p_dec->p_fifo->b_error ) |
|---|
| | 127 | { |
|---|
| | 128 | DecoderError( p_dec->p_fifo ); |
|---|
| 132 | 129 | } |
|---|
| 133 | 130 | |
|---|
| 134 | 131 | /* End of the audio decoder thread */ |
|---|
| 135 | | EndThread( p_adec ); |
|---|
| | 132 | EndThread( p_dec ); |
|---|
| 136 | 133 | |
|---|
| 137 | 134 | return( 0 ); |
|---|
| … | … | |
| 145 | 142 | * DecodeThread: decodes a mpeg frame |
|---|
| 146 | 143 | *****************************************************************************/ |
|---|
| 147 | | static void DecodeThread( adec_thread_t * p_adec ) |
|---|
| | 144 | static void DecodeThread( adec_thread_t * p_dec ) |
|---|
| 148 | 145 | { |
|---|
| 149 | | mtime_t i_pts; |
|---|
| 150 | | aout_buffer_t *p_aout_buffer; |
|---|
| | 146 | mtime_t pts; |
|---|
| | 147 | aout_buffer_t * p_aout_buffer; |
|---|
| 151 | 148 | |
|---|
| 152 | 149 | adec_sync_info_t sync_info; |
|---|
| 153 | 150 | |
|---|
| 154 | | if( ! adec_SyncFrame (p_adec, &sync_info) ) |
|---|
| 155 | | { |
|---|
| 156 | | |
|---|
| | 151 | /* Look for sync word - should be 0x0b77 */ |
|---|
| | 152 | RealignBits( &p_dec->bit_stream ); |
|---|
| | 153 | while( (ShowBits( &p_dec->bit_stream, 16 ) & 0xfff0) != 0xfff0 && |
|---|
| | 154 | (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error)) |
|---|
| | 155 | { |
|---|
| | 156 | RemoveBits( &p_dec->bit_stream, 8 ); |
|---|
| | 157 | } |
|---|
| | 158 | |
|---|
| | 159 | /* Set the Presentation Time Stamp */ |
|---|
| | 160 | NextPTS( &p_dec->bit_stream, &pts, NULL ); |
|---|
| | 161 | if ( pts != 0 && pts != aout_DateGet( &p_dec->end_date ) ) |
|---|
| | 162 | { |
|---|
| | 163 | aout_DateSet( &p_dec->end_date, pts ); |
|---|
| | 164 | } |
|---|
| | 165 | |
|---|
| | 166 | if( !adec_SyncFrame( p_dec, &sync_info ) ) |
|---|
| | 167 | { |
|---|
| 157 | 168 | /* Create the output fifo if it doesn't exist yet */ |
|---|
| 158 | | if( ( p_adec->p_aout_input == NULL )|| |
|---|
| 159 | | ( p_adec->output_format.i_channels != ( sync_info.b_stereo ? 2 : 1 ) )|| |
|---|
| 160 | | ( p_adec->output_format.i_rate != sync_info.sample_rate ) ) |
|---|
| 161 | | { |
|---|
| 162 | | if( p_adec->p_aout_input ) |
|---|
| | 169 | if( ( p_dec->p_aout_input == NULL )|| |
|---|
| | 170 | ( p_dec->output_format.i_channels != ( sync_info.b_stereo ? 2 : 1 ) )|| |
|---|
| | 171 | ( p_dec->output_format.i_rate != sync_info.sample_rate ) ) |
|---|
| | 172 | { |
|---|
| | 173 | if( p_dec->p_aout_input ) |
|---|
| 163 | 174 | { |
|---|
| 164 | 175 | /* Delete old output */ |
|---|
| 165 | | msg_Warn( p_adec->p_fifo, "opening a new aout" ); |
|---|
| 166 | | aout_InputDelete( p_adec->p_aout, p_adec->p_aout_input ); |
|---|
| | 176 | msg_Warn( p_dec->p_fifo, "opening a new aout" ); |
|---|
| | 177 | aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input ); |
|---|
| 167 | 178 | } |
|---|
| 168 | 179 | |
|---|
| 169 | 180 | /* Set output configuration */ |
|---|
| 170 | | p_adec->output_format.i_format = AOUT_FMT_FLOAT32; |
|---|
| 171 | | p_adec->output_format.i_channels = ( sync_info.b_stereo ? 2 : 1 ); |
|---|
| 172 | | p_adec->output_format.i_rate = sync_info.sample_rate; |
|---|
| 173 | | p_adec->p_aout_input = aout_InputNew( p_adec->p_fifo, |
|---|
| 174 | | &p_adec->p_aout, |
|---|
| 175 | | &p_adec->output_format ); |
|---|
| 176 | | } |
|---|
| 177 | | |
|---|
| 178 | | if( p_adec->p_aout_input == NULL ) |
|---|
| 179 | | { |
|---|
| 180 | | msg_Err( p_adec->p_fifo, "failed to create aout fifo" ); |
|---|
| 181 | | p_adec->p_fifo->b_error = 1; |
|---|
| | 181 | p_dec->output_format.i_format = AOUT_FMT_FLOAT32; |
|---|
| | 182 | p_dec->output_format.i_channels = ( sync_info.b_stereo ? 2 : 1 ); |
|---|
| | 183 | p_dec->output_format.i_rate = sync_info.sample_rate; |
|---|
| | 184 | aout_DateInit( &p_dec->end_date, sync_info.sample_rate ); |
|---|
| | 185 | p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo, |
|---|
| | 186 | &p_dec->p_aout, |
|---|
| | 187 | &p_dec->output_format ); |
|---|
| | 188 | } |
|---|
| | 189 | |
|---|
| | 190 | if( p_dec->p_aout_input == NULL ) |
|---|
| | 191 | { |
|---|
| | 192 | msg_Err( p_dec->p_fifo, "failed to create aout fifo" ); |
|---|
| | 193 | p_dec->p_fifo->b_error = 1; |
|---|
| 182 | 194 | return; |
|---|
| 183 | 195 | } |
|---|
| 184 | 196 | |
|---|
| 185 | | p_aout_buffer = aout_BufferNew( p_adec->p_aout, |
|---|
| 186 | | p_adec->p_aout_input, |
|---|
| 187 | | ADEC_FRAME_SIZE ); |
|---|
| | 197 | if( !aout_DateGet( &p_dec->end_date ) ) |
|---|
| | 198 | { |
|---|
| | 199 | /* We've just started the stream, wait for the first PTS. */ |
|---|
| | 200 | return; |
|---|
| | 201 | } |
|---|
| | 202 | |
|---|
| | 203 | p_aout_buffer = aout_BufferNew( p_dec->p_aout, |
|---|
| | 204 | p_dec->p_aout_input, |
|---|
| | 205 | ADEC_FRAME_NB ); |
|---|
| 188 | 206 | if( !p_aout_buffer ) |
|---|
| 189 | 207 | { |
|---|
| 190 | | msg_Err( p_adec->p_fifo, "cannot get aout buffer" ); |
|---|
| 191 | | p_adec->p_fifo->b_error = 1; |
|---|
| | 208 | msg_Err( p_dec->p_fifo, "cannot get aout buffer" ); |
|---|
| | 209 | p_dec->p_fifo->b_error = 1; |
|---|
| 192 | 210 | return; |
|---|
| 193 | 211 | } |
|---|
| 194 | | |
|---|
| 195 | | p_adec->i_sync = 1; |
|---|
| 196 | | |
|---|
| 197 | | |
|---|
| 198 | | CurrentPTS( &p_adec->bit_stream, &i_pts, NULL ); |
|---|
| 199 | | if( i_pts > 0 ) |
|---|
| 200 | | { |
|---|
| 201 | | p_adec->i_pts = i_pts; |
|---|
| 202 | | } |
|---|
| 203 | | p_aout_buffer->start_date = p_adec->i_pts; |
|---|
| 204 | | p_adec->i_pts += (mtime_t)1000000 * (mtime_t)ADEC_FRAME_SIZE / |
|---|
| 205 | | (mtime_t)p_adec->output_format.i_rate; |
|---|
| 206 | | p_aout_buffer->end_date = p_adec->i_pts; |
|---|
| 207 | | |
|---|
| 208 | | if( adec_DecodeFrame (p_adec, (float*)p_aout_buffer->p_buffer ) ) |
|---|
| | 212 | p_aout_buffer->start_date = aout_DateGet( &p_dec->end_date ); |
|---|
| | 213 | p_aout_buffer->end_date = aout_DateIncrement( &p_dec->end_date, |
|---|
| | 214 | ADEC_FRAME_NB ); |
|---|
| | 215 | |
|---|
| | 216 | if( adec_DecodeFrame (p_dec, (float*)p_aout_buffer->p_buffer ) ) |
|---|
| 209 | 217 | { |
|---|
| 210 | 218 | /* Ouch, failed decoding... We'll have to resync */ |
|---|
| 211 | | p_adec->i_sync = 0; |
|---|
| 212 | | aout_BufferDelete( p_adec->p_aout, p_adec->p_aout_input, p_aout_buffer ); |
|---|
| | 219 | aout_BufferDelete( p_dec->p_aout, p_dec->p_aout_input, p_aout_buffer ); |
|---|
| 213 | 220 | } |
|---|
| 214 | 221 | else |
|---|
| 215 | 222 | { |
|---|
| 216 | | aout_BufferPlay( p_adec->p_aout, p_adec->p_aout_input, p_aout_buffer ); |
|---|
| | 223 | aout_BufferPlay( p_dec->p_aout, p_dec->p_aout_input, p_aout_buffer ); |
|---|
| 217 | 224 | } |
|---|
| 218 | 225 | } |
|---|
| … | … | |
| 225 | 232 | * initialization. |
|---|
| 226 | 233 | *****************************************************************************/ |
|---|
| 227 | | static void EndThread ( adec_thread_t *p_adec ) |
|---|
| | 234 | static void EndThread ( adec_thread_t *p_dec ) |
|---|
| 228 | 235 | { |
|---|
| 229 | 236 | /* If the audio output fifo was created, we destroy it */ |
|---|
| 230 | | if( p_adec->p_aout_input ) |
|---|
| 231 | | { |
|---|
| 232 | | aout_InputDelete( p_adec->p_aout, p_adec->p_aout_input ); |
|---|
| | 237 | if( p_dec->p_aout_input ) |
|---|
| | 238 | { |
|---|
| | 239 | aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input ); |
|---|
| 233 | 240 | |
|---|
| 234 | 241 | } |
|---|
| 235 | 242 | |
|---|
| 236 | 243 | /* Destroy descriptor */ |
|---|
| 237 | | free( p_adec ); |
|---|
| 238 | | } |
|---|
| 239 | | |
|---|
| | 244 | free( p_dec ); |
|---|
| | 245 | } |
|---|
| | 246 | |
|---|
| r764fd89 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1999, 2000 VideoLAN |
|---|
| 5 | | * $Id: decoder.h,v 1.2 2002/08/17 15:35:10 fenrir Exp $ |
|---|
| | 5 | * $Id: decoder.h,v 1.3 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Michel Kaempf <maxx@via.ecp.fr> |
|---|
| … | … | |
| 53 | 53 | aout_input_t *p_aout_input; /* opaque */ |
|---|
| 54 | 54 | audio_sample_format_t output_format; |
|---|
| 55 | | mtime_t i_pts; |
|---|
| 56 | | |
|---|
| | 55 | audio_date_t end_date; |
|---|
| 57 | 56 | } adec_thread_t; |
|---|
| 58 | 57 | |
|---|
| r764fd89 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1999-2001 VideoLAN |
|---|
| 5 | | * $Id: generic.c,v 1.2 2002/08/17 15:35:10 fenrir Exp $ |
|---|
| | 5 | * $Id: generic.c,v 1.3 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Michel Kaempf <maxx@via.ecp.fr> |
|---|
| … | … | |
| 47 | 47 | int adec_SyncFrame( adec_thread_t * p_adec, adec_sync_info_t * p_sync_info ) |
|---|
| 48 | 48 | { |
|---|
| 49 | | static int mpeg1_sample_rate[3] = {44100, 48000, 32000}; |
|---|
| 50 | | static int mpeg1_layer1_bit_rate[15] = |
|---|
| | 49 | static const int mpeg1_sample_rate[3] = {44100, 48000, 32000}; |
|---|
| | 50 | static const int mpeg1_layer1_bit_rate[15] = |
|---|
| 51 | 51 | { |
|---|
| 52 | 52 | 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 |
|---|
| 53 | 53 | }; |
|---|
| 54 | | static int mpeg1_layer2_bit_rate[15] = |
|---|
| | 54 | static const int mpeg1_layer2_bit_rate[15] = |
|---|
| 55 | 55 | { |
|---|
| 56 | 56 | 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 |
|---|
| 57 | 57 | }; |
|---|
| 58 | | static int mpeg2_layer1_bit_rate[15] = |
|---|
| | 58 | static const int mpeg2_layer1_bit_rate[15] = |
|---|
| 59 | 59 | { |
|---|
| 60 | 60 | 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 |
|---|
| 61 | 61 | }; |
|---|
| 62 | | static int mpeg2_layer2_bit_rate[15] = |
|---|
| | 62 | static const int mpeg2_layer2_bit_rate[15] = |
|---|
| 63 | 63 | { |
|---|
| 64 | 64 | 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 |
|---|
| 65 | 65 | }; |
|---|
| 66 | | static int * bit_rate_table[8] = |
|---|
| | 66 | static const int * bit_rate_table[8] = |
|---|
| 67 | 67 | { |
|---|
| 68 | 68 | NULL, NULL, mpeg2_layer2_bit_rate, mpeg2_layer1_bit_rate, |
|---|
| r764fd89 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1999-2001 VideoLAN |
|---|
| 5 | | * $Id: layer2.c,v 1.3 2002/08/17 15:35:10 fenrir Exp $ |
|---|
| | 5 | * $Id: layer2.c,v 1.4 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Michel Kaempf <maxx@via.ecp.fr> |
|---|
| … | … | |
| 435 | 435 | { |
|---|
| 436 | 436 | DCT32( &p_adec->bank_0, sample[s] ); |
|---|
| 437 | | PCM( &p_adec->bank_0, buffer, 2 ); |
|---|
| 438 | | |
|---|
| 439 | | /* FIXME: one shouldn't have to do it twice ! */ |
|---|
| 440 | | DCT32( &p_adec->bank_1, sample[s] ); |
|---|
| 441 | | PCM( &p_adec->bank_1, buffer + 1, 2 ); |
|---|
| 442 | | |
|---|
| 443 | | buffer += 64; |
|---|
| | 437 | PCM( &p_adec->bank_0, buffer, 1 ); |
|---|
| | 438 | |
|---|
| | 439 | buffer += 32; |
|---|
| 444 | 440 | } |
|---|
| 445 | 441 | } |
|---|
| r5ffbc97 |
r15f3b0f |
|
| 1 | 1 | /***************************************************************************** |
|---|
| 2 | | * spdif.c: A52 pass-through to external decoder with enabled soundcard |
|---|
| | 2 | * spdif.c: A/52 pass-through to external decoder with enabled soundcard |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2001-2002 VideoLAN |
|---|
| 5 | | * $Id: spdif.c,v 1.6 2002/08/19 21:31:11 massiot Exp $ |
|---|
| | 5 | * $Id: spdif.c,v 1.7 2002/08/26 23:00:22 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: St�ane Borel <stef@via.ecp.fr> |
|---|
| … | … | |
| 118 | 118 | { |
|---|
| 119 | 119 | spdif_thread_t * p_dec; |
|---|
| 120 | | mtime_t last_date = 0; |
|---|
| | 120 | audio_date_t end_date; |
|---|
| 121 | 121 | |
|---|
| 122 | 122 | /* Allocate the memory needed to store the thread's structure */ |
|---|
| … | … | |
| 155 | 155 | } |
|---|
| 156 | 156 | |
|---|
| | 157 | /* Set the Presentation Time Stamp */ |
|---|
| | 158 | NextPTS( &p_dec->bit_stream, &pts, NULL ); |
|---|
| | 159 | if ( pts != 0 && pts != aout_DateGet( &end_date ) ) |
|---|
| | 160 | { |
|---|
| | 161 | aout_DateSet( &end_date, pts ); |
|---|
| | 162 | } |
|---|
| | 163 | |
|---|
| 157 | 164 | /* Get A/52 frame header */ |
|---|
| 158 | 165 | GetChunk( &p_dec->bit_stream, p_header, 7 ); |
|---|
| … | … | |
| 184 | 191 | p_dec->output_format.i_bytes_per_frame = i_frame_size; |
|---|
| 185 | 192 | p_dec->output_format.i_frame_length = A52_FRAME_NB; |
|---|
| 186 | | /* p_dec->output_format.i_channels = i_channels; */ |
|---|
| | 193 | aout_DateInit( &end_date, i_rate ); |
|---|
| 187 | 194 | p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo, |
|---|
| 188 | 195 | &p_dec->p_aout, |
|---|
| … | … | |
| 196 | 203 | } |
|---|
| 197 | 204 | |
|---|
| 198 | | /* Set the Presentation Time Stamp */ |
|---|
| 199 | | CurrentPTS( &p_dec->bit_stream, &pts, NULL ); |
|---|
| 200 | | if ( pts != 0 ) |
|---|
| 201 | | { |
|---|
| 202 | | last_date = pts; |
|---|
| 203 | | } |
|---|
| 204 | | |
|---|
| 205 | | if ( !last_date ) |
|---|
| | 205 | if ( !aout_DateGet( &end_date ) ) |
|---|
| 206 | 206 | { |
|---|
| 207 | 207 | byte_t p_junk[3840]; |
|---|
| … | … | |
| 215 | 215 | A52_FRAME_NB ); |
|---|
| 216 | 216 | if ( p_buffer == NULL ) return -1; |
|---|
| 217 | | p_buffer->start_date = last_date; |
|---|
| 218 | | last_date += (mtime_t)(A52_FRAME_NB * 1000000) |
|---|
| 219 | | / p_dec->output_format.i_rate; |
|---|
| 220 | | p_buffer->end_date = last_date; |
|---|
| | 217 | p_buffer->start_date = aout_DateGet( &end_date ); |
|---|
| | 218 | p_buffer->end_date = aout_DateIncrement( &end_date, |
|---|
| | 219 | A52_FRAME_NB ); |
|---|
| 221 | 220 | |
|---|
| 222 | 221 | /* Get the whole frame. */ |
|---|
| r711160b |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: input.c,v 1.8 2002/08/24 10:19:43 sam Exp $ |
|---|
| | 5 | * $Id: input.c,v 1.9 2002/08/26 23:00:23 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Christophe Massiot <massiot@via.ecp.fr> |
|---|
| … | … | |
| 30 | 30 | #include <vlc/vlc.h> |
|---|
| 31 | 31 | |
|---|
| | 32 | #ifdef HAVE_ALLOCA_H |
|---|
| | 33 | # include <alloca.h> |
|---|
| | 34 | #endif |
|---|
| | 35 | |
|---|
| 32 | 36 | #include "audio_output.h" |
|---|
| 33 | 37 | #include "aout_internal.h" |
|---|
| r1c13a98 |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: mixer.c,v 1.9 2002/08/21 22:41:59 massiot Exp $ |
|---|
| | 5 | * $Id: mixer.c,v 1.10 2002/08/26 23:00:23 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Christophe Massiot <massiot@via.ecp.fr> |
|---|
| … | … | |
| 250 | 250 | return -1; |
|---|
| 251 | 251 | } |
|---|
| 252 | | p_output_buffer->i_nb_samples = p_aout->output.i_nb_samples; |
|---|
| 253 | | p_output_buffer->i_nb_bytes = p_aout->output.i_nb_samples |
|---|
| | 252 | /* This is again a bit kludgy - for the S/PDIF mixer. */ |
|---|
| | 253 | if ( p_aout->mixer.output_alloc.i_alloc_type != AOUT_ALLOC_NONE ) |
|---|
| | 254 | { |
|---|
| | 255 | p_output_buffer->i_nb_samples = p_aout->output.i_nb_samples; |
|---|
| | 256 | p_output_buffer->i_nb_bytes = p_aout->output.i_nb_samples |
|---|
| 254 | 257 | * p_aout->mixer.mixer.i_bytes_per_frame |
|---|
| 255 | 258 | / p_aout->mixer.mixer.i_frame_length; |
|---|
| | 259 | } |
|---|
| 256 | 260 | p_output_buffer->start_date = start_date; |
|---|
| 257 | 261 | p_output_buffer->end_date = end_date; |
|---|
| r347c0fe |
r15f3b0f |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1998-2001 VideoLAN |
|---|
| 5 | | * $Id: input_ext-dec.c,v 1.33 2002/07/24 15:21:47 sam Exp $ |
|---|
| | 5 | * $Id: input_ext-dec.c,v 1.34 2002/08/26 23:00:23 massiot Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Christophe Massiot <massiot@via.ecp.fr> |
|---|
| … | … | |
| 430 | 430 | /* Check if the current PTS is already valid (ie. if the first byte |
|---|
| 431 | 431 | * of the packet has already been used in the decoder). */ |
|---|
| 432 | | ptrdiff_t p_diff = p_bit_stream->p_byte - p_bit_stream->p_pts_validity; |
|---|
| | 432 | ptrdiff_t p_diff = p_bit_stream->p_pts_validity - p_bit_stream->p_byte; |
|---|
| 433 | 433 | if( p_diff < 0 || p_diff > 4 /* We are far away so it is valid */ |
|---|
| 434 | 434 | || (p_diff * 8) >= p_bit_stream->fifo.i_available |
|---|
| … | … | |
| 447 | 447 | } |
|---|
| 448 | 448 | |
|---|
| | 449 | /***************************************************************************** |
|---|
| | 450 | * NextPTS: returns the PTS and DTS for the next starting byte |
|---|
| | 451 | *****************************************************************************/ |
|---|
| | 452 | void NextPTS( bit_stream_t * p_bit_stream, mtime_t * pi_pts, |
|---|
| | 453 | mtime_t * pi_dts ) |
|---|
| | 454 | { |
|---|
| | 455 | /* Check if the current PTS is already valid (ie. if the first byte |
|---|
| | 456 | * of the packet has already been used in the decoder). */ |
|---|
| | 457 | ptrdiff_t p_diff = p_bit_stream->p_pts_validity - p_bit_stream->p_byte - 1; |
|---|
| | 458 | if( p_diff < 0 || p_diff > 4 /* We are far away so it is valid */ |
|---|
| | 459 | || (p_diff * 8) >= p_bit_stream->fifo.i_available |
|---|
| | 460 | /* We have buffered less bytes than actually read */ ) |
|---|
| | 461 | { |
|---|
| | 462 | *pi_pts = p_bit_stream->i_pts; |
|---|
| | 463 | if( pi_dts != NULL ) *pi_dts = p_bit_stream->i_dts; |
|---|
| | 464 | p_bit_stream->i_pts = 0; |
|---|
| | 465 | p_bit_stream->i_dts = 0; |
|---|
| | 466 | } |
|---|
| | 467 | else |
|---|
| | 468 | { |
|---|
| | 469 | *pi_pts = 0; |
|---|
| | 470 | if( pi_dts != NULL) *pi_dts = 0; |
|---|
| | 471 | } |
|---|
| | 472 | } |
|---|
| | 473 | |
|---|
| ra2c6740 |
r15f3b0f |
|
| 215 | 215 | (p_symbols)->UnalignedGetBits_inner = UnalignedGetBits; \ |
|---|
| 216 | 216 | (p_symbols)->CurrentPTS_inner = CurrentPTS; \ |
|---|
| | 217 | (p_symbols)->NextPTS_inner = NextPTS; \ |
|---|
| 217 | 218 | (p_symbols)->DecoderError_inner = DecoderError; \ |
|---|
| 218 | 219 | (p_symbols)->__input_SetStatus_inner = __input_SetStatus; \ |
|---|