comparison h264.c @ 7481:ca205cc57734 libavcodec

Fix static leaks in h264.c. Patch by Art Clarke aclarke A vlideshow D com
author cehoyos
date Mon, 04 Aug 2008 21:45:05 +0000
parents 82918a570d86
children ecf3c774f5e1
comparison
equal deleted inserted replaced
7480:82918a570d86 7481:ca205cc57734
47 * is held for delayed output. 47 * is held for delayed output.
48 */ 48 */
49 #define DELAYED_PIC_REF 4 49 #define DELAYED_PIC_REF 4
50 50
51 static VLC coeff_token_vlc[4]; 51 static VLC coeff_token_vlc[4];
52 static VLC_TYPE coeff_token_vlc_tables[520+332+280+256][2];
53 static const int coeff_token_vlc_tables_size[4]={520,332,280,256};
54
52 static VLC chroma_dc_coeff_token_vlc; 55 static VLC chroma_dc_coeff_token_vlc;
56 static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2];
57 static const int chroma_dc_coeff_token_vlc_table_size = 256;
53 58
54 static VLC total_zeros_vlc[15]; 59 static VLC total_zeros_vlc[15];
60 static VLC_TYPE total_zeros_vlc_tables[15][512][2];
61 static const int total_zeros_vlc_tables_size = 512;
62
55 static VLC chroma_dc_total_zeros_vlc[3]; 63 static VLC chroma_dc_total_zeros_vlc[3];
64 static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2];
65 static const int chroma_dc_total_zeros_vlc_tables_size = 8;
56 66
57 static VLC run_vlc[6]; 67 static VLC run_vlc[6];
68 static VLC_TYPE run_vlc_tables[6][8][2];
69 static const int run_vlc_tables_size = 8;
70
58 static VLC run7_vlc; 71 static VLC run7_vlc;
72 static VLC_TYPE run7_vlc_table[96][2];
73 static const int run7_vlc_table_size = 96;
59 74
60 static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp); 75 static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp);
61 static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); 76 static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
62 static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); 77 static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
63 static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); 78 static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
1935 static av_cold void decode_init_vlc(void){ 1950 static av_cold void decode_init_vlc(void){
1936 static int done = 0; 1951 static int done = 0;
1937 1952
1938 if (!done) { 1953 if (!done) {
1939 int i; 1954 int i;
1955 int offset;
1940 done = 1; 1956 done = 1;
1941 1957
1958 chroma_dc_coeff_token_vlc.table = chroma_dc_coeff_token_vlc_table;
1959 chroma_dc_coeff_token_vlc.table_allocated = chroma_dc_coeff_token_vlc_table_size;
1942 init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5, 1960 init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5,
1943 &chroma_dc_coeff_token_len [0], 1, 1, 1961 &chroma_dc_coeff_token_len [0], 1, 1,
1944 &chroma_dc_coeff_token_bits[0], 1, 1, 1); 1962 &chroma_dc_coeff_token_bits[0], 1, 1,
1945 1963 INIT_VLC_USE_NEW_STATIC);
1964
1965 offset = 0;
1946 for(i=0; i<4; i++){ 1966 for(i=0; i<4; i++){
1967 coeff_token_vlc[i].table = coeff_token_vlc_tables+offset;
1968 coeff_token_vlc[i].table_allocated = coeff_token_vlc_tables_size[i];
1947 init_vlc(&coeff_token_vlc[i], COEFF_TOKEN_VLC_BITS, 4*17, 1969 init_vlc(&coeff_token_vlc[i], COEFF_TOKEN_VLC_BITS, 4*17,
1948 &coeff_token_len [i][0], 1, 1, 1970 &coeff_token_len [i][0], 1, 1,
1949 &coeff_token_bits[i][0], 1, 1, 1); 1971 &coeff_token_bits[i][0], 1, 1,
1950 } 1972 INIT_VLC_USE_NEW_STATIC);
1973 offset += coeff_token_vlc_tables_size[i];
1974 }
1975 /*
1976 * This is a one time safety check to make sure that
1977 * the packed static coeff_token_vlc table sizes
1978 * were initialized correctly.
1979 */
1980 assert(offset == sizeof(coeff_token_vlc_tables)/(sizeof(VLC_TYPE)*2));
1951 1981
1952 for(i=0; i<3; i++){ 1982 for(i=0; i<3; i++){
1953 init_vlc(&chroma_dc_total_zeros_vlc[i], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4, 1983 chroma_dc_total_zeros_vlc[i].table = chroma_dc_total_zeros_vlc_tables[i];
1984 chroma_dc_total_zeros_vlc[i].table_allocated = chroma_dc_total_zeros_vlc_tables_size;
1985 init_vlc(&chroma_dc_total_zeros_vlc[i],
1986 CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,
1954 &chroma_dc_total_zeros_len [i][0], 1, 1, 1987 &chroma_dc_total_zeros_len [i][0], 1, 1,
1955 &chroma_dc_total_zeros_bits[i][0], 1, 1, 1); 1988 &chroma_dc_total_zeros_bits[i][0], 1, 1,
1989 INIT_VLC_USE_NEW_STATIC);
1956 } 1990 }
1957 for(i=0; i<15; i++){ 1991 for(i=0; i<15; i++){
1958 init_vlc(&total_zeros_vlc[i], TOTAL_ZEROS_VLC_BITS, 16, 1992 total_zeros_vlc[i].table = total_zeros_vlc_tables[i];
1993 total_zeros_vlc[i].table_allocated = total_zeros_vlc_tables_size;
1994 init_vlc(&total_zeros_vlc[i],
1995 TOTAL_ZEROS_VLC_BITS, 16,
1959 &total_zeros_len [i][0], 1, 1, 1996 &total_zeros_len [i][0], 1, 1,
1960 &total_zeros_bits[i][0], 1, 1, 1); 1997 &total_zeros_bits[i][0], 1, 1,
1998 INIT_VLC_USE_NEW_STATIC);
1961 } 1999 }
1962 2000
1963 for(i=0; i<6; i++){ 2001 for(i=0; i<6; i++){
1964 init_vlc(&run_vlc[i], RUN_VLC_BITS, 7, 2002 run_vlc[i].table = run_vlc_tables[i];
2003 run_vlc[i].table_allocated = run_vlc_tables_size;
2004 init_vlc(&run_vlc[i],
2005 RUN_VLC_BITS, 7,
1965 &run_len [i][0], 1, 1, 2006 &run_len [i][0], 1, 1,
1966 &run_bits[i][0], 1, 1, 1); 2007 &run_bits[i][0], 1, 1,
1967 } 2008 INIT_VLC_USE_NEW_STATIC);
2009 }
2010 run7_vlc.table = run7_vlc_table,
2011 run7_vlc.table_allocated = run7_vlc_table_size;
1968 init_vlc(&run7_vlc, RUN7_VLC_BITS, 16, 2012 init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
1969 &run_len [6][0], 1, 1, 2013 &run_len [6][0], 1, 1,
1970 &run_bits[6][0], 1, 1, 1); 2014 &run_bits[6][0], 1, 1,
2015 INIT_VLC_USE_NEW_STATIC);
1971 } 2016 }
1972 } 2017 }
1973 2018
1974 static void free_tables(H264Context *h){ 2019 static void free_tables(H264Context *h){
1975 int i; 2020 int i;