diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-03-25 01:08:13 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-03-25 01:08:13 +0000 |
commit | 1de1bfe314bb8c48b3e508f5001927988588fcf6 (patch) | |
tree | e6ce56cbabdcd4420b16c4dd9e9707205c5619f1 /src | |
parent | 63a62a45142380d67db3d2d5cb57891b2c9371e7 (diff) | |
download | mpd-1de1bfe314bb8c48b3e508f5001927988588fcf6.tar.gz mpd-1de1bfe314bb8c48b3e508f5001927988588fcf6.tar.xz mpd-1de1bfe314bb8c48b3e508f5001927988588fcf6.zip |
fix and detect differences between faad2 1.1 and 2.0
git-svn-id: https://svn.musicpd.org/mpd/trunk@459 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/aac_decode.c | 39 | ||||
-rw-r--r-- | src/mp4_decode.c | 20 | ||||
-rw-r--r-- | src/mp4ff/mp4ff_int_types.h | 9 |
3 files changed, 54 insertions, 14 deletions
diff --git a/src/aac_decode.c b/src/aac_decode.c index c4d8dcf4d..03f291fcc 100644 --- a/src/aac_decode.c +++ b/src/aac_decode.c @@ -210,6 +210,7 @@ float getAacFloatTotalTime(char * file) { unsigned long sampleRate; unsigned char channels; FILE * fp = fopen(file,"r"); + size_t bread; if(fp==NULL) return -1; @@ -223,12 +224,13 @@ float getAacFloatTotalTime(char * file) { faacDecSetConfiguration(decoder,config); fillAacBuffer(&b); - if(faacDecInit(decoder,b.buffer,b.bytesIntoBuffer, - &sampleRate,&channels) >= 0 && - sampleRate > 0 && channels > 0) - { - length = 0; - } +#ifdef HAVE_FAAD_BUFLEN_FUNCS + bread = faacDecInit(decoder,b.buffer,b.bytesIntoBuffer, + &sampleRate,&channels); +#else + bread = faacDecInit(decoder,b.buffer,&sampleRate,&channels); +#endif + if(bread >= 0 && sampleRate > 0 && channels > 0) length = 0; faacDecClose(decoder); } @@ -291,9 +293,14 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { faacDecSetConfiguration(decoder,config); fillAacBuffer(&b); - if((bread = faacDecInit(decoder,b.buffer,b.bytesIntoBuffer, - &sampleRate,&channels)) < 0) - { + +#ifdef HAVE_FAAD_BUFLEN_FUNCS + bread = faacDecInit(decoder,b.buffer,b.bytesIntoBuffer, + &sampleRate,&channels); +#else + bread = faacDecInit(decoder,b.buffer,&sampleRate,&channels); +#endif + if(bread < 0) { ERROR("Error not a AAC stream.\n"); faacDecClose(decoder); fclose(b.infile); @@ -317,8 +324,12 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { break; } +#ifdef HAVE_FAAD_BUFLEN_FUNCS sampleBuffer = faacDecDecode(decoder,&frameInfo,b.buffer, b.bytesIntoBuffer); +#else + sampleBuffer = faacDecDecode(decoder,&frameInfo,b.buffer); +#endif if(frameInfo.error > 0) { ERROR("error decoding AAC file: %s\n",dc->file); @@ -328,9 +339,13 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { break; } +#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE + sampleRate = frameInfo.samplerate; +#endif + if(dc->start) { af->channels = frameInfo.channels; - af->sampleRate = frameInfo.samplerate; + af->sampleRate = sampleRate; dc->state = DECODE_STATE_DECODE; dc->start = 0; } @@ -341,10 +356,10 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { if(sampleCount>0) { bitRate = frameInfo.bytesconsumed*8.0* - frameInfo.channels*frameInfo.samplerate/ + frameInfo.channels*sampleRate/ frameInfo.samples/1024+0.5; time+= (float)(frameInfo.samples)/frameInfo.channels/ - frameInfo.samplerate; + sampleRate; } sampleBufferLen = sampleCount*2; diff --git a/src/mp4_decode.c b/src/mp4_decode.c index 6ecce1853..a697a8b3d 100644 --- a/src/mp4_decode.c +++ b/src/mp4_decode.c @@ -44,12 +44,24 @@ int mp4_getAACTrack(mp4ff_t *infile) { for (i = 0; i < numTracks; i++) { unsigned char *buff = NULL; int buff_size = 0; +#ifdef HAVE_MP4AUDIOSPECIFICCONFIG mp4AudioSpecificConfig mp4ASC; +#else + unsigned long dummy1_32; + unsigned char dummy2_8, dummy3_8, dummy4_8, dummy5_8, dummy6_8, + dummy7_8, dummy8_8; +#endif mp4ff_get_decoder_config(infile, i, &buff, &buff_size); if (buff) { +#ifdef HAVE_MP4AUDIOSPECIFICCONFIG rc = AudioSpecificConfig(buff, buff_size, &mp4ASC); +#else + rc = AudioSpecificConfig(buff, &dummy1_32, &dummy2_8, + &dummy3_8, &dummy4_8, &dummy5_8, + &dummy6_8, &dummy7_8, &dummy8_8); +#endif free(buff); if (rc < 0) continue; return i; @@ -220,8 +232,12 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { continue; } +#ifdef HAVE_FAAD_BUFLEN_FUNCS sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer, mp4BufferSize); +#else + sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer); +#endif if(mp4Buffer) free(mp4Buffer); if(frameInfo.error > 0) { @@ -234,9 +250,11 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { if(dc->start) { channels = frameInfo.channels; +#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE scale = frameInfo.samplerate; +#endif + af->sampleRate = scale; af->channels = frameInfo.channels; - af->sampleRate = frameInfo.samplerate; dc->state = DECODE_STATE_DECODE; dc->start = 0; } diff --git a/src/mp4ff/mp4ff_int_types.h b/src/mp4ff/mp4ff_int_types.h index 8dbf7bc2e..88651a81c 100644 --- a/src/mp4ff/mp4ff_int_types.h +++ b/src/mp4ff/mp4ff_int_types.h @@ -15,9 +15,16 @@ typedef unsigned __int64 uint64_t; #else -#include <stdint.h> +#include "../../config.h" +#ifdef HAVE_STDINT_H +#include <stdint.h> +#else +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif #endif +#endif #endif |