FFmpeg
Loading...
Searching...
No Matches
qdm2_tablegen.h
Go to the documentation of this file.
1/*
2 * Header file for hardcoded QDM2 tables
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_QDM2_TABLEGEN_H
24#define AVCODEC_QDM2_TABLEGEN_H
25
26#include <stdint.h>
27#include <math.h>
29#include "qdm2data.h"
30
31#define SOFTCLIP_THRESHOLD 27600
32#define HARDCLIP_THRESHOLD 35716
33
34#if CONFIG_HARDCODED_TABLES
35#define softclip_table_init()
36#define rnd_table_init()
37#define init_noise_samples()
38#define qdm2_init_vlc()
39#include "libavcodec/qdm2_tables.h"
40#else
42static float noise_table[4096 + 20];
43static uint8_t random_dequant_index[256][5];
44static uint8_t random_dequant_type24[128][3];
45static float noise_samples[128];
46
47static av_cold void softclip_table_init(void) {
48 int i;
49 double dfl = SOFTCLIP_THRESHOLD - 32767;
50 float delta = 1.0 / -dfl;
51 for (i = 0; i < HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1; i++)
52 softclip_table[i] = SOFTCLIP_THRESHOLD - ((int)(sin((float)i * delta) * dfl) & 0x0000FFFF);
53}
54
55
56// random generated table
57static av_cold void rnd_table_init(void) {
58 int i,j;
59 uint32_t ldw;
60 uint64_t random_seed = 0;
61 float delta = 1.0 / 16384.0;
62 for(i = 0; i < 4096 ;i++) {
63 random_seed = random_seed * 214013 + 2531011;
64 noise_table[i] = (delta * (float)(((int32_t)random_seed >> 16) & 0x00007FFF)- 1.0) * 1.3;
65 }
66
67 for (i = 0; i < 256 ;i++) {
68 random_seed = 81;
69 ldw = i;
70 for (j = 0; j < 5 ;j++) {
71 random_dequant_index[i][j] = ldw / random_seed;
72 ldw %= random_seed;
73 random_seed /= 3;
74 }
75 }
76 for (i = 0; i < 128 ;i++) {
77 random_seed = 25;
78 ldw = i;
79 for (j = 0; j < 3 ;j++) {
80 random_dequant_type24[i][j] = ldw / random_seed;
81 ldw %= random_seed;
82 random_seed /= 5;
83 }
84 }
85}
86
87
88static av_cold void init_noise_samples(void) {
89 int i;
90 unsigned random_seed = 0;
91 float delta = 1.0 / 16384.0;
92 for (i = 0; i < 128;i++) {
93 random_seed = random_seed * 214013 + 2531011;
94 noise_samples[i] = (delta * (float)((random_seed >> 16) & 0x00007fff) - 1.0);
95 }
96}
97
111
112static VLCElem qdm2_table[3838];
113
114static av_cold void build_vlc(VLC *vlc, int nb_bits, int nb_codes,
115 unsigned *offset, const uint8_t tab[][2])
116{
117 vlc->table = &qdm2_table[*offset];
119 ff_vlc_init_from_lengths(vlc, nb_bits, nb_codes,
120 &tab[0][1], 2, &tab[0][0], 2, 1,
122 *offset += vlc->table_size;
123}
124
153
154#endif /* CONFIG_HARDCODED_TABLES */
155
156#endif /* AVCODEC_QDM2_TABLEGEN_H */
int32_t
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
unsigned offset
Definition libaomenc.c:763
static const int8_t noise_table[256]
Data table used for TrueHD noise generation function.
Definition mlpdec.c:1041
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
#define SOFTCLIP_THRESHOLD
static av_cold void build_vlc(VLC *vlc, int nb_bits, int nb_codes, unsigned *offset, const uint8_t tab[][2])
static VLC vlc_tab_diff
static av_cold void init_noise_samples(void)
static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD+1]
static float noise_samples[128]
static uint8_t random_dequant_index[256][5]
static VLC fft_stereo_exp_vlc
static VLC fft_stereo_phase_vlc
static VLC vlc_tab_run
static VLC vlc_tab_fft_tone_offset[5]
static VLC vlc_tab_level
static VLC vlc_tab_type34
static VLC vlc_tab_tone_level_idx_mid
static VLC fft_level_exp_alt_vlc
static VLC vlc_tab_type30
static VLCElem qdm2_table[3838]
static av_cold void qdm2_init_vlc(void)
static av_cold void rnd_table_init(void)
static uint8_t random_dequant_type24[128][3]
static av_cold void softclip_table_init(void)
static VLC fft_level_exp_vlc
static VLC vlc_tab_tone_level_idx_hi2
#define HARDCLIP_THRESHOLD
static VLC vlc_tab_tone_level_idx_hi1
Various QDM2 tables.
static const uint8_t tab_diff[33][2]
Definition qdm2data.h:46
static const uint8_t tab_tone_level_idx_mid[13][2]
Definition qdm2data.h:69
static const uint8_t tab_fft_tone_offset[][2]
Definition qdm2data.h:98
static const uint8_t fft_stereo_phase[9][2]
Definition qdm2data.h:159
static const uint8_t tab_tone_level_idx_hi1[20][2]
Definition qdm2data.h:61
static const uint8_t tab_fft_tone_offset_sizes[]
Definition qdm2data.h:94
static const uint8_t fft_level_exp_alt[28][2]
FFT TABLES.
Definition qdm2data.h:137
static const uint8_t tab_run[6][2]
Definition qdm2data.h:56
static const uint8_t tab_type34[10][2]
Definition qdm2data.h:89
static const uint8_t tab_level[24][2]
VLC TABLES.
Definition qdm2data.h:38
static const uint8_t fft_level_exp[20][2]
Definition qdm2data.h:146
static const uint8_t tab_type30[9][2]
Definition qdm2data.h:83
static const uint8_t fft_stereo_exp[7][2]
Definition qdm2data.h:154
static const uint8_t tab_tone_level_idx_hi2[18][2]
Definition qdm2data.h:76
#define FF_ARRAY_ELEMS(a)
Definition vlc.h:32
Definition vlc.h:50
int table_size
Definition vlc.h:53
int table_allocated
Definition vlc.h:53
VLCElem * table
Definition vlc.h:52
static const struct twinvq_data tab
int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
Definition vlc.c:306
#define VLC_INIT_LE
Definition vlc.h:197
#define VLC_INIT_STATIC_OVERLONG
Definition vlc.h:191
float delta