2 * Header file for hardcoded QDM2 tables
4 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
6 * This file is part of FFmpeg.
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.
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.
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
23 #ifndef AVCODEC_QDM2_TABLEGEN_H
24 #define AVCODEC_QDM2_TABLEGEN_H
28 #include "libavutil/attributes.h"
30 #define SOFTCLIP_THRESHOLD 27600
31 #define HARDCLIP_THRESHOLD 35716
33 #if CONFIG_HARDCODED_TABLES
34 #define softclip_table_init()
35 #define rnd_table_init()
36 #define init_noise_samples()
37 #include "libavcodec/qdm2_tables.h"
39 static uint16_t softclip_table
[HARDCLIP_THRESHOLD
- SOFTCLIP_THRESHOLD
+ 1];
40 static float noise_table
[4096 + 20];
41 static uint8_t random_dequant_index
[256][5];
42 static uint8_t random_dequant_type24
[128][3];
43 static float noise_samples
[128];
45 static av_cold
void softclip_table_init(void) {
47 double dfl
= SOFTCLIP_THRESHOLD
- 32767;
48 float delta
= 1.0 / -dfl
;
49 for (i
= 0; i
< HARDCLIP_THRESHOLD
- SOFTCLIP_THRESHOLD
+ 1; i
++)
50 softclip_table
[i
] = SOFTCLIP_THRESHOLD
- ((int)(sin((float)i
* delta
) * dfl
) & 0x0000FFFF);
54 // random generated table
55 static av_cold
void rnd_table_init(void) {
58 uint64_t random_seed
= 0;
59 float delta
= 1.0 / 16384.0;
60 for(i
= 0; i
< 4096 ;i
++) {
61 random_seed
= random_seed
* 214013 + 2531011;
62 noise_table
[i
] = (delta
* (float)(((int32_t)random_seed
>> 16) & 0x00007FFF)- 1.0) * 1.3;
65 for (i
= 0; i
< 256 ;i
++) {
68 for (j
= 0; j
< 5 ;j
++) {
69 random_dequant_index
[i
][j
] = ldw
/ random_seed
;
74 for (i
= 0; i
< 128 ;i
++) {
77 for (j
= 0; j
< 3 ;j
++) {
78 random_dequant_type24
[i
][j
] = ldw
/ random_seed
;
86 static av_cold
void init_noise_samples(void) {
88 unsigned random_seed
= 0;
89 float delta
= 1.0 / 16384.0;
90 for (i
= 0; i
< 128;i
++) {
91 random_seed
= random_seed
* 214013 + 2531011;
92 noise_samples
[i
] = (delta
* (float)((random_seed
>> 16) & 0x00007fff) - 1.0);
95 #endif /* CONFIG_HARDCODED_TABLES */
97 #endif /* AVCODEC_QDM2_TABLEGEN_H */