FFmpeg
libavcodec
cbrt_tablegen.h
Go to the documentation of this file.
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
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
ff_cbrt_dbl_tableinit
(
AAC_RENAME
(
ff_cbrt_tab_internal
).
tmp
);
50
51
double
cbrt_2 = 2 *
cbrt
(2);
52
for
(
int
idx =
TMP_LUT_SIZE
- 1; idx >= 0; --idx) {
53
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
for
(
int
i
= 2 * idx + 1;
i
<
LUT_SIZE
;
i
*= 2) {
59
AAC_RENAME
(
ff_cbrt_tab_internal
).
cbrt_tab
[
i
] =
CBRT
(cbrt_val);
60
cbrt_val *= cbrt_2;
61
}
62
}
63
AAC_RENAME
(
ff_cbrt_tab_internal
).
cbrt_tab
[0] =
CBRT
(0);
64
}
65
66
#endif
/* AVCODEC_CBRT_TABLEGEN_H */
ff_cbrt_tab_internal
union CBRT ff_cbrt_tab_internal
AAC_RENAME
union CBRT AAC_RENAME(ff_cbrt_tab_internal)
TMP_LUT_SIZE
#define TMP_LUT_SIZE
Definition:
cbrt_data.h:42
intfloat.h
CBRT
Definition:
cbrt_data.h:49
cbrt
#define cbrt
Definition:
tablegen.h:35
av_cold
#define av_cold
Definition:
attributes.h:106
tmp
static uint8_t tmp[40]
Definition:
aes_ctr.c:52
attributes.h
cbrt_data.h
i
#define i(width, name, range_min, range_max)
Definition:
cbs_h2645.c:256
LUT_SIZE
#define LUT_SIZE
Definition:
bgmc.c:40
ff_cbrt_dbl_tableinit
void ff_cbrt_dbl_tableinit(double tmp_lut[TMP_LUT_SIZE])
Creates a LUT (of doubles) for the powers of the odd integers: tmp_lut[idx] will be set to (2 * idx +...
Definition:
cbrt_tablegen_common.c:31
CBRT
#define CBRT(x)
Definition:
cbrt_tablegen.h:37
CBRT::cbrt_tab
uint32_t cbrt_tab[LUT_SIZE]
Definition:
cbrt_data.h:50
ff_cbrt_tableinit
av_cold void AAC_RENAME() ff_cbrt_tableinit(void)
Definition:
cbrt_tablegen.h:42
aac_defines.h
CBRT::tmp
double tmp[TMP_LUT_SIZE]
Definition:
cbrt_data.h:51
Generated on Sun Oct 19 2025 19:21:46 for FFmpeg by
1.8.17