yading@10: /* yading@10: * Copyright (c) 2012 yading@10: * MIPS Technologies, Inc., California. yading@10: * yading@10: * Redistribution and use in source and binary forms, with or without yading@10: * modification, are permitted provided that the following conditions yading@10: * are met: yading@10: * 1. Redistributions of source code must retain the above copyright yading@10: * notice, this list of conditions and the following disclaimer. yading@10: * 2. Redistributions in binary form must reproduce the above copyright yading@10: * notice, this list of conditions and the following disclaimer in the yading@10: * documentation and/or other materials provided with the distribution. yading@10: * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its yading@10: * contributors may be used to endorse or promote products derived from yading@10: * this software without specific prior written permission. yading@10: * yading@10: * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND yading@10: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE yading@10: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE yading@10: * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE yading@10: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL yading@10: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS yading@10: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) yading@10: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT yading@10: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY yading@10: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF yading@10: * SUCH DAMAGE. yading@10: * yading@10: * Authors: Darko Laus (darko@mips.com) yading@10: * Djordje Pesut (djordje@mips.com) yading@10: * Mirjana Vulin (mvulin@mips.com) yading@10: * yading@10: * AAC Spectral Band Replication decoding functions optimized for MIPS yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: /** yading@10: * @file yading@10: * Reference: libavcodec/aacdec.c yading@10: */ yading@10: yading@10: #ifndef AVCODEC_MIPS_AACDEC_FLOAT_H yading@10: #define AVCODEC_MIPS_AACDEC_FLOAT_H yading@10: yading@10: #include "libavcodec/aac.h" yading@10: yading@10: #if HAVE_INLINE_ASM && HAVE_MIPSFPU yading@10: static inline float *VMUL2_mips(float *dst, const float *v, unsigned idx, yading@10: const float *scale) yading@10: { yading@10: float temp0, temp1, temp2; yading@10: int temp3, temp4; yading@10: float *ret; yading@10: yading@10: __asm__ volatile( yading@10: "andi %[temp3], %[idx], 15 \n\t" yading@10: "ext %[temp4], %[idx], 4, 4 \n\t" yading@10: "sll %[temp3], %[temp3], 2 \n\t" yading@10: "sll %[temp4], %[temp4], 2 \n\t" yading@10: "lwc1 %[temp2], 0(%[scale]) \n\t" yading@10: "lwxc1 %[temp0], %[temp3](%[v]) \n\t" yading@10: "lwxc1 %[temp1], %[temp4](%[v]) \n\t" yading@10: "mul.s %[temp0], %[temp0], %[temp2] \n\t" yading@10: "mul.s %[temp1], %[temp1], %[temp2] \n\t" yading@10: "addiu %[ret], %[dst], 8 \n\t" yading@10: "swc1 %[temp0], 0(%[dst]) \n\t" yading@10: "swc1 %[temp1], 4(%[dst]) \n\t" yading@10: yading@10: : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), yading@10: [temp2]"=&f"(temp2), [temp3]"=&r"(temp3), yading@10: [temp4]"=&r"(temp4), [ret]"=&r"(ret) yading@10: : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), yading@10: [dst]"r"(dst) yading@10: : "memory" yading@10: ); yading@10: return ret; yading@10: } yading@10: yading@10: static inline float *VMUL4_mips(float *dst, const float *v, unsigned idx, yading@10: const float *scale) yading@10: { yading@10: int temp0, temp1, temp2, temp3; yading@10: float temp4, temp5, temp6, temp7, temp8; yading@10: float *ret; yading@10: yading@10: __asm__ volatile( yading@10: "andi %[temp0], %[idx], 3 \n\t" yading@10: "ext %[temp1], %[idx], 2, 2 \n\t" yading@10: "ext %[temp2], %[idx], 4, 2 \n\t" yading@10: "ext %[temp3], %[idx], 6, 2 \n\t" yading@10: "sll %[temp0], %[temp0], 2 \n\t" yading@10: "sll %[temp1], %[temp1], 2 \n\t" yading@10: "sll %[temp2], %[temp2], 2 \n\t" yading@10: "sll %[temp3], %[temp3], 2 \n\t" yading@10: "lwc1 %[temp4], 0(%[scale]) \n\t" yading@10: "lwxc1 %[temp5], %[temp0](%[v]) \n\t" yading@10: "lwxc1 %[temp6], %[temp1](%[v]) \n\t" yading@10: "lwxc1 %[temp7], %[temp2](%[v]) \n\t" yading@10: "lwxc1 %[temp8], %[temp3](%[v]) \n\t" yading@10: "mul.s %[temp5], %[temp5], %[temp4] \n\t" yading@10: "mul.s %[temp6], %[temp6], %[temp4] \n\t" yading@10: "mul.s %[temp7], %[temp7], %[temp4] \n\t" yading@10: "mul.s %[temp8], %[temp8], %[temp4] \n\t" yading@10: "addiu %[ret], %[dst], 16 \n\t" yading@10: "swc1 %[temp5], 0(%[dst]) \n\t" yading@10: "swc1 %[temp6], 4(%[dst]) \n\t" yading@10: "swc1 %[temp7], 8(%[dst]) \n\t" yading@10: "swc1 %[temp8], 12(%[dst]) \n\t" yading@10: yading@10: : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), yading@10: [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), yading@10: [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), yading@10: [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), yading@10: [temp8]"=&f"(temp8), [ret]"=&r"(ret) yading@10: : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), yading@10: [dst]"r"(dst) yading@10: : "memory" yading@10: ); yading@10: return ret; yading@10: } yading@10: yading@10: static inline float *VMUL2S_mips(float *dst, const float *v, unsigned idx, yading@10: unsigned sign, const float *scale) yading@10: { yading@10: int temp0, temp1, temp2, temp3, temp4, temp5; yading@10: float temp6, temp7, temp8, temp9; yading@10: float *ret; yading@10: yading@10: __asm__ volatile( yading@10: "andi %[temp0], %[idx], 15 \n\t" yading@10: "ext %[temp1], %[idx], 4, 4 \n\t" yading@10: "lw %[temp4], 0(%[scale]) \n\t" yading@10: "srl %[temp2], %[sign], 1 \n\t" yading@10: "sll %[temp3], %[sign], 31 \n\t" yading@10: "sll %[temp2], %[temp2], 31 \n\t" yading@10: "sll %[temp0], %[temp0], 2 \n\t" yading@10: "sll %[temp1], %[temp1], 2 \n\t" yading@10: "lwxc1 %[temp8], %[temp0](%[v]) \n\t" yading@10: "lwxc1 %[temp9], %[temp1](%[v]) \n\t" yading@10: "xor %[temp5], %[temp4], %[temp2] \n\t" yading@10: "xor %[temp4], %[temp4], %[temp3] \n\t" yading@10: "mtc1 %[temp5], %[temp6] \n\t" yading@10: "mtc1 %[temp4], %[temp7] \n\t" yading@10: "mul.s %[temp8], %[temp8], %[temp6] \n\t" yading@10: "mul.s %[temp9], %[temp9], %[temp7] \n\t" yading@10: "addiu %[ret], %[dst], 8 \n\t" yading@10: "swc1 %[temp8], 0(%[dst]) \n\t" yading@10: "swc1 %[temp9], 4(%[dst]) \n\t" yading@10: yading@10: : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), yading@10: [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), yading@10: [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), yading@10: [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), yading@10: [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), yading@10: [ret]"=&r"(ret) yading@10: : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), yading@10: [dst]"r"(dst), [sign]"r"(sign) yading@10: : "memory" yading@10: ); yading@10: return ret; yading@10: } yading@10: yading@10: static inline float *VMUL4S_mips(float *dst, const float *v, unsigned idx, yading@10: unsigned sign, const float *scale) yading@10: { yading@10: int temp0, temp1, temp2, temp3, temp4; yading@10: float temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17; yading@10: float *ret; yading@10: unsigned int mask = 1U << 31; yading@10: yading@10: __asm__ volatile( yading@10: "lw %[temp0], 0(%[scale]) \n\t" yading@10: "and %[temp1], %[idx], 3 \n\t" yading@10: "ext %[temp2], %[idx], 2, 2 \n\t" yading@10: "ext %[temp3], %[idx], 4, 2 \n\t" yading@10: "ext %[temp4], %[idx], 6, 2 \n\t" yading@10: "sll %[temp1], %[temp1], 2 \n\t" yading@10: "sll %[temp2], %[temp2], 2 \n\t" yading@10: "sll %[temp3], %[temp3], 2 \n\t" yading@10: "sll %[temp4], %[temp4], 2 \n\t" yading@10: "lwxc1 %[temp10], %[temp1](%[v]) \n\t" yading@10: "lwxc1 %[temp11], %[temp2](%[v]) \n\t" yading@10: "lwxc1 %[temp12], %[temp3](%[v]) \n\t" yading@10: "lwxc1 %[temp13], %[temp4](%[v]) \n\t" yading@10: "and %[temp1], %[sign], %[mask] \n\t" yading@10: "ext %[temp2], %[idx], 12, 1 \n\t" yading@10: "ext %[temp3], %[idx], 13, 1 \n\t" yading@10: "ext %[temp4], %[idx], 14, 1 \n\t" yading@10: "sllv %[sign], %[sign], %[temp2] \n\t" yading@10: "xor %[temp1], %[temp0], %[temp1] \n\t" yading@10: "and %[temp2], %[sign], %[mask] \n\t" yading@10: "mtc1 %[temp1], %[temp14] \n\t" yading@10: "xor %[temp2], %[temp0], %[temp2] \n\t" yading@10: "sllv %[sign], %[sign], %[temp3] \n\t" yading@10: "mtc1 %[temp2], %[temp15] \n\t" yading@10: "and %[temp3], %[sign], %[mask] \n\t" yading@10: "sllv %[sign], %[sign], %[temp4] \n\t" yading@10: "xor %[temp3], %[temp0], %[temp3] \n\t" yading@10: "and %[temp4], %[sign], %[mask] \n\t" yading@10: "mtc1 %[temp3], %[temp16] \n\t" yading@10: "xor %[temp4], %[temp0], %[temp4] \n\t" yading@10: "mtc1 %[temp4], %[temp17] \n\t" yading@10: "mul.s %[temp10], %[temp10], %[temp14] \n\t" yading@10: "mul.s %[temp11], %[temp11], %[temp15] \n\t" yading@10: "mul.s %[temp12], %[temp12], %[temp16] \n\t" yading@10: "mul.s %[temp13], %[temp13], %[temp17] \n\t" yading@10: "addiu %[ret], %[dst], 16 \n\t" yading@10: "swc1 %[temp10], 0(%[dst]) \n\t" yading@10: "swc1 %[temp11], 4(%[dst]) \n\t" yading@10: "swc1 %[temp12], 8(%[dst]) \n\t" yading@10: "swc1 %[temp13], 12(%[dst]) \n\t" yading@10: yading@10: : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), yading@10: [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), yading@10: [temp4]"=&r"(temp4), [temp10]"=&f"(temp10), yading@10: [temp11]"=&f"(temp11), [temp12]"=&f"(temp12), yading@10: [temp13]"=&f"(temp13), [temp14]"=&f"(temp14), yading@10: [temp15]"=&f"(temp15), [temp16]"=&f"(temp16), yading@10: [temp17]"=&f"(temp17), [ret]"=&r"(ret), yading@10: [sign]"+r"(sign) yading@10: : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), yading@10: [dst]"r"(dst), [mask]"r"(mask) yading@10: : "memory" yading@10: ); yading@10: return ret; yading@10: } yading@10: yading@10: #define VMUL2 VMUL2_mips yading@10: #define VMUL4 VMUL4_mips yading@10: #define VMUL2S VMUL2S_mips yading@10: #define VMUL4S VMUL4S_mips yading@10: #endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ yading@10: yading@10: #endif /* AVCODEC_MIPS_AACDEC_FLOAT_H */