Decoding raw AMR
Decoding raw AMR
- Subject: Decoding raw AMR
- From: Martin Storsjö <email@hidden>
- Date: Mon, 22 Jan 2007 02:47:12 +0200 (EET)
Hello,
I've been trying to decode raw blocks of AMR-NB encoded data, without
success.
The data to decode is recorded using low-level recording APIs on a mobile
phone, and is supplied to my application as raw blocks (in my case 32
bytes per block, which should be uncompressed to 160 samples of 16 bit
data) with no other framing except that the length of the blocks is known.
I'm able to decode these blocks without problems using the reference
AMR implementation from 3gpp.org, but I haven't succeeded in doing the
same using CoreAudio or QuickTime.
First I tried using the AudioConvert-API, but
AudioConverterFillComplexBuffer returned the error code '!stt'
(kAudioCodecStateError), which I didn't manage to debug any further.
The current attempt is to directly use the AudioCodec component, but this
approach also gives me the '!stt' error code. The code I'm trying to use
is this (error checks omitted for readability):
AudioStreamBasicDescription inputFormat, outputFormat;
memset(&inputFormat, 0, sizeof(inputFormat));
inputFormat.mFormatID = 'samr';
inputFormat.mSampleRate = 8000;
inputFormat.mChannelsPerFrame = 1;
OpenADefaultComponent('adec', 'samr', &codec);
UInt32 size = sizeof(outputFormat);
AudioCodecGetProperty(codec, kAudioCodecPropertyCurrentOutputFormat, &size, &outputFormat);
AudioCodecInitialize(codec, &inputFormat, &outputFormat, NULL, 0);
UInt32 inputSize = size; // 32 bytes
UInt32 numberPackets = 1;
// this gives no error, but numberPackets is set to 0
AudioCodecAppendInputData(codec, inputData, &inputSize, &numberPackets, NULL);
UInt32 outputSize = sizeof(buffer);
numberPackets = 1;
UInt32 outStatus = 0;
// this returns '!stt'
AudioCodecProduceOutputPackets(codec, buffer, &outputSize, &numberPackets, NULL, &outStatus);
Since the error is a codec state error, I assume I should initialize the
codec further, but more exactly what is missing?
Or is there any example code anywhere showing how to decode this kind of
low-level unframed AMR data using e.g. the AudioConverter API?
Kind regards,
// Martin
_______________________________________________
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