diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-03-14 13:19:19 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-03-14 13:19:19 +0000 |
commit | 3502a54f597a678a39679d2699a02c9fbba534f8 (patch) | |
tree | ec518ed2708e612306cbf47b11b7dc86651fdd43 /libavcodec | |
parent | efddbce9d0118ba748fadfdd801b10f141882222 (diff) | |
download | ffmpeg-3502a54f597a678a39679d2699a02c9fbba534f8.tar.gz |
kill av_mallocz_static() calls in init_rl()
Originally committed as revision 8402 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h261.c | 6 | ||||
-rw-r--r-- | libavcodec/h263.c | 18 | ||||
-rw-r--r-- | libavcodec/mpeg12.c | 10 | ||||
-rw-r--r-- | libavcodec/mpegvideo.c | 16 | ||||
-rw-r--r-- | libavcodec/msmpeg4.c | 6 | ||||
-rw-r--r-- | libavcodec/rl.h | 7 |
6 files changed, 38 insertions, 25 deletions
diff --git a/libavcodec/h261.c b/libavcodec/h261.c index 8d4ca08cd4..83f3136e3e 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -58,6 +58,8 @@ typedef struct H261Context{ int gob_start_code_skipped; // 1 if gob start code is already read before gob header is read }H261Context; +static uint8_t static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3]; + void ff_h261_loop_filter(MpegEncContext *s){ H261Context * h= (H261Context*)s; const int linesize = s->linesize; @@ -285,7 +287,7 @@ void ff_h261_encode_init(MpegEncContext *s){ if (!done) { done = 1; - init_rl(&h261_rl_tcoeff, 1); + init_rl(&h261_rl_tcoeff, static_rl_table_store); } s->min_qcoeff= -127; @@ -392,7 +394,7 @@ static void h261_decode_init_vlc(H261Context *h){ init_vlc(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63, &h261_cbp_tab[0][1], 2, 1, &h261_cbp_tab[0][0], 2, 1, 1); - init_rl(&h261_rl_tcoeff, 1); + init_rl(&h261_rl_tcoeff, static_rl_table_store); init_vlc_rl(&h261_rl_tcoeff, 1); } } diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 789ece7eac..ab662c457b 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -101,6 +101,8 @@ static uint8_t uni_h263_inter_rl_len [64*64*2*2]; //#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run) + (level)*64) #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level)) +static uint8_t static_rl_table_store[5][2][2*MAX_RUN + MAX_LEVEL + 3]; + /* mpeg4 inter max level: 24/6 @@ -2030,9 +2032,9 @@ void h263_encode_init(MpegEncContext *s) init_uni_dc_tab(); - init_rl(&rl_inter, 1); - init_rl(&rl_intra, 1); - init_rl(&rl_intra_aic, 1); + init_rl(&rl_inter, static_rl_table_store[0]); + init_rl(&rl_intra, static_rl_table_store[1]); + init_rl(&rl_intra_aic, static_rl_table_store[2]); init_uni_mpeg4_rl_tab(&rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len); init_uni_mpeg4_rl_tab(&rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len); @@ -2991,11 +2993,11 @@ void h263_decode_init_vlc(MpegEncContext *s) init_vlc(&mv_vlc, MV_VLC_BITS, 33, &mvtab[0][1], 2, 1, &mvtab[0][0], 2, 1, 1); - init_rl(&rl_inter, 1); - init_rl(&rl_intra, 1); - init_rl(&rvlc_rl_inter, 1); - init_rl(&rvlc_rl_intra, 1); - init_rl(&rl_intra_aic, 1); + init_rl(&rl_inter, static_rl_table_store[0]); + init_rl(&rl_intra, static_rl_table_store[1]); + init_rl(&rvlc_rl_inter, static_rl_table_store[3]); + init_rl(&rvlc_rl_intra, static_rl_table_store[4]); + init_rl(&rl_intra_aic, static_rl_table_store[2]); init_vlc_rl(&rl_inter, 1); init_vlc_rl(&rl_intra, 1); init_vlc_rl(&rvlc_rl_inter, 1); diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index d0a3885471..a40a65aade 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -108,6 +108,8 @@ static uint8_t mpeg1_index_run[2][64]; static int8_t mpeg1_max_level[2][64]; #endif //CONFIG_ENCODERS +static uint8_t static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; + static void init_2d_vlc_rl(RLTable *rl, int use_static) { int i; @@ -825,9 +827,9 @@ void ff_mpeg1_encode_init(MpegEncContext *s) int i; done=1; - init_rl(&rl_mpeg1, 1); + init_rl(&rl_mpeg1, static_rl_table_store[0]); if(s->intra_vlc_format) - init_rl(&rl_mpeg2, 1); + init_rl(&rl_mpeg2, static_rl_table_store[1]); for(i=0; i<64; i++) { @@ -1075,8 +1077,8 @@ static void init_vlcs(void) init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, &table_mb_btype[0][1], 2, 1, &table_mb_btype[0][0], 2, 1, 1); - init_rl(&rl_mpeg1, 1); - init_rl(&rl_mpeg2, 1); + init_rl(&rl_mpeg1, static_rl_table_store[0]); + init_rl(&rl_mpeg2, static_rl_table_store[1]); init_2d_vlc_rl(&rl_mpeg1, 1); init_2d_vlc_rl(&rl_mpeg2, 1); diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 5b4638fdfc..f0069fa1e8 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1411,14 +1411,14 @@ int MPV_encode_end(AVCodecContext *avctx) #endif //CONFIG_ENCODERS -void init_rl(RLTable *rl, int use_static) +void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]) { int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1]; uint8_t index_run[MAX_RUN+1]; int last, run, level, start, end, i; /* If table is static, we can quit if rl->max_level[0] is not NULL */ - if(use_static && rl->max_level[0]) + if(static_store && rl->max_level[0]) return; /* compute max_level[], max_run[] and index_run[] */ @@ -1444,18 +1444,18 @@ void init_rl(RLTable *rl, int use_static) if (run > max_run[level]) max_run[level] = run; } - if(use_static) - rl->max_level[last] = av_mallocz_static(MAX_RUN + 1); + if(static_store) + rl->max_level[last] = static_store[last]; else rl->max_level[last] = av_malloc(MAX_RUN + 1); memcpy(rl->max_level[last], max_level, MAX_RUN + 1); - if(use_static) - rl->max_run[last] = av_mallocz_static(MAX_LEVEL + 1); + if(static_store) + rl->max_run[last] = static_store[last] + MAX_RUN + 1; else rl->max_run[last] = av_malloc(MAX_LEVEL + 1); memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1); - if(use_static) - rl->index_run[last] = av_mallocz_static(MAX_RUN + 1); + if(static_store) + rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2; else rl->index_run[last] = av_malloc(MAX_RUN + 1); memcpy(rl->index_run[last], index_run, MAX_RUN + 1); diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index a8124172b6..62076d1409 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -91,6 +91,8 @@ int frame_count = 0; static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2]; #endif //CONFIG_ENCODERS +static uint8_t static_rl_table_store[NB_RL_TABLES][2][2*MAX_RUN + MAX_LEVEL + 3]; + static void common_init(MpegEncContext * s) { static int inited=0; @@ -186,7 +188,7 @@ void ff_msmpeg4_encode_init(MpegEncContext *s) init_mv_table(&mv_tables[0]); init_mv_table(&mv_tables[1]); for(i=0;i<NB_RL_TABLES;i++) - init_rl(&rl_table[i], 1); + init_rl(&rl_table[i], static_rl_table_store[i]); for(i=0; i<NB_RL_TABLES; i++){ int level; @@ -1051,7 +1053,7 @@ int ff_msmpeg4_decode_init(MpegEncContext *s) done = 1; for(i=0;i<NB_RL_TABLES;i++) { - init_rl(&rl_table[i], 1); + init_rl(&rl_table[i], static_rl_table_store[i]); init_vlc_rl(&rl_table[i], 1); } for(i=0;i<2;i++) { diff --git a/libavcodec/rl.h b/libavcodec/rl.h index adcde604ad..1c2aae25ae 100644 --- a/libavcodec/rl.h +++ b/libavcodec/rl.h @@ -20,7 +20,12 @@ typedef struct RLTable { RL_VLC_ELEM *rl_vlc[32]; ///< decoding only } RLTable; -void init_rl(RLTable *rl, int use_static); +/** + * + * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold + * the level and run tables, if this is NULL av_malloc() will be used + */ +void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]); void init_vlc_rl(RLTable *rl, int use_static); static inline int get_rl_index(const RLTable *rl, int last, int run, int level) |