00001 /* 00002 * Header file for hardcoded DV 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 DV_TABLEGEN_H 00024 #define DV_TABLEGEN_H 00025 00026 #include <stdint.h> 00027 #include "dv_vlc_data.h" 00028 00029 #if CONFIG_SMALL 00030 #define DV_VLC_MAP_RUN_SIZE 15 00031 #define DV_VLC_MAP_LEV_SIZE 23 00032 #else 00033 #define DV_VLC_MAP_RUN_SIZE 64 00034 #define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check 00035 #endif 00036 00037 /* VLC encoding lookup table */ 00038 struct dv_vlc_pair { 00039 uint32_t vlc; 00040 uint32_t size; 00041 }; 00042 00043 #if CONFIG_HARDCODED_TABLES 00044 #define dv_vlc_map_tableinit() 00045 #include "libavcodec/dv_tables.h" 00046 #else 00047 static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]; 00048 00049 static void dv_vlc_map_tableinit(void) 00050 { 00051 int i, j; 00052 for (i = 0; i < NB_DV_VLC - 1; i++) { 00053 if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE) 00054 continue; 00055 #if CONFIG_SMALL 00056 if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE) 00057 continue; 00058 #endif 00059 00060 if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0) 00061 continue; 00062 00063 dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc = 00064 dv_vlc_bits[i] << (!!dv_vlc_level[i]); 00065 dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size = 00066 dv_vlc_len[i] + (!!dv_vlc_level[i]); 00067 } 00068 for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) { 00069 #if CONFIG_SMALL 00070 for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) { 00071 if (dv_vlc_map[i][j].size == 0) { 00072 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | 00073 (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); 00074 dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + 00075 dv_vlc_map[0][j].size; 00076 } 00077 } 00078 #else 00079 for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) { 00080 if (dv_vlc_map[i][j].size == 0) { 00081 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | 00082 (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); 00083 dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + 00084 dv_vlc_map[0][j].size; 00085 } 00086 dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc = 00087 dv_vlc_map[i][j].vlc | 1; 00088 dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size = 00089 dv_vlc_map[i][j].size; 00090 } 00091 #endif 00092 } 00093 } 00094 #endif /* CONFIG_HARDCODED_TABLES */ 00095 00096 #endif /* DV_TABLEGEN_H */