Mercurial > libavcodec.hg
comparison qdm2_tablegen.h @ 11488:424b8482f316 libavcodec
Allow hard-coding several QDM2 tables (about 32 kB size).
author | reimar |
---|---|
date | Sun, 14 Mar 2010 19:30:25 +0000 |
parents | |
children | 8bef88bc329d |
comparison
equal
deleted
inserted
replaced
11487:62da6bfd50fd | 11488:424b8482f316 |
---|---|
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 QDM2_TABLEGEN_H | |
24 #define QDM2_TABLEGEN_H | |
25 | |
26 #include <stdint.h> | |
27 #include <math.h> | |
28 | |
29 #define SOFTCLIP_THRESHOLD 27600 | |
30 #define HARDCLIP_THRESHOLD 35716 | |
31 | |
32 #if CONFIG_HARDCODED_TABLES | |
33 #define softclip_table_init() | |
34 #define rnd_table_init() | |
35 #define init_noise_samples() | |
36 #include "libavcodec/qdm2_tables.h" | |
37 #else | |
38 static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1]; | |
39 static float noise_table[4096]; | |
40 static uint8_t random_dequant_index[256][5]; | |
41 static uint8_t random_dequant_type24[128][3]; | |
42 static float noise_samples[128]; | |
43 | |
44 static av_cold void softclip_table_init(void) { | |
45 int i; | |
46 double dfl = SOFTCLIP_THRESHOLD - 32767; | |
47 float delta = 1.0 / -dfl; | |
48 for (i = 0; i < HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1; i++) | |
49 softclip_table[i] = SOFTCLIP_THRESHOLD - ((int)(sin((float)i * delta) * dfl) & 0x0000FFFF); | |
50 } | |
51 | |
52 | |
53 // random generated table | |
54 static av_cold void rnd_table_init(void) { | |
55 int i,j; | |
56 uint32_t ldw,hdw; | |
57 uint64_t tmp64_1; | |
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; | |
63 } | |
64 | |
65 for (i = 0; i < 256 ;i++) { | |
66 random_seed = 81; | |
67 ldw = i; | |
68 for (j = 0; j < 5 ;j++) { | |
69 random_dequant_index[i][j] = (uint8_t)((ldw / random_seed) & 0xFF); | |
70 ldw = (uint32_t)ldw % (uint32_t)random_seed; | |
71 tmp64_1 = (random_seed * 0x55555556); | |
72 hdw = (uint32_t)(tmp64_1 >> 32); | |
73 random_seed = (uint64_t)(hdw + (ldw >> 31)); | |
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] = (uint8_t)((ldw / random_seed) & 0xFF); | |
81 ldw = (uint32_t)ldw % (uint32_t)random_seed; | |
82 tmp64_1 = (random_seed * 0x66666667); | |
83 hdw = (uint32_t)(tmp64_1 >> 33); | |
84 random_seed = hdw + (ldw >> 31); | |
85 } | |
86 } | |
87 } | |
88 | |
89 | |
90 static av_cold void init_noise_samples(void) { | |
91 int i; | |
92 int random_seed = 0; | |
93 float delta = 1.0 / 16384.0; | |
94 for (i = 0; i < 128;i++) { | |
95 random_seed = random_seed * 214013 + 2531011; | |
96 noise_samples[i] = (delta * (float)((random_seed >> 16) & 0x00007fff) - 1.0); | |
97 } | |
98 } | |
99 #endif /* CONFIG_HARDCODED_TABLES */ | |
100 | |
101 #endif /* QDM2_TABLEGEN_H */ |