]> git.sesse.net Git - ffmpeg/blob - libavcodec/arm/dca.h
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / arm / dca.h
1 /*
2  * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVCODEC_ARM_DCA_H
22 #define AVCODEC_ARM_DCA_H
23
24 #include <stdint.h>
25 #include "config.h"
26 #include "libavutil/intmath.h"
27
28 #if HAVE_ARMV6 && HAVE_INLINE_ASM
29
30 #define decode_blockcode decode_blockcode
31 static inline int decode_blockcode(int code, int levels, int *values)
32 {
33     int v0, v1, v2, v3;
34
35     __asm__ ("smmul   %4, %8, %11           \n"
36              "smlabb  %8, %4, %10, %8       \n"
37              "smmul   %5, %4, %11           \n"
38              "sub     %8, %8, %9, lsr #1    \n"
39              "smlabb  %4, %5, %10, %4       \n"
40              "smmul   %6, %5, %11           \n"
41              "str     %8, %0                \n"
42              "sub     %4, %4, %9, lsr #1    \n"
43              "smlabb  %5, %6, %10, %5       \n"
44              "smmul   %7, %6, %11           \n"
45              "str     %4, %1                \n"
46              "sub     %5, %5, %9, lsr #1    \n"
47              "smlabb  %6, %7, %10, %6       \n"
48              "cmp     %7, #0                \n"
49              "str     %5, %2                \n"
50              "sub     %6, %6, %9, lsr #1    \n"
51              "it      eq                    \n"
52              "mvneq   %7, #0                \n"
53              "str     %6, %3                \n"
54              : "=m"(values[0]), "=m"(values[1]),
55                "=m"(values[2]), "=m"(values[3]),
56                "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3),
57                "+&r"(code)
58              : "r"(levels - 1), "r"(-levels), "r"(ff_inverse[levels])
59              : "cc");
60
61     return v3;
62 }
63
64 #endif
65
66 #if HAVE_NEON && HAVE_INLINE_ASM && HAVE_ASM_MOD_Y
67
68 #define int8x8_fmul_int32 int8x8_fmul_int32
69 static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale)
70 {
71     __asm__ ("vcvt.f32.s32 %2,  %2,  #4         \n"
72              "vld1.8       {d0},     [%1,:64]   \n"
73              "vmovl.s8     q0,  d0              \n"
74              "vmovl.s16    q1,  d1              \n"
75              "vmovl.s16    q0,  d0              \n"
76              "vcvt.f32.s32 q0,  q0              \n"
77              "vcvt.f32.s32 q1,  q1              \n"
78              "vmul.f32     q0,  q0,  %y2        \n"
79              "vmul.f32     q1,  q1,  %y2        \n"
80              "vst1.32      {q0-q1},  [%m0,:128] \n"
81              : "=Um"(*(float (*)[8])dst)
82              : "r"(src), "x"(scale)
83              : "d0", "d1", "d2", "d3");
84 }
85
86 #endif
87
88 #endif /* AVCODEC_ARM_DCA_H */