[Flac-dev] Using libFLAC++
Josh Coalson
xflac at yahoo.com
Tue Feb 18 09:46:02 PST 2003
samples come out of the decoder in 32-bit signed int. the loop is
just converting them to 16-bit signed.
the aliasing of 'buffer' into 's16buffer' etc is just a hack to use
the same buffer space to convert to different target formats.
--- David Bishop <tech at bishop.dhs.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> [meta: Thanks, Josh, for clearing that up]
>
> Continuing my quest to make everyone think I'm an idiot, could
> someone
> explain the following code to me? I.e., what the two for loops are
> accomplishing, and what, *exactly*, is in s16buffer when it's done.
> Assume I want to write a .wav file from this decoded flac*. Is it
> already in
> approximately the right format, or do I have to do some sort of
> conversion? This code is ripped almost directly from decode.c in
> flac/,
> just heavily cut down to deal with only 1 type of file (i.e., I'm not
>
> dealing with differing endianess right now).
>
> [this code is in my write callback]
>
> static FLAC__int8 s8buffer[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS
> * sizeof(FLAC__int32)];
> FLAC__int16 *s16buffer = (FLAC__int16 *)s8buffer;
>
> if( wide_samples > 0 ) {
> for(sample = wide_sample = 0; wide_sample < wide_samples;
> wide_sample++) {
> for(channel = 0; channel < channels; channel++, sample++) {
> s16buffer[sample] =
> (FLAC__int16)(buffer[channel][wide_sample]);
> }
> }
> }
>
> Sorry for the newbie-style questions, I'm afraid I'm not that good,
> and
> it's showing through :-)
>
> D.A.Bishop
>
> *I don't, but assume I do :-)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQE+UIkMEHLN/FXAbC0RAvl2AKDBea/q+8T57qxR3nL+cd8jvyds9QCfUeK+
> UALSFQcE9o0Ho1sprO5faEc=
> =0HHl
> -----END PGP SIGNATURE-----
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
More information about the Flac-dev
mailing list