Changeset 17bba6bc4fd5244bd8c847c5a8992508698a93cb
- Timestamp:
- 12/03/08 21:19:24
(7 months ago)
- Author:
- Rafaël Carré <funman@videolan.org>
- git-committer:
- Rafaël Carré <funman@videolan.org> 1205353164 +0100
- git-parent:
[7c79c5512c7f3a7da087f0dc942f9377e7caa7c6]
- git-author:
- Rafaël Carré <funman@videolan.org> 1205339346 +0100
- Message:
Fix adts packetizer
Get channels information from decoder specific config
Add (commented) useless variables from ADTS header
Detect unsupported configurations and start (commented) support
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra74d545 |
r17bba6b |
|
| 240 | 240 | } |
|---|
| 241 | 241 | |
|---|
| | 242 | p_dec->fmt_out.audio.i_channels = |
|---|
| | 243 | (p_config[i_index == 0x0f ? 4 : 1] >> 3) & 0x0f; |
|---|
| | 244 | |
|---|
| 242 | 245 | msg_Dbg( p_dec, "AAC %dHz %d samples/frame", |
|---|
| 243 | 246 | p_dec->fmt_out.audio.i_rate, |
|---|
| … | … | |
| 246 | 249 | aout_DateInit( &p_sys->end_date, p_dec->fmt_out.audio.i_rate ); |
|---|
| 247 | 250 | |
|---|
| 248 | | p_dec->fmt_out.audio.i_channels = p_dec->fmt_in.audio.i_channels; |
|---|
| 249 | 251 | p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; |
|---|
| 250 | 252 | p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra ); |
|---|
| … | … | |
| 334 | 336 | |
|---|
| 335 | 337 | /* Fixed header between frames */ |
|---|
| 336 | | i_id = ( (p_buf[1] >> 3) & 0x01 ) ? 2 : 4; |
|---|
| | 338 | i_id = ( (p_buf[1] >> 3) & 0x01) ? 2 : 4; /* MPEG-2 or 4 */ |
|---|
| 337 | 339 | b_crc = !(p_buf[1] & 0x01); |
|---|
| 338 | 340 | i_profile = p_buf[2] >> 6; |
|---|
| 339 | 341 | i_sample_rate_idx = (p_buf[2] >> 2) & 0x0f; |
|---|
| 340 | 342 | *pi_sample_rate = pi_sample_rates[i_sample_rate_idx]; |
|---|
| | 343 | //private_bit = (p_buf[2] >> 1) & 0x01; |
|---|
| 341 | 344 | *pi_channels = ((p_buf[2] & 0x01) << 2) | ((p_buf[3] >> 6) & 0x03); |
|---|
| | 345 | //original_copy = (p_buf[3] >> 5) & 0x01; |
|---|
| | 346 | //home = (p_buf[3] >> 4) & 0x01; |
|---|
| 342 | 347 | |
|---|
| 343 | 348 | /* Variable header */ |
|---|
| | 349 | //copyright_id_bit = (p_buf[3] >> 3) & 0x01; |
|---|
| | 350 | //copyright_id_start = (p_buf[3] >> 2) & 0x01; |
|---|
| 344 | 351 | i_frame_size = ((p_buf[3] & 0x03) << 11) | (p_buf[4] << 3) | |
|---|
| 345 | | ((p_buf[5] >> 5) & 0x7); |
|---|
| 346 | | //i_raw_blocks_in_frame = (p_buf[6] & 0x02) + 1; |
|---|
| | 352 | ((p_buf[5] >> 5) /*& 0x7*/); |
|---|
| | 353 | //uint16_t buffer_fullness = ((p_buf[5] & 0x1f) << 6) | (p_buf[6] >> 2); |
|---|
| | 354 | unsigned short i_raw_blocks_in_frame = p_buf[6] & 0x03; |
|---|
| 347 | 355 | |
|---|
| 348 | 356 | if( !*pi_sample_rate || !*pi_channels || !i_frame_size ) |
|---|
| 349 | 357 | { |
|---|
| | 358 | msg_Warn( p_dec, "Invalid ADTS header" ); |
|---|
| 350 | 359 | return 0; |
|---|
| 351 | 360 | } |
|---|
| 352 | 361 | |
|---|
| 353 | | /* Fixme */ |
|---|
| 354 | 362 | *pi_frame_length = 1024; |
|---|
| | 363 | |
|---|
| | 364 | if( i_raw_blocks_in_frame == 0 ) |
|---|
| | 365 | { |
|---|
| | 366 | if( b_crc ) |
|---|
| | 367 | { |
|---|
| | 368 | msg_Warn( p_dec, "ADTS CRC not supported" ); |
|---|
| | 369 | //uint16_t crc = (p_buf[7] << 8) | p_buf[8]; |
|---|
| | 370 | } |
|---|
| | 371 | } |
|---|
| | 372 | else |
|---|
| | 373 | { |
|---|
| | 374 | msg_Err( p_dec, "Multiple blocks per frame in ADTS not supported" ); |
|---|
| | 375 | return 0; |
|---|
| | 376 | #if 0 |
|---|
| | 377 | int i; |
|---|
| | 378 | const uint8_t *p_pos = p_buf + 7; |
|---|
| | 379 | uint16_t crc_block; |
|---|
| | 380 | uint16_t i_block_pos[3]; |
|---|
| | 381 | if( b_crc ) |
|---|
| | 382 | { |
|---|
| | 383 | for( i = 0 ; i < i_raw_blocks_in_frame ; i++ ) |
|---|
| | 384 | { /* the 1st block's position is known ... */ |
|---|
| | 385 | i_block_pos[i] = (*p_pos << 8) | *(p_pos+1); |
|---|
| | 386 | p_pos += 2; |
|---|
| | 387 | } |
|---|
| | 388 | crc_block = (*p_pos << 8) | *(p_pos+1); |
|---|
| | 389 | p_pos += 2; |
|---|
| | 390 | } |
|---|
| | 391 | for( i = 0 ; i <= i_raw_blocks_in_frame ; i++ ) |
|---|
| | 392 | { |
|---|
| | 393 | //read 1 block |
|---|
| | 394 | if( b_crc ) |
|---|
| | 395 | { |
|---|
| | 396 | msg_Err( p_dec, "ADTS CRC not supported" ); |
|---|
| | 397 | //uint16_t crc = (*p_pos << 8) | *(p_pos+1); |
|---|
| | 398 | //p_pos += 2; |
|---|
| | 399 | } |
|---|
| | 400 | } |
|---|
| | 401 | #endif |
|---|
| | 402 | } |
|---|
| | 403 | |
|---|
| 355 | 404 | |
|---|
| 356 | 405 | /* Build the decoder specific info header */ |
|---|