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
42# PROP Target_Dir ""42# PROP Target_Dir ""
43MTL=midl.exe43MTL=midl.exe
44# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c44# 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 /c45# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /c
46# ADD BASE RSC /l 0x413 /d "NDEBUG"46# ADD BASE RSC /l 0x413 /d "NDEBUG"
47# ADD RSC /l 0x413 /d "NDEBUG"47# ADD RSC /l 0x413 /d "NDEBUG"
48BSC32=bscmake.exe48BSC32=bscmake.exe
frontend/main.c+7−6
@@ -16,7 +16,7 @@ · 15 unmodified lines
16** along with this program; if not, write to the Free Software16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**18**
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 $
20**/20**/
21 21
22#ifdef _WIN3222#ifdef _WIN32
@@ -135,10 +135,11 @@ void usage(void) · 112 unmodified lines
135 fprintf(stderr, " 2: 24 bit PCM data.\n");135 fprintf(stderr, " 2: 24 bit PCM data.\n");
136 fprintf(stderr, " 3: 32 bit PCM data.\n");136 fprintf(stderr, " 3: 32 bit PCM data.\n");
137 fprintf(stderr, " 4: 32 bit floating point data.\n");137 fprintf(stderr, " 4: 32 bit floating point data.\n");
138 fprintf(stderr, " 5: 16 bit PCM data (dithered).\n");138 fprintf(stderr, " 5: 64 bit floating point data.\n");
139 fprintf(stderr, " 6: 16 bit PCM data (dithered with LIGHT noise shaping).\n");139 fprintf(stderr, " 6: 16 bit PCM data (dithered).\n");
140 fprintf(stderr, " 7: 16 bit PCM data (dithered with MEDIUM noise shaping).\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 HEAVY 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");
142 fprintf(stderr, " -s X Force the samplerate to X (for RAW files).\n");143 fprintf(stderr, " -s X Force the samplerate to X (for RAW files).\n");
143 fprintf(stderr, " -l X Set object type. Supported object types:\n");144 fprintf(stderr, " -l X Set object type. Supported object types:\n");
144 fprintf(stderr, " 0: Main object type.\n");145 fprintf(stderr, " 0: Main object type.\n");
@@ -583,7 +584,7 @@ int main(int argc, char *argv[]) · 438 unmodified lines
583 outputFormat = FAAD_FMT_16BIT; /* just use default */584 outputFormat = FAAD_FMT_16BIT; /* just use default */
584 } else {585 } else {
585 outputFormat = atoi(dr);586 outputFormat = atoi(dr);
586 if ((outputFormat < 1) || (outputFormat > 8))587 if ((outputFormat < 1) || (outputFormat > 9))
587 showHelp = 1;588 showHelp = 1;
588 }589 }
589 }590 }
include/faad.h+11−10
@@ -16,7 +16,7 @@ · 15 unmodified lines
16** along with this program; if not, write to the Free Software16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**18**
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 $
20**/20**/
21 21
22#ifndef __AACDEC_H__22#ifndef __AACDEC_H__
@@ -55,15 +55,16 @@ extern "C" { · 32 unmodified lines
55#define ADTS 255#define ADTS 2
56 56
57/* library output formats */57/* library output formats */
58#define FAAD_FMT_16BIT 158#define FAAD_FMT_16BIT 1
59#define FAAD_FMT_24BIT 259#define FAAD_FMT_24BIT 2
60#define FAAD_FMT_32BIT 360#define FAAD_FMT_32BIT 3
61#define FAAD_FMT_FLOAT 461#define FAAD_FMT_FLOAT 4
62#define FAAD_FMT_16BIT_DITHER 562#define FAAD_FMT_DOUBLE 5
63#define FAAD_FMT_16BIT_L_SHAPE 663#define FAAD_FMT_16BIT_DITHER 6
64#define FAAD_FMT_16BIT_M_SHAPE 764#define FAAD_FMT_16BIT_L_SHAPE 7
65#define FAAD_FMT_16BIT_H_SHAPE 865#define FAAD_FMT_16BIT_M_SHAPE 8
66 66#define FAAD_FMT_16BIT_H_SHAPE 9
67
67/* Capabilities */68/* Capabilities */
68#define LC_DEC_CAP (1<<0)69#define LC_DEC_CAP (1<<0)
69#define MAIN_DEC_CAP (1<<1)70#define MAIN_DEC_CAP (1<<1)
libfaad/decoder.c+13−8
@@ -16,7 +16,7 @@ · 15 unmodified lines
16** along with this program; if not, write to the Free Software 16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**18**
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 $
20**/20**/
21 21
22#include "common.h"22#include "common.h"
@@ -225,8 +225,8 @@ int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer, · 202 unmodified lines
225 return -1;225 return -1;
226 226
227#ifndef FIXED_POINT227#ifndef FIXED_POINT
228 if (hDecoder->config.outputFormat >= 5)228 if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
229 Init_Dither(16, hDecoder->config.outputFormat - 5);229 Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
230#endif230#endif
231 231
232 return bits;232 return bits;
@@ -288,8 +288,8 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer, · 55 unmodified lines
288#endif288#endif
289 289
290#ifndef FIXED_POINT290#ifndef FIXED_POINT
291 if (hDecoder->config.outputFormat >= 5)291 if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
292 Init_Dither(16, hDecoder->config.outputFormat - 5);292 Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
293#endif293#endif
294 294
295 return 0;295 return 0;
@@ -314,8 +314,8 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 18 unmodified lines
314 hDecoder->fb = filter_bank_init(hDecoder->frameLength);314 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
315 315
316#ifndef FIXED_POINT316#ifndef FIXED_POINT
317 if (hDecoder->config.outputFormat >= 5)317 if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
318 Init_Dither(16, hDecoder->config.outputFormat - 5);318 Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
319#endif319#endif
320 320
321 return 0;321 return 0;
@@ -481,7 +481,12 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 159 unmodified lines
481 }481 }
482 482
483 if (hDecoder->sample_buffer == NULL)483 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 }
485 490
486 sample_buffer = hDecoder->sample_buffer;491 sample_buffer = hDecoder->sample_buffer;
487 492
libfaad/decoder.h+13−9
@@ -16,7 +16,7 @@ · 15 unmodified lines
16** along with this program; if not, write to the Free Software 16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**18**
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 $
20**/20**/
21 21
22#ifndef __DECODER_H__22#ifndef __DECODER_H__
@@ -45,14 +45,18 @@ extern "C" { · 22 unmodified lines
45#include "ic_predict.h"45#include "ic_predict.h"
46 46
47 47
48#define FAAD_FMT_16BIT 148/* library output formats */
49#define FAAD_FMT_24BIT 249#define FAAD_FMT_16BIT 1
50#define FAAD_FMT_32BIT 350#define FAAD_FMT_24BIT 2
51#define FAAD_FMT_FLOAT 451#define FAAD_FMT_32BIT 3
52#define FAAD_FMT_16BIT_DITHER 552#define FAAD_FMT_FLOAT 4
53#define FAAD_FMT_16BIT_L_SHAPE 653#define FAAD_FMT_DOUBLE 5
54#define FAAD_FMT_16BIT_M_SHAPE 754#define FAAD_FMT_16BIT_DITHER 6
55#define FAAD_FMT_16BIT_H_SHAPE 855#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
56 60
57#define LC_DEC_CAP (1<<0)61#define LC_DEC_CAP (1<<0)
58#define MAIN_DEC_CAP (1<<1)62#define MAIN_DEC_CAP (1<<1)
libfaad/output.c+15−1
@@ -16,7 +16,7 @@ · 15 unmodified lines
16** along with this program; if not, write to the Free Software 16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**18**
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 $
20**/20**/
21 21
22#include "common.h"22#include "common.h"
@@ -53,6 +53,7 @@ void* output_to_PCM(real_t **input, void *sample_buffer, uint8_t channels, · 30 unmodified lines
53 int16_t *short_sample_buffer = (int16_t*)sample_buffer;53 int16_t *short_sample_buffer = (int16_t*)sample_buffer;
54 int32_t *int_sample_buffer = (int32_t*)sample_buffer;54 int32_t *int_sample_buffer = (int32_t*)sample_buffer;
55 float32_t *float_sample_buffer = (float32_t*)sample_buffer;55 float32_t *float_sample_buffer = (float32_t*)sample_buffer;
56 double *double_sample_buffer = (double*)sample_buffer;
56 57
57 /* Copy output to a standard PCM buffer */58 /* Copy output to a standard PCM buffer */
58 switch (format)59 switch (format)
@@ -147,6 +148,19 @@ void* output_to_PCM(real_t **input, void *sample_buffer, uint8_t channels, · 88 unmodified lines
147 }148 }
148 }149 }
149 break;150 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;
150 }164 }
151 165
152 return sample_buffer;166 return sample_buffer;
plugins/foo_mp4/foo_mp4.cpp+7−9
@@ -16,7 +16,7 @@ · 15 unmodified lines
16** along with this program; if not, write to the Free Software16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.17** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18**18**
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 $
20**/20**/
21 21
22#include <mp4.h>22#include <mp4.h>
@@ -38,6 +38,7 @@ public: · 15 unmodified lines
38 unsigned __int8 *buffer;38 unsigned __int8 *buffer;
39 unsigned __int32 buffer_size;39 unsigned __int32 buffer_size;
40 unsigned __int8 channels;40 unsigned __int8 channels;
41 unsigned __int32 samplerate;
41 faacDecConfigurationPtr config;42 faacDecConfigurationPtr config;
42 43
43 m_reader = r;44 m_reader = r;
@@ -46,7 +47,7 @@ public: · 2 unmodified lines
46 if (!hDecoder) return 0;47 if (!hDecoder) return 0;
47 48
48 config = faacDecGetCurrentConfiguration(hDecoder);49 config = faacDecGetCurrentConfiguration(hDecoder);
49 config->outputFormat = FAAD_FMT_FLOAT;50 config->outputFormat = FAAD_FMT_DOUBLE;
50 faacDecSetConfiguration(hDecoder, config);51 faacDecSetConfiguration(hDecoder, config);
51 52
52 hFile = MP4ReadCb(0, open_cb, close_cb, read_cb, write_cb,53 hFile = MP4ReadCb(0, open_cb, close_cb, read_cb, write_cb,
@@ -62,7 +63,7 @@ public: · 9 unmodified lines
62 if (!buffer) return 0;63 if (!buffer) return 0;
63 64
64 int rc = faacDecInit2(hDecoder, (unsigned char*)buffer, buffer_size,65 int rc = faacDecInit2(hDecoder, (unsigned char*)buffer, buffer_size,
65 (unsigned long*)&m_samplerate, (unsigned char*)&channels);66 (unsigned long*)&samplerate, (unsigned char*)&channels);
66 if (buffer) free(buffer);67 if (buffer) free(buffer);
67 if (rc < 0) return 0;68 if (rc < 0) return 0;
68 69
@@ -78,7 +79,7 @@ public: · 9 unmodified lines
78 (double)(__int64)MP4GetTrackIntegerProperty(hFile,79 (double)(__int64)MP4GetTrackIntegerProperty(hFile,
79 track, "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.avgBitrate")) + 0.5);80 track, "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.avgBitrate")) + 0.5);
80 info->info_set_int("channels", (__int64)channels);81 info->info_set_int("channels", (__int64)channels);
81 info->info_set_int("samplerate", (__int64)m_samplerate);82 info->info_set_int("samplerate", (__int64)samplerate);
82 83
83 ReadMP4Tag(info);84 ReadMP4Tag(info);
84 85
@@ -127,10 +128,10 @@ public: · 42 unmodified lines
127 if (frameInfo.error || (sampleId > numSamples))128 if (frameInfo.error || (sampleId > numSamples))
128 return 0;129 return 0;
129 130
130 chunk->data = (float*)sample_buffer;131 chunk->data = (audio_sample*)sample_buffer;
131 chunk->samples = frameInfo.samples/frameInfo.channels;132 chunk->samples = frameInfo.samples/frameInfo.channels;
132 chunk->nch = frameInfo.channels;133 chunk->nch = frameInfo.channels;
133 chunk->srate = m_samplerate;134 chunk->srate = frameInfo.samplerate;
134 135
135 return 1;136 return 1;
136 }137 }
@@ -147,7 +148,6 @@ public: · 10 unmodified lines
147 if (track < 1) return 0;148 if (track < 1) return 0;
148 149
149 MP4TagDelete(hFile, track);150 MP4TagDelete(hFile, track);
150// MP4TagCreate(hFile, track);
151 151
152 /* replay gain writing */152 /* replay gain writing */
153 const char *p = NULL;153 const char *p = NULL;
@@ -204,8 +204,6 @@ private: · 50 unmodified lines
204 MP4SampleId sampleId, numSamples;204 MP4SampleId sampleId, numSamples;
205 MP4TrackId track;205 MP4TrackId track;
206 206
207 unsigned __int32 m_samplerate;
208
209 faacDecHandle hDecoder;207 faacDecHandle hDecoder;
210 208
211 int ReadMP4Tag(file_info *info)209 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