[oe-commits] unknown libmad: add conditional patch for avr32 optimizations
koen commit
openembedded-commits at lists.openembedded.org
Wed Jan 23 17:58:21 UTC 2008
libmad: add conditional patch for avr32 optimizations
Author: koen at openembedded.org
Branch: unknown
Revision: cb45e5c9ed8d58fb2b56d6cc8384c7bc16192509
ViewMTN: http://monotone.openembedded.org/revision/info/cb45e5c9ed8d58fb2b56d6cc8384c7bc16192509
Files:
1
packages/libmad/files
packages/libmad/files/libmad-0.15.1b-avr32-optimization.patch
packages/libmad/libmad_0.15.1b.bb
Diffs:
#
# mt diff -r37bb2ee00fd0e67a5581e111b614262b6a4cdfd6 -rcb45e5c9ed8d58fb2b56d6cc8384c7bc16192509
#
#
#
# add_dir "packages/libmad/files"
#
# add_file "packages/libmad/files/libmad-0.15.1b-avr32-optimization.patch"
# content [e0949dad838b63c646d58ab74e97aa86a3247427]
#
# patch "packages/libmad/libmad_0.15.1b.bb"
# from [665b1da8a10eee5f7c348c575c00d2aa41c3f48e]
# to [2b0495867f9b6b0af95ad5fd1cf1a6e344db7ac7]
#
============================================================
--- packages/libmad/files/libmad-0.15.1b-avr32-optimization.patch e0949dad838b63c646d58ab74e97aa86a3247427
+++ packages/libmad/files/libmad-0.15.1b-avr32-optimization.patch e0949dad838b63c646d58ab74e97aa86a3247427
@@ -0,0 +1,2922 @@
+diff --git a/bit.c b/bit.c
+index c2bfb24..262ce3a 100644
+--- a/bit.c
++++ b/bit.c
+@@ -25,12 +25,6 @@
+
+ # include "global.h"
+
+-# ifdef HAVE_LIMITS_H
+-# include <limits.h>
+-# else
+-# define CHAR_BIT 8
+-# endif
+-
+ # include "bit.h"
+
+ /*
+@@ -81,6 +75,8 @@ unsigned short const crc_table[256] = {
+
+ # define CRC_POLY 0x8005
+
++#ifndef FPM_AVR32
++
+ /*
+ * NAME: bit->init()
+ * DESCRIPTION: initialize bit pointer struct
+@@ -190,6 +186,8 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
+ }
+ # endif
+
++#endif
++
+ /*
+ * NAME: bit->crc()
+ * DESCRIPTION: compute CRC-check word
+diff --git a/bit.h b/bit.h
+index 5a51570..70f550a 100644
+--- a/bit.h
++++ b/bit.h
+@@ -22,6 +22,92 @@
+ # ifndef LIBMAD_BIT_H
+ # define LIBMAD_BIT_H
+
++# ifdef HAVE_LIMITS_H
++# include <limits.h>
++# else
++# define CHAR_BIT 8
++# endif
++
++#ifdef FPM_AVR32
++
++struct mad_bitptr {
++ unsigned char const *byte;
++ unsigned int read_bytes;
++};
++
++/*
++ * NAME: bit->init()
++ * DESCRIPTION: initialize bit pointer struct
++ */
++static void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
++{
++ bitptr->byte = byte;
++ bitptr->read_bytes = 0;
++}
++
++/*
++ * NAME: bit->length()
++ * DESCRIPTION: return number of bits between start and end points
++ */
++static unsigned int mad_bit_length(struct mad_bitptr const *begin,
++ struct mad_bitptr const *end)
++{
++ return (end->read_bytes - begin->read_bytes) +
++ 8 * (end->byte - begin->byte);
++}
++
++/*
++ * NAME: bit->nextbyte()
++ * DESCRIPTION: return pointer to next unprocessed byte
++ */
++static unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
++{
++ return bitptr->byte + ((bitptr->read_bytes + 0x7) >> 3);
++}
++
++/*
++ * NAME: bit->skip()
++ * DESCRIPTION: advance bit pointer
++ */
++static void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
++{
++ bitptr->read_bytes += len;
++ bitptr->byte += (bitptr->read_bytes >> 3);
++ bitptr->read_bytes &= 0x7;
++}
++
++/*
++ * NAME: bit->read()
++ * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
++ */
++static unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
++{
++ register unsigned long value;
++
++ if (!len)
++ return 0;
++
++ value = *(unsigned int *)bitptr->byte;
++
++ value <<= bitptr->read_bytes;
++ value >>= (32 - len);
++
++ bitptr->read_bytes += len;
++ bitptr->byte += (bitptr->read_bytes >> 3);
++ bitptr->read_bytes &= 0x7;
++
++ return value;
++}
++
++# define mad_bit_finish(bitptr) /* nothing */
++
++static unsigned long mad_bit_bitsleft(struct mad_bitptr *bitptr)
++{
++ return (8 - (bitptr)->read_bytes);
++}
++
++#else /* #ifdef FPM_AVR32 */
++
+ struct mad_bitptr {
+ unsigned char const *byte;
+ unsigned short cache;
+@@ -42,6 +128,8 @@ void mad_bit_skip(struct mad_bitptr *, unsigned int);
+ unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
+ void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
+
++#endif
++
+ unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
+
+ # endif
+diff --git a/configure b/configure
+index ee421cc..7a9f0c8 100755
+--- a/configure
++++ b/configure
+@@ -1048,7 +1048,7 @@ Optional Features:
+ --enable-speed optimize for speed over accuracy
+ --enable-accuracy optimize for accuracy over speed
+ --enable-fpm=ARCH use ARCH-specific fixed-point math routines (one of:
+- intel, arm, mips, sparc, ppc, 64bit, default)
++ intel, arm, avr32, mips, sparc, ppc, 64bit, default)
+ --enable-sso use subband synthesis optimization
+ --disable-aso disable architecture-specific optimizations
+ --enable-strict-iso use strict ISO/IEC interpretations
+@@ -21477,6 +21477,7 @@ if test "${enable_fpm+set}" = set; then
+ no|default|approx) FPM="DEFAULT" ;;
+ intel|i?86) FPM="INTEL" ;;
+ arm) FPM="ARM" ;;
++ avr32) FPM="AVR32" ;;
+ mips) FPM="MIPS" ;;
+ sparc) FPM="SPARC" ;;
+ ppc|powerpc) FPM="PPC" ;;
+@@ -21498,6 +21499,7 @@ then
+ case "$host" in
+ i?86-*) FPM="INTEL" ;;
+ arm*-*) FPM="ARM" ;;
++ avr32*-*) FPM="AVR32" ;;
+ mips*-*) FPM="MIPS" ;;
+ sparc*-*) FPM="SPARC" ;;
+ powerpc*-*) FPM="PPC" ;;
+@@ -21554,6 +21556,11 @@ then
+ ASO="$ASO -DASO_IMDCT"
+ ASO_OBJS="imdct_l_arm.lo"
+ ;;
++ avr32*-*)
++ ASO="$ASO -DASO_INTERLEAVE2"
++ ASO="$ASO -DASO_ZEROCHECK"
++ ASO_OBJS="dct32_avr32.lo synth_avr32.lo imdct_avr32.lo"
++ ;;
+ mips*-*)
+ ASO="$ASO -DASO_INTERLEAVE2"
+ ASO="$ASO -DASO_ZEROCHECK"
+diff --git a/configure.ac b/configure.ac
+index 9b79399..063cb9b 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -274,13 +274,14 @@ fi
+ AC_MSG_CHECKING(for architecture-specific fixed-point math routines)
+ AC_ARG_ENABLE(fpm, AC_HELP_STRING([--enable-fpm=ARCH],
+ [use ARCH-specific fixed-point math routines
+- (one of: intel, arm, mips, sparc, ppc, 64bit, default)]),
++ (one of: intel, arm, avr32, mips, sparc, ppc, 64bit, default)]),
+ [
+ case "$enableval" in
+ yes) ;;
+ no|default|approx) FPM="DEFAULT" ;;
+ intel|i?86) FPM="INTEL" ;;
+ arm) FPM="ARM" ;;
++ avr32) FPM="AVR32" ;;
+ mips) FPM="MIPS" ;;
+ sparc) FPM="SPARC" ;;
+ ppc|powerpc) FPM="PPC" ;;
+@@ -298,6 +299,7 @@ then
+ case "$host" in
+ i?86-*) FPM="INTEL" ;;
+ arm*-*) FPM="ARM" ;;
++ avr32*-*) FPM="AVR32" ;;
+ mips*-*) FPM="MIPS" ;;
+ sparc*-*) FPM="SPARC" ;;
+ powerpc*-*) FPM="PPC" ;;
+@@ -343,6 +345,11 @@ then
+ ASO="$ASO -DASO_IMDCT"
+ ASO_OBJS="imdct_l_arm.lo"
+ ;;
++ avr32*-*)
++ ASO="$ASO -DASO_INTERLEAVE2"
++ ASO="$ASO -DASO_ZEROCHECK"
++ ASO_OBJS="dct32_avr32.lo synth_avr32.lo imdct_avr32.lo"
++ ;;
+ mips*-*)
+ ASO="$ASO -DASO_INTERLEAVE2"
+ ASO="$ASO -DASO_ZEROCHECK"
+diff --git a/dct32_avr32.S b/dct32_avr32.S
+new file mode 100644
+index 0000000..7513340
+--- /dev/null
++++ b/dct32_avr32.S
+@@ -0,0 +1,780 @@
++/*
++ Optimized 32-point Discrete Cosine Transform (DCT)
++ Copyright 2003-2006 Atmel Corporation.
++
++ Written by Ronny Pedersen, Atmel Norway
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
++
++#define SHIFT 12
++#define MAD_F_SCALEBITS 28
++#define SLOTS 8
++
++#define MAD_F(x) ((x + (1 << 15)) >> 16)
++
++# define costab1 MAD_F(0x7fd8878e)
++# define costab2 MAD_F(0x7f62368f)
++# define costab3 MAD_F(0x7e9d55fc)
++# define costab4 MAD_F(0x7d8a5f40)
++# define costab5 MAD_F(0x7c29fbee)
++# define costab6 MAD_F(0x7a7d055b)
++# define costab7 MAD_F(0x78848414)
++# define costab8 MAD_F(0x7641af3d)
++# define costab9 MAD_F(0x73b5ebd1)
++# define costab10 MAD_F(0x70e2cbc6)
++# define costab11 MAD_F(0x6dca0d14)
++# define costab12 MAD_F(0x6a6d98a4)
++# define costab13 MAD_F(0x66cf8120)
++# define costab14 MAD_F(0x62f201ac)
++# define costab15 MAD_F(0x5ed77c8a)
++# define costab16 MAD_F(0x5a82799a)
++# define costab17 MAD_F(0x55f5a4d2)
++# define costab18 MAD_F(0x5133cc94)
++# define costab19 MAD_F(0x4c3fdff4)
++# define costab20 MAD_F(0x471cece7)
++# define costab21 MAD_F(0x41ce1e65)
++# define costab22 MAD_F(0x3c56ba70)
++# define costab23 MAD_F(0x36ba2014)
++# define costab24 MAD_F(0x30fbc54d)
++# define costab25 MAD_F(0x2b1f34eb)
++# define costab26 MAD_F(0x25280c5e)
++# define costab27 MAD_F(0x1f19f97b)
++# define costab28 MAD_F(0x18f8b83c)
++# define costab29 MAD_F(0x12c8106f)
++# define costab30 MAD_F(0x0c8bd35e)
++# define costab31 MAD_F(0x0647d97c)
++
++
++ .macro butterfly2_in out1, out2, out3, out4, in, idx_in1, idx_in2, idx_in3, idx_in4, coeff1, coeff2, tmplo, tmphi
++ mov \tmplo, \coeff1
++ ld.w \out1, \in[\idx_in1 * 4]
++ ld.w \out2, \in[\idx_in2 * 4]
++ ld.w \out3, \in[\idx_in3 * 4]
++ ld.w \out4, \in[\idx_in4 * 4]
++ sub \tmphi, \out1, \out2
++ add \out1, \out2
++ mulsatrndwh.w \out2, \tmphi, \tmplo:b
++
++ sub \tmphi, \out3, \out4
++ mov \tmplo, \coeff2
++ add \out3, \out4
++ mulsatrndwh.w \out4, \tmphi, \tmplo:b
++ .endm
++
++ .macro butterfly2 in1, in2, in3, in4, coeff1, tmplo, tmphi, tmp
++ mov \tmp, \coeff1
++ sub \tmphi, \in1, \in2
++ add \in1, \in2
++ mulsatrndwh.w \in2, \tmphi, \tmp:b
++
++ sub \tmphi, \in3, \in4
++ add \in3, \in4
++ mulsatrndwh.w \in4, \tmphi, \tmp:b
++ .endm
++
++ .macro butterfly4 in1, in2, in3, in4, in5, in6, in7, in8, coeff1, tmplo, tmphi, tmp
++ mov \tmp, \coeff1
++ sub \tmphi, \in1, \in2
++ add \in1, \in2
++ mulsatrndwh.w \in2, \tmphi, \tmp:b
++
++ sub \tmphi, \in3, \in4
++ add \in3, \in4
++ mulsatrndwh.w \in4, \tmphi, \tmp:b
++
++ sub \tmphi, \in5, \in6
++ add \in5, \in6
++ mulsatrndwh.w \in6, \tmphi, \tmp:b
++
++ sub \tmphi, \in7, \in8
++ add \in7, \in8
++ mulsatrndwh.w \in8, \tmphi, \tmp:b
++ .endm
++
++ .macro scale reg
++ .endm
++
++/*void dct32( mad_fixed_t const in[32], unsigned int slot,
++ mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) */
++
++ .global dct32_avr32
++dct32_avr32:
++ stm --sp, r0-r7, r9-r11, lr
++
++ sub sp, 32*4
++
++/* t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
++ t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31); */
++ butterfly2_in r4/*t0*/, r5/*t16*/, r6/*t1*/, r7/*t17*/, r12, 0, 31, 15, 16, costab1, costab31, r10, r11
++
++/* t41 = t16 + t17;
++ t59 = MUL(t16 - t17, costab2);
++ t33 = t0 + t1;
++ t50 = MUL(t0 - t1, costab2);*/
++ butterfly2 r5/*t41*/, r7/*t59*/, r4/*t33*/, r6/*t50*/, costab2, r10, r11, lr
++
++/* t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15);
++ t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17); */
++ butterfly2_in r0/*t2*/, r1/*t18*/, r2/*t3*/, r3/*t19*/, r12, 7, 24, 8, 23, costab15, costab17, r10, r11
++
++/* t42 = t18 + t19;
++ t60 = MUL(t18 - t19, costab30);
++ t34 = t2 + t3;
++ t51 = MUL(t2 - t3, costab30); */
++ butterfly2 r1/*t42*/, r3/*t60*/, r0/*t34*/, r2/*t51*/, costab30, r10, r11, lr
++
++/* t73 = t41 + t42; t94 = MUL(t41 - t42, costab4);
++ t83 = t59 + t60; t106 = MUL(t59 - t60, costab4); */
++
++
++/* t69 = t33 + t34; t89 = MUL(t33 - t34, costab4);
++ t78 = t50 + t51; t100 = MUL(t50 - t51, costab4); */
++ butterfly4 r5/*t73*/, r1/*t94*/, r7/*t83*/, r3/*t106*/,r4/*t69*/, r0/*t89*/, r6/*t78*/, r2/*t100*/, costab4, r10, r11, lr
++
++/* Store away the computed butterflies:
++ sp[0-7] = t83, t78, t73, t69, t106, t100, t94, t89 */
++ stm sp, r0-r7
++
++
++/* t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7);
++ t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25); */
++ butterfly2_in r4/*t4*/, r5/*t20*/, r6/*t5*/, r7/*t21*/, r12, 3, 28, 12, 19, costab7, costab25, r10, r11
++
++/* t43 = t20 + t21;
++ t61 = MUL(t20 - t21, costab14);
++ t35 = t4 + t5;
++ t52 = MUL(t4 - t5, costab14); */
++ butterfly2 r5/*t43*/, r7/*t61*/, r4/*t35*/, r6/*t52*/, costab14, r10, r11, lr
++
++/* t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9);
++ t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23); */
++ butterfly2_in r0/*t6*/, r1/*t22*/, r2/*t7*/, r3/*t23*/, r12, 4, 27, 11, 20, costab9, costab23, r10, r11
++
++/* t44 = t22 + t23;
++ t62 = MUL(t22 - t23, costab18);
++ t36 = t6 + t7;
++ t53 = MUL(t6 - t7, costab18); */
++ butterfly2 r1/*t44*/, r3/*t62*/, r0/*t36*/, r2/*t53*/, costab18, r10, r11, lr
++
++/* t74 = t43 + t44; t95 = MUL(t43 - t44, costab28);
++ t84 = t61 + t62; t107 = MUL(t61 - t62, costab28); */
++
++/* t70 = t35 + t36; t90 = MUL(t35 - t36, costab28);
++ t79 = t52 + t53; t101 = MUL(t52 - t53, costab28); */
++ butterfly4 r5/*t74*/, r1/*t95*/, r7/*t84*/, r3/*t107*/, r4/*t70*/, r0/*t90*/, r6/*t79*/, r2/*t101*/, costab28, r10, r11, lr
++
++/* Store away the computed butterflies:
++ sp[8-15] = t84, t79, t74, t70, t107, t101, t95, t90 */
++ sub r10, sp, -8*4
++ stm r10, r0-r7
++
++
++/* t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3);
++ t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29); */
++ butterfly2_in r4/*t8*/, r5/*t24*/, r6/*t9*/, r7/*t25*/, r12, 1, 30, 14, 17, costab3, costab29, r10, r11
++
++
++/* t45 = t24 + t25;
++ t63 = MUL(t24 - t25, costab6);
++ t37 = t8 + t9;
++ t54 = MUL(t8 - t9, costab6); */
++ butterfly2 r5/*t45*/, r7/*t63*/, r4/*t37*/, r6/*t54*/, costab6, r10, r11, lr
++
++/* t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13);
++ t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19); */
++ butterfly2_in r0/*t10*/, r1/*t26*/, r2/*t11*/, r3/*t27*/, r12, 6, 25, 9, 22, costab13, costab19, r10, r11
++
++/* t46 = t26 + t27;
++ t64 = MUL(t26 - t27, costab26);
++ t38 = t10 + t11;
++ t55 = MUL(t10 - t11, costab26); */
++ butterfly2 r1/*t46*/, r3/*t64*/, r0/*t38*/, r2/*t55*/, costab26, r10, r11, lr
++
++/* t75 = t45 + t46; t96 = MUL(t45 - t46, costab12);
++ t85 = t63 + t64; t108 = MUL(t63 - t64, costab12); */
++
++/* t71 = t37 + t38; t91 = MUL(t37 - t38, costab12);
++ t80 = t54 + t55; t102 = MUL(t54 - t55, costab12); */
++ butterfly4 r5/*t75*/, r1/*t96*/, r7/*t85*/, r3/*t108*/, r4/*t71*/, r0/*t91*/, r6/*t80*/, r2/*t102*/, costab12, r10, r11, lr
++
++/* Store away the computed butterflies:
++ sp[16-23] = t85, t80, t75, t71, t108, t102, t96, t91 */
++ sub r10, sp, -16*4
++ stm r10, r0-r7
++
++/* t12 = in[2] + in[29]; t28 = MUL(in[2] - in[29], costab5);
++ t13 = in[13] + in[18]; t29 = MUL(in[13] - in[18], costab27); */
++ butterfly2_in r4/*t12*/, r5/*t28*/, r6/*t13*/, r7/*t29*/, r12, 2, 29, 13, 18, costab5, costab27, r10, r11
++
++/* t47 = t28 + t29;
++ t65 = MUL(t28 - t29, costab10);
++ t39 = t12 + t13;
++ t56 = MUL(t12 - t13, costab10); */
++ butterfly2 r5/*t47*/, r7/*t65*/, r4/*t39*/, r6/*t56*/, costab10, r10, r11, lr
++
++/* t14 = in[5] + in[26]; t30 = MUL(in[5] - in[26], costab11);
++ t15 = in[10] + in[21]; t31 = MUL(in[10] - in[21], costab21);*/
++ butterfly2_in r0/*t14*/, r1/*t30*/, r2/*t15*/, r3/*t31*/, r12, 5, 26, 10, 21, costab11, costab21, r10, r11
++
++/* t48 = t30 + t31;
++ t66 = MUL(t30 - t31, costab22);
++ t40 = t14 + t15;
++ t57 = MUL(t14 - t15, costab22);*/
++ butterfly2 r1/*t48*/, r3/*t66*/, r0/*t40*/, r2/*t57*/, costab22, r10, r11, lr
++
++/* t76 = t47 + t48; t97 = MUL(t47 - t48, costab20);
++ t86 = t65 + t66; t109 = MUL(t65 - t66, costab20);*/
++
++/* t72 = t39 + t40; t92 = MUL(t39 - t40, costab20);
++ t81 = t56 + t57; t103 = MUL(t56 - t57, costab20);*/
++ butterfly4 r5/*t76*/, r1/*t97*/, r7/*t86*/, r3/*t109*/,r4/*t72*/, r0/*t92*/, r6/*t81*/, r2/*t103*/, costab20, r10, r11, lr
++
++/* Store away the computed butterflies:
++ sp[24-31] = t86, t81, t76, t72, t109, t103, t97, t92 */
++ sub r10, sp, -24*4
++ stm r10, r0-r7
++
++/* We now have the following on the stack:
++
++ sp[0-7] = t83, t78, t73, t69, t106, t100, t94, t89
++ sp[8-15] = t84, t79, t74, t70, t107, t101, t95, t90
++ sp[16-23] = t85, t80, %s
>>> DIFF TRUNCATED @ 16K
More information about the Openembedded-commits
mailing list