History

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.

Andreas Rheinhardt committed 3 years ago

Commit ff886fc1 parent 5a9e1854 files · +54 −53Browse files

Unified · Split

4 files
  1. libavcodec/h263dec.h +4 −4
  2. libavcodec/ituh263dec.c +35 −34
  3. libavcodec/mpeg4videodec.c +9 −9
  4. libavcodec/msmpeg4dec.c +6 −6
libavcodec/h263dec.h+4−4
@@ -33,10 +33,10 @@ · 32 unmodified lines
3333 #define CBPY_VLC_BITS 6
3434 #define TEX_VLC_BITS 9
3535
36−extern VLC ff_h263_intra_MCBPC_vlc;
37−extern VLC ff_h263_inter_MCBPC_vlc;
38−extern VLC ff_h263_cbpy_vlc;
39−extern VLC ff_h263_mv_vlc;
36+extern VLCElem ff_h263_intra_MCBPC_vlc[];
37+extern VLCElem ff_h263_inter_MCBPC_vlc[];
38+extern VLCElem ff_h263_cbpy_vlc[];
39+extern VLCElem ff_h263_mv_vlc[];
4040
4141 extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[];
4242
libavcodec/ituh263dec.c+35−34
@@ -99,38 +99,38 @@ void ff_h263_show_pict_info(MpegEncContext *s){ · 98 unmodified lines
9999 /***********************************************/
100100 /* decoding */
101101
102−VLC ff_h263_intra_MCBPC_vlc;
103−VLC ff_h263_inter_MCBPC_vlc;
104−VLC ff_h263_cbpy_vlc;
105−VLC ff_h263_mv_vlc;
106−static VLC h263_mbtype_b_vlc;
107−static VLC cbpc_b_vlc;
102+VLCElem ff_h263_intra_MCBPC_vlc[72];
103+VLCElem ff_h263_inter_MCBPC_vlc[198];
104+VLCElem ff_h263_cbpy_vlc[64];
105+VLCElem ff_h263_mv_vlc[538];
106+static VLCElem h263_mbtype_b_vlc[80];
107+static VLCElem cbpc_b_vlc[8];
108108
109109 /* init vlcs */
110110
111111 static av_cold void h263_decode_init_vlc(void)
112112 {
113− VLC_INIT_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
114− ff_h263_intra_MCBPC_bits, 1, 1,
115− ff_h263_intra_MCBPC_code, 1, 1, 72);
116− VLC_INIT_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
117− ff_h263_inter_MCBPC_bits, 1, 1,
118− ff_h263_inter_MCBPC_code, 1, 1, 198);
119− VLC_INIT_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
120− &ff_h263_cbpy_tab[0][1], 2, 1,
121− &ff_h263_cbpy_tab[0][0], 2, 1, 64);
122− VLC_INIT_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33,
123− &ff_mvtab[0][1], 2, 1,
124− &ff_mvtab[0][0], 2, 1, 538);
113+ VLC_INIT_STATIC_TABLE(ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
114+ ff_h263_intra_MCBPC_bits, 1, 1,
115+ ff_h263_intra_MCBPC_code, 1, 1, 0);
116+ VLC_INIT_STATIC_TABLE(ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
117+ ff_h263_inter_MCBPC_bits, 1, 1,
118+ ff_h263_inter_MCBPC_code, 1, 1, 0);
119+ VLC_INIT_STATIC_TABLE(ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
120+ &ff_h263_cbpy_tab[0][1], 2, 1,
121+ &ff_h263_cbpy_tab[0][0], 2, 1, 0);
122+ VLC_INIT_STATIC_TABLE(ff_h263_mv_vlc, H263_MV_VLC_BITS, 33,
123+ &ff_mvtab[0][1], 2, 1,
124+ &ff_mvtab[0][0], 2, 1, 0);
125125 ff_h263_init_rl_inter();
126126 VLC_INIT_RL(ff_h263_rl_inter, 554);
127127 INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554);
128− VLC_INIT_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
129− &ff_h263_mbtype_b_tab[0][1], 2, 1,
130− &ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
131− VLC_INIT_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
132− &ff_cbpc_b_tab[0][1], 2, 1,
133− &ff_cbpc_b_tab[0][0], 2, 1, 8);
128+ VLC_INIT_STATIC_TABLE(h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
129+ &ff_h263_mbtype_b_tab[0][1], 2, 1,
130+ &ff_h263_mbtype_b_tab[0][0], 2, 1, 0);
131+ VLC_INIT_STATIC_TABLE(cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
132+ &ff_cbpc_b_tab[0][1], 2, 1,
133+ &ff_cbpc_b_tab[0][0], 2, 1, 0);
134134 }
135135
136136 av_cold void ff_h263_decode_init_vlc(void)
@@ -273,7 +273,7 @@ int ff_h263_resync(MpegEncContext *s){ · 136 unmodified lines
273273 int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
274274 {
275275 int code, val, sign, shift;
276− code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2);
276+ code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
277277
278278 if (code == 0)
279279 return pred;
@@ -366,13 +366,13 @@ static void preview_obmc(MpegEncContext *s){ · 86 unmodified lines
366366 s->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
367367 goto end;
368368 }
369− cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
369+ cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
370370 }while(cbpc == 20);
371371
372372 if(cbpc & 4){
373373 s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
374374 }else{
375− get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
375+ get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
376376 if (cbpc & 8) {
377377 if(s->modified_quant){
378378 if(get_bits1(&s->gb)) skip_bits(&s->gb, 1);
@@ -809,7 +809,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 430 unmodified lines
809809 s->mb_skipped = !(s->obmc | s->loop_filter);
810810 goto end;
811811 }
812− cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
812+ cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
813813 if (cbpc < 0){
814814 av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
815815 return SLICE_ERROR;
@@ -824,7 +824,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 8 unmodified lines
824824
825825 if(s->pb_frame && get_bits1(&s->gb))
826826 pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
827− cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
827+ cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
828828
829829 if (cbpy < 0) {
830830 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, · 74 unmodified lines
905905 mot_val1[1 ]= mot_val1[3 ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
906906
907907 do{
908− mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
908+ mb_type = get_vlc2(&s->gb, h263_mbtype_b_vlc,
909+ H263_MBTYPE_B_VLC_BITS, 2);
909910 if (mb_type < 0){
910911 av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
911912 return SLICE_ERROR;
@@ -917,13 +918,13 @@ int ff_h263_decode_mb(MpegEncContext *s, · 5 unmodified lines
917918 s->mb_intra = IS_INTRA(mb_type);
918919 if(HAS_CBP(mb_type)){
919920 s->bdsp.clear_blocks(s->block[0]);
920− cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
921+ cbpc = get_vlc2(&s->gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
921922 if(s->mb_intra){
922923 dquant = IS_QUANT(mb_type);
923924 goto intra;
924925 }
925926
926− cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
927+ cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
927928
928929 if (cbpy < 0){
929930 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, · 79 unmodified lines
10091010 s->current_picture.mb_type[xy] = mb_type;
10101011 } else { /* I-Frame */
10111012 do{
1012− cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
1013+ cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
10131014 if (cbpc < 0){
10141015 av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
10151016 return SLICE_ERROR;
@@ -1034,7 +1035,7 @@ intra: · 18 unmodified lines
10341035
10351036 if(s->pb_frame && get_bits1(&s->gb))
10361037 pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
1037− cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1038+ cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
10381039 if(cbpy<0){
10391040 av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
10401041 return SLICE_ERROR;
libavcodec/mpeg4videodec.c+9−9
@@ -961,7 +961,7 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) · 960 unmodified lines
961961 if (show_bits(&s->gb, 19) == DC_MARKER)
962962 return mb_num - 1;
963963
964− cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
964+ cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
965965 if (cbpc < 0) {
966966 av_log(s->avctx, AV_LOG_ERROR,
967967 "mcbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
@@ -1033,7 +1033,7 @@ try_again: · 65 unmodified lines
10331033 continue;
10341034 }
10351035
1036− cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
1036+ cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
10371037 if (cbpc < 0) {
10381038 av_log(s->avctx, AV_LOG_ERROR,
10391039 "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) · 108 unmodified lines
11481148
11491149 if (s->pict_type == AV_PICTURE_TYPE_I) {
11501150 int ac_pred = get_bits1(&s->gb);
1151− int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1151+ int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
11521152 if (cbpy < 0) {
11531153 av_log(s->avctx, AV_LOG_ERROR,
11541154 "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) · 7 unmodified lines
11621162 int i;
11631163 int dir = 0;
11641164 int ac_pred = get_bits1(&s->gb);
1165− int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1165+ int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
11661166
11671167 if (cbpy < 0) {
11681168 av_log(s->avctx, AV_LOG_ERROR,
@@ -1194,7 +1194,7 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count) · 25 unmodified lines
11941194 s->current_picture.qscale_table[xy] = s->qscale;
11951195 s->cbp_table[xy] = 0;
11961196 } else {
1197− int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1197+ int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
11981198
11991199 if (cbpy < 0) {
12001200 av_log(s->avctx, AV_LOG_ERROR,
@@ -1690,7 +1690,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 489 unmodified lines
16901690 }
16911691 goto end;
16921692 }
1693− cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
1693+ cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
16941694 if (cbpc < 0) {
16951695 av_log(s->avctx, AV_LOG_ERROR,
16961696 "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]) · 12 unmodified lines
17091709 s->mcsel = get_bits1(&s->gb);
17101710 else
17111711 s->mcsel = 0;
1712− cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1) ^ 0x0F;
1712+ cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1) ^ 0x0F;
17131713 if (cbpy < 0) {
17141714 av_log(s->avctx, AV_LOG_ERROR,
17151715 "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]) · 236 unmodified lines
19521952 int use_intra_dc_vlc;
19531953
19541954 do {
1955− cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
1955+ cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
19561956 if (cbpc < 0) {
19571957 av_log(s->avctx, AV_LOG_ERROR,
19581958 "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
@@ -1970,7 +1970,7 @@ intra: · 11 unmodified lines
19701970 else
19711971 s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
19721972
1973− cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1973+ cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
19741974 if (cbpy < 0) {
19751975 av_log(s->avctx, AV_LOG_ERROR,
19761976 "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
libavcodec/msmpeg4dec.c+6−6
@@ -75,7 +75,7 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) · 74 unmodified lines
7575 {
7676 int code, val, sign, shift;
7777
78− code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2);
78+ code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
7979 ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
8080 if (code < 0)
8181 return 0xffff;
@@ -127,7 +127,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 45 unmodified lines
127127 if(s->msmpeg4_version==2)
128128 code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
129129 else
130− code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
130+ code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
131131 if(code<0 || code>7){
132132 av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
133133 return -1;
@@ -141,7 +141,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 7 unmodified lines
141141 if(s->msmpeg4_version==2)
142142 cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
143143 else
144− cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
144+ cbp = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
145145 if(cbp<0 || cbp>3){
146146 av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
147147 return -1;
@@ -151,7 +151,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 3 unmodified lines
151151 if (!s->mb_intra) {
152152 int mx, my, cbpy;
153153
154− cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
154+ cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
155155 if(cbpy<0){
156156 av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
157157 return -1;
@@ -173,7 +173,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 15 unmodified lines
173173 int v;
174174 if(s->msmpeg4_version==2){
175175 s->ac_pred = get_bits1(&s->gb);
176− v = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
176+ v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
177177 if (v < 0) {
178178 av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
179179 return -1;
@@ -181,7 +181,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 1 unmodified line
181181 cbp|= v<<2;
182182 } else{
183183 s->ac_pred = 0;
184− v = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
184+ v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
185185 if (v < 0) {
186186 av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
187187 return -1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t