Re: Converting to LPCM 32bit
Re: Converting to LPCM 32bit
- Subject: Re: Converting to LPCM 32bit
- From: Gennady Dudarek <email@hidden>
- Date: Mon, 8 Jan 2007 23:33:56 +0200
I'm not sure but probably my notes can help you.
On Jan 5, 2007, at 10:25 AM, Sandeep Chandna wrote:
Brad,
Thanks for the response.
I am using SCAudio for conversion. In Dumpster I could find the
SampleDescription->dataFormat in the two cases as
'in32' and 'fl32' which as far as i know means integer,32,big
endian and float,32,big endian (correct me if i am wrong).
I could not find any corresponding dataFormats for Little Endian
for 32 bit formats as available for 16 bit case - 'sowt' . Is there
any other setting in the
dumpster output that changes bigEndian to littleEndian?
These constants do not specify endian information. In case of using
SampleDescription endian information shall be provided via atom lists
(usually lists of QT atoms added somewhere at end of sample
description or by using special functions). I never used SCAudio but
in SoundConverter API it shall be provided by SoundConverterSetInfo.
The code can look like this (http://developer.apple.com/samplecode/
audiocodec/listing5.html):
typedef struct {
AudioFormatAtom formatData;
AudioEndianAtom endianData;
AudioTerminatorAtom terminatorData;
} AudioCompressionAtom, *AudioCompressionAtomPtr,
**AudioCompressionAtomHandle;
AudioCompressionAtomHandle atom;
AudioCompressionAtomPtr atomPtr;
atom = (AudioCompressionAtomHandle)NewHandle(sizeof
(AudioCompressionAtom));
atomPtr = *atom;
atomPtr->formatData.size = EndianU32_NtoB(sizeof(AudioFormatAtom));
atomPtr->formatData.atomType = EndianU32_NtoB(kAudioFormatAtomType);
atomPtr->formatData.format = EndianU32_NtoB(myFormat); //
specify data format there (like 'in32' or 'fl32')
atomPtr->endianData.size = EndianU32_NtoB(sizeof(AudioEndianAtom));
atomPtr->endianData.atomType = EndianU32_NtoB(kAudioEndianAtomType);
atomPtr->endianData.littleEndian = EndianU16_NtoB(myEndian); //
true if little endian
atomPtr->terminatorData.size = EndianU32_NtoB(sizeof
(AudioTerminatorAtom));
atomPtr->terminatorData.atomType = EndianU32_NtoB
(kAudioTerminatorAtomType);
SoundConverterSetInfo(sc, siCompressionParams, atomPtr);
Also, I am using QTSoundDescriptionCreate to create the SDH, and
output ASBD is defined as given in my last mail (qouted here).
Looks like returned sound description does not contain required
extension.
Try to find value of 'enda' atom in returned sound description, if it
is correct that means - bug is somewhere in your further code.
asbd.mFormatID = kAudioFormatLinearPCM
asbd.mSampleRate = sampleRate;
asbd.mFormatFlags = kAudioFormatFlagIsPacked |
kAudioFormatFlagIsFloat ; // 32bit, float, little-endian - NOT
WORKING
/* and other cases as follows:
asbd.mFormatFlags = kAudioFormatFlagIsPacked |
kAudioFormatFlagIsSignedInteger ; // 32bit, integer, little-
endian - NOT WORKING
asbd.mFormatFlags = kAudioFormatFlagIsPacked |
kAudioFormatFlagIsFloat | kAudioFormatFlagIsBigEndian ; // 32bit,
float, big-endian - WORKING
asbd.mFormatFlags = kAudioFormatFlagIsPacked |
kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsSignedInteger ; //
32bit, integer, big-endian - WORKING
*/
asbd.mBytesPerPacket = 4
asbd.mFramesPerPacket = 1;
asbd.mBytesPerFrame = 4
asbd.mChannelsPerFrame = 1
asbd.mBitsPerChannel = 32
asbd.mReserved = 0;
QTSoundDescriptionCreate( &asbd, pLayout, layoutSize, NULL, 0,
kQTSoundDescriptionKind_Movie_LowestPossibleVersion,
&sdh);
My input format in the both 32 bit cases is as follows:
iasbd.mFormatID = kAudioFormatLinearPCM;
iasbd.mSampleRate = sampleRate;
iasbd.mFormatFlags = kAudioFormatFlagIsSignedInteger|
kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian; // LPCM,
32bit, signed , native endian
iasbd.mBytesPerPacket = 4; // for 32bit, 3 for 24
iasbd.mFramesPerPacket = 1;
iasbd.mBytesPerFrame = 4; //for 32bit, 3 for 24
iasbd.mChannelsPerFrame = 1;
iasbd.mBitsPerChannel = 32; //for 32 bit, 24 for 24bit case
iasbd.mReserved = 0;
Am I initializing the input ASBD (isabd) wrongly? or do I need to
initialize the sound description in some other manner. My input is
always LPCM, signed, native endian.
Thanks
Sandeep
On 04/01/07, Brad Ford <email@hidden> wrote: Sandeep,
You don't specify how you are performing the audio conversion
(SoundConverter? AudioConverter? SCAudio?). You also don't specify
what your source format is. The data you're feeding the converter
might be in the wrong format. You also don't specify what you're
using to write your movie file. Perhaps the conversion is completely
correct, but the sample description you're building for the movie is
wrong, and therefore interpreted as big endian when the data is
really little endian. You can verify this for yourself by opening
one of the affected movies in Dumpster and altering the bits in the
audio sample description fields so that it specifies little endian
instead of big. If it plays correctly, then there's nothing wrong
with your conversion code -- it's just the part that builds the movie
track's sample description. By the way, 8 bit will always work for
you because there's no such thing as 8-bit big or little endian.
Endianness only comes into play when you've got words longer than 8
bits.
-Brad Ford
QuickTime Engineering
On Jan 3, 2007, at 11:27 PM, Sandeep Chandna wrote:
> Hi,
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@gmail.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden