../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
20 / 20
100.0%
Branches:
8 / 8
100.0%
Functions:
2 / 2
100.0%

libavcodec/cbrt_tablegen.h
Line Branch Exec Source
1 /*
2 * Header file for hardcoded AAC cube-root table
3 *
4 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef AVCODEC_CBRT_TABLEGEN_H
24 #define AVCODEC_CBRT_TABLEGEN_H
25
26 #include <assert.h>
27 #include <stdint.h>
28 #include <math.h>
29 #include "libavutil/attributes.h"
30 #include "libavutil/intfloat.h"
31 #include "libavcodec/aac_defines.h"
32 #include "cbrt_data.h"
33
34 #if USE_FIXED
35 #define CBRT(x) lrint((x) * 8192)
36 #else
37 #define CBRT(x) av_float2int((float)(x))
38 #endif
39
40 union CBRT AAC_RENAME(ff_cbrt_tab_internal);
41
42 319 av_cold void AAC_RENAME(ff_cbrt_tableinit)(void)
43 {
44 static_assert(2 * sizeof(AAC_RENAME(ff_cbrt_tab_internal).cbrt_tab[0])
45 >= sizeof(AAC_RENAME(ff_cbrt_tab_internal).tmp[0]),
46 "unexpected sizeofs");
47 // We reuse ff_cbrt_tab_internal.tmp as a LUT (of doubles) for the roots
48 // of the odd integers: tmp[idx] contains (2 * idx + 1)^{4/3}.
49 319 ff_cbrt_dbl_tableinit(AAC_RENAME(ff_cbrt_tab_internal).tmp);
50
51 319 double cbrt_2 = 2 * cbrt(2);
52
4/4
ff_cbrt_tableinit:
✓ Branch 9 → 4 taken 1236992 times.
✓ Branch 9 → 10 taken 302 times.
ff_cbrt_tableinit_fixed:
✓ Branch 8 → 4 taken 69632 times.
✓ Branch 8 → 9 taken 17 times.
1306943 for (int idx = TMP_LUT_SIZE - 1; idx >= 0; --idx) {
53 1306624 double cbrt_val = AAC_RENAME(ff_cbrt_tab_internal).tmp[idx];
54 // Due to i * sizeof(ff_cbrt_tab_internal.cbrt_tab[0]) >=
55 // 2 * idx * sizeof(ff_cbrt_tab_internal.cbrt_tab[0]) >= idx * sizeof(double)
56 // we don't clobber the double-LUT entries with index < idx
57 // in the loop below. This is why we process idx in descending order.
58
4/4
ff_cbrt_tableinit:
✓ Branch 7 → 5 taken 2473682 times.
✓ Branch 7 → 8 taken 1236992 times.
ff_cbrt_tableinit_fixed:
✓ Branch 6 → 5 taken 139247 times.
✓ Branch 6 → 7 taken 69632 times.
3919553 for (int i = 2 * idx + 1; i < LUT_SIZE; i *= 2) {
59 2612929 AAC_RENAME(ff_cbrt_tab_internal).cbrt_tab[i] = CBRT(cbrt_val);
60 2612929 cbrt_val *= cbrt_2;
61 }
62 }
63 319 AAC_RENAME(ff_cbrt_tab_internal).cbrt_tab[0] = CBRT(0);
64 319 }
65
66 #endif /* AVCODEC_CBRT_TABLEGEN_H */
67