Mercurial > libavcodec.hg
comparison mpeg12.c @ 2370:26560d4fdb1f libavcodec
Memory leak fix patch by (Burkhard Plaum <plaum >at< ipf.uni-stuttgart )dot( de>)
author | michael |
---|---|
date | Sat, 27 Nov 2004 18:10:06 +0000 |
parents | 857e16e85aea |
children | f67b63ed036d |
comparison
equal
deleted
inserted
replaced
2369:ce47b1d51cb1 | 2370:26560d4fdb1f |
---|---|
102 | 102 |
103 static uint8_t mpeg1_index_run[2][64]; | 103 static uint8_t mpeg1_index_run[2][64]; |
104 static int8_t mpeg1_max_level[2][64]; | 104 static int8_t mpeg1_max_level[2][64]; |
105 #endif //CONFIG_ENCODERS | 105 #endif //CONFIG_ENCODERS |
106 | 106 |
107 static void init_2d_vlc_rl(RLTable *rl) | 107 static void init_2d_vlc_rl(RLTable *rl, int use_static) |
108 { | 108 { |
109 int i; | 109 int i; |
110 | 110 |
111 init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2, | 111 init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2, |
112 &rl->table_vlc[0][1], 4, 2, | 112 &rl->table_vlc[0][1], 4, 2, |
113 &rl->table_vlc[0][0], 4, 2); | 113 &rl->table_vlc[0][0], 4, 2, use_static); |
114 | 114 |
115 | 115 if(use_static) |
116 rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM)); | 116 rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM)); |
117 else | |
118 rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM)); | |
119 | |
117 for(i=0; i<rl->vlc.table_size; i++){ | 120 for(i=0; i<rl->vlc.table_size; i++){ |
118 int code= rl->vlc.table[i][0]; | 121 int code= rl->vlc.table[i][0]; |
119 int len = rl->vlc.table[i][1]; | 122 int len = rl->vlc.table[i][1]; |
120 int level, run; | 123 int level, run; |
121 | 124 |
761 int f_code; | 764 int f_code; |
762 int mv; | 765 int mv; |
763 int i; | 766 int i; |
764 | 767 |
765 done=1; | 768 done=1; |
766 init_rl(&rl_mpeg1); | 769 init_rl(&rl_mpeg1, 1); |
767 | 770 |
768 for(i=0; i<64; i++) | 771 for(i=0; i<64; i++) |
769 { | 772 { |
770 mpeg1_max_level[0][i]= rl_mpeg1.max_level[0][i]; | 773 mpeg1_max_level[0][i]= rl_mpeg1.max_level[0][i]; |
771 mpeg1_index_run[0][i]= rl_mpeg1.index_run[0][i]; | 774 mpeg1_index_run[0][i]= rl_mpeg1.index_run[0][i]; |
989 if (!done) { | 992 if (!done) { |
990 done = 1; | 993 done = 1; |
991 | 994 |
992 init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12, | 995 init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12, |
993 vlc_dc_lum_bits, 1, 1, | 996 vlc_dc_lum_bits, 1, 1, |
994 vlc_dc_lum_code, 2, 2); | 997 vlc_dc_lum_code, 2, 2, 1); |
995 init_vlc(&dc_chroma_vlc, DC_VLC_BITS, 12, | 998 init_vlc(&dc_chroma_vlc, DC_VLC_BITS, 12, |
996 vlc_dc_chroma_bits, 1, 1, | 999 vlc_dc_chroma_bits, 1, 1, |
997 vlc_dc_chroma_code, 2, 2); | 1000 vlc_dc_chroma_code, 2, 2, 1); |
998 init_vlc(&mv_vlc, MV_VLC_BITS, 17, | 1001 init_vlc(&mv_vlc, MV_VLC_BITS, 17, |
999 &mbMotionVectorTable[0][1], 2, 1, | 1002 &mbMotionVectorTable[0][1], 2, 1, |
1000 &mbMotionVectorTable[0][0], 2, 1); | 1003 &mbMotionVectorTable[0][0], 2, 1, 1); |
1001 init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36, | 1004 init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36, |
1002 &mbAddrIncrTable[0][1], 2, 1, | 1005 &mbAddrIncrTable[0][1], 2, 1, |
1003 &mbAddrIncrTable[0][0], 2, 1); | 1006 &mbAddrIncrTable[0][0], 2, 1, 1); |
1004 init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64, | 1007 init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64, |
1005 &mbPatTable[0][1], 2, 1, | 1008 &mbPatTable[0][1], 2, 1, |
1006 &mbPatTable[0][0], 2, 1); | 1009 &mbPatTable[0][0], 2, 1, 1); |
1007 | 1010 |
1008 init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, | 1011 init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, |
1009 &table_mb_ptype[0][1], 2, 1, | 1012 &table_mb_ptype[0][1], 2, 1, |
1010 &table_mb_ptype[0][0], 2, 1); | 1013 &table_mb_ptype[0][0], 2, 1, 1); |
1011 init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, | 1014 init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, |
1012 &table_mb_btype[0][1], 2, 1, | 1015 &table_mb_btype[0][1], 2, 1, |
1013 &table_mb_btype[0][0], 2, 1); | 1016 &table_mb_btype[0][0], 2, 1, 1); |
1014 init_rl(&rl_mpeg1); | 1017 init_rl(&rl_mpeg1, 1); |
1015 init_rl(&rl_mpeg2); | 1018 init_rl(&rl_mpeg2, 1); |
1016 | 1019 |
1017 init_2d_vlc_rl(&rl_mpeg1); | 1020 init_2d_vlc_rl(&rl_mpeg1, 1); |
1018 init_2d_vlc_rl(&rl_mpeg2); | 1021 init_2d_vlc_rl(&rl_mpeg2, 1); |
1019 } | 1022 } |
1020 } | 1023 } |
1021 | 1024 |
1022 static inline int get_dmv(MpegEncContext *s) | 1025 static inline int get_dmv(MpegEncContext *s) |
1023 { | 1026 { |