annotate qdm2_tablegen.h @ 12514:e6d711ba5760 libavcodec

rawdec: ensure that there is always a valid palette for formats that should have one like gray8 etc.
author reimar
date Sat, 25 Sep 2010 08:44:35 +0000
parents 4b2300246240
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11488
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
1 /*
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
2 * Header file for hardcoded QDM2 tables
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
3 *
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
4 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
5 *
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
6 * This file is part of FFmpeg.
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
7 *
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
12 *
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
16 * Lesser General Public License for more details.
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
17 *
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
21 */
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
22
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
23 #ifndef QDM2_TABLEGEN_H
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
24 #define QDM2_TABLEGEN_H
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
25
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
26 #include <stdint.h>
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
27 #include <math.h>
11967
4b2300246240 Remove unnecessary ../ from include directives
mru
parents: 11552
diff changeset
28 #include "libavutil/attributes.h"
11488
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
29
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
30 #define SOFTCLIP_THRESHOLD 27600
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
31 #define HARDCLIP_THRESHOLD 35716
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
32
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
33 #if CONFIG_HARDCODED_TABLES
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
34 #define softclip_table_init()
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
35 #define rnd_table_init()
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
36 #define init_noise_samples()
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
37 #include "libavcodec/qdm2_tables.h"
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
38 #else
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
39 static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1];
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
40 static float noise_table[4096];
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
41 static uint8_t random_dequant_index[256][5];
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
42 static uint8_t random_dequant_type24[128][3];
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
43 static float noise_samples[128];
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
44
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
45 static av_cold void softclip_table_init(void) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
46 int i;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
47 double dfl = SOFTCLIP_THRESHOLD - 32767;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
48 float delta = 1.0 / -dfl;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
49 for (i = 0; i < HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1; i++)
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
50 softclip_table[i] = SOFTCLIP_THRESHOLD - ((int)(sin((float)i * delta) * dfl) & 0x0000FFFF);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
51 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
52
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
53
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
54 // random generated table
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
55 static av_cold void rnd_table_init(void) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
56 int i,j;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
57 uint32_t ldw,hdw;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
58 uint64_t tmp64_1;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
59 uint64_t random_seed = 0;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
60 float delta = 1.0 / 16384.0;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
61 for(i = 0; i < 4096 ;i++) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
62 random_seed = random_seed * 214013 + 2531011;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
63 noise_table[i] = (delta * (float)(((int32_t)random_seed >> 16) & 0x00007FFF)- 1.0) * 1.3;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
64 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
65
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
66 for (i = 0; i < 256 ;i++) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
67 random_seed = 81;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
68 ldw = i;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
69 for (j = 0; j < 5 ;j++) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
70 random_dequant_index[i][j] = (uint8_t)((ldw / random_seed) & 0xFF);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
71 ldw = (uint32_t)ldw % (uint32_t)random_seed;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
72 tmp64_1 = (random_seed * 0x55555556);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
73 hdw = (uint32_t)(tmp64_1 >> 32);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
74 random_seed = (uint64_t)(hdw + (ldw >> 31));
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
75 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
76 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
77 for (i = 0; i < 128 ;i++) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
78 random_seed = 25;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
79 ldw = i;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
80 for (j = 0; j < 3 ;j++) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
81 random_dequant_type24[i][j] = (uint8_t)((ldw / random_seed) & 0xFF);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
82 ldw = (uint32_t)ldw % (uint32_t)random_seed;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
83 tmp64_1 = (random_seed * 0x66666667);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
84 hdw = (uint32_t)(tmp64_1 >> 33);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
85 random_seed = hdw + (ldw >> 31);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
86 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
87 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
88 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
89
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
90
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
91 static av_cold void init_noise_samples(void) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
92 int i;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
93 int random_seed = 0;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
94 float delta = 1.0 / 16384.0;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
95 for (i = 0; i < 128;i++) {
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
96 random_seed = random_seed * 214013 + 2531011;
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
97 noise_samples[i] = (delta * (float)((random_seed >> 16) & 0x00007fff) - 1.0);
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
98 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
99 }
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
100 #endif /* CONFIG_HARDCODED_TABLES */
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
101
424b8482f316 Allow hard-coding several QDM2 tables (about 32 kB size).
reimar
parents:
diff changeset
102 #endif /* QDM2_TABLEGEN_H */