aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/arm/aac.h
blob: 6d5df4933a0acaf62b03b693750df0d801cab579 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
 *
 * This file is part of Libav.
 *
 * Libav is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Libav 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Libav; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef AVCODEC_ARM_AAC_H
#define AVCODEC_ARM_AAC_H

#include "config.h"

#if HAVE_NEON && HAVE_INLINE_ASM

#define VMUL2 VMUL2
static inline float *VMUL2(float *dst, const float *v, unsigned idx,
                           const float *scale)
{
    unsigned v0, v1;
    __asm__ ("ubfx     %0,  %6,  #0, #4      \n\t"
             "ubfx     %1,  %6,  #4, #4      \n\t"
             "ldr      %0,  [%5, %0, lsl #2] \n\t"
             "ldr      %1,  [%5, %1, lsl #2] \n\t"
             "vld1.32  {d1[]},   [%7,:32]    \n\t"
             "vmov     d0,  %0,  %1          \n\t"
             "vmul.f32 d0,  d0,  d1          \n\t"
             "vst1.32  {d0},     [%2,:64]!   \n\t"
             : "=&r"(v0), "=&r"(v1), "+r"(dst), "=m"(dst[0]), "=m"(dst[1])
             : "r"(v), "r"(idx), "r"(scale)
             : "d0", "d1");
    return dst;
}

#define VMUL4 VMUL4
static inline float *VMUL4(float *dst, const float *v, unsigned idx,
                           const float *scale)
{
    unsigned v0, v1, v2, v3;
    __asm__ ("ubfx     %0,  %10, #0, #2      \n\t"
             "ubfx     %1,  %10, #2, #2      \n\t"
             "ldr      %0,  [%9, %0, lsl #2] \n\t"
             "ubfx     %2,  %10, #4, #2      \n\t"
             "ldr      %1,  [%9, %1, lsl #2] \n\t"
             "ubfx     %3,  %10, #6, #2      \n\t"
             "ldr      %2,  [%9, %2, lsl #2] \n\t"
             "vmov     d0,  %0,  %1          \n\t"
             "ldr      %3,  [%9, %3, lsl #2] \n\t"
             "vld1.32  {d2[],d3[]},[%11,:32] \n\t"
             "vmov     d1,  %2,  %3          \n\t"
             "vmul.f32 q0,  q0,  q1          \n\t"
             "vst1.32  {q0},     [%4,:128]!  \n\t"
             : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
               "=m"(dst[0]), "=m"(dst[1]), "=m"(dst[2]), "=m"(dst[3])
             : "r"(v), "r"(idx), "r"(scale)
             : "d0", "d1", "d2", "d3");
    return dst;
}

#define VMUL2S VMUL2S
static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
                            unsigned sign, const float *scale)
{
    unsigned v0, v1, v2, v3;
    __asm__ ("ubfx     %0,  %8,  #0, #4      \n\t"
             "ubfx     %1,  %8,  #4, #4      \n\t"
             "ldr      %0,  [%7, %0, lsl #2] \n\t"
             "lsl      %2,  %10, #30         \n\t"
             "ldr      %1,  [%7, %1, lsl #2] \n\t"
             "lsl      %3,  %10, #31         \n\t"
             "vmov     d0,  %0,  %1          \n\t"
             "bic      %2,  %2,  #1<<30      \n\t"
             "vld1.32  {d1[]},   [%9,:32]    \n\t"
             "vmov     d2,  %2,  %3          \n\t"
             "veor     d0,  d0,  d2          \n\t"
             "vmul.f32 d0,  d0,  d1          \n\t"
             "vst1.32  {d0},     [%4,:64]!   \n\t"
             : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
               "=m"(dst[0]), "=m"(dst[1])
             : "r"(v), "r"(idx), "r"(scale), "r"(sign)
             : "d0", "d1", "d2");
    return dst;
}

#define VMUL4S VMUL4S
static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
                            unsigned sign, const float *scale)
{
    unsigned v0, v1, v2, v3, nz;
    __asm__ ("vld1.32  {d2[],d3[]},[%13,:32] \n\t"
             "ubfx     %0,  %12, #0, #2      \n\t"
             "ubfx     %1,  %12, #2, #2      \n\t"
             "ldr      %0,  [%11,%0, lsl #2] \n\t"
             "ubfx     %2,  %12, #4, #2      \n\t"
             "ldr      %1,  [%11,%1, lsl #2] \n\t"
             "ubfx     %3,  %12, #6, #2      \n\t"
             "ldr      %2,  [%11,%2, lsl #2] \n\t"
             "vmov     d0,  %0,  %1          \n\t"
             "ldr      %3,  [%11,%3, lsl #2] \n\t"
             "lsr      %6,  %12, #12         \n\t"
             "rbit     %6,  %6               \n\t"
             "vmov     d1,  %2,  %3          \n\t"
             "lsls     %6,  %6,  #1          \n\t"
             "and      %0,  %5,  #1<<31      \n\t"
             "lslcs    %5,  %5,  #1          \n\t"
             "lsls     %6,  %6,  #1          \n\t"
             "and      %1,  %5,  #1<<31      \n\t"
             "lslcs    %5,  %5,  #1          \n\t"
             "lsls     %6,  %6,  #1          \n\t"
             "and      %2,  %5,  #1<<31      \n\t"
             "lslcs    %5,  %5,  #1          \n\t"
             "vmov     d4,  %0,  %1          \n\t"
             "and      %3,  %5,  #1<<31      \n\t"
             "vmov     d5,  %2,  %3          \n\t"
             "veor     q0,  q0,  q2          \n\t"
             "vmul.f32 q0,  q0,  q1          \n\t"
             "vst1.32  {q0},     [%4,:128]!  \n\t"
             : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
               "+r"(sign), "=r"(nz),
               "=m"(dst[0]), "=m"(dst[1]), "=m"(dst[2]), "=m"(dst[3])
             : "r"(v), "r"(idx), "r"(scale)
             : "cc", "d0", "d1", "d2", "d3", "d4", "d5");
    return dst;
}

#endif /* HAVE_NEON && HAVE_INLINE_ASM */

#endif /* AVCODEC_ARM_AAC_H */