samples in FLAC are always signed. they must be signed going into the encoder (flac converts unsigned samples to signed) and they come out of the decoder signed. Josh --- David Bishop <tech@bishop.dhs.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Followup to original question: how do I determine if a particular > flac file is > signed (and then, if big or little endian) or unsigned? Unless I'm > missing > something obvious, I don't see a ->get_signedness() :-) > > Thanks, > > D.A.Bishop > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.1 (GNU/Linux) > > iD8DBQE+UGGDEHLN/FXAbC0RAn+rAJ4yVhW+U55hcFnnG6y3KIS8D8gAZgCfbhhp > by9hsCqWdBAm1Cedmm4Kt6I> =bXDf > -----END PGP SIGNATURE----- > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Flac-dev mailing list > Flac-dev@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/flac-dev__________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com
-----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-----
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@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