[xiph-commits] r3339 -
libfishsound/branches/1.0-stable-flac/src/libfishsound
conrad at svn.annodex.net
conrad at svn.annodex.net
Fri Jan 11 05:56:55 PST 2008
Author: conrad
Date: 2008-01-11 05:56:55 -0800 (Fri, 11 Jan 2008)
New Revision: 3339
Modified:
libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c
Log:
implement non-interleaved decode output for FLAC
*** FLAC passes encdec-audio.c ***
Modified: libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c
===================================================================
--- libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c 2008-01-11 13:55:42 UTC (rev 3338)
+++ libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c 2008-01-11 13:56:55 UTC (rev 3339)
@@ -45,7 +45,7 @@
#include "private.h"
#include "convert.h"
-#define DEBUG
+/*#define DEBUG*/
#if HAVE_FLAC
@@ -65,6 +65,8 @@
} version;
unsigned short header_packets;
void * ipcm;
+ float * pcm_out[8]; /* non-interleaved pcm, output (decode only);
+ * FLAC does max 8 channels */
} FishSoundFlacInfo;
int
@@ -140,7 +142,7 @@
printf("fs_flac_write_callback: IN, blocksize %d\n", blocksize);
#endif
- fsound->frameno += blocksize * channels;
+ fsound->frameno += blocksize;
if (fsound->callback.decoded_float) {
float norm = 1.0 / ((1 << (frame->header.bits_per_sample - 1)));
@@ -163,14 +165,13 @@
float ** retpcm, *p;
FLAC__int32 * s = (FLAC__int32 *)buffer;
- fi->ipcm = realloc(fi->ipcm, sizeof(float) * channels * blocksize);
- retpcm = fi->ipcm;
+ for (j = 0; j < channels; j++) {
+ fi->pcm_out[j] = realloc(fi->pcm_out[j], sizeof(float) * blocksize);
+ }
for (i = 0; i < blocksize; i++)
for (j = 0; j < channels; j++) {
-#if 0
- p = retpcm[j];
+ p = fi->pcm_out[j];
p[i] = s[i*channels + j] * norm;
-#endif
}
df = (FishSoundDecoded_Float)fsound->callback.decoded_float;
df (fsound, retpcm, blocksize, fsound->user_data);
@@ -495,6 +496,7 @@
fs_flac_delete (FishSound * fsound)
{
FishSoundFlacInfo * fi = (FishSoundFlacInfo *)fsound->codec_data;
+ int i;
#ifdef DEBUG
printf("fs_flac_delete: IN\n");
@@ -508,7 +510,12 @@
FLAC__stream_encoder_delete(fi->fse);
if (fi->buffer) fs_free(fi->buffer);
}
+
if (fi->ipcm) fs_free(fi->ipcm);
+ for (i = 0; i < 8; i++) {
+ if (fi->pcm_out[i]) fs_free (fi->pcm_out[i]);
+ }
+
fs_free (fi);
fsound->codec_data = NULL;
@@ -557,16 +564,21 @@
fs_flac_init (FishSound * fsound)
{
FishSoundFlacInfo *fi;
+ int i;
fi = fs_malloc (sizeof (FishSoundFlacInfo));
if (fi == NULL) return NULL;
fi->packetno = 0;
fi->header = 0;
- fi->ipcm = NULL;
fi->header_packets = 0;
fi->fsd = NULL;
fi->fse = NULL;
+ fi->ipcm = NULL;
+ for (i = 0; i < 8; i++) {
+ fi->pcm_out[i] = NULL;
+ }
+
fsound->codec_data = fi;
return fsound;
More information about the commits
mailing list