summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/libaudiofile/Makefile4
-rw-r--r--package/libaudiofile/patches/patch-Makefile_in4
-rw-r--r--package/libaudiofile/patches/patch-Makefile_in.orig11
-rw-r--r--package/libaudiofile/patches/patch-audiofile_pc_in9
-rw-r--r--package/libaudiofile/patches/patch-libaudiofile_WAVE_cpp31
-rw-r--r--package/libaudiofile/patches/patch-libaudiofile_modules_BlockCodec_cpp14
-rw-r--r--package/libaudiofile/patches/patch-libaudiofile_modules_IMA_cpp20
-rw-r--r--package/libaudiofile/patches/patch-libaudiofile_modules_MSADPCM_cpp84
-rw-r--r--package/libaudiofile/patches/patch-sfcommands_sfconvert_c50
9 files changed, 224 insertions, 3 deletions
diff --git a/package/libaudiofile/Makefile b/package/libaudiofile/Makefile
index 9b3dfd639..d4eb742f2 100644
--- a/package/libaudiofile/Makefile
+++ b/package/libaudiofile/Makefile
@@ -22,9 +22,11 @@ include ${ADK_TOPDIR}/mk/package.mk
$(eval $(call PKG_template,LIBAUDIOFILE,libaudiofile,${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
-CONFIGURE_ENV+= ac_cv_linux_vers=2
TARGET_CPPFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE
+CONFIGURE_ENV+= ac_cv_linux_vers=2
+CONFIGURE_ARGS+= --disable-examples
+
libaudiofile-install:
${INSTALL_DIR} ${IDIR_LIBAUDIOFILE}/usr/lib
${CP} ${WRKINST}/usr/lib/libaudiofile.so* ${IDIR_LIBAUDIOFILE}/usr/lib/
diff --git a/package/libaudiofile/patches/patch-Makefile_in b/package/libaudiofile/patches/patch-Makefile_in
index 6753979af..85f3a34b4 100644
--- a/package/libaudiofile/patches/patch-Makefile_in
+++ b/package/libaudiofile/patches/patch-Makefile_in
@@ -1,11 +1,11 @@
--- audiofile-0.3.6.orig/Makefile.in 2013-03-07 08:27:14.000000000 +0100
-+++ audiofile-0.3.6/Makefile.in 2013-12-23 15:53:28.000000000 +0100
++++ audiofile-0.3.6/Makefile.in 2017-04-26 02:24:43.284904375 +0200
@@ -294,7 +294,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = gtest libaudiofile sfcommands test examples docs
-+SUBDIRS = gtest libaudiofile sfcommands
++SUBDIRS = gtest libaudiofile
EXTRA_DIST = \
ACKNOWLEDGEMENTS \
NOTES \
diff --git a/package/libaudiofile/patches/patch-Makefile_in.orig b/package/libaudiofile/patches/patch-Makefile_in.orig
new file mode 100644
index 000000000..6753979af
--- /dev/null
+++ b/package/libaudiofile/patches/patch-Makefile_in.orig
@@ -0,0 +1,11 @@
+--- audiofile-0.3.6.orig/Makefile.in 2013-03-07 08:27:14.000000000 +0100
++++ audiofile-0.3.6/Makefile.in 2013-12-23 15:53:28.000000000 +0100
+@@ -294,7 +294,7 @@ target_alias = @target_alias@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-SUBDIRS = gtest libaudiofile sfcommands test examples docs
++SUBDIRS = gtest libaudiofile sfcommands
+ EXTRA_DIST = \
+ ACKNOWLEDGEMENTS \
+ NOTES \
diff --git a/package/libaudiofile/patches/patch-audiofile_pc_in b/package/libaudiofile/patches/patch-audiofile_pc_in
new file mode 100644
index 000000000..703abb21b
--- /dev/null
+++ b/package/libaudiofile/patches/patch-audiofile_pc_in
@@ -0,0 +1,9 @@
+--- audiofile-0.3.6.orig/audiofile.pc.in 2013-02-11 18:23:26.000000000 +0100
++++ audiofile-0.3.6/audiofile.pc.in 2017-04-26 02:14:32.397720674 +0200
+@@ -8,5 +8,5 @@ Description: audiofile
+ Requires:
+ Version: @VERSION@
+ Libs: -L${libdir} -laudiofile
+-Libs.private: -lm
++Libs.private: @FLAC_LIBS@ @COVERAGE_LIBS@ -lm
+ Cflags: -I${includedir}
diff --git a/package/libaudiofile/patches/patch-libaudiofile_WAVE_cpp b/package/libaudiofile/patches/patch-libaudiofile_WAVE_cpp
new file mode 100644
index 000000000..863086d8b
--- /dev/null
+++ b/package/libaudiofile/patches/patch-libaudiofile_WAVE_cpp
@@ -0,0 +1,31 @@
+--- audiofile-0.3.6.orig/libaudiofile/WAVE.cpp 2013-03-06 06:30:03.000000000 +0100
++++ audiofile-0.3.6/libaudiofile/WAVE.cpp 2017-04-26 02:15:19.828763007 +0200
+@@ -281,6 +281,12 @@ status WAVEFile::parseFormat(const Tag &
+
+ /* numCoefficients should be at least 7. */
+ assert(numCoefficients >= 7 && numCoefficients <= 255);
++ if (numCoefficients < 7 || numCoefficients > 255)
++ {
++ _af_error(AF_BAD_HEADER,
++ "Bad number of coefficients");
++ return AF_FAIL;
++ }
+
+ m_msadpcmNumCoefficients = numCoefficients;
+
+@@ -326,6 +332,7 @@ status WAVEFile::parseFormat(const Tag &
+ {
+ _af_error(AF_BAD_NOT_IMPLEMENTED,
+ "IMA ADPCM compression supports only 4 bits per sample");
++ return AF_FAIL;
+ }
+
+ int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
+@@ -333,6 +340,7 @@ status WAVEFile::parseFormat(const Tag &
+ {
+ _af_error(AF_BAD_CODEC_CONFIG,
+ "Invalid samples per block for IMA ADPCM compression");
++ return AF_FAIL;
+ }
+
+ track->f.sampleWidth = 16;
diff --git a/package/libaudiofile/patches/patch-libaudiofile_modules_BlockCodec_cpp b/package/libaudiofile/patches/patch-libaudiofile_modules_BlockCodec_cpp
new file mode 100644
index 000000000..0e7188da5
--- /dev/null
+++ b/package/libaudiofile/patches/patch-libaudiofile_modules_BlockCodec_cpp
@@ -0,0 +1,14 @@
+--- audiofile-0.3.6.orig/libaudiofile/modules/BlockCodec.cpp 2013-03-06 06:30:03.000000000 +0100
++++ audiofile-0.3.6/libaudiofile/modules/BlockCodec.cpp 2017-04-26 02:15:29.573388050 +0200
+@@ -52,8 +52,9 @@ void BlockCodec::runPull()
+ // Decompress into m_outChunk.
+ for (int i=0; i<blocksRead; i++)
+ {
+- decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
+- static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount);
++ if (decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
++ static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount)==0)
++ break;
+
+ framesRead += m_framesPerPacket;
+ }
diff --git a/package/libaudiofile/patches/patch-libaudiofile_modules_IMA_cpp b/package/libaudiofile/patches/patch-libaudiofile_modules_IMA_cpp
new file mode 100644
index 000000000..97936327e
--- /dev/null
+++ b/package/libaudiofile/patches/patch-libaudiofile_modules_IMA_cpp
@@ -0,0 +1,20 @@
+--- audiofile-0.3.6.orig/libaudiofile/modules/IMA.cpp 2013-03-06 06:30:03.000000000 +0100
++++ audiofile-0.3.6/libaudiofile/modules/IMA.cpp 2017-04-26 02:15:03.959745133 +0200
+@@ -169,7 +169,7 @@ int IMA::decodeBlockWAVE(const uint8_t *
+ if (encoded[1] & 0x80)
+ m_adpcmState[c].previousValue -= 0x10000;
+
+- m_adpcmState[c].index = encoded[2];
++ m_adpcmState[c].index = clamp(encoded[2], 0, 88);
+
+ *decoded++ = m_adpcmState[c].previousValue;
+
+@@ -210,7 +210,7 @@ int IMA::decodeBlockQT(const uint8_t *en
+ predictor -= 0x10000;
+
+ state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16);
+- state.index = encoded[1] & 0x7f;
++ state.index = clamp(encoded[1] & 0x7f, 0, 88);
+ encoded += 2;
+
+ for (int n=0; n<m_framesPerPacket; n+=2)
diff --git a/package/libaudiofile/patches/patch-libaudiofile_modules_MSADPCM_cpp b/package/libaudiofile/patches/patch-libaudiofile_modules_MSADPCM_cpp
new file mode 100644
index 000000000..baea099e8
--- /dev/null
+++ b/package/libaudiofile/patches/patch-libaudiofile_modules_MSADPCM_cpp
@@ -0,0 +1,84 @@
+--- audiofile-0.3.6.orig/libaudiofile/modules/MSADPCM.cpp 2013-03-06 06:30:03.000000000 +0100
++++ audiofile-0.3.6/libaudiofile/modules/MSADPCM.cpp 2017-04-26 02:15:29.573388050 +0200
+@@ -101,24 +101,60 @@ static const int16_t adaptationTable[] =
+ 768, 614, 512, 409, 307, 230, 230, 230
+ };
+
++int firstBitSet(int x)
++{
++ int position=0;
++ while (x!=0)
++ {
++ x>>=1;
++ ++position;
++ }
++ return position;
++}
++
++#ifndef __has_builtin
++#define __has_builtin(x) 0
++#endif
++
++int multiplyCheckOverflow(int a, int b, int *result)
++{
++#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
++ return __builtin_mul_overflow(a, b, result);
++#else
++ if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
++ return true;
++ *result = a * b;
++ return false;
++#endif
++}
++
++
+ // Compute a linear PCM value from the given differential coded value.
+ static int16_t decodeSample(ms_adpcm_state &state,
+- uint8_t code, const int16_t *coefficient)
++ uint8_t code, const int16_t *coefficient, bool *ok=NULL)
+ {
+ int linearSample = (state.sample1 * coefficient[0] +
+ state.sample2 * coefficient[1]) >> 8;
++ int delta;
+
+ linearSample += ((code & 0x08) ? (code - 0x10) : code) * state.delta;
+
+ linearSample = clamp(linearSample, MIN_INT16, MAX_INT16);
+
+- int delta = (state.delta * adaptationTable[code]) >> 8;
++ if (multiplyCheckOverflow(state.delta, adaptationTable[code], &delta))
++ {
++ if (ok) *ok=false;
++ _af_error(AF_BAD_COMPRESSION, "Error decoding sample");
++ return 0;
++ }
++ delta >>= 8;
+ if (delta < 16)
+ delta = 16;
+
+ state.delta = delta;
+ state.sample2 = state.sample1;
+ state.sample1 = linearSample;
++ if (ok) *ok=true;
+
+ return static_cast<int16_t>(linearSample);
+ }
+@@ -212,13 +248,16 @@ int MSADPCM::decodeBlock(const uint8_t *
+ {
+ uint8_t code;
+ int16_t newSample;
++ bool ok;
+
+ code = *encoded >> 4;
+- newSample = decodeSample(*state[0], code, coefficient[0]);
++ newSample = decodeSample(*state[0], code, coefficient[0], &ok);
++ if (!ok) return 0;
+ *decoded++ = newSample;
+
+ code = *encoded & 0x0f;
+- newSample = decodeSample(*state[1], code, coefficient[1]);
++ newSample = decodeSample(*state[1], code, coefficient[1], &ok);
++ if (!ok) return 0;
+ *decoded++ = newSample;
+
+ encoded++;
diff --git a/package/libaudiofile/patches/patch-sfcommands_sfconvert_c b/package/libaudiofile/patches/patch-sfcommands_sfconvert_c
new file mode 100644
index 000000000..cdf0e8dc3
--- /dev/null
+++ b/package/libaudiofile/patches/patch-sfcommands_sfconvert_c
@@ -0,0 +1,50 @@
+--- audiofile-0.3.6.orig/sfcommands/sfconvert.c 2013-03-06 06:30:03.000000000 +0100
++++ audiofile-0.3.6/sfcommands/sfconvert.c 2017-04-26 02:15:11.864252147 +0200
+@@ -45,6 +45,33 @@ void printusage (void);
+ void usageerror (void);
+ bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid);
+
++int firstBitSet(int x)
++{
++ int position=0;
++ while (x!=0)
++ {
++ x>>=1;
++ ++position;
++ }
++ return position;
++}
++
++#ifndef __has_builtin
++#define __has_builtin(x) 0
++#endif
++
++int multiplyCheckOverflow(int a, int b, int *result)
++{
++#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
++ return __builtin_mul_overflow(a, b, result);
++#else
++ if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
++ return true;
++ *result = a * b;
++ return false;
++#endif
++}
++
+ int main (int argc, char **argv)
+ {
+ if (argc == 2)
+@@ -323,8 +350,11 @@ bool copyaudiodata (AFfilehandle infile,
+ {
+ int frameSize = afGetVirtualFrameSize(infile, trackid, 1);
+
+- const int kBufferFrameCount = 65536;
+- void *buffer = malloc(kBufferFrameCount * frameSize);
++ int kBufferFrameCount = 65536;
++ int bufferSize;
++ while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize))
++ kBufferFrameCount /= 2;
++ void *buffer = malloc(bufferSize);
+
+ AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK);
+ AFframecount totalFramesWritten = 0;