GCC Code Coverage Report
Directory: ../../../ffmpeg/ Exec Total Coverage
File: src/libavcodec/synth_filter.c Lines: 103 103 100.0 %
Date: 2020-08-14 10:39:37 Branches: 24 24 100.0 %

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 "fft.h"
23
#include "dcadct.h"
24
#include "dcamath.h"
25
#include "synth_filter.h"
26
27
50220
static void synth_filter_float(FFTContext *imdct,
28
                               float *synth_buf_ptr, int *synth_buf_offset,
29
                               float synth_buf2[32], const float window[512],
30
                               float out[32], const float in[32], float scale)
31
{
32
50220
    float *synth_buf = synth_buf_ptr + *synth_buf_offset;
33
    int i, j;
34
35
50220
    imdct->imdct_half(imdct, synth_buf, in);
36
37
853740
    for (i = 0; i < 16; i++) {
38
803520
        float a = synth_buf2[i     ];
39
803520
        float b = synth_buf2[i + 16];
40
803520
        float c = 0;
41
803520
        float d = 0;
42
4419072
        for (j = 0; j < 512 - *synth_buf_offset; j += 64) {
43
3615552
            a += window[i + j     ] * (-synth_buf[15 - i + j      ]);
44
3615552
            b += window[i + j + 16] * ( synth_buf[     i + j      ]);
45
3615552
            c += window[i + j + 32] * ( synth_buf[16 + i + j      ]);
46
3615552
            d += window[i + j + 48] * ( synth_buf[31 - i + j      ]);
47
        }
48
3616128
        for (     ; j < 512; j += 64) {
49
2812608
            a += window[i + j     ] * (-synth_buf[15 - i + j - 512]);
50
2812608
            b += window[i + j + 16] * ( synth_buf[     i + j - 512]);
51
2812608
            c += window[i + j + 32] * ( synth_buf[16 + i + j - 512]);
52
2812608
            d += window[i + j + 48] * ( synth_buf[31 - i + j - 512]);
53
        }
54
803520
        out[i     ] = a * scale;
55
803520
        out[i + 16] = b * scale;
56
803520
        synth_buf2[i     ] = c;
57
803520
        synth_buf2[i + 16] = d;
58
    }
59
60
50220
    *synth_buf_offset = (*synth_buf_offset - 32) & 511;
61
50220
}
62
63
3136
static void synth_filter_float_64(FFTContext *imdct,
64
                                  float *synth_buf_ptr, int *synth_buf_offset,
65
                                  float synth_buf2[64], const float window[1024],
66
                                  float out[64], const float in[64], float scale)
67
{
68
3136
    float *synth_buf = synth_buf_ptr + *synth_buf_offset;
69
    int i, j;
70
71
3136
    imdct->imdct_half(imdct, synth_buf, in);
72
73
103488
    for (i = 0; i < 32; i++) {
74
100352
        float a = synth_buf2[i     ];
75
100352
        float b = synth_buf2[i + 32];
76
100352
        float c = 0;
77
100352
        float d = 0;
78
551936
        for (j = 0; j < 1024 - *synth_buf_offset; j += 128) {
79
451584
            a += window[i + j     ] * (-synth_buf[31 - i + j       ]);
80
451584
            b += window[i + j + 32] * ( synth_buf[     i + j       ]);
81
451584
            c += window[i + j + 64] * ( synth_buf[32 + i + j       ]);
82
451584
            d += window[i + j + 96] * ( synth_buf[63 - i + j       ]);
83
        }
84
451584
        for (     ; j < 1024; j += 128) {
85
351232
            a += window[i + j     ] * (-synth_buf[31 - i + j - 1024]);
86
351232
            b += window[i + j + 32] * ( synth_buf[     i + j - 1024]);
87
351232
            c += window[i + j + 64] * ( synth_buf[32 + i + j - 1024]);
88
351232
            d += window[i + j + 96] * ( synth_buf[63 - i + j - 1024]);
89
        }
90
100352
        out[i     ] = a * scale;
91
100352
        out[i + 32] = b * scale;
92
100352
        synth_buf2[i     ] = c;
93
100352
        synth_buf2[i + 32] = d;
94
    }
95
96
3136
    *synth_buf_offset = (*synth_buf_offset - 64) & 1023;
97
3136
}
98
99
117376
static void synth_filter_fixed(DCADCTContext *imdct,
100
                               int32_t *synth_buf_ptr, int *synth_buf_offset,
101
                               int32_t synth_buf2[32], const int32_t window[512],
102
                               int32_t out[32], const int32_t in[32])
103
{
104
117376
    int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset;
105
    int i, j;
106
107
117376
    imdct->imdct_half[0](synth_buf, in);
108
109
1995392
    for (i = 0; i < 16; i++) {
110
1878016
        int64_t a = synth_buf2[i     ] * (INT64_C(1) << 21);
111
1878016
        int64_t b = synth_buf2[i + 16] * (INT64_C(1) << 21);
112
1878016
        int64_t c = 0;
113
1878016
        int64_t d = 0;
114
10329088
        for (j = 0; j < 512 - *synth_buf_offset; j += 64) {
115
8451072
            a += (int64_t)window[i + j     ] * synth_buf[     i + j      ];
116
8451072
            b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j      ];
117
8451072
            c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j      ];
118
8451072
            d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j      ];
119
        }
120
8451072
        for (     ; j < 512; j += 64) {
121
6573056
            a += (int64_t)window[i + j     ] * synth_buf[     i + j - 512];
122
6573056
            b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j - 512];
123
6573056
            c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j - 512];
124
6573056
            d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j - 512];
125
        }
126
1878016
        out[i     ] = clip23(norm21(a));
127
1878016
        out[i + 16] = clip23(norm21(b));
128
1878016
        synth_buf2[i     ] = norm21(c);
129
1878016
        synth_buf2[i + 16] = norm21(d);
130
    }
131
132
117376
    *synth_buf_offset = (*synth_buf_offset - 32) & 511;
133
117376
}
134
135
6720
static void synth_filter_fixed_64(DCADCTContext *imdct,
136
                                  int32_t *synth_buf_ptr, int *synth_buf_offset,
137
                                  int32_t synth_buf2[64], const int32_t window[1024],
138
                                  int32_t out[64], const int32_t in[64])
139
{
140
6720
    int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset;
141
    int i, j;
142
143
6720
    imdct->imdct_half[1](synth_buf, in);
144
145
221760
    for (i = 0; i < 32; i++) {
146
215040
        int64_t a = synth_buf2[i     ] * (INT64_C(1) << 20);
147
215040
        int64_t b = synth_buf2[i + 32] * (INT64_C(1) << 20);
148
215040
        int64_t c = 0;
149
215040
        int64_t d = 0;
150
1182720
        for (j = 0; j < 1024 - *synth_buf_offset; j += 128) {
151
967680
            a += (int64_t)window[i + j     ] * synth_buf[     i + j       ];
152
967680
            b += (int64_t)window[i + j + 32] * synth_buf[31 - i + j       ];
153
967680
            c += (int64_t)window[i + j + 64] * synth_buf[32 + i + j       ];
154
967680
            d += (int64_t)window[i + j + 96] * synth_buf[63 - i + j       ];
155
        }
156
967680
        for (     ; j < 1024; j += 128) {
157
752640
            a += (int64_t)window[i + j     ] * synth_buf[     i + j - 1024];
158
752640
            b += (int64_t)window[i + j + 32] * synth_buf[31 - i + j - 1024];
159
752640
            c += (int64_t)window[i + j + 64] * synth_buf[32 + i + j - 1024];
160
752640
            d += (int64_t)window[i + j + 96] * synth_buf[63 - i + j - 1024];
161
        }
162
215040
        out[i     ] = clip23(norm20(a));
163
215040
        out[i + 32] = clip23(norm20(b));
164
215040
        synth_buf2[i     ] = norm20(c);
165
215040
        synth_buf2[i + 32] = norm20(d);
166
    }
167
168
6720
    *synth_buf_offset = (*synth_buf_offset - 64) & 1023;
169
6720
}
170
171
105
av_cold void ff_synth_filter_init(SynthFilterContext *c)
172
{
173
105
    c->synth_filter_float    = synth_filter_float;
174
105
    c->synth_filter_float_64 = synth_filter_float_64;
175
105
    c->synth_filter_fixed    = synth_filter_fixed;
176
105
    c->synth_filter_fixed_64 = synth_filter_fixed_64;
177
178
    if (ARCH_AARCH64)
179
        ff_synth_filter_init_aarch64(c);
180
    if (ARCH_ARM)
181
        ff_synth_filter_init_arm(c);
182
    if (ARCH_X86)
183
105
        ff_synth_filter_init_x86(c);
184
105
}