summaryrefslogtreecommitdiff
path: root/package/libmad/patches
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2013-10-16 18:00:36 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2013-10-16 18:00:36 +0200
commit7a464646964980beb100d22836ad36c02c695744 (patch)
tree3cc4aa0e3ff1a90e5a6d10b6067694a127352df8 /package/libmad/patches
parent94f93c55a89f4d0b686a97f20dae65afe37823ce (diff)
parent29fcf823c3a97b1bb7074b0ca685547582216e0c (diff)
Merge branch 'master' of git+ssh://openadk.org/git/openadk
Diffstat (limited to 'package/libmad/patches')
-rw-r--r--package/libmad/patches/patch-fixed_h44
-rw-r--r--package/libmad/patches/patch-imdct_l_arm_S11
-rw-r--r--package/libmad/patches/patch-layer12_c173
-rw-r--r--package/libmad/patches/patch-layer3_c15
4 files changed, 243 insertions, 0 deletions
diff --git a/package/libmad/patches/patch-fixed_h b/package/libmad/patches/patch-fixed_h
new file mode 100644
index 000000000..3e6eb292d
--- /dev/null
+++ b/package/libmad/patches/patch-fixed_h
@@ -0,0 +1,44 @@
+--- libmad-0.15.1b.orig/fixed.h 2004-02-17 03:02:03.000000000 +0100
++++ libmad-0.15.1b/fixed.h 2013-10-16 10:51:56.000000000 +0200
+@@ -275,12 +275,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t
+ : "+r" (lo), "+r" (hi) \
+ : "%r" (x), "r" (y))
+
++#ifdef __thumb__
++/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
++ operand. If needed this code can also support Thumb-1
++ (simply append "s" to the end of the second two instructions). */
++# define MAD_F_MLN(hi, lo) \
++ asm ("rsbs %0, %0, #0\n\t" \
++ "sbc %1, %1, %1\n\t" \
++ "sub %1, %1, %2" \
++ : "+&r" (lo), "=&r" (hi) \
++ : "r" (hi) \
++ : "cc")
++#else /* ! __thumb__ */
+ # define MAD_F_MLN(hi, lo) \
+ asm ("rsbs %0, %2, #0\n\t" \
+ "rsc %1, %3, #0" \
+- : "=r" (lo), "=r" (hi) \
++ : "=&r" (lo), "=r" (hi) \
+ : "0" (lo), "1" (hi) \
+ : "cc")
++#endif /* __thumb__ */
+
+ # define mad_f_scale64(hi, lo) \
+ ({ mad_fixed_t __result; \
+@@ -297,6 +310,14 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t
+
+ /* --- MIPS ---------------------------------------------------------------- */
+
++# elif defined(FPM_MIPS) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
++ typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
++# define MAD_F_MLX(hi, lo, x, y) \
++ do { \
++ u64_di_t __ll = (u64_di_t) (x) * (y); \
++ hi = __ll >> 32; \
++ lo = __ll; \
++ } while (0)
+ # elif defined(FPM_MIPS)
+
+ /*
diff --git a/package/libmad/patches/patch-imdct_l_arm_S b/package/libmad/patches/patch-imdct_l_arm_S
new file mode 100644
index 000000000..f071b4888
--- /dev/null
+++ b/package/libmad/patches/patch-imdct_l_arm_S
@@ -0,0 +1,11 @@
+--- libmad-0.15.1b.orig/imdct_l_arm.S 2001-03-25 22:03:34.000000000 +0200
++++ libmad-0.15.1b/imdct_l_arm.S 2013-10-16 10:51:50.000000000 +0200
+@@ -468,7 +468,7 @@ _III_imdct_l:
+
+ @----
+
+- add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?)
++ adr r2, imdct36_long_karray
+
+
+ loop:
diff --git a/package/libmad/patches/patch-layer12_c b/package/libmad/patches/patch-layer12_c
new file mode 100644
index 000000000..275a1c5b7
--- /dev/null
+++ b/package/libmad/patches/patch-layer12_c
@@ -0,0 +1,173 @@
+--- libmad-0.15.1b.orig/layer12.c 2004-02-05 10:02:39.000000000 +0100
++++ libmad-0.15.1b/layer12.c 2013-10-16 10:51:25.000000000 +0200
+@@ -134,6 +134,12 @@ int mad_layer_I(struct mad_stream *strea
+ for (sb = 0; sb < bound; ++sb) {
+ for (ch = 0; ch < nch; ++ch) {
+ nb = mad_bit_read(&stream->ptr, 4);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ if (nb == 15) {
+ stream->error = MAD_ERROR_BADBITALLOC;
+@@ -146,6 +152,12 @@ int mad_layer_I(struct mad_stream *strea
+
+ for (sb = bound; sb < 32; ++sb) {
+ nb = mad_bit_read(&stream->ptr, 4);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ if (nb == 15) {
+ stream->error = MAD_ERROR_BADBITALLOC;
+@@ -162,6 +174,12 @@ int mad_layer_I(struct mad_stream *strea
+ for (ch = 0; ch < nch; ++ch) {
+ if (allocation[ch][sb]) {
+ scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ # if defined(OPT_STRICT)
+ /*
+@@ -187,6 +205,12 @@ int mad_layer_I(struct mad_stream *strea
+ frame->sbsample[ch][s][sb] = nb ?
+ mad_f_mul(I_sample(&stream->ptr, nb),
+ sf_table[scalefactor[ch][sb]]) : 0;
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+ }
+ }
+
+@@ -195,6 +219,12 @@ int mad_layer_I(struct mad_stream *strea
+ mad_fixed_t sample;
+
+ sample = I_sample(&stream->ptr, nb);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ for (ch = 0; ch < nch; ++ch) {
+ frame->sbsample[ch][s][sb] =
+@@ -403,7 +433,15 @@ int mad_layer_II(struct mad_stream *stre
+ nbal = bitalloc_table[offsets[sb]].nbal;
+
+ for (ch = 0; ch < nch; ++ch)
++ {
+ allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
++ }
+ }
+
+ for (sb = bound; sb < sblimit; ++sb) {
+@@ -411,6 +449,13 @@ int mad_layer_II(struct mad_stream *stre
+
+ allocation[0][sb] =
+ allocation[1][sb] = mad_bit_read(&stream->ptr, nbal);
++
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+ }
+
+ /* decode scalefactor selection info */
+@@ -419,6 +464,12 @@ int mad_layer_II(struct mad_stream *stre
+ for (ch = 0; ch < nch; ++ch) {
+ if (allocation[ch][sb])
+ scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+ }
+ }
+
+@@ -442,6 +493,12 @@ int mad_layer_II(struct mad_stream *stre
+ for (ch = 0; ch < nch; ++ch) {
+ if (allocation[ch][sb]) {
+ scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ switch (scfsi[ch][sb]) {
+ case 2:
+@@ -452,11 +509,23 @@ int mad_layer_II(struct mad_stream *stre
+
+ case 0:
+ scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+ /* fall through */
+
+ case 1:
+ case 3:
+ scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+ }
+
+ if (scfsi[ch][sb] & 1)
+@@ -488,6 +557,12 @@ int mad_layer_II(struct mad_stream *stre
+ index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];
+
+ II_samples(&stream->ptr, &qc_table[index], samples);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ for (s = 0; s < 3; ++s) {
+ frame->sbsample[ch][3 * gr + s][sb] =
+@@ -506,6 +581,12 @@ int mad_layer_II(struct mad_stream *stre
+ index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];
+
+ II_samples(&stream->ptr, &qc_table[index], samples);
++ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ for (ch = 0; ch < nch; ++ch) {
+ for (s = 0; s < 3; ++s) {
diff --git a/package/libmad/patches/patch-layer3_c b/package/libmad/patches/patch-layer3_c
new file mode 100644
index 000000000..d8e4249de
--- /dev/null
+++ b/package/libmad/patches/patch-layer3_c
@@ -0,0 +1,15 @@
+--- libmad-0.15.1b.orig/layer3.c 2004-01-23 10:41:32.000000000 +0100
++++ libmad-0.15.1b/layer3.c 2013-10-16 10:51:25.000000000 +0200
+@@ -2608,6 +2608,12 @@ int mad_layer_III(struct mad_stream *str
+ next_md_begin = 0;
+
+ md_len = si.main_data_begin + frame_space - next_md_begin;
++ if (md_len + MAD_BUFFER_GUARD > MAD_BUFFER_MDLEN)
++ {
++ stream->error = MAD_ERROR_LOSTSYNC;
++ stream->sync = 0;
++ return -1;
++ }
+
+ frame_used = 0;
+