FFmpeg
Loading...
Searching...
No Matches
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>
30#include "libavutil/intfloat.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
40union CBRT AAC_RENAME(ff_cbrt_tab_internal);
41
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 */
#define AAC_RENAME(x)
Definition aac_defines.h:99
#define LUT_SIZE
Definition bgmc.c:40
#define ff_cbrt_tableinit()
Definition cbrt_data.h:35
#define CBRT(x)
av_cold void ff_cbrt_dbl_tableinit(double tmp_lut[TMP_LUT_SIZE])
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
#define cbrt
Definition tablegen.h:35
static uint8_t tmp[40]
Definition aes_ctr.c:52