• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/qdm2_tablegen.h

Go to the documentation of this file.
00001 /*
00002  * Header file for hardcoded QDM2 tables
00003  *
00004  * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
00005  *
00006  * This file is part of FFmpeg.
00007  *
00008  * FFmpeg is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * FFmpeg is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with FFmpeg; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 #ifndef QDM2_TABLEGEN_H
00024 #define QDM2_TABLEGEN_H
00025 
00026 #include <stdint.h>
00027 #include <math.h>
00028 #include "../libavutil/attributes.h"
00029 
00030 #define SOFTCLIP_THRESHOLD 27600
00031 #define HARDCLIP_THRESHOLD 35716
00032 
00033 #if CONFIG_HARDCODED_TABLES
00034 #define softclip_table_init()
00035 #define rnd_table_init()
00036 #define init_noise_samples()
00037 #include "libavcodec/qdm2_tables.h"
00038 #else
00039 static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1];
00040 static float noise_table[4096];
00041 static uint8_t random_dequant_index[256][5];
00042 static uint8_t random_dequant_type24[128][3];
00043 static float noise_samples[128];
00044 
00045 static av_cold void softclip_table_init(void) {
00046     int i;
00047     double dfl = SOFTCLIP_THRESHOLD - 32767;
00048     float delta = 1.0 / -dfl;
00049     for (i = 0; i < HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1; i++)
00050         softclip_table[i] = SOFTCLIP_THRESHOLD - ((int)(sin((float)i * delta) * dfl) & 0x0000FFFF);
00051 }
00052 
00053 
00054 // random generated table
00055 static av_cold void rnd_table_init(void) {
00056     int i,j;
00057     uint32_t ldw,hdw;
00058     uint64_t tmp64_1;
00059     uint64_t random_seed = 0;
00060     float delta = 1.0 / 16384.0;
00061     for(i = 0; i < 4096 ;i++) {
00062         random_seed = random_seed * 214013 + 2531011;
00063         noise_table[i] = (delta * (float)(((int32_t)random_seed >> 16) & 0x00007FFF)- 1.0) * 1.3;
00064     }
00065 
00066     for (i = 0; i < 256 ;i++) {
00067         random_seed = 81;
00068         ldw = i;
00069         for (j = 0; j < 5 ;j++) {
00070             random_dequant_index[i][j] = (uint8_t)((ldw / random_seed) & 0xFF);
00071             ldw = (uint32_t)ldw % (uint32_t)random_seed;
00072             tmp64_1 = (random_seed * 0x55555556);
00073             hdw = (uint32_t)(tmp64_1 >> 32);
00074             random_seed = (uint64_t)(hdw + (ldw >> 31));
00075         }
00076     }
00077     for (i = 0; i < 128 ;i++) {
00078         random_seed = 25;
00079         ldw = i;
00080         for (j = 0; j < 3 ;j++) {
00081             random_dequant_type24[i][j] = (uint8_t)((ldw / random_seed) & 0xFF);
00082             ldw = (uint32_t)ldw % (uint32_t)random_seed;
00083             tmp64_1 = (random_seed * 0x66666667);
00084             hdw = (uint32_t)(tmp64_1 >> 33);
00085             random_seed = hdw + (ldw >> 31);
00086         }
00087     }
00088 }
00089 
00090 
00091 static av_cold void init_noise_samples(void) {
00092     int i;
00093     int random_seed = 0;
00094     float delta = 1.0 / 16384.0;
00095     for (i = 0; i < 128;i++) {
00096         random_seed = random_seed * 214013 + 2531011;
00097         noise_samples[i] = (delta * (float)((random_seed >> 16) & 0x00007fff) - 1.0);
00098     }
00099 }
00100 #endif /* CONFIG_HARDCODED_TABLES */
00101 
00102 #endif /* QDM2_TABLEGEN_H */

Generated on Fri Sep 16 2011 17:17:42 for FFmpeg by  doxygen 1.7.1