Changeset 5f782bc34f618ef58e01cd8fcba1f2fc0cb29402
- Timestamp:
- 11/11/03 01:37:59 (5 years ago)
- git-parent:
- Files:
-
- modules/demux/a52sys.c (modified) (6 diffs)
- modules/demux/aac.c (modified) (5 diffs)
- modules/demux/asf/asf.c (modified) (14 diffs)
- modules/demux/au.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/demux/a52sys.c
r05ca109 r5f782bc 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: a52sys.c,v 1. 6 2003/09/12 16:26:40fenrir Exp $5 * $Id: a52sys.c,v 1.7 2003/11/11 00:37:59 fenrir Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 56 56 mtime_t i_time; 57 57 58 es_ descriptor_t*p_es;58 es_out_id_t *p_es; 59 59 }; 60 60 … … 77 77 78 78 /***************************************************************************** 79 * Open: initializes A ACdemux structures79 * Open: initializes A52 demux structures 80 80 *****************************************************************************/ 81 81 static int Open( vlc_object_t * p_this ) … … 89 89 module_t *p_id3; 90 90 91 es_format_t fmt; 92 91 93 92 94 if( p_input->psz_demux && !strncmp( p_input->psz_demux, "a52", 3 ) ) … … 167 169 goto error; 168 170 } 169 if( input_AddProgram( p_input, 0, 0) == NULL )170 {171 vlc_mutex_unlock( &p_input->stream.stream_lock );172 msg_Err( p_input, "cannot add program" );173 goto error;174 }175 p_input->stream.pp_programs[0]->b_is_ok = 0;176 p_input->stream.p_selected_program = p_input->stream.pp_programs[0];177 178 171 p_input->stream.i_mux_rate = 0 / 50; 179 180 p_sys->p_es = input_AddES( p_input,181 p_input->stream.p_selected_program,182 1 , AUDIO_ES, NULL, 0 );183 184 p_sys->p_es->i_stream_id = 1;185 p_sys->p_es->i_fourcc = VLC_FOURCC( 'a', '5', '2', ' ' );186 input_SelectES( p_input, p_sys->p_es );187 188 p_input->stream.p_selected_program->b_is_ok = 1;189 172 vlc_mutex_unlock( &p_input->stream.stream_lock ); 190 173 174 es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'a', '5', '2', ' ' ) ); 175 p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt ); 191 176 return VLC_SUCCESS; 192 177 … … 266 251 p_sys->i_time * 9 / 100 ); 267 252 268 if( !p_sys->p_es->p_decoder_fifo ) 269 { 270 msg_Err( p_input, "no audio decoder" ); 271 input_DeletePES( p_input->p_method_data, p_pes ); 272 return( -1 ); 273 } 274 275 input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes ); 253 es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes ); 254 276 255 p_sys->i_time += (mtime_t)1000000 * 277 256 (mtime_t)1536 / modules/demux/aac.c
r05ca109 r5f782bc 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: aac.c,v 1. 4 2003/09/12 16:26:40fenrir Exp $5 * $Id: aac.c,v 1.5 2003/11/11 00:37:59 fenrir Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 57 57 mtime_t i_time; 58 58 59 es_ descriptor_t*p_es;59 es_out_id_t *p_es; 60 60 }; 61 61 … … 101 101 module_t *p_id3; 102 102 103 es_format_t fmt; 104 103 105 104 106 if( p_input->psz_demux && !strncmp( p_input->psz_demux, "aac", 3 ) ) … … 182 184 goto error; 183 185 } 184 if( input_AddProgram( p_input, 0, 0) == NULL )185 {186 vlc_mutex_unlock( &p_input->stream.stream_lock );187 msg_Err( p_input, "cannot add program" );188 goto error;189 }190 p_input->stream.pp_programs[0]->b_is_ok = 0;191 p_input->stream.p_selected_program = p_input->stream.pp_programs[0];192 193 186 p_input->stream.i_mux_rate = 0 / 50; 194 195 p_sys->p_es = input_AddES( p_input,196 p_input->stream.p_selected_program,197 1 , AUDIO_ES, NULL, 0 );198 199 p_sys->p_es->i_stream_id = 1;200 p_sys->p_es->i_fourcc = VLC_FOURCC( 'm', 'p', '4', 'a' );201 input_SelectES( p_input, p_sys->p_es );202 203 p_input->stream.p_selected_program->b_is_ok = 1;204 187 vlc_mutex_unlock( &p_input->stream.stream_lock ); 188 189 es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', '4', 'a' ) ); 190 p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt ); 205 191 206 192 return VLC_SUCCESS; … … 280 266 p_sys->i_time * 9 / 100 ); 281 267 282 if( !p_sys->p_es->p_decoder_fifo ) 283 { 284 msg_Err( p_input, "no audio decoder" ); 285 input_DeletePES( p_input->p_method_data, p_pes ); 286 return( -1 ); 287 } 288 289 input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes ); 268 es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes ); 269 290 270 p_sys->i_time += (mtime_t)1000000 * 291 271 (mtime_t)AAC_FRAME_SAMPLES( h ) / modules/demux/asf/asf.c
r05ca109 r5f782bc 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002-2003 VideoLAN 5 * $Id: asf.c,v 1.3 8 2003/09/12 16:26:40fenrir Exp $5 * $Id: asf.c,v 1.39 2003/11/11 00:37:59 fenrir Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 55 55 { 56 56 int i_cat; 57 es_descriptor_t *p_es; 57 58 es_out_id_t *p_es; 59 58 60 asf_object_stream_properties_t *p_sp; 59 61 … … 94 96 demux_sys_t *p_sys; 95 97 unsigned int i_stream; 96 unsigned int i;97 98 asf_object_content_description_t *p_cd; 98 99 … … 149 150 msg_Dbg( p_input, "found %d streams", p_sys->i_streams ); 150 151 151 /* create one program */152 152 vlc_mutex_lock( &p_input->stream.stream_lock ); 153 153 if( input_InitStream( p_input, 0 ) == -1) … … 157 157 goto error; 158 158 } 159 if( input_AddProgram( p_input, 0, 0) == NULL )160 {161 vlc_mutex_unlock( &p_input->stream.stream_lock );162 msg_Err( p_input, "cannot add program" );163 goto error;164 }165 p_input->stream.p_selected_program = p_input->stream.pp_programs[0];166 159 p_input->stream.i_mux_rate = 0 ; /* updated later */ 167 160 vlc_mutex_unlock( &p_input->stream.stream_lock ); … … 185 178 p_stream->p_es = NULL; 186 179 187 if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) ) 188 { 189 int i_codec; 190 if( p_sp->p_type_specific_data ) 191 { 192 i_codec = GetWLE( p_sp->p_type_specific_data ); 193 } 194 else 195 { 196 i_codec = -1; 180 if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) && 181 p_sp->i_type_specific_data_length >= sizeof( WAVEFORMATEX ) - 2 ) 182 { 183 es_format_t fmt; 184 uint8_t *p_data = p_sp->p_type_specific_data; 185 186 es_format_Init( &fmt, AUDIO_ES, 0 ); 187 wf_tag_to_fourcc( GetWLE( &p_data[0] ), &fmt.i_codec, NULL ); 188 fmt.audio.i_channels = GetWLE( &p_data[2] ); 189 fmt.audio.i_samplerate = GetDWLE( &p_data[4] ); 190 fmt.audio.i_bitrate = GetDWLE( &p_data[8] ) * 8; 191 fmt.audio.i_blockalign = GetWLE( &p_data[12] ); 192 fmt.audio.i_bitspersample = GetWLE( &p_data[14] ); 193 194 if( p_sp->i_type_specific_data_length > sizeof( WAVEFORMATEX ) ) 195 { 196 fmt.i_extra_type = ES_EXTRA_TYPE_WAVEFORMATEX; 197 fmt.i_extra = __MIN( GetWLE( &p_data[16] ), 198 p_sp->i_type_specific_data_length - sizeof( WAVEFORMATEX ) ); 199 fmt.p_extra = malloc( fmt.i_extra ); 200 memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )], fmt.i_extra ); 197 201 } 198 202 199 203 p_stream->i_cat = AUDIO_ES; 200 p_stream->p_es = input_AddES( p_input, 201 p_input->stream.p_selected_program, 202 p_sp->i_stream_number, AUDIO_ES, NULL, 0 ); 204 p_stream->p_es = es_out_Add( p_input->p_es_out, &fmt ); 203 205 204 206 msg_Dbg( p_input, 205 "adding new audio stream(codec:0x%x,ID:%d)", 206 i_codec, 207 p_sp->i_stream_number ); 208 wf_tag_to_fourcc( i_codec, &p_stream->p_es->i_fourcc, NULL ); 209 210 if( p_sp->i_type_specific_data_length > 0 ) 211 { 212 WAVEFORMATEX *p_wf; 213 size_t i_size; 214 uint8_t *p_data; 215 216 i_size = p_sp->i_type_specific_data_length; 217 218 p_wf = malloc( i_size ); 219 p_stream->p_es->p_waveformatex = (void*)p_wf; 220 p_data = p_sp->p_type_specific_data; 221 222 p_wf->wFormatTag = GetWLE( p_data ); 223 p_wf->nChannels = GetWLE( p_data + 2 ); 224 p_wf->nSamplesPerSec = GetDWLE( p_data + 4 ); 225 p_wf->nAvgBytesPerSec = GetDWLE( p_data + 8 ); 226 p_wf->nBlockAlign = GetWLE( p_data + 12 ); 227 p_wf->wBitsPerSample = GetWLE( p_data + 14 ); 228 p_wf->cbSize = __MIN( GetWLE( p_data + 16 ), i_size - sizeof( WAVEFORMATEX )); 229 if( p_wf->cbSize > 0 ) 230 { 231 memcpy( &p_wf[1], p_data + sizeof( WAVEFORMATEX ), p_wf->cbSize ); 232 } 233 } 234 } 235 else 236 if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) ) 237 { 207 "added new audio stream(codec:0x%x,ID:%d)", 208 GetWLE( p_data ), p_sp->i_stream_number ); 209 } 210 else if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) && 211 p_sp->i_type_specific_data_length >= 11 + sizeof( BITMAPINFOHEADER ) ) 212 { 213 es_format_t fmt; 214 uint8_t *p_data = &p_sp->p_type_specific_data[11]; 215 216 es_format_Init( &fmt, VIDEO_ES, 217 VLC_FOURCC( p_data[16], p_data[17], p_data[18], p_data[19] ) ); 218 fmt.video.i_width = GetDWLE( p_data + 4 ); 219 fmt.video.i_height= GetDWLE( p_data + 8 ); 220 221 if( p_sp->i_type_specific_data_length > 11 + sizeof( BITMAPINFOHEADER ) ) 222 { 223 fmt.i_extra_type = ES_EXTRA_TYPE_BITMAPINFOHEADER; 224 fmt.i_extra = __MIN( GetDWLE( p_data ), 225 p_sp->i_type_specific_data_length - 11 - sizeof( BITMAPINFOHEADER ) ); 226 fmt.p_extra = malloc( fmt.i_extra ); 227 memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )], fmt.i_extra ); 228 } 229 238 230 p_stream->i_cat = VIDEO_ES; 239 p_stream->p_es = input_AddES( p_input, 240 p_input->stream.p_selected_program, 241 p_sp->i_stream_number, VIDEO_ES, NULL, 0 ); 242 243 msg_Dbg( p_input, "adding new video stream(ID:%d)", 231 p_stream->p_es = es_out_Add( p_input->p_es_out, &fmt ); 232 233 msg_Dbg( p_input, "added new video stream(ID:%d)", 244 234 p_sp->i_stream_number ); 245 if( p_sp->p_type_specific_data )246 {247 p_stream->p_es->i_fourcc =248 VLC_FOURCC( p_sp->p_type_specific_data[27],249 p_sp->p_type_specific_data[28],250 p_sp->p_type_specific_data[29],251 p_sp->p_type_specific_data[30] );252 }253 else254 {255 p_stream->p_es->i_fourcc =256 VLC_FOURCC( 'u','n','d','f' );257 }258 if( p_sp->i_type_specific_data_length > 11 )259 {260 BITMAPINFOHEADER *p_bih;261 size_t i_size;262 uint8_t *p_data;263 264 i_size = p_sp->i_type_specific_data_length - 11;265 266 p_bih = malloc( i_size );267 p_stream->p_es->p_bitmapinfoheader = (void*)p_bih;268 p_data = p_sp->p_type_specific_data + 11;269 270 p_bih->biSize = GetDWLE( p_data );271 p_bih->biWidth = GetDWLE( p_data + 4 );272 p_bih->biHeight = GetDWLE( p_data + 8 );273 p_bih->biPlanes = GetDWLE( p_data + 12 );274 p_bih->biBitCount = GetDWLE( p_data + 14 );275 p_bih->biCompression= GetDWLE( p_data + 16 );276 p_bih->biSizeImage = GetDWLE( p_data + 20 );277 p_bih->biXPelsPerMeter = GetDWLE( p_data + 24 );278 p_bih->biYPelsPerMeter = GetDWLE( p_data + 28 );279 p_bih->biClrUsed = GetDWLE( p_data + 32 );280 p_bih->biClrImportant = GetDWLE( p_data + 36 );281 282 if( i_size > sizeof( BITMAPINFOHEADER ) )283 {284 memcpy( &p_bih[1],285 p_data + sizeof( BITMAPINFOHEADER ),286 i_size - sizeof( BITMAPINFOHEADER ) );287 }288 }289 290 235 } 291 236 else … … 295 240 p_sp->i_stream_number ); 296 241 } 297 298 vlc_mutex_lock( &p_input->stream.stream_lock ); 299 if( p_stream->p_es ) 300 { 301 input_SelectES( p_input, p_stream->p_es ); 302 } 303 vlc_mutex_unlock( &p_input->stream.stream_lock ); 304 } 305 242 } 306 243 307 244 p_sys->i_data_begin = p_sys->p_root->p_data->i_object_pos + 50; … … 346 283 } 347 284 } 348 349 vlc_mutex_lock( &p_input->stream.stream_lock );350 p_input->stream.p_selected_program->b_is_ok = 1;351 vlc_mutex_unlock( &p_input->stream.stream_lock );352 353 285 354 286 /* We add all info about this stream */ … … 380 312 } 381 313 314 #if 0 315 /* FIXME to port to new way */ 382 316 for( i_stream = 0, i = 0; i < 128; i++ ) 383 317 { … … 421 355 input_AddInfo( p_cat, _("Resolution"), "%dx%d", 422 356 p_bih->biWidth, p_bih->biHeight ); 423 input_AddInfo( p_cat, _("Planes"), "%d", p_bih->biPlanes );424 input_AddInfo( p_cat, _("Bits Per Pixel"), "%d", p_bih->biBitCount );425 input_AddInfo( p_cat, _("Image Size"), "%d", p_bih->biSizeImage );426 input_AddInfo( p_cat, _("X pixels per meter"), "%d",427 p_bih->biXPelsPerMeter );428 input_AddInfo( p_cat, _("Y pixels per meter"), "%d",429 p_bih->biYPelsPerMeter );430 357 } 431 358 432 359 i_stream++; 433 360 } 361 #endif 434 362 435 363 return VLC_SUCCESS; … … 450 378 vlc_bool_t b_play_audio; 451 379 int i; 452 vlc_bool_t b_stream;453 454 b_stream = VLC_FALSE;455 for( i = 0; i < 128; i++ )456 {457 if( p_sys->stream[i] &&458 p_sys->stream[i]->p_es &&459 p_sys->stream[i]->p_es->p_decoder_fifo )460 {461 b_stream = VLC_TRUE;462 }463 }464 if( !b_stream )465 {466 msg_Warn( p_input, "no stream selected, exiting..." );467 return( 0 );468 }469 380 470 381 /* catch seek from user */ … … 587 498 { 588 499 #define p_stream p_sys->stream[i_stream] 589 if( p_stream && p_stream->p_es && p_stream-> p_es->p_decoder_fifo && p_stream->i_time > 0)500 if( p_stream && p_stream->p_es && p_stream->i_time > 0) 590 501 { 591 502 if( i_time < 0 ) … … 802 713 } 803 714 804 if( !p_stream->p_es || !p_stream->p_es->p_decoder_fifo)715 if( !p_stream->p_es ) 805 716 { 806 717 i_skip += i_payload_data_length; … … 833 744 if( p_stream->p_pes->i_pes_size > 0 ) 834 745 { 835 if( p_stream->p_es->p_decoder_fifo && 836 ( b_play_audio || p_stream->i_cat != AUDIO_ES ) ) 837 { 838 p_stream->p_pes->i_rate = 839 p_input->stream.control.i_rate; 840 input_DecodePES( p_stream->p_es->p_decoder_fifo, 841 p_stream->p_pes ); 842 } 843 else 844 { 845 input_DeletePES( p_input->p_method_data, 846 p_stream->p_pes ); 847 } 746 es_out_Send( p_input->p_es_out, p_stream->p_es, p_stream->p_pes ); 848 747 p_stream->p_pes = NULL; 849 748 } modules/demux/au.c
r05ca109 r5f782bc 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001-2003 VideoLAN 5 * $Id: au.c,v 1. 7 2003/09/12 16:26:40fenrir Exp $5 * $Id: au.c,v 1.8 2003/11/11 00:37:59 fenrir Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 94 94 { 95 95 au_t au; 96 WAVEFORMATEX wf;97 96 98 97 mtime_t i_time; 99 98 100 es_descriptor_t *p_es; 99 es_format_t fmt; 100 es_out_id_t *p_es; 101 101 102 102 int i_frame_size; … … 114 114 115 115 uint8_t *p_peek; 116 117 vlc_fourcc_t i_fourcc;118 116 119 117 int i_cat; … … 171 169 172 170 /* Create WAVEFORMATEX structure */ 173 p_sys->wf.nChannels = p_sys->au.i_channels; 174 p_sys->wf.nSamplesPerSec= p_sys->au.i_sample_rate; 175 p_sys->wf.cbSize = 0; 176 171 es_format_Init( &p_sys->fmt, AUDIO_ES, 0 ); 172 p_sys->fmt.audio.i_channels = p_sys->au.i_channels; 173 p_sys->fmt.audio.i_samplerate = p_sys->au.i_sample_rate; 177 174 switch( p_sys->au.i_encoding ) 178 175 { 179 176 case AU_ALAW_8: /* 8-bit ISDN A-law */ 180 p_sys->wf.wFormatTag = WAVE_FORMAT_ALAW; // FIXME ?? 181 p_sys->wf.wBitsPerSample = 8; 182 p_sys->wf.nBlockAlign = 1 * p_sys->wf.nChannels; 183 i_fourcc = VLC_FOURCC( 'a','l','a','w' ); 177 p_sys->fmt.i_codec = VLC_FOURCC( 'a','l','a','w' ); 178 p_sys->fmt.audio.i_bitspersample = 8; 179 p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels; 184 180 i_cat = AU_CAT_PCM; 185 181 break; 186 182 187 183 case AU_MULAW_8: /* 8-bit ISDN u-law */ 188 p_sys->wf.wFormatTag = WAVE_FORMAT_MULAW; // FIXME ?? 189 p_sys->wf.wBitsPerSample = 8; 190 p_sys->wf.nBlockAlign = 1 * p_sys->wf.nChannels; 191 i_fourcc = VLC_FOURCC( 'u','l','a','w' ); 184 p_sys->fmt.i_codec = VLC_FOURCC( 'u','l','a','w' ); 185 p_sys->fmt.audio.i_bitspersample = 8; 186 p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels; 192 187 i_cat = AU_CAT_PCM; 193 188 break; 194 189 195 190 case AU_LINEAR_8: /* 8-bit linear PCM */ 196 p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; 197 p_sys->wf.wBitsPerSample = 8; 198 p_sys->wf.nBlockAlign = 1 * p_sys->wf.nChannels; 199 i_fourcc = VLC_FOURCC( 't','w','o','s' ); 191 p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' ); 192 p_sys->fmt.audio.i_bitspersample = 8; 193 p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels; 200 194 i_cat = AU_CAT_PCM; 201 195 break; 202 196 203 197 case AU_LINEAR_16: /* 16-bit linear PCM */ 204 p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; 205 p_sys->wf.wBitsPerSample = 16; 206 p_sys->wf.nBlockAlign = 2 * p_sys->wf.nChannels; 207 i_fourcc = VLC_FOURCC( 't','w','o','s' ); 198 p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' ); 199 p_sys->fmt.audio.i_bitspersample = 16; 200 p_sys->fmt.audio.i_blockalign = 2 * p_sys->fmt.audio.i_channels; 208 201 i_cat = AU_CAT_PCM; 209 202 break; 210 203 211 204 case AU_LINEAR_24: /* 24-bit linear PCM */ 212 p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; 213 p_sys->wf.wBitsPerSample = 24; 214 p_sys->wf.nBlockAlign = 3 * p_sys->wf.nChannels; 215 i_fourcc = VLC_FOURCC( 't','w','o','s' ); 205 p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' ); 206 p_sys->fmt.audio.i_bitspersample = 24; 207 p_sys->fmt.audio.i_blockalign = 3 * p_sys->fmt.audio.i_channels; 216 208 i_cat = AU_CAT_PCM; 217 209 break; 218 210 219 211 case AU_LINEAR_32: /* 32-bit linear PCM */ 220 p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; 221 p_sys->wf.wBitsPerSample = 32; 222 p_sys->wf.nBlockAlign = 4 * p_sys->wf.nChannels; 223 i_fourcc = VLC_FOURCC( 't','w','o','s' ); 212 p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' ); 213 p_sys->fmt.audio.i_bitspersample = 32; 214 p_sys->fmt.audio.i_blockalign = 4 * p_sys->fmt.audio.i_channels; 224 215 i_cat = AU_CAT_PCM; 225 216 break; 226 217 227 218 case AU_FLOAT: /* 32-bit IEEE floating point */ 228 p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; 229 p_sys->wf.wBitsPerSample = 32; 230 p_sys->wf.nBlockAlign = 4 * p_sys->wf.nChannels; 231 i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_FLOAT ); 219 p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_FLOAT ); 220 p_sys->fmt.audio.i_bitspersample = 32; 221 p_sys->fmt.audio.i_blockalign = 4 * p_sys->fmt.audio.i_channels; 232 222 i_cat = AU_CAT_PCM; 233 223 break; 234 224 235 225 case AU_DOUBLE: /* 64-bit IEEE floating point */ 236 p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; 237 p_sys->wf.wBitsPerSample = 64; 238 p_sys->wf.nBlockAlign = 8 * p_sys->wf.nChannels; 239 i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_DOUBLE ); 226 p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_DOUBLE ); 227 p_sys->fmt.audio.i_bitspersample = 64; 228 p_sys->fmt.audio.i_blockalign = 8 * p_sys->fmt.audio.i_channels; 240 229 i_cat = AU_CAT_PCM; 241 230 break; 242 231 243 232 case AU_ADPCM_G721: /* 4-bit CCITT g.721 ADPCM */ 244 p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; 245 p_sys->wf.wBitsPerSample = 0; 246 p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; 247 i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G721 ); 233 p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G721 ); 234 p_sys->fmt.audio.i_bitspersample = 0; 235 p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels; 248 236 i_cat = AU_CAT_ADPCM; 249 237 break; 250 238 251 239 case AU_ADPCM_G722: /* CCITT g.722 ADPCM */ 252 p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; 253 p_sys->wf.wBitsPerSample = 0; 254 p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; 255 i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G722 ); 240 p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G722 ); 241 p_sys->fmt.audio.i_bitspersample = 0; 242 p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels; 256 243 i_cat = AU_CAT_ADPCM; 257 244 break; 258 245 259 246 case AU_ADPCM_G723_3: /* CCITT g.723 3-bit ADPCM */ 260 p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; 261 p_sys->wf.wBitsPerSample = 0; 262 p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; 263 i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_3 ); 247 p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_3 ); 248 p_sys->fmt.audio.i_bitspersample = 0; 249 p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels; 264 250 i_cat = AU_CAT_ADPCM; 265 251 break; 266 252 267 253 case AU_ADPCM_G723_5: /* CCITT g.723 5-bit ADPCM */ 268 p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; 269 p_sys->wf.wBitsPerSample = 0; 270 p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; 271 i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_5 ); 254 p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_5 ); 255 p_sys->fmt.audio.i_bitspersample = 0; 256 p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels; 272 257 i_cat = AU_CAT_ADPCM; 273 258 break; … … 278 263 goto error; 279 264 } 280 p_sys-> wf.nAvgBytesPerSec = p_sys->wf.nSamplesPerSec * p_sys->wf.nChannels * p_sys->wf.wBitsPerSample / 8;281 282 265 p_sys->fmt.audio.i_bitrate = p_sys->fmt.audio.i_samplerate * 266 p_sys->fmt.audio.i_channels * 267 p_sys->fmt.audio.i_bitspersample; 283 268 284 269 if( i_cat == AU_CAT_UNKNOWN || i_cat == AU_CAT_ADPCM ) … … 295 280 296 281 /* read samples for 50ms of */ 297 i_samples = __MAX( p_sys-> wf.nSamplesPerSec/ 20, 1 );298 299 p_sys->i_frame_size = i_samples * p_sys-> wf.nChannels * ( (p_sys->wf.wBitsPerSample + 7) / 8 );300 301 if( p_sys-> wf.nBlockAlign > 0 )282 i_samples = __MAX( p_sys->fmt.audio.i_samplerate / 20, 1 ); 283 284 p_sys->i_frame_size = i_samples * p_sys->fmt.audio.i_channels * ( (p_sys->fmt.audio.i_bitspersample + 7) / 8 ); 285 286 if( p_sys->fmt.audio.i_blockalign > 0 ) 302 287 { 303 if( ( i_modulo = p_sys->i_frame_size % p_sys-> wf.nBlockAlign ) != 0 )288 if( ( i_modulo = p_sys->i_frame_size % p_sys->fmt.audio.i_blockalign ) != 0 ) 304 289 { 305 p_sys->i_frame_size += p_sys-> wf.nBlockAlign - i_modulo;290 p_sys->i_frame_size += p_sys->fmt.audio.i_blockalign - i_modulo; 306 291 } 307 292 } … … 309 294 p_sys->i_frame_length = (mtime_t)1000000 * 310 295 (mtime_t)i_samples / 311 (mtime_t)p_sys-> wf.nSamplesPerSec;296 (mtime_t)p_sys->fmt.audio.i_samplerate; 312 297 313 298 p_input->pf_demux = DemuxPCM; … … 315 300 } 316 301 317 /* create one program */318 302 vlc_mutex_lock( &p_input->stream.stream_lock ); 319 303 if( input_InitStream( p_input, 0 ) == -1) … … 323 307 goto error; 324 308 } 325 if( input_AddProgram( p_input, 0, 0) == NULL ) 326 { 327 vlc_mutex_unlock( &p_input->stream.stream_lock ); 328 msg_Err( p_input, "cannot add program" ); 329 goto error; 330 } 331 332 p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 333 p_input->stream.i_mux_rate = p_sys->wf.nAvgBytesPerSec / 50; 334 335 p_sys->p_es = input_AddES( p_input, p_input->stream.p_selected_program, 336 0x01, AUDIO_ES, NULL, 0 ); 337 338 p_sys->p_es->i_stream_id = 0x01; 339 p_sys->p_es->i_fourcc = i_fourcc; 340 p_sys->p_es->p_waveformatex= malloc( sizeof( WAVEFORMATEX ) ); 341 memcpy( p_sys->p_es->p_waveformatex, &p_sys->wf, sizeof( WAVEFORMATEX ) ); 342 343 input_SelectES( p_input, p_sys->p_es ); 344 345 p_input->stream.p_selected_program->b_is_ok = 1; 309 p_input->stream.i_mux_rate = p_sys->fmt.audio.i_bitrate / 50 / 8; 346 310 vlc_mutex_unlock( &p_input->stream.stream_lock ); 347 311 312 p_sys->p_es = es_out_Add( p_input->p_es_out, &p_sys->fmt ); 348 313 return VLC_SUCCESS; 349 314 … … 367 332 int64_t i_pos = stream_Tell( p_input->s ); 368 333 369 if( p_sys-> wf.nBlockAlign != 0 )334 if( p_sys->fmt.audio.i_blockalign != 0 ) 370 335 { 371 i_pos += p_sys-> wf.nBlockAlign - i_pos % p_sys->wf.nBlockAlign;336 i_pos += p_sys->fmt.audio.i_blockalign - i_pos % p_sys->fmt.audio.i_blockalign; 372 337 if( stream_Seek( p_input->s, i_pos ) ) 373 338 { … … 391 356 p_sys->i_time * 9 / 100 ); 392 357 393 if( !p_sys->p_es->p_decoder_fifo ) 394 { 395 msg_Err( p_input, "no audio decoder" ); 396 input_DeletePES( p_input->p_method_data, p_pes ); 397 return( -1 ); 398 } 399 400 input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes ); 358 es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes ); 359 401 360 p_sys->i_time += p_sys->i_frame_length; 361 402 362 return( 1 ); 403 363 }
