Changeset 1076
- Timestamp:
- 06/13/09 22:31:28 (15 months ago)
- Location:
- trunk/FFissionCodec
- Files:
-
- 2 modified
-
FFissionDecoder.cpp (modified) (5 diffs)
-
FFissionDecoder.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/FFissionCodec/FFissionDecoder.cpp
r1055 r1076 102 102 } 103 103 else 104 dtsPassthrough = 0; 104 dtsPassthrough = 0; 105 106 int initialMap[6] = {0, 1, 2, 3, 4, 5}; 107 memcpy(fullChannelMap, initialMap, sizeof(initialMap)); 105 108 } 106 109 … … 327 330 if(mInputFormat.mFormatID != kAudioFormatDTS) 328 331 dtsPassthrough = 0; 332 else 333 { 334 switch (mInputFormat.mChannelsPerFrame) { 335 case 3: 336 case 6: 337 { 338 int chanMap[6] = {1, 2, 0, 5, 3, 4};//L R C -> C L R and L R C LFE Ls Rs -> C L R Ls Rs LFE 339 memcpy(fullChannelMap, chanMap, sizeof(chanMap)); 340 break; 341 } 342 case 4: 343 case 5: 344 { 345 int chanMap[6] = {1, 2, 0, 3, 4, 5};//L R C Cs -> C L R Cs and L R C Ls Rs -> C L R Ls Rs 346 memcpy(fullChannelMap, chanMap, sizeof(chanMap)); 347 break; 348 } 349 default: 350 break; 351 } 352 } 329 353 } 330 354 … … 492 516 } 493 517 518 UInt32 FFissionDecoder::InterleaveSamples(void *outputDataUntyped, Byte *inputDataUntyped, int amountToCopy) 519 { 520 SInt16 *outputData = (SInt16 *)outputDataUntyped; 521 SInt16 *inputData = (SInt16 *)inputDataUntyped; 522 int channelCount = avContext->channels; 523 int framesToCopy = amountToCopy / channelCount / 2; 524 for(int i=0; i<framesToCopy; i++) 525 { 526 for(int j=0; j<channelCount; j++) 527 { 528 outputData[fullChannelMap[j]] = inputData[j]; 529 } 530 outputData += channelCount; 531 inputData += channelCount; 532 } 533 534 return framesToCopy * channelCount * 2; 535 } 536 494 537 UInt32 FFissionDecoder::ProduceOutputPackets(void* outOutputData, 495 538 UInt32& ioOutputDataByteSize, // number of bytes written to outOutputData … … 511 554 if (outBufUsed > 0) { 512 555 int amountToCopy = FFMIN(outBufUsed, ioOutputDataByteSize); 513 memcpy(outData, outputBuffer, amountToCopy);556 amountToCopy = InterleaveSamples(outData, outputBuffer, amountToCopy); 514 557 outBufUsed -= amountToCopy; 515 558 written += amountToCopy; … … 550 593 // copy up to the amount requested 551 594 int amountToCopy = FFMIN(outBufUsed, ioOutputDataByteSize - written); 552 memcpy(outData + written, outputBuffer, amountToCopy);595 amountToCopy = InterleaveSamples(outData + written, outputBuffer, amountToCopy); 553 596 outBufUsed -= amountToCopy; 554 597 written += amountToCopy; -
trunk/FFissionCodec/FFissionDecoder.h
r1044 r1076 44 44 45 45 virtual void AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription); 46 virtual UInt32 InterleaveSamples(void *outputDataUntyped, Byte *inputDataUntyped, int amountToCopy); 46 47 virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets, AudioStreamPacketDescription* outPacketDescription); 47 48 … … 60 61 int outBufUsed; 61 62 bool dtsPassthrough; 63 int fullChannelMap[6]; 62 64 }; 63 65
