FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/cbrt_tablegen.h
Date: 2025-10-10 03:51:19
Exec Total Coverage
Lines: 10 10 100.0%
Functions: 2 2 100.0%
Branches: 4 4 100.0%

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 187 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 187 ff_cbrt_dbl_tableinit(AAC_RENAME(ff_cbrt_tab_internal).tmp);
50
51 187 double cbrt_2 = 2 * cbrt(2);
52
2/2
✓ Branch 0 taken 765952 times.
✓ Branch 1 taken 187 times.
766139 for (int idx = TMP_LUT_SIZE - 1; idx >= 0; --idx) {
53 765952 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
2/2
✓ Branch 0 taken 1531717 times.
✓ Branch 1 taken 765952 times.
2297669 for (int i = 2 * idx + 1; i < LUT_SIZE; i *= 2) {
59 1531717 AAC_RENAME(ff_cbrt_tab_internal).cbrt_tab[i] = CBRT(cbrt_val);
60 1531717 cbrt_val *= cbrt_2;
61 }
62 }
63 187 AAC_RENAME(ff_cbrt_tab_internal).cbrt_tab[0] = CBRT(0);
64 187 }
65
66 #endif /* AVCODEC_CBRT_TABLEGEN_H */
67