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