Re: Apple Lossless source bit depth (was: no subject)
Re: Apple Lossless source bit depth (was: no subject)
- Subject: Re: Apple Lossless source bit depth (was: no subject)
- From: Doug Wyatt <email@hidden>
- Date: Tue, 6 Dec 2005 12:40:17 -0800
On Dec 6, 2005, at 11:34 AM, Dan Morgan wrote:
I have read that apple lossless will give about a factor of two
compression,
but I was not seeing this when I used it. The audio being recorded
was the
sound of a conference room. I tried a variety of different
approaches in
my code and could not get it to compress, so I tried running WhackedTV
with output format set to apple lossless, and it also did not
compress.
Has anyone noticed this before?
Is apple lossless tuned to particular types of data and just does
not work
well on other types of data?
afconvert is a good way to experiment with AudioConverter ...
create a float source file for testing:
$ afconvert -d BEF32 /System/Library/Sounds/Submarine.aiff /tmp/foo.caf
$ afinfo /tmp/foo.caf
File: /tmp/foo.caf
File type ID: caff
Data format: 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-
endian float
no channel layout.
encode it to lossless:
$ afconvert -d alac /tmp/foo.caf /tmp/foo2.caf -v
Input file: foo.caf, 42998 frames
Formats:
Input file 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-
endian float
Output file 2 ch, 44100 Hz, 'alac' (0x00000004) from 32-bit
source, 4096 frames/packet
Stereo
Output client 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-
endian float
AudioConverter 0x2028424 [0x316aa0]:
PCMConverter 0x316bc0
Input: 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-endian
float
Output: 2 ch, 44100 Hz, 'lpcm' (0x0000000E) 32-bit big-endian
signed integer
CodecConverter 0x316d80
Input: 2 ch, 44100 Hz, 'lpcm' (0x0000000E) 32-bit big-endian
signed integer
Output: 2 ch, 44100 Hz, 'alac' (0x00000004) from 32-bit
source, 4096 frames/packet
Output layout tag: 650002
Output file: foo2.caf, 45056 frames
$ afinfo /tmp/foo2.caf
File: /tmp/foo2.caf
File type ID: caff
Data format: 2 ch, 44100 Hz, 'alac' (0x00000004) from 32-bit
source, 4096 frames/packet
no channel layout.
audio bytes: 207837
*** Notice that the source floats were converted to 32-bit integer
before being passed to the lossless encoder.
encode it to lossless, specifying a 16-bit source bit depth (the /1
tag on 'alac'):
$ afconvert -d alac/1 /tmp/foo.caf /tmp/foo2.caf -v
Input file: foo.caf, 42998 frames
Formats:
Input file 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-
endian float
Output file 2 ch, 44100 Hz, 'alac' (0x00000001) from 16-bit
source, 4096 frames/packet
Stereo
Output client 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-
endian float
AudioConverter 0x2028424 [0x316aa0]:
PCMConverter 0x316bc0
Input: 2 ch, 44100 Hz, 'lpcm' (0x0000000B) 32-bit big-endian
float
Output: 2 ch, 44100 Hz, 'lpcm' (0x0000000E) 16-bit big-endian
signed integer
CodecConverter 0x316d60
Input: 2 ch, 44100 Hz, 'lpcm' (0x0000000E) 16-bit big-endian
signed integer
Output: 2 ch, 44100 Hz, 'alac' (0x00000001) from 16-bit
source, 4096 frames/packet
Output layout tag: 650002
Output file: foo2.caf, 45056 frames
$ afinfo /tmp/foo3.caf
File: /tmp/foo3.caf
File type ID: caff
Data format: 2 ch, 44100 Hz, 'alac' (0x00000001) from 16-bit
source, 4096 frames/packet
no channel layout.
audio bytes: 35845
*** notice "from 16-bit source" and smaller "audio bytes"
So I suspect that when you're creating an AudioConverter to encode to
lossless, you're passing a floating point source format, and leaving
the lossless stream description's mFormatFlags 0. In this situation,
the AudioConverter is converting the source floats to 32-bit integers
before passing them to the lossless encoder, since the lossless
encoder can only take integer input directly.
Explicitly setting the mFormatFlags to one of the appropriate
constants (search for "lossless" in CoreAudioTypes.h) defeats the 32-
bit assumption.
(If you pass the AudioConverter an integer source format without
specifying a lossless bit depth, it does the right thing.)
Doug
_______________________________________________
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
References: | |
| >(no subject) (From: "Dan Morgan" <email@hidden>) |