Changeset 39

Show
Ignore:
Timestamp:
04/05/07 18:36:36 (2 years ago)
Author:
gbooker
Message:

Patch for Big Endian by David Conrad.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/A52/ACShepA52Decoder.cpp

    r38 r39  
    117117                { 
    118118                        for (int channels = 1; channels <= 2; channels++) { 
    119                                 CAStreamBasicDescription theOutputFormat(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, channels, 16, kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked); 
     119                                CAStreamBasicDescription theOutputFormat(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, channels, 16, kIntPCMOutFormatFlag); 
    120120                                AddOutputFormat(theOutputFormat); 
    121121                                //      This decoder only takes an A/52 or AC-3 stream as it's input 
     
    515515                { 
    516516                        static const uint8_t p_sync_le[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 }; 
     517                        static const uint8_t p_sync_be[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x01 }; 
    517518                         
    518519                        uint8_t *myOutputData = (uint8_t *)(outOutputData); 
     
    521522                         
    522523                        memset(myOutputData, 0, 2 * 2 * 256 * 6); 
    523                         memcpy(myOutputData, p_sync_le, 6); 
    524524                        input_data = GetBytes(bytes_to_read); 
    525                         myOutputData[5] = input_data[5] & 0x7; 
    526                         myOutputData[6] = (bytes_to_read << 4) & 0xff; 
    527                         myOutputData[7] = (bytes_to_read >> 4) & 0xff; 
    528                         unsigned int i; 
    529                         for(i=0; i<bytes_to_read; i+=2) 
     525                         
     526                        if (mOutputFormat.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) 
    530527                        { 
    531                                 myOutputData[i+8] = input_data[i+1]; 
    532                                 myOutputData[i+9] = input_data[i]; 
     528                                memcpy(myOutputData, p_sync_be, 6); 
     529                                myOutputData[4] = input_data[5] & 0x7; 
     530                                myOutputData[6] = (bytes_to_read >> 4) & 0xff; 
     531                                myOutputData[7] = (bytes_to_read << 4) & 0xff; 
     532                                memcpy(&myOutputData[8], input_data, bytes_to_read); 
     533                        }  
     534                        else 
     535                        { 
     536                                memcpy(myOutputData, p_sync_le, 6); 
     537                                myOutputData[5] = input_data[5] & 0x7; 
     538                                myOutputData[6] = (bytes_to_read << 4) & 0xff; 
     539                                myOutputData[7] = (bytes_to_read >> 4) & 0xff; 
     540                                unsigned int i; 
     541                                for(i=0; i<bytes_to_read; i+=2) 
     542                                { 
     543                                        myOutputData[i+8] = input_data[i+1]; 
     544                                        myOutputData[i+9] = input_data[i]; 
     545                                } 
    533546                        } 
    534547                        output_offset += mOutputFormat.mChannelsPerFrame * 256 * 6;     //Our framed hack