Hello.
This patch adds a new encoding function, lame_encode_buffer_long_interleaved
. This does the same as lame_encode_buffer_interleaved, only it uses samples
in long format instead of sample_t.
Bye
Fabrizio Gennari
__________________________________________________________________
Tiscali Ricaricasa
la prima prepagata per navigare in Internet a meno di un'urbana e
risparmiare su tutte le tue telefonate. Acquistala on line e non avrai
nessun costo di attivazione n� di ricarica!
http://ricaricasaonline.tiscali.it/
diff -ruN lame-3.92-old/include/lame.h lame-3.92/include/lame.h
--- lame-3.92-old/include/lame.h Fri Apr 12 21:38:18 2002
+++ lame-3.92/include/lame.h Thu Oct 31 16:48:34 2002
@@ -574,6 +574,26 @@
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
int mp3buf_size ); /* number of valid octets in this
stream */
+/*
+ * as above, but but for long's.
+ * !! NOTE: !! data must be scaled to be in the same range as
+ * type 'long'. Data should be in the range: +/- 2^(8*size(long)-1)
+ *
+ * NOTE:
+ * num_samples = number of samples in the L (or R)
+ * channel, not the total number of samples in pcm[]
+ */
+
+int CDECL lame_encode_buffer_long_interleaved(
+ lame_global_flags* gfp, /* global context handlei */
+ const long pcm[], /* PCM data for left and right
+ channel, interleaved */
+ int num_samples, /* number of samples per channel,
+ _not_ number of samples in
+ pcm[] */
+ unsigned char* mp3buf, /* pointer to encoded MP3 stream */
+ int mp3buf_size ); /* number of valid octets in this
+ stream */
/* as lame_encode_buffer, but for 'float's.
diff -ruN lame-3.92-old/libmp3lame/lame.c lame-3.92/libmp3lame/lame.c
--- lame-3.92-old/libmp3lame/lame.c Mon Apr 15 18:55:00 2002
+++ lame-3.92/libmp3lame/lame.c Thu Oct 31 16:42:12 2002
@@ -1805,6 +1805,36 @@
}
+int
+lame_encode_buffer_long_interleaved(lame_global_flags * gfp,
+ const long buffer[],
+ int nsamples,
+ unsigned char *mp3buf, int mp3buf_size)
+{
+ int ret, i;
+ sample_t *buffer_l;
+ sample_t *buffer_r;
+
+ buffer_l = calloc(sizeof(sample_t), nsamples);
+ buffer_r = calloc(sizeof(sample_t), nsamples);
+ if (buffer_l == NULL || buffer_r == NULL) {
+ if (buffer_l != NULL) free(buffer_l);
+ if (buffer_r != NULL) free(buffer_r);
+ return -2;
+ }
+ for (i = 0; i < nsamples; i++) {
+ buffer_l[i] = buffer[2 * i] * (1.0 / ( 1 << (8 * sizeof(long) - 16)));
+ buffer_r[i] = buffer[2 * i + 1] * (1.0 / ( 1 << (8 * sizeof(long) - 16)));
+ }
+ ret =
+ lame_encode_buffer_sample_t(gfp, buffer_l, buffer_r, nsamples, mp3buf,
+ mp3buf_size);
+ free(buffer_l);
+ free(buffer_r);
+ return ret;
+
+}
+
/*}}}*/
/* int lame_encode (lame_global_flags* gfp, short int
in_buffer[2][1152], char* mp3buf, int size ) *//*{{{
*/