History

library can now output 64 bit doubles

menno committed 23 years ago

Commit 2b65b581 parent a0ba9ba7 files · +67 −44Browse files

Unified · Split

7 files
  1. common/mp4v2/libmp4v2_cb.dsp +1 −1
  2. frontend/main.c +7 −6
  3. include/faad.h +11 −10
  4. libfaad/decoder.c +13 −8
  5. libfaad/decoder.h +13 −9
  6. libfaad/output.c +15 −1
  7. plugins/foo_mp4/foo_mp4.cpp +7 −9
common/mp4v2/libmp4v2_cb.dsp+1−1
@@ -42,7 +42,7 @@ RSC=rc.exe · 41 unmodified lines
4242 # PROP Target_Dir ""
4343 MTL=midl.exe
4444 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
45−# ADD CPP /nologo /MT /W3 /GX /O2 /I ".\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /c
45+# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /c
4646 # ADD BASE RSC /l 0x413 /d "NDEBUG"
4747 # ADD RSC /l 0x413 /d "NDEBUG"
4848 BSC32=bscmake.exe
frontend/main.c+7−6
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 ** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
19−** $Id: main.c,v 1.29 2003/03/05 14:24:50 menno Exp $
19+** $Id: main.c,v 1.30 2003/04/02 20:07:44 menno Exp $
2020 **/
2121
2222 #ifdef _WIN32
@@ -135,10 +135,11 @@ void usage(void) · 112 unmodified lines
135135 fprintf(stderr, " 2: 24 bit PCM data.\n");
136136 fprintf(stderr, " 3: 32 bit PCM data.\n");
137137 fprintf(stderr, " 4: 32 bit floating point data.\n");
138− fprintf(stderr, " 5: 16 bit PCM data (dithered).\n");
139− fprintf(stderr, " 6: 16 bit PCM data (dithered with LIGHT noise shaping).\n");
140− fprintf(stderr, " 7: 16 bit PCM data (dithered with MEDIUM noise shaping).\n");
141− fprintf(stderr, " 8: 16 bit PCM data (dithered with HEAVY noise shaping).\n");
138+ fprintf(stderr, " 5: 64 bit floating point data.\n");
139+ fprintf(stderr, " 6: 16 bit PCM data (dithered).\n");
140+ fprintf(stderr, " 7: 16 bit PCM data (dithered with LIGHT noise shaping).\n");
141+ fprintf(stderr, " 8: 16 bit PCM data (dithered with MEDIUM noise shaping).\n");
142+ fprintf(stderr, " 9: 16 bit PCM data (dithered with HEAVY noise shaping).\n");
142143 fprintf(stderr, " -s X Force the samplerate to X (for RAW files).\n");
143144 fprintf(stderr, " -l X Set object type. Supported object types:\n");
144145 fprintf(stderr, " 0: Main object type.\n");
@@ -583,7 +584,7 @@ int main(int argc, char *argv[]) · 438 unmodified lines
583584 outputFormat = FAAD_FMT_16BIT; /* just use default */
584585 } else {
585586 outputFormat = atoi(dr);
586− if ((outputFormat < 1) || (outputFormat > 8))
587+ if ((outputFormat < 1) || (outputFormat > 9))
587588 showHelp = 1;
588589 }
589590 }
include/faad.h+11−10
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 ** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
19−** $Id: faad.h,v 1.20 2003/03/05 14:24:52 menno Exp $
19+** $Id: faad.h,v 1.21 2003/04/02 20:07:45 menno Exp $
2020 **/
2121
2222 #ifndef __AACDEC_H__
@@ -55,15 +55,16 @@ extern "C" { · 32 unmodified lines
5555 #define ADTS 2
5656
5757 /* library output formats */
58−#define FAAD_FMT_16BIT 1
59−#define FAAD_FMT_24BIT 2
60−#define FAAD_FMT_32BIT 3
61−#define FAAD_FMT_FLOAT 4
62−#define FAAD_FMT_16BIT_DITHER 5
63−#define FAAD_FMT_16BIT_L_SHAPE 6
64−#define FAAD_FMT_16BIT_M_SHAPE 7
65−#define FAAD_FMT_16BIT_H_SHAPE 8
66−
58+#define FAAD_FMT_16BIT 1
59+#define FAAD_FMT_24BIT 2
60+#define FAAD_FMT_32BIT 3
61+#define FAAD_FMT_FLOAT 4
62+#define FAAD_FMT_DOUBLE 5
63+#define FAAD_FMT_16BIT_DITHER 6
64+#define FAAD_FMT_16BIT_L_SHAPE 7
65+#define FAAD_FMT_16BIT_M_SHAPE 8
66+#define FAAD_FMT_16BIT_H_SHAPE 9
67+
6768 /* Capabilities */
6869 #define LC_DEC_CAP (1<<0)
6970 #define MAIN_DEC_CAP (1<<1)
libfaad/decoder.c+13−8
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 ** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
19−** $Id: decoder.c,v 1.53 2003/03/05 14:24:53 menno Exp $
19+** $Id: decoder.c,v 1.54 2003/04/02 20:07:45 menno Exp $
2020 **/
2121
2222 #include "common.h"
@@ -225,8 +225,8 @@ int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer, · 202 unmodified lines
225225 return -1;
226226
227227 #ifndef FIXED_POINT
228− if (hDecoder->config.outputFormat >= 5)
229− Init_Dither(16, hDecoder->config.outputFormat - 5);
228+ if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
229+ Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
230230 #endif
231231
232232 return bits;
@@ -288,8 +288,8 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer, · 55 unmodified lines
288288 #endif
289289
290290 #ifndef FIXED_POINT
291− if (hDecoder->config.outputFormat >= 5)
292− Init_Dither(16, hDecoder->config.outputFormat - 5);
291+ if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
292+ Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
293293 #endif
294294
295295 return 0;
@@ -314,8 +314,8 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 18 unmodified lines
314314 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
315315
316316 #ifndef FIXED_POINT
317− if (hDecoder->config.outputFormat >= 5)
318− Init_Dither(16, hDecoder->config.outputFormat - 5);
317+ if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
318+ Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
319319 #endif
320320
321321 return 0;
@@ -481,7 +481,12 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 159 unmodified lines
481481 }
482482
483483 if (hDecoder->sample_buffer == NULL)
484− hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(real_t));
484+ {
485+ if (hDecoder->config.outputFormat == FAAD_FMT_DOUBLE)
486+ hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(double));
487+ else
488+ hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(real_t));
489+ }
485490
486491 sample_buffer = hDecoder->sample_buffer;
487492
libfaad/decoder.h+13−9
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 ** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
19−** $Id: decoder.h,v 1.21 2003/03/05 14:24:55 menno Exp $
19+** $Id: decoder.h,v 1.22 2003/04/02 20:07:46 menno Exp $
2020 **/
2121
2222 #ifndef __DECODER_H__
@@ -45,14 +45,18 @@ extern "C" { · 22 unmodified lines
4545 #include "ic_predict.h"
4646
4747
48−#define FAAD_FMT_16BIT 1
49−#define FAAD_FMT_24BIT 2
50−#define FAAD_FMT_32BIT 3
51−#define FAAD_FMT_FLOAT 4
52−#define FAAD_FMT_16BIT_DITHER 5
53−#define FAAD_FMT_16BIT_L_SHAPE 6
54−#define FAAD_FMT_16BIT_M_SHAPE 7
55−#define FAAD_FMT_16BIT_H_SHAPE 8
48+/* library output formats */
49+#define FAAD_FMT_16BIT 1
50+#define FAAD_FMT_24BIT 2
51+#define FAAD_FMT_32BIT 3
52+#define FAAD_FMT_FLOAT 4
53+#define FAAD_FMT_DOUBLE 5
54+#define FAAD_FMT_16BIT_DITHER 6
55+#define FAAD_FMT_16BIT_L_SHAPE 7
56+#define FAAD_FMT_16BIT_M_SHAPE 8
57+#define FAAD_FMT_16BIT_H_SHAPE 9
58+
59+#define FAAD_FMT_DITHER_LOWEST FAAD_FMT_16BIT_DITHER
5660
5761 #define LC_DEC_CAP (1<<0)
5862 #define MAIN_DEC_CAP (1<<1)
libfaad/output.c+15−1
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 ** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
19−** $Id: output.c,v 1.14 2002/11/28 18:48:30 menno Exp $
19+** $Id: output.c,v 1.15 2003/04/02 20:07:46 menno Exp $
2020 **/
2121
2222 #include "common.h"
@@ -53,6 +53,7 @@ void* output_to_PCM(real_t **input, void *sample_buffer, uint8_t channels, · 30 unmodified lines
5353 int16_t *short_sample_buffer = (int16_t*)sample_buffer;
5454 int32_t *int_sample_buffer = (int32_t*)sample_buffer;
5555 float32_t *float_sample_buffer = (float32_t*)sample_buffer;
56+ double *double_sample_buffer = (double*)sample_buffer;
5657
5758 /* Copy output to a standard PCM buffer */
5859 switch (format)
@@ -147,6 +148,19 @@ void* output_to_PCM(real_t **input, void *sample_buffer, uint8_t channels, · 88 unmodified lines
147148 }
148149 }
149150 break;
151+ case FAAD_FMT_DOUBLE:
152+ for (ch = 0; ch < channels; ch++)
153+ {
154+ for(i = 0; i < frame_len; i++)
155+ {
156+ if (input[ch][i] > (1<<15)-1)
157+ input[ch][i] = (1<<15)-1;
158+ else if (input[ch][i] < -(1<<15))
159+ input[ch][i] = -(1<<15);
160+ double_sample_buffer[(i*channels)+ch] = (double)input[ch][i]*FLOAT_SCALE;
161+ }
162+ }
163+ break;
150164 }
151165
152166 return sample_buffer;
plugins/foo_mp4/foo_mp4.cpp+7−9
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 ** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
19−** $Id: foo_mp4.cpp,v 1.14 2003/02/09 20:42:50 menno Exp $
19+** $Id: foo_mp4.cpp,v 1.15 2003/04/02 20:07:46 menno Exp $
2020 **/
2121
2222 #include <mp4.h>
@@ -38,6 +38,7 @@ public: · 15 unmodified lines
3838 unsigned __int8 *buffer;
3939 unsigned __int32 buffer_size;
4040 unsigned __int8 channels;
41+ unsigned __int32 samplerate;
4142 faacDecConfigurationPtr config;
4243
4344 m_reader = r;
@@ -46,7 +47,7 @@ public: · 2 unmodified lines
4647 if (!hDecoder) return 0;
4748
4849 config = faacDecGetCurrentConfiguration(hDecoder);
49− config->outputFormat = FAAD_FMT_FLOAT;
50+ config->outputFormat = FAAD_FMT_DOUBLE;
5051 faacDecSetConfiguration(hDecoder, config);
5152
5253 hFile = MP4ReadCb(0, open_cb, close_cb, read_cb, write_cb,
@@ -62,7 +63,7 @@ public: · 9 unmodified lines
6263 if (!buffer) return 0;
6364
6465 int rc = faacDecInit2(hDecoder, (unsigned char*)buffer, buffer_size,
65− (unsigned long*)&m_samplerate, (unsigned char*)&channels);
66+ (unsigned long*)&samplerate, (unsigned char*)&channels);
6667 if (buffer) free(buffer);
6768 if (rc < 0) return 0;
6869
@@ -78,7 +79,7 @@ public: · 9 unmodified lines
7879 (double)(__int64)MP4GetTrackIntegerProperty(hFile,
7980 track, "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.avgBitrate")) + 0.5);
8081 info->info_set_int("channels", (__int64)channels);
81− info->info_set_int("samplerate", (__int64)m_samplerate);
82+ info->info_set_int("samplerate", (__int64)samplerate);
8283
8384 ReadMP4Tag(info);
8485
@@ -127,10 +128,10 @@ public: · 42 unmodified lines
127128 if (frameInfo.error || (sampleId > numSamples))
128129 return 0;
129130
130− chunk->data = (float*)sample_buffer;
131+ chunk->data = (audio_sample*)sample_buffer;
131132 chunk->samples = frameInfo.samples/frameInfo.channels;
132133 chunk->nch = frameInfo.channels;
133− chunk->srate = m_samplerate;
134+ chunk->srate = frameInfo.samplerate;
134135
135136 return 1;
136137 }
@@ -147,7 +148,6 @@ public: · 10 unmodified lines
147148 if (track < 1) return 0;
148149
149150 MP4TagDelete(hFile, track);
150−// MP4TagCreate(hFile, track);
151151
152152 /* replay gain writing */
153153 const char *p = NULL;
@@ -204,8 +204,6 @@ private: · 50 unmodified lines
204204 MP4SampleId sampleId, numSamples;
205205 MP4TrackId track;
206206
207− unsigned __int32 m_samplerate;
208−
209207 faacDecHandle hDecoder;
210208
211209 int ReadMP4Tag(file_info *info)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t