Changeset 17bba6bc4fd5244bd8c847c5a8992508698a93cb

Show
Ignore:
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
  • modules/packetizer/mpeg4audio.c

    ra74d545 r17bba6b  
    240240        } 
    241241 
     242        p_dec->fmt_out.audio.i_channels = 
     243            (p_config[i_index == 0x0f ? 4 : 1] >> 3) & 0x0f; 
     244 
    242245        msg_Dbg( p_dec, "AAC %dHz %d samples/frame", 
    243246                 p_dec->fmt_out.audio.i_rate, 
     
    246249        aout_DateInit( &p_sys->end_date, p_dec->fmt_out.audio.i_rate ); 
    247250 
    248         p_dec->fmt_out.audio.i_channels = p_dec->fmt_in.audio.i_channels; 
    249251        p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra; 
    250252        p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra ); 
     
    334336 
    335337    /* 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 */ 
    337339    b_crc = !(p_buf[1] & 0x01); 
    338340    i_profile = p_buf[2] >> 6; 
    339341    i_sample_rate_idx = (p_buf[2] >> 2) & 0x0f; 
    340342    *pi_sample_rate = pi_sample_rates[i_sample_rate_idx]; 
     343    //private_bit = (p_buf[2] >> 1) & 0x01; 
    341344    *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; 
    342347 
    343348    /* Variable header */ 
     349    //copyright_id_bit = (p_buf[3] >> 3) & 0x01; 
     350    //copyright_id_start = (p_buf[3] >> 2) & 0x01; 
    344351    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; 
    347355 
    348356    if( !*pi_sample_rate || !*pi_channels || !i_frame_size ) 
    349357    { 
     358        msg_Warn( p_dec, "Invalid ADTS header" ); 
    350359        return 0; 
    351360    } 
    352361 
    353     /* Fixme */ 
    354362    *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 
    355404 
    356405    /* Build the decoder specific info header */