FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/msmpeg4dec.c
Date: 2024-04-19 17:50:32
Exec Total Coverage
Lines: 405 465 87.1%
Functions: 11 11 100.0%
Branches: 211 274 77.0%

Line Branch Exec Source
1 /*
2 * MSMPEG4 backend for encoder and decoder
3 * Copyright (c) 2001 Fabrice Bellard
4 * Copyright (c) 2002-2013 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "libavutil/thread.h"
26
27 #include "avcodec.h"
28 #include "codec_internal.h"
29 #include "mpegutils.h"
30 #include "mpegvideo.h"
31 #include "msmpeg4.h"
32 #include "msmpeg4dec.h"
33 #include "libavutil/imgutils.h"
34 #include "h263.h"
35 #include "h263data.h"
36 #include "h263dec.h"
37 #include "mpeg4videodec.h"
38 #include "msmpeg4data.h"
39 #include "msmpeg4_vc1_data.h"
40
41 #define V2_INTRA_CBPC_VLC_BITS 3
42 #define V2_MB_TYPE_VLC_BITS 7
43 #define MV_VLC_BITS 9
44 #define TEX_VLC_BITS 9
45
46 #define DEFAULT_INTER_INDEX 3
47
48 5490 static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
49 int32_t **dc_val_ptr)
50 {
51 int i;
52
53
2/2
✓ Branch 0 taken 3660 times.
✓ Branch 1 taken 1830 times.
5490 if (n < 4) {
54 3660 i= 0;
55 } else {
56 1830 i= n-3;
57 }
58
59 5490 *dc_val_ptr= &s->last_dc[i];
60 5490 return s->last_dc[i];
61 }
62
63 /****************************************/
64 /* decoding stuff */
65
66 const VLCElem *ff_mb_non_intra_vlc[4];
67 static VLCElem v2_dc_lum_vlc[1472];
68 static VLCElem v2_dc_chroma_vlc[1506];
69 static VLCElem v2_intra_cbpc_vlc[8];
70 static VLCElem v2_mb_type_vlc[128];
71 VLCElem ff_inter_intra_vlc[8];
72
73 /* This is identical to H.263 except that its range is multiplied by 2. */
74 132268 static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
75 {
76 int code, val, sign, shift;
77
78 132268 code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
79 ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
80
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132268 times.
132268 if (code < 0)
81 return 0xffff;
82
83
2/2
✓ Branch 0 taken 68571 times.
✓ Branch 1 taken 63697 times.
132268 if (code == 0)
84 68571 return pred;
85 63697 sign = get_bits1(&s->gb);
86 63697 shift = f_code - 1;
87 63697 val = code;
88
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63697 times.
63697 if (shift) {
89 val = (val - 1) << shift;
90 val |= get_bits(&s->gb, shift);
91 val++;
92 }
93
2/2
✓ Branch 0 taken 26289 times.
✓ Branch 1 taken 37408 times.
63697 if (sign)
94 26289 val = -val;
95
96 63697 val += pred;
97
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 63559 times.
63697 if (val <= -64)
98 138 val += 64;
99
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 63546 times.
63559 else if (val >= 64)
100 13 val -= 64;
101
102 63697 return val;
103 }
104
105 76350 static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
106 {
107 int cbp, code, i;
108 76350 uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
109
110
2/2
✓ Branch 0 taken 70035 times.
✓ Branch 1 taken 6315 times.
76350 if (s->pict_type == AV_PICTURE_TYPE_P) {
111
1/2
✓ Branch 0 taken 70035 times.
✗ Branch 1 not taken.
70035 if (s->use_skip_mb_code) {
112
2/2
✓ Branch 1 taken 1159 times.
✓ Branch 2 taken 68876 times.
70035 if (get_bits1(&s->gb)) {
113 /* skip mb */
114 1159 s->mb_intra = 0;
115
2/2
✓ Branch 0 taken 6954 times.
✓ Branch 1 taken 1159 times.
8113 for(i=0;i<6;i++)
116 6954 s->block_last_index[i] = -1;
117 1159 s->mv_dir = MV_DIR_FORWARD;
118 1159 s->mv_type = MV_TYPE_16X16;
119 1159 s->mv[0][0][0] = 0;
120 1159 s->mv[0][0][1] = 0;
121 1159 s->mb_skipped = 1;
122 1159 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
123 1159 return 0;
124 }
125 }
126
127
2/2
✓ Branch 0 taken 53160 times.
✓ Branch 1 taken 15716 times.
68876 if(s->msmpeg4_version==2)
128 53160 code = get_vlc2(&s->gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
129 else
130 15716 code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
131
2/4
✓ Branch 0 taken 68876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68876 times.
68876 if(code<0 || code>7){
132 av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
133 return -1;
134 }
135
136 68876 s->mb_intra = code >>2;
137
138 68876 cbp = code & 0x3;
139 } else {
140 6315 s->mb_intra = 1;
141
2/2
✓ Branch 0 taken 5985 times.
✓ Branch 1 taken 330 times.
6315 if(s->msmpeg4_version==2)
142 5985 cbp = get_vlc2(&s->gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
143 else
144 330 cbp = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
145
2/4
✓ Branch 0 taken 6315 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6315 times.
6315 if(cbp<0 || cbp>3){
146 av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
147 return -1;
148 }
149 }
150
151
2/2
✓ Branch 0 taken 66134 times.
✓ Branch 1 taken 9057 times.
75191 if (!s->mb_intra) {
152 int mx, my, cbpy;
153
154 66134 cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66134 times.
66134 if(cbpy<0){
156 av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
157 return -1;
158 }
159
160 66134 cbp|= cbpy<<2;
161
4/4
✓ Branch 0 taken 51003 times.
✓ Branch 1 taken 15131 times.
✓ Branch 2 taken 40593 times.
✓ Branch 3 taken 10410 times.
66134 if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
162
163 66134 ff_h263_pred_motion(s, 0, 0, &mx, &my);
164 66134 mx= msmpeg4v2_decode_motion(s, mx, 1);
165 66134 my= msmpeg4v2_decode_motion(s, my, 1);
166
167 66134 s->mv_dir = MV_DIR_FORWARD;
168 66134 s->mv_type = MV_TYPE_16X16;
169 66134 s->mv[0][0][0] = mx;
170 66134 s->mv[0][0][1] = my;
171 66134 *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
172 } else {
173 int v;
174
2/2
✓ Branch 0 taken 8142 times.
✓ Branch 1 taken 915 times.
9057 if(s->msmpeg4_version==2){
175 8142 s->ac_pred = get_bits1(&s->gb);
176 8142 v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8142 times.
8142 if (v < 0) {
178 av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
179 return -1;
180 }
181 8142 cbp|= v<<2;
182 } else{
183 915 s->ac_pred = 0;
184 915 v = get_vlc2(&s->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 915 times.
915 if (v < 0) {
186 av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
187 return -1;
188 }
189 915 cbp|= v<<2;
190
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 330 times.
915 if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
191 }
192 9057 *mb_type_ptr = MB_TYPE_INTRA;
193 }
194
195 75191 s->bdsp.clear_blocks(s->block[0]);
196
2/2
✓ Branch 0 taken 451146 times.
✓ Branch 1 taken 75191 times.
526337 for (i = 0; i < 6; i++) {
197
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 451146 times.
451146 if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
198 {
199 av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
200 return -1;
201 }
202 }
203 75191 return 0;
204 }
205
206 129600 static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
207 {
208 int cbp, code, i;
209 uint8_t *coded_val;
210 129600 uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
211
212
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 129600 times.
129600 if (get_bits_left(&s->gb) <= 0)
213 return AVERROR_INVALIDDATA;
214
215
2/2
✓ Branch 0 taken 116442 times.
✓ Branch 1 taken 13158 times.
129600 if (s->pict_type == AV_PICTURE_TYPE_P) {
216
1/2
✓ Branch 0 taken 116442 times.
✗ Branch 1 not taken.
116442 if (s->use_skip_mb_code) {
217
2/2
✓ Branch 1 taken 1554 times.
✓ Branch 2 taken 114888 times.
116442 if (get_bits1(&s->gb)) {
218 /* skip mb */
219 1554 s->mb_intra = 0;
220
2/2
✓ Branch 0 taken 9324 times.
✓ Branch 1 taken 1554 times.
10878 for(i=0;i<6;i++)
221 9324 s->block_last_index[i] = -1;
222 1554 s->mv_dir = MV_DIR_FORWARD;
223 1554 s->mv_type = MV_TYPE_16X16;
224 1554 s->mv[0][0][0] = 0;
225 1554 s->mv[0][0][1] = 0;
226 1554 s->mb_skipped = 1;
227 1554 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
228
229 1554 return 0;
230 }
231 }
232
233 114888 code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX], MB_NON_INTRA_VLC_BITS, 3);
234 //s->mb_intra = (code & 0x40) ? 0 : 1;
235 114888 s->mb_intra = (~code & 0x40) >> 6;
236
237 114888 cbp = code & 0x3f;
238 } else {
239 13158 s->mb_intra = 1;
240 13158 code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 2);
241 /* predict coded block pattern */
242 13158 cbp = 0;
243
2/2
✓ Branch 0 taken 78948 times.
✓ Branch 1 taken 13158 times.
92106 for(i=0;i<6;i++) {
244 78948 int val = ((code >> (5 - i)) & 1);
245
2/2
✓ Branch 0 taken 52632 times.
✓ Branch 1 taken 26316 times.
78948 if (i < 4) {
246 52632 int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
247 52632 val = val ^ pred;
248 52632 *coded_val = val;
249 }
250 78948 cbp |= val << (5 - i);
251 }
252 }
253
254
2/2
✓ Branch 0 taken 109652 times.
✓ Branch 1 taken 18394 times.
128046 if (!s->mb_intra) {
255 int mx, my;
256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109652 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109652 if(s->per_mb_rl_table && cbp){
257 s->rl_table_index = decode012(&s->gb);
258 s->rl_chroma_table_index = s->rl_table_index;
259 }
260 109652 ff_h263_pred_motion(s, 0, 0, &mx, &my);
261 109652 ff_msmpeg4_decode_motion(s, &mx, &my);
262 109652 s->mv_dir = MV_DIR_FORWARD;
263 109652 s->mv_type = MV_TYPE_16X16;
264 109652 s->mv[0][0][0] = mx;
265 109652 s->mv[0][0][1] = my;
266 109652 *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
267 } else {
268 ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
269 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
270 show_bits(&s->gb, 24));
271 18394 s->ac_pred = get_bits1(&s->gb);
272 18394 *mb_type_ptr = MB_TYPE_INTRA;
273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18394 times.
18394 if(s->inter_intra_pred){
274 s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1);
275 ff_dlog(s, "%d%d %d %d/",
276 s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
277 }
278
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18394 if(s->per_mb_rl_table && cbp){
279 s->rl_table_index = decode012(&s->gb);
280 s->rl_chroma_table_index = s->rl_table_index;
281 }
282 }
283
284 128046 s->bdsp.clear_blocks(s->block[0]);
285
2/2
✓ Branch 0 taken 768276 times.
✓ Branch 1 taken 128046 times.
896322 for (i = 0; i < 6; i++) {
286
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 768276 times.
768276 if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
287 {
288 av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
289 return -1;
290 }
291 }
292
293 128046 return 0;
294 }
295
296 /* init all vlc decoding tables */
297 26 static av_cold void msmpeg4_decode_init_static(void)
298 {
299 static VLCElem vlc_buf[3714 + 2694 + 1636 + 2648 + 1532 + 2488];
300 26 VLCInitState state = VLC_INIT_STATE(vlc_buf);
301 MVTable *mv;
302
303 26 INIT_FIRST_VLC_RL(ff_rl_table[0], 642);
304 26 INIT_FIRST_VLC_RL(ff_rl_table[1], 1104);
305 26 INIT_FIRST_VLC_RL(ff_rl_table[2], 554);
306
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 26 times.
858 VLC_INIT_RL(ff_rl_table[3], 940);
307
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 26 times.
858 VLC_INIT_RL(ff_rl_table[4], 962);
308 /* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been
309 * initialized in ff_h263_decode_init() earlier. So just copy the VLCs. */
310 av_assert1(ff_h263_rl_inter.rl_vlc[0]);
311 26 memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
312
313 26 VLC_INIT_STATIC_TABLE(v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 512,
314 &ff_v2_dc_lum_table[0][1], 8, 4,
315 &ff_v2_dc_lum_table[0][0], 8, 4, 0);
316 26 VLC_INIT_STATIC_TABLE(v2_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 512,
317 &ff_v2_dc_chroma_table[0][1], 8, 4,
318 &ff_v2_dc_chroma_table[0][0], 8, 4, 0);
319
320 26 VLC_INIT_STATIC_TABLE(v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
321 &ff_v2_intra_cbpc[0][1], 2, 1,
322 &ff_v2_intra_cbpc[0][0], 2, 1, 0);
323 26 VLC_INIT_STATIC_TABLE(v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
324 &ff_v2_mb_type[0][1], 2, 1,
325 &ff_v2_mb_type[0][0], 2, 1, 0);
326
327 26 mv = &ff_mv_tables[0];
328 52 mv->vlc = ff_vlc_init_tables_sparse(&state, MV_VLC_BITS,
329 MSMPEG4_MV_TABLES_NB_ELEMS + 1,
330 26 mv->table_mv_bits, 1, 1,
331 26 mv->table_mv_code, 2, 2,
332 NULL, 0, 0, 0);
333 26 mv = &ff_mv_tables[1];
334 52 mv->vlc = ff_vlc_init_tables_sparse(&state, MV_VLC_BITS,
335 MSMPEG4_MV_TABLES_NB_ELEMS + 1,
336 26 mv->table_mv_bits, 1, 1,
337 26 mv->table_mv_code, 2, 2,
338 NULL, 0, 0, 0);
339
340
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
130 for (unsigned i = 0; i < 4; i++) {
341 104 ff_mb_non_intra_vlc[i] =
342 104 ff_vlc_init_tables_sparse(&state, MB_NON_INTRA_VLC_BITS, 128,
343 104 &ff_wmv2_inter_table[i][0][1], 8, 4,
344 104 &ff_wmv2_inter_table[i][0][0], 8, 4,
345 NULL, 0, 0, 0);
346 }
347
348 26 VLC_INIT_STATIC_TABLE(ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
349 &ff_table_inter_intra[0][1], 2, 1,
350 &ff_table_inter_intra[0][0], 2, 1, 0);
351 26 ff_msmp4_vc1_vlcs_init_once();
352 26 }
353
354 45 av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
355 {
356 static AVOnce init_static_once = AV_ONCE_INIT;
357 45 MpegEncContext *s = avctx->priv_data;
358 int ret;
359
360
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
45 if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
361 return ret;
362
363
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
45 if (ff_h263_decode_init(avctx) < 0)
364 return -1;
365
366 45 ff_msmpeg4_common_init(s);
367
368
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
45 switch(s->msmpeg4_version){
369 11 case 1:
370 case 2:
371 11 s->decode_mb= msmpeg4v12_decode_mb;
372 11 break;
373 22 case 3:
374 case 4:
375 22 s->decode_mb= msmpeg4v34_decode_mb;
376 22 break;
377 12 case 5:
378 12 break;
379 }
380
381 45 s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
382
383 45 ff_thread_once(&init_static_once, msmpeg4_decode_init_static);
384
385 45 return 0;
386 }
387
388 675 int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
389 {
390 int code;
391
392 // at minimum one bit per macroblock is required at least in a valid frame,
393 // we discard frames much smaller than this. Frames smaller than 1/8 of the
394 // smallest "black/skip" frame generally contain not much recoverable content
395 // while at the same time they have the highest computational requirements
396 // per byte
397
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
675 if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
398 return AVERROR_INVALIDDATA;
399
400
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 625 times.
675 if(s->msmpeg4_version==1){
401 50 int start_code = get_bits_long(&s->gb, 32);
402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(start_code!=0x00000100){
403 av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
404 return -1;
405 }
406
407 50 skip_bits(&s->gb, 5); // frame number */
408 }
409
410 675 s->pict_type = get_bits(&s->gb, 2) + 1;
411
2/2
✓ Branch 0 taken 611 times.
✓ Branch 1 taken 64 times.
675 if (s->pict_type != AV_PICTURE_TYPE_I &&
412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 s->pict_type != AV_PICTURE_TYPE_P){
413 av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
414 return -1;
415 }
416 675 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675 times.
675 if(s->qscale==0){
418 av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
419 return -1;
420 }
421
422
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 611 times.
675 if (s->pict_type == AV_PICTURE_TYPE_I) {
423 64 code = get_bits(&s->gb, 5);
424
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 63 times.
64 if(s->msmpeg4_version==1){
425
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(code==0 || code>s->mb_height){
426 av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
427 return -1;
428 }
429
430 1 s->slice_height = code;
431 }else{
432 /* 0x17: one slice, 0x18: two slices, ... */
433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if (code < 0x17){
434 av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
435 return -1;
436 }
437
438 63 s->slice_height = s->mb_height / (code - 0x16);
439 }
440
441
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
64 switch(s->msmpeg4_version){
442 21 case 1:
443 case 2:
444 21 s->rl_chroma_table_index = 2;
445 21 s->rl_table_index = 2;
446
447 21 s->dc_table_index = 0; //not used
448 21 break;
449 23 case 3:
450 23 s->rl_chroma_table_index = decode012(&s->gb);
451 23 s->rl_table_index = decode012(&s->gb);
452
453 23 s->dc_table_index = get_bits1(&s->gb);
454 23 break;
455 20 case 4:
456 20 ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
457
458
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
459 else s->per_mb_rl_table= 0;
460
461
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!s->per_mb_rl_table){
462 20 s->rl_chroma_table_index = decode012(&s->gb);
463 20 s->rl_table_index = decode012(&s->gb);
464 }
465
466 20 s->dc_table_index = get_bits1(&s->gb);
467 20 s->inter_intra_pred= 0;
468 20 break;
469 }
470 64 s->no_rounding = 1;
471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s->avctx->debug&FF_DEBUG_PICT_INFO)
472 av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
473 s->qscale,
474 s->rl_chroma_table_index,
475 s->rl_table_index,
476 s->dc_table_index,
477 s->per_mb_rl_table,
478 s->slice_height);
479 } else {
480
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
611 switch(s->msmpeg4_version){
481 229 case 1:
482 case 2:
483
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 180 times.
229 if(s->msmpeg4_version==1)
484 49 s->use_skip_mb_code = 1;
485 else
486 180 s->use_skip_mb_code = get_bits1(&s->gb);
487 229 s->rl_table_index = 2;
488 229 s->rl_chroma_table_index = s->rl_table_index;
489 229 s->dc_table_index = 0; //not used
490 229 s->mv_table_index = 0;
491 229 break;
492 202 case 3:
493 202 s->use_skip_mb_code = get_bits1(&s->gb);
494 202 s->rl_table_index = decode012(&s->gb);
495 202 s->rl_chroma_table_index = s->rl_table_index;
496
497 202 s->dc_table_index = get_bits1(&s->gb);
498
499 202 s->mv_table_index = get_bits1(&s->gb);
500 202 break;
501 180 case 4:
502 180 s->use_skip_mb_code = get_bits1(&s->gb);
503
504
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
505 else s->per_mb_rl_table= 0;
506
507
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!s->per_mb_rl_table){
508 180 s->rl_table_index = decode012(&s->gb);
509 180 s->rl_chroma_table_index = s->rl_table_index;
510 }
511
512 180 s->dc_table_index = get_bits1(&s->gb);
513
514 180 s->mv_table_index = get_bits1(&s->gb);
515
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
180 s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
516 180 break;
517 }
518
519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 if(s->avctx->debug&FF_DEBUG_PICT_INFO)
520 av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
521 s->use_skip_mb_code,
522 s->rl_table_index,
523 s->rl_chroma_table_index,
524 s->dc_table_index,
525 s->mv_table_index,
526 s->per_mb_rl_table,
527 s->qscale);
528
529
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 229 times.
611 if(s->flipflop_rounding){
530 382 s->no_rounding ^= 1;
531 }else{
532 229 s->no_rounding = 0;
533 }
534 }
535 ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
536 s->inter_intra_pred, s->width, s->height);
537
538 675 s->esc3_level_length= 0;
539 675 s->esc3_run_length= 0;
540
541 675 return 0;
542 }
543
544 64 int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
545 {
546 64 int left= buf_size*8 - get_bits_count(&s->gb);
547
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 21 times.
64 int length= s->msmpeg4_version>=3 ? 17 : 16;
548 /* the alt_bitstream reader could read over the end so we need to check it */
549
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
64 if(left>=length && left<length+8)
550 {
551 63 skip_bits(&s->gb, 5); /* fps */
552 63 s->bit_rate= get_bits(&s->gb, 11)*1024;
553
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 20 times.
63 if(s->msmpeg4_version>=3)
554 43 s->flipflop_rounding= get_bits1(&s->gb);
555 else
556 20 s->flipflop_rounding= 0;
557 }
558
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else if(left<length+8)
559 {
560 1 s->flipflop_rounding= 0;
561
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(s->msmpeg4_version != 2)
562 1 av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
563 }
564 else
565 {
566 av_log(s->avctx, AV_LOG_ERROR, "I-frame too long, ignoring ext header\n");
567 }
568
569 64 return 0;
570 }
571
572 230712 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
573 {
574 int level, pred;
575
576
2/2
✓ Branch 0 taken 54342 times.
✓ Branch 1 taken 176370 times.
230712 if(s->msmpeg4_version<=2){
577
2/2
✓ Branch 0 taken 36228 times.
✓ Branch 1 taken 18114 times.
54342 if (n < 4) {
578 36228 level = get_vlc2(&s->gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
579 } else {
580 18114 level = get_vlc2(&s->gb, v2_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 3);
581 }
582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54342 times.
54342 if (level < 0) {
583 av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
584 *dir_ptr = 0;
585 return -1;
586 }
587 54342 level-=256;
588 } else {
589 176370 level = get_vlc2(&s->gb, ff_msmp4_dc_vlc[s->dc_table_index][n >= 4],
590 MSMP4_DC_VLC_BITS, 3);
591
592
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 176322 times.
176370 if (level == DC_MAX) {
593 48 level = get_bits(&s->gb, 8);
594
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 42 times.
48 if (get_bits1(&s->gb))
595 6 level = -level;
596
2/2
✓ Branch 0 taken 153813 times.
✓ Branch 1 taken 22509 times.
176322 } else if (level != 0) {
597
2/2
✓ Branch 1 taken 74512 times.
✓ Branch 2 taken 79301 times.
153813 if (get_bits1(&s->gb))
598 74512 level = -level;
599 }
600 }
601
602
2/2
✓ Branch 0 taken 5490 times.
✓ Branch 1 taken 225222 times.
230712 if(s->msmpeg4_version==1){
603 int32_t *dc_val;
604 5490 pred = msmpeg4v1_pred_dc(s, n, &dc_val);
605 5490 level += pred;
606
607 /* update predictor */
608 5490 *dc_val= level;
609 }else{
610 int16_t *dc_val;
611 225222 pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
612 225222 level += pred;
613
614 /* update predictor */
615
2/2
✓ Branch 0 taken 150148 times.
✓ Branch 1 taken 75074 times.
225222 if (n < 4) {
616 150148 *dc_val = level * s->y_dc_scale;
617 } else {
618 75074 *dc_val = level * s->c_dc_scale;
619 }
620 }
621
622 230712 return level;
623 }
624
625 1472610 int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
626 int n, int coded, const uint8_t *scan_table)
627 {
628 int level, i, last, run, run_diff;
629 1472610 int av_uninit(dc_pred_dir);
630 RLTable *rl;
631 RL_VLC_ELEM *rl_vlc;
632 int qmul, qadd;
633
634
2/2
✓ Branch 0 taken 230712 times.
✓ Branch 1 taken 1241898 times.
1472610 if (s->mb_intra) {
635 230712 qmul=1;
636 230712 qadd=0;
637
638 /* DC coef */
639 230712 level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
640
641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 230712 times.
230712 if (level < 0){
642 av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
643 if(s->inter_intra_pred) level=0;
644 }
645
2/2
✓ Branch 0 taken 153808 times.
✓ Branch 1 taken 76904 times.
230712 if (n < 4) {
646 153808 rl = &ff_rl_table[s->rl_table_index];
647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153808 times.
153808 if(level > 256*s->y_dc_scale){
648 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
649 if(!s->inter_intra_pred) return -1;
650 }
651 } else {
652 76904 rl = &ff_rl_table[3 + s->rl_chroma_table_index];
653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76904 times.
76904 if(level > 256*s->c_dc_scale){
654 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
655 if(!s->inter_intra_pred) return -1;
656 }
657 }
658 230712 block[0] = level;
659
660 230712 run_diff = s->msmpeg4_version >= 4;
661 230712 i = 0;
662
2/2
✓ Branch 0 taken 42456 times.
✓ Branch 1 taken 188256 times.
230712 if (!coded) {
663 42456 goto not_coded;
664 }
665
2/2
✓ Branch 0 taken 3224 times.
✓ Branch 1 taken 185032 times.
188256 if (s->ac_pred) {
666
2/2
✓ Branch 0 taken 1928 times.
✓ Branch 1 taken 1296 times.
3224 if (dc_pred_dir == 0)
667 1928 scan_table = s->permutated_intra_v_scantable; /* left */
668 else
669 1296 scan_table = s->permutated_intra_h_scantable; /* top */
670 } else {
671 185032 scan_table = s->intra_scantable.permutated;
672 }
673 188256 rl_vlc= rl->rl_vlc[0];
674 } else {
675 1241898 qmul = s->qscale << 1;
676 1241898 qadd = (s->qscale - 1) | 1;
677 1241898 i = -1;
678 1241898 rl = &ff_rl_table[3 + s->rl_table_index];
679
680
2/2
✓ Branch 0 taken 306018 times.
✓ Branch 1 taken 935880 times.
1241898 if(s->msmpeg4_version==2)
681 306018 run_diff = 0;
682 else
683 935880 run_diff = 1;
684
685
2/2
✓ Branch 0 taken 633723 times.
✓ Branch 1 taken 608175 times.
1241898 if (!coded) {
686 633723 s->block_last_index[n] = i;
687 633723 return 0;
688 }
689
2/2
✓ Branch 0 taken 420993 times.
✓ Branch 1 taken 187182 times.
608175 if(!scan_table)
690 420993 scan_table = s->inter_scantable.permutated;
691 608175 rl_vlc= rl->rl_vlc[s->qscale];
692 }
693 {
694 796431 OPEN_READER(re, &s->gb);
695 for(;;) {
696 9175903 UPDATE_CACHE(re, &s->gb);
697
2/2
✓ Branch 1 taken 297834 times.
✓ Branch 2 taken 4688333 times.
4986167 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
698
2/2
✓ Branch 0 taken 162066 times.
✓ Branch 1 taken 4824101 times.
4986167 if (level==0) {
699 int cache;
700 162066 cache= GET_CACHE(re, &s->gb);
701 /* escape */
702
4/4
✓ Branch 0 taken 140175 times.
✓ Branch 1 taken 21891 times.
✓ Branch 2 taken 74501 times.
✓ Branch 3 taken 65674 times.
162066 if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
703
4/4
✓ Branch 0 taken 74501 times.
✓ Branch 1 taken 21891 times.
✓ Branch 2 taken 19659 times.
✓ Branch 3 taken 54842 times.
96392 if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
704 /* third escape */
705
2/2
✓ Branch 0 taken 19659 times.
✓ Branch 1 taken 21891 times.
41550 if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
706 41550 UPDATE_CACHE(re, &s->gb);
707
2/2
✓ Branch 0 taken 34734 times.
✓ Branch 1 taken 6816 times.
41550 if(s->msmpeg4_version<=3){
708 34734 last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
709 34734 run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
710 34734 level= SHOW_SBITS(re, &s->gb, 8);
711 34734 SKIP_COUNTER(re, &s->gb, 1+6+8);
712 }else{
713 int sign;
714 6816 last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
715
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 6432 times.
6816 if(!s->esc3_level_length){
716 int ll;
717 ff_dlog(s->avctx, "ESC-3 %X at %d %d\n",
718 show_bits(&s->gb, 24), s->mb_x, s->mb_y);
719
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 306 times.
384 if(s->qscale<8){
720 78 ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if(ll==0){
722 ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
723 }
724 }else{
725 306 ll=2;
726
4/4
✓ Branch 0 taken 1734 times.
✓ Branch 1 taken 280 times.
✓ Branch 3 taken 1708 times.
✓ Branch 4 taken 26 times.
2014 while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
727 1708 ll++;
728 1708 SKIP_BITS(re, &s->gb, 1);
729 }
730
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 280 times.
306 if(ll<8) SKIP_BITS(re, &s->gb, 1);
731 }
732
733 384 s->esc3_level_length= ll;
734 384 s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
735 384 UPDATE_CACHE(re, &s->gb);
736 }
737 6816 run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
738 6816 SKIP_BITS(re, &s->gb, s->esc3_run_length);
739
740 6816 sign= SHOW_UBITS(re, &s->gb, 1);
741 6816 SKIP_BITS(re, &s->gb, 1);
742
743 6816 level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
744 6816 SKIP_BITS(re, &s->gb, s->esc3_level_length);
745
2/2
✓ Branch 0 taken 3395 times.
✓ Branch 1 taken 3421 times.
6816 if(sign) level= -level;
746 }
747
748 //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
749
2/2
✓ Branch 0 taken 20943 times.
✓ Branch 1 taken 20607 times.
41550 if (level>0) level= level * qmul + qadd;
750 20607 else level= level * qmul - qadd;
751 41550 i+= run + 1;
752
2/2
✓ Branch 0 taken 18888 times.
✓ Branch 1 taken 22662 times.
41550 if(last) i+=192;
753 } else {
754 /* second escape */
755 54842 SKIP_BITS(re, &s->gb, 2);
756
2/2
✓ Branch 1 taken 7490 times.
✓ Branch 2 taken 47352 times.
54842 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
757 54842 i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
758 54842 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
759 54842 LAST_SKIP_BITS(re, &s->gb, 1);
760 }
761 } else {
762 /* first escape */
763 65674 SKIP_BITS(re, &s->gb, 1);
764
2/2
✓ Branch 1 taken 8895 times.
✓ Branch 2 taken 56779 times.
65674 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
765 65674 i+= run;
766 65674 level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
767 65674 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
768 65674 LAST_SKIP_BITS(re, &s->gb, 1);
769 }
770 } else {
771 4824101 i+= run;
772 4824101 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
773 4824101 LAST_SKIP_BITS(re, &s->gb, 1);
774 }
775
2/2
✓ Branch 0 taken 796431 times.
✓ Branch 1 taken 4189736 times.
4986167 if (i > 62){
776 796431 i-= 192;
777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796431 times.
796431 if(i&(~63)){
778 const int left= get_bits_left(&s->gb);
779 if (((i + 192 == 64 && level / qmul == -1) ||
780 !(s->avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))) &&
781 left >= 0) {
782 av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
783 i = 63;
784 break;
785 }else{
786 av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
787 return -1;
788 }
789 }
790
791 796431 block[scan_table[i]] = level;
792 796431 break;
793 }
794
795 4189736 block[scan_table[i]] = level;
796 }
797 796431 CLOSE_READER(re, &s->gb);
798 }
799 838887 not_coded:
800
2/2
✓ Branch 0 taken 230712 times.
✓ Branch 1 taken 608175 times.
838887 if (s->mb_intra) {
801 230712 ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
802
2/2
✓ Branch 0 taken 4194 times.
✓ Branch 1 taken 226518 times.
230712 if (s->ac_pred) {
803 4194 i = 63; /* XXX: not optimal */
804 }
805 }
806
4/4
✓ Branch 0 taken 411234 times.
✓ Branch 1 taken 427653 times.
✓ Branch 2 taken 358446 times.
✓ Branch 3 taken 52788 times.
838887 if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
807 838887 s->block_last_index[n] = i;
808
809 838887 return 0;
810 }
811
812 228076 void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
813 {
814 MVTable *mv;
815 int code, mx, my;
816
817 228076 mv = &ff_mv_tables[s->mv_table_index];
818
819 228076 code = get_vlc2(&s->gb, mv->vlc, MV_VLC_BITS, 2);
820
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 226220 times.
228076 if (code == MSMPEG4_MV_TABLES_NB_ELEMS) {
821 1856 mx = get_bits(&s->gb, 6);
822 1856 my = get_bits(&s->gb, 6);
823 } else {
824 226220 mx = mv->table_mvx[code];
825 226220 my = mv->table_mvy[code];
826 }
827
828 228076 mx += *mx_ptr - 32;
829 228076 my += *my_ptr - 32;
830 /* WARNING : they do not do exactly modulo encoding */
831
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 228054 times.
228076 if (mx <= -64)
832 22 mx += 64;
833
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 228044 times.
228054 else if (mx >= 64)
834 10 mx -= 64;
835
836
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 228070 times.
228076 if (my <= -64)
837 6 my += 64;
838
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 228066 times.
228070 else if (my >= 64)
839 4 my -= 64;
840 228076 *mx_ptr = mx;
841 228076 *my_ptr = my;
842 228076 }
843
844 const FFCodec ff_msmpeg4v1_decoder = {
845 .p.name = "msmpeg4v1",
846 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 1"),
847 .p.type = AVMEDIA_TYPE_VIDEO,
848 .p.id = AV_CODEC_ID_MSMPEG4V1,
849 .priv_data_size = sizeof(MpegEncContext),
850 .init = ff_msmpeg4_decode_init,
851 .close = ff_h263_decode_end,
852 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
853 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
854 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
855 .p.max_lowres = 3,
856 };
857
858 const FFCodec ff_msmpeg4v2_decoder = {
859 .p.name = "msmpeg4v2",
860 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 2"),
861 .p.type = AVMEDIA_TYPE_VIDEO,
862 .p.id = AV_CODEC_ID_MSMPEG4V2,
863 .priv_data_size = sizeof(MpegEncContext),
864 .init = ff_msmpeg4_decode_init,
865 .close = ff_h263_decode_end,
866 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
867 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
868 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
869 .p.max_lowres = 3,
870 };
871
872 const FFCodec ff_msmpeg4v3_decoder = {
873 .p.name = "msmpeg4",
874 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 3"),
875 .p.type = AVMEDIA_TYPE_VIDEO,
876 .p.id = AV_CODEC_ID_MSMPEG4V3,
877 .priv_data_size = sizeof(MpegEncContext),
878 .init = ff_msmpeg4_decode_init,
879 .close = ff_h263_decode_end,
880 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
881 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
882 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
883 .p.max_lowres = 3,
884 };
885
886 const FFCodec ff_wmv1_decoder = {
887 .p.name = "wmv1",
888 CODEC_LONG_NAME("Windows Media Video 7"),
889 .p.type = AVMEDIA_TYPE_VIDEO,
890 .p.id = AV_CODEC_ID_WMV1,
891 .priv_data_size = sizeof(MpegEncContext),
892 .init = ff_msmpeg4_decode_init,
893 .close = ff_h263_decode_end,
894 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
895 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
896 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
897 .p.max_lowres = 3,
898 };
899