diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-20 19:30:32 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-10-31 20:46:59 +0100 |
commit | ff886fc28200cd9aa4df5d073ff5e78c31e6160d (patch) | |
tree | 01dede7e01c13f6a9c5085ecfab7a7d54bfdd2f1 | |
parent | 5a9e185dfc8391c949a1654c95403b6710065089 (diff) | |
download | ffmpeg-ff886fc28200cd9aa4df5d073ff5e78c31e6160d.tar.gz |
avcodec/ituh263dec: Avoid superfluous VLC structures
Of all these VLCs here, only VLC.table was really used
after init, so use the ff_vlc_init_tables API
to get rid of them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/h263dec.h | 8 | ||||
-rw-r--r-- | libavcodec/ituh263dec.c | 69 | ||||
-rw-r--r-- | libavcodec/mpeg4videodec.c | 18 | ||||
-rw-r--r-- | libavcodec/msmpeg4dec.c | 12 |
4 files changed, 54 insertions, 53 deletions
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h index 9f1db72903..06ff7c1c48 100644 --- a/libavcodec/h263dec.h +++ b/libavcodec/h263dec.h @@ -33,10 +33,10 @@ #define CBPY_VLC_BITS 6 #define TEX_VLC_BITS 9 -extern VLC ff_h263_intra_MCBPC_vlc; -extern VLC ff_h263_inter_MCBPC_vlc; -extern VLC ff_h263_cbpy_vlc; -extern VLC ff_h263_mv_vlc; +extern VLCElem ff_h263_intra_MCBPC_vlc[]; +extern VLCElem ff_h263_inter_MCBPC_vlc[]; +extern VLCElem ff_h263_cbpy_vlc[]; +extern VLCElem ff_h263_mv_vlc[]; extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]; diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index f9c8476ecd..aeeda1cc42 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -99,38 +99,38 @@ void ff_h263_show_pict_info(MpegEncContext *s){ /***********************************************/ /* decoding */ -VLC ff_h263_intra_MCBPC_vlc; -VLC ff_h263_inter_MCBPC_vlc; -VLC ff_h263_cbpy_vlc; -VLC ff_h263_mv_vlc; -static VLC h263_mbtype_b_vlc; -static VLC cbpc_b_vlc; +VLCElem ff_h263_intra_MCBPC_vlc[72]; +VLCElem ff_h263_inter_MCBPC_vlc[198]; +VLCElem ff_h263_cbpy_vlc[64]; +VLCElem ff_h263_mv_vlc[538]; +static VLCElem h263_mbtype_b_vlc[80]; +static VLCElem cbpc_b_vlc[8]; /* init vlcs */ static av_cold void h263_decode_init_vlc(void) { - VLC_INIT_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, - ff_h263_intra_MCBPC_bits, 1, 1, - ff_h263_intra_MCBPC_code, 1, 1, 72); - VLC_INIT_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28, - ff_h263_inter_MCBPC_bits, 1, 1, - ff_h263_inter_MCBPC_code, 1, 1, 198); - VLC_INIT_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16, - &ff_h263_cbpy_tab[0][1], 2, 1, - &ff_h263_cbpy_tab[0][0], 2, 1, 64); - VLC_INIT_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33, - &ff_mvtab[0][1], 2, 1, - &ff_mvtab[0][0], 2, 1, 538); + VLC_INIT_STATIC_TABLE(ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, + ff_h263_intra_MCBPC_bits, 1, 1, + ff_h263_intra_MCBPC_code, 1, 1, 0); + VLC_INIT_STATIC_TABLE(ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28, + ff_h263_inter_MCBPC_bits, 1, 1, + ff_h263_inter_MCBPC_code, 1, 1, 0); + VLC_INIT_STATIC_TABLE(ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16, + &ff_h263_cbpy_tab[0][1], 2, 1, + &ff_h263_cbpy_tab[0][0], 2, 1, 0); + VLC_INIT_STATIC_TABLE(ff_h263_mv_vlc, H263_MV_VLC_BITS, 33, + &ff_mvtab[0][1], 2, 1, + &ff_mvtab[0][0], 2, 1, 0); ff_h263_init_rl_inter(); VLC_INIT_RL(ff_h263_rl_inter, 554); INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554); - VLC_INIT_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15, - &ff_h263_mbtype_b_tab[0][1], 2, 1, - &ff_h263_mbtype_b_tab[0][0], 2, 1, 80); - VLC_INIT_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4, - &ff_cbpc_b_tab[0][1], 2, 1, - &ff_cbpc_b_tab[0][0], 2, 1, 8); + VLC_INIT_STATIC_TABLE(h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15, + &ff_h263_mbtype_b_tab[0][1], 2, 1, + &ff_h263_mbtype_b_tab[0][0], 2, 1, 0); + VLC_INIT_STATIC_TABLE(cbpc_b_vlc, CBPC_B_VLC_BITS, 4, + &ff_cbpc_b_tab[0][1], 2, 1, + &ff_cbpc_b_tab[0][0], 2, 1, 0); } av_cold void ff_h263_decode_init_vlc(void) @@ -273,7 +273,7 @@ int ff_h263_resync(MpegEncContext *s){ int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code) { int code, val, sign, shift; - code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2); + code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2); if (code == 0) return pred; @@ -366,13 +366,13 @@ static void preview_obmc(MpegEncContext *s){ s->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; goto end; } - cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2); }while(cbpc == 20); if(cbpc & 4){ s->current_picture.mb_type[xy] = MB_TYPE_INTRA; }else{ - get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpc & 8) { if(s->modified_quant){ if(get_bits1(&s->gb)) skip_bits(&s->gb, 1); @@ -809,7 +809,7 @@ int ff_h263_decode_mb(MpegEncContext *s, s->mb_skipped = !(s->obmc | s->loop_filter); goto end; } - cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2); if (cbpc < 0){ av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y); return SLICE_ERROR; @@ -824,7 +824,7 @@ int ff_h263_decode_mb(MpegEncContext *s, if(s->pb_frame && get_bits1(&s->gb)) pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb); - cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpy < 0) { av_log(s->avctx, AV_LOG_ERROR, "cbpy damaged at %d %d\n", s->mb_x, s->mb_y); @@ -905,7 +905,8 @@ int ff_h263_decode_mb(MpegEncContext *s, mot_val1[1 ]= mot_val1[3 ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0; do{ - mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2); + mb_type = get_vlc2(&s->gb, h263_mbtype_b_vlc, + H263_MBTYPE_B_VLC_BITS, 2); if (mb_type < 0){ av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y); return SLICE_ERROR; @@ -917,13 +918,13 @@ int ff_h263_decode_mb(MpegEncContext *s, s->mb_intra = IS_INTRA(mb_type); if(HAS_CBP(mb_type)){ s->bdsp.clear_blocks(s->block[0]); - cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1); + cbpc = get_vlc2(&s->gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1); if(s->mb_intra){ dquant = IS_QUANT(mb_type); goto intra; } - cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpy < 0){ av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y); @@ -1009,7 +1010,7 @@ int ff_h263_decode_mb(MpegEncContext *s, s->current_picture.mb_type[xy] = mb_type; } else { /* I-Frame */ do{ - cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2); if (cbpc < 0){ av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y); return SLICE_ERROR; @@ -1034,7 +1035,7 @@ intra: if(s->pb_frame && get_bits1(&s->gb)) pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb); - cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if(cbpy<0){ av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); return SLICE_ERROR; diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 97aec68981..ff1f20d1f3 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -961,7 +961,7 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) if (show_bits(&s->gb, 19) == DC_MARKER) return mb_num - 1; - cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2); if (cbpc < 0) { av_log(s->avctx, AV_LOG_ERROR, "mcbpc corrupted at %d %d\n", s->mb_x, s->mb_y); @@ -1033,7 +1033,7 @@ try_again: continue; } - cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2); if (cbpc < 0) { av_log(s->avctx, AV_LOG_ERROR, "mcbpc corrupted at %d %d\n", s->mb_x, s->mb_y); @@ -1148,7 +1148,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count) if (s->pict_type == AV_PICTURE_TYPE_I) { int ac_pred = get_bits1(&s->gb); - int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpy < 0) { av_log(s->avctx, AV_LOG_ERROR, "cbpy corrupted at %d %d\n", s->mb_x, s->mb_y); @@ -1162,7 +1162,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count) int i; int dir = 0; int ac_pred = get_bits1(&s->gb); - int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpy < 0) { av_log(s->avctx, AV_LOG_ERROR, @@ -1194,7 +1194,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count) s->current_picture.qscale_table[xy] = s->qscale; s->cbp_table[xy] = 0; } else { - int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpy < 0) { av_log(s->avctx, AV_LOG_ERROR, @@ -1690,7 +1690,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) } goto end; } - cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2); if (cbpc < 0) { av_log(s->avctx, AV_LOG_ERROR, "mcbpc damaged at %d %d\n", s->mb_x, s->mb_y); @@ -1709,7 +1709,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) s->mcsel = get_bits1(&s->gb); else s->mcsel = 0; - cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1) ^ 0x0F; + cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1) ^ 0x0F; if (cbpy < 0) { av_log(s->avctx, AV_LOG_ERROR, "P cbpy damaged at %d %d\n", s->mb_x, s->mb_y); @@ -1952,7 +1952,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) int use_intra_dc_vlc; do { - cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); + cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2); if (cbpc < 0) { av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y); @@ -1970,7 +1970,7 @@ intra: else s->current_picture.mb_type[xy] = MB_TYPE_INTRA; - cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (cbpy < 0) { av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index a81241b1bb..e61045c2f9 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -75,7 +75,7 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) { int code, val, sign, shift; - code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2); + code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2); ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred); if (code < 0) return 0xffff; @@ -127,7 +127,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) if(s->msmpeg4_version==2) code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1); else - code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); + code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2); if(code<0 || code>7){ av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y); return -1; @@ -141,7 +141,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) if(s->msmpeg4_version==2) cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1); else - cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); + cbp = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2); if(cbp<0 || cbp>3){ av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; @@ -151,7 +151,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) if (!s->mb_intra) { int mx, my, cbpy; - cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if(cbpy<0){ av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; @@ -173,7 +173,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) int v; if(s->msmpeg4_version==2){ s->ac_pred = get_bits1(&s->gb); - v = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (v < 0) { av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n"); return -1; @@ -181,7 +181,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) cbp|= v<<2; } else{ s->ac_pred = 0; - v = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); + v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); if (v < 0) { av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n"); return -1; |