Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * Copyright (C) 2016 foo86 | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | #include "dcadct.h" | ||
23 | #include "dcamath.h" | ||
24 | #include "synth_filter.h" | ||
25 | |||
26 | 50460 | static void synth_filter_float(AVTXContext *imdct, | |
27 | float *synth_buf_ptr, int *synth_buf_offset, | ||
28 | float synth_buf2[32], const float window[512], | ||
29 | float out[32], float in[32], float scale, | ||
30 | av_tx_fn imdct_fn) | ||
31 | { | ||
32 | 50460 | float *synth_buf = synth_buf_ptr + *synth_buf_offset; | |
33 | int i, j; | ||
34 | |||
35 | 50460 | imdct_fn(imdct, synth_buf, in, sizeof(float)); | |
36 | |||
37 |
2/2✓ Branch 0 taken 807360 times.
✓ Branch 1 taken 50460 times.
|
857820 | for (i = 0; i < 16; i++) { |
38 | 807360 | float a = synth_buf2[i ]; | |
39 | 807360 | float b = synth_buf2[i + 16]; | |
40 | 807360 | float c = 0; | |
41 | 807360 | float d = 0; | |
42 |
2/2✓ Branch 0 taken 3632832 times.
✓ Branch 1 taken 807360 times.
|
4440192 | for (j = 0; j < 512 - *synth_buf_offset; j += 64) { |
43 | 3632832 | a += window[i + j ] * (-synth_buf[15 - i + j ]); | |
44 | 3632832 | b += window[i + j + 16] * ( synth_buf[ i + j ]); | |
45 | 3632832 | c += window[i + j + 32] * ( synth_buf[16 + i + j ]); | |
46 | 3632832 | d += window[i + j + 48] * ( synth_buf[31 - i + j ]); | |
47 | } | ||
48 |
2/2✓ Branch 0 taken 2826048 times.
✓ Branch 1 taken 807360 times.
|
3633408 | for ( ; j < 512; j += 64) { |
49 | 2826048 | a += window[i + j ] * (-synth_buf[15 - i + j - 512]); | |
50 | 2826048 | b += window[i + j + 16] * ( synth_buf[ i + j - 512]); | |
51 | 2826048 | c += window[i + j + 32] * ( synth_buf[16 + i + j - 512]); | |
52 | 2826048 | d += window[i + j + 48] * ( synth_buf[31 - i + j - 512]); | |
53 | } | ||
54 | 807360 | out[i ] = a * scale; | |
55 | 807360 | out[i + 16] = b * scale; | |
56 | 807360 | synth_buf2[i ] = c; | |
57 | 807360 | synth_buf2[i + 16] = d; | |
58 | } | ||
59 | |||
60 | 50460 | *synth_buf_offset = (*synth_buf_offset - 32) & 511; | |
61 | 50460 | } | |
62 | |||
63 | 3136 | static void synth_filter_float_64(AVTXContext *imdct, | |
64 | float *synth_buf_ptr, int *synth_buf_offset, | ||
65 | float synth_buf2[64], const float window[1024], | ||
66 | float out[64], float in[64], float scale, | ||
67 | av_tx_fn imdct_fn) | ||
68 | { | ||
69 | 3136 | float *synth_buf = synth_buf_ptr + *synth_buf_offset; | |
70 | int i, j; | ||
71 | |||
72 | 3136 | imdct_fn(imdct, synth_buf, in, sizeof(float)); | |
73 | |||
74 |
2/2✓ Branch 0 taken 100352 times.
✓ Branch 1 taken 3136 times.
|
103488 | for (i = 0; i < 32; i++) { |
75 | 100352 | float a = synth_buf2[i ]; | |
76 | 100352 | float b = synth_buf2[i + 32]; | |
77 | 100352 | float c = 0; | |
78 | 100352 | float d = 0; | |
79 |
2/2✓ Branch 0 taken 451584 times.
✓ Branch 1 taken 100352 times.
|
551936 | for (j = 0; j < 1024 - *synth_buf_offset; j += 128) { |
80 | 451584 | a += window[i + j ] * (-synth_buf[31 - i + j ]); | |
81 | 451584 | b += window[i + j + 32] * ( synth_buf[ i + j ]); | |
82 | 451584 | c += window[i + j + 64] * ( synth_buf[32 + i + j ]); | |
83 | 451584 | d += window[i + j + 96] * ( synth_buf[63 - i + j ]); | |
84 | } | ||
85 |
2/2✓ Branch 0 taken 351232 times.
✓ Branch 1 taken 100352 times.
|
451584 | for ( ; j < 1024; j += 128) { |
86 | 351232 | a += window[i + j ] * (-synth_buf[31 - i + j - 1024]); | |
87 | 351232 | b += window[i + j + 32] * ( synth_buf[ i + j - 1024]); | |
88 | 351232 | c += window[i + j + 64] * ( synth_buf[32 + i + j - 1024]); | |
89 | 351232 | d += window[i + j + 96] * ( synth_buf[63 - i + j - 1024]); | |
90 | } | ||
91 | 100352 | out[i ] = a * scale; | |
92 | 100352 | out[i + 32] = b * scale; | |
93 | 100352 | synth_buf2[i ] = c; | |
94 | 100352 | synth_buf2[i + 32] = d; | |
95 | } | ||
96 | |||
97 | 3136 | *synth_buf_offset = (*synth_buf_offset - 64) & 1023; | |
98 | 3136 | } | |
99 | |||
100 | 117696 | static void synth_filter_fixed(DCADCTContext *imdct, | |
101 | int32_t *synth_buf_ptr, int *synth_buf_offset, | ||
102 | int32_t synth_buf2[32], const int32_t window[512], | ||
103 | int32_t out[32], const int32_t in[32]) | ||
104 | { | ||
105 | 117696 | int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset; | |
106 | int i, j; | ||
107 | |||
108 | 117696 | imdct->imdct_half[0](synth_buf, in); | |
109 | |||
110 |
2/2✓ Branch 0 taken 1883136 times.
✓ Branch 1 taken 117696 times.
|
2000832 | for (i = 0; i < 16; i++) { |
111 | 1883136 | int64_t a = synth_buf2[i ] * (INT64_C(1) << 21); | |
112 | 1883136 | int64_t b = synth_buf2[i + 16] * (INT64_C(1) << 21); | |
113 | 1883136 | int64_t c = 0; | |
114 | 1883136 | int64_t d = 0; | |
115 |
2/2✓ Branch 0 taken 8474112 times.
✓ Branch 1 taken 1883136 times.
|
10357248 | for (j = 0; j < 512 - *synth_buf_offset; j += 64) { |
116 | 8474112 | a += (int64_t)window[i + j ] * synth_buf[ i + j ]; | |
117 | 8474112 | b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j ]; | |
118 | 8474112 | c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j ]; | |
119 | 8474112 | d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j ]; | |
120 | } | ||
121 |
2/2✓ Branch 0 taken 6590976 times.
✓ Branch 1 taken 1883136 times.
|
8474112 | for ( ; j < 512; j += 64) { |
122 | 6590976 | a += (int64_t)window[i + j ] * synth_buf[ i + j - 512]; | |
123 | 6590976 | b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j - 512]; | |
124 | 6590976 | c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j - 512]; | |
125 | 6590976 | d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j - 512]; | |
126 | } | ||
127 | 1883136 | out[i ] = clip23(norm21(a)); | |
128 | 1883136 | out[i + 16] = clip23(norm21(b)); | |
129 | 1883136 | synth_buf2[i ] = norm21(c); | |
130 | 1883136 | synth_buf2[i + 16] = norm21(d); | |
131 | } | ||
132 | |||
133 | 117696 | *synth_buf_offset = (*synth_buf_offset - 32) & 511; | |
134 | 117696 | } | |
135 | |||
136 | 6720 | static void synth_filter_fixed_64(DCADCTContext *imdct, | |
137 | int32_t *synth_buf_ptr, int *synth_buf_offset, | ||
138 | int32_t synth_buf2[64], const int32_t window[1024], | ||
139 | int32_t out[64], const int32_t in[64]) | ||
140 | { | ||
141 | 6720 | int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset; | |
142 | int i, j; | ||
143 | |||
144 | 6720 | imdct->imdct_half[1](synth_buf, in); | |
145 | |||
146 |
2/2✓ Branch 0 taken 215040 times.
✓ Branch 1 taken 6720 times.
|
221760 | for (i = 0; i < 32; i++) { |
147 | 215040 | int64_t a = synth_buf2[i ] * (INT64_C(1) << 20); | |
148 | 215040 | int64_t b = synth_buf2[i + 32] * (INT64_C(1) << 20); | |
149 | 215040 | int64_t c = 0; | |
150 | 215040 | int64_t d = 0; | |
151 |
2/2✓ Branch 0 taken 967680 times.
✓ Branch 1 taken 215040 times.
|
1182720 | for (j = 0; j < 1024 - *synth_buf_offset; j += 128) { |
152 | 967680 | a += (int64_t)window[i + j ] * synth_buf[ i + j ]; | |
153 | 967680 | b += (int64_t)window[i + j + 32] * synth_buf[31 - i + j ]; | |
154 | 967680 | c += (int64_t)window[i + j + 64] * synth_buf[32 + i + j ]; | |
155 | 967680 | d += (int64_t)window[i + j + 96] * synth_buf[63 - i + j ]; | |
156 | } | ||
157 |
2/2✓ Branch 0 taken 752640 times.
✓ Branch 1 taken 215040 times.
|
967680 | for ( ; j < 1024; j += 128) { |
158 | 752640 | a += (int64_t)window[i + j ] * synth_buf[ i + j - 1024]; | |
159 | 752640 | b += (int64_t)window[i + j + 32] * synth_buf[31 - i + j - 1024]; | |
160 | 752640 | c += (int64_t)window[i + j + 64] * synth_buf[32 + i + j - 1024]; | |
161 | 752640 | d += (int64_t)window[i + j + 96] * synth_buf[63 - i + j - 1024]; | |
162 | } | ||
163 | 215040 | out[i ] = clip23(norm20(a)); | |
164 | 215040 | out[i + 32] = clip23(norm20(b)); | |
165 | 215040 | synth_buf2[i ] = norm20(c); | |
166 | 215040 | synth_buf2[i + 32] = norm20(d); | |
167 | } | ||
168 | |||
169 | 6720 | *synth_buf_offset = (*synth_buf_offset - 64) & 1023; | |
170 | 6720 | } | |
171 | |||
172 | 112 | av_cold void ff_synth_filter_init(SynthFilterContext *c) | |
173 | { | ||
174 | 112 | c->synth_filter_float = synth_filter_float; | |
175 | 112 | c->synth_filter_float_64 = synth_filter_float_64; | |
176 | 112 | c->synth_filter_fixed = synth_filter_fixed; | |
177 | 112 | c->synth_filter_fixed_64 = synth_filter_fixed_64; | |
178 | |||
179 | #if ARCH_AARCH64 | ||
180 | ff_synth_filter_init_aarch64(c); | ||
181 | #elif ARCH_ARM | ||
182 | ff_synth_filter_init_arm(c); | ||
183 | #elif ARCH_X86 | ||
184 | 112 | ff_synth_filter_init_x86(c); | |
185 | #endif | ||
186 | 112 | } | |
187 |