FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
msmpeg4dec.c
Go to the documentation of this file.
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 "avcodec.h"
26 #include "internal.h"
27 #include "mpegutils.h"
28 #include "mpegvideo.h"
29 #include "msmpeg4.h"
30 #include "libavutil/imgutils.h"
31 #include "h263.h"
32 #include "mpeg4video.h"
33 #include "msmpeg4data.h"
34 #include "vc1data.h"
35 #include "wmv2.h"
36 
37 #define DC_VLC_BITS 9
38 #define V2_INTRA_CBPC_VLC_BITS 3
39 #define V2_MB_TYPE_VLC_BITS 7
40 #define MV_VLC_BITS 9
41 #define V2_MV_VLC_BITS 9
42 #define TEX_VLC_BITS 9
43 
44 #define DEFAULT_INTER_INDEX 3
45 
46 static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
47  int32_t **dc_val_ptr)
48 {
49  int i;
50 
51  if (n < 4) {
52  i= 0;
53  } else {
54  i= n-3;
55  }
56 
57  *dc_val_ptr= &s->last_dc[i];
58  return s->last_dc[i];
59 }
60 
61 /****************************************/
62 /* decoding stuff */
63 
69 static VLC v2_mv_vlc;
71 
72 /* This is identical to H.263 except that its range is multiplied by 2. */
73 static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
74 {
75  int code, val, sign, shift;
76 
77  code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2);
78  ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
79  if (code < 0)
80  return 0xffff;
81 
82  if (code == 0)
83  return pred;
84  sign = get_bits1(&s->gb);
85  shift = f_code - 1;
86  val = code;
87  if (shift) {
88  val = (val - 1) << shift;
89  val |= get_bits(&s->gb, shift);
90  val++;
91  }
92  if (sign)
93  val = -val;
94 
95  val += pred;
96  if (val <= -64)
97  val += 64;
98  else if (val >= 64)
99  val -= 64;
100 
101  return val;
102 }
103 
104 static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
105 {
106  int cbp, code, i;
107  uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
108 
109  if (s->pict_type == AV_PICTURE_TYPE_P) {
110  if (s->use_skip_mb_code) {
111  if (get_bits1(&s->gb)) {
112  /* skip mb */
113  s->mb_intra = 0;
114  for(i=0;i<6;i++)
115  s->block_last_index[i] = -1;
116  s->mv_dir = MV_DIR_FORWARD;
117  s->mv_type = MV_TYPE_16X16;
118  s->mv[0][0][0] = 0;
119  s->mv[0][0][1] = 0;
120  s->mb_skipped = 1;
121  *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
122  return 0;
123  }
124  }
125 
126  if(s->msmpeg4_version==2)
127  code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
128  else
130  if(code<0 || code>7){
131  av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
132  return -1;
133  }
134 
135  s->mb_intra = code >>2;
136 
137  cbp = code & 0x3;
138  } else {
139  s->mb_intra = 1;
140  if(s->msmpeg4_version==2)
141  cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
142  else
144  if(cbp<0 || cbp>3){
145  av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
146  return -1;
147  }
148  }
149 
150  if (!s->mb_intra) {
151  int mx, my, cbpy;
152 
154  if(cbpy<0){
155  av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
156  return -1;
157  }
158 
159  cbp|= cbpy<<2;
160  if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
161 
162  ff_h263_pred_motion(s, 0, 0, &mx, &my);
163  mx= msmpeg4v2_decode_motion(s, mx, 1);
164  my= msmpeg4v2_decode_motion(s, my, 1);
165 
166  s->mv_dir = MV_DIR_FORWARD;
167  s->mv_type = MV_TYPE_16X16;
168  s->mv[0][0][0] = mx;
169  s->mv[0][0][1] = my;
170  *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
171  } else {
172  int v;
173  if(s->msmpeg4_version==2){
174  s->ac_pred = get_bits1(&s->gb);
176  if (v < 0) {
177  av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
178  return -1;
179  }
180  cbp|= v<<2;
181  } else{
182  s->ac_pred = 0;
184  if (v < 0) {
185  av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
186  return -1;
187  }
188  cbp|= v<<2;
189  if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
190  }
191  *mb_type_ptr = MB_TYPE_INTRA;
192  }
193 
194  s->bdsp.clear_blocks(s->block[0]);
195  for (i = 0; i < 6; i++) {
196  if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
197  {
198  av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
199  return -1;
200  }
201  }
202  return 0;
203 }
204 
205 static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
206 {
207  int cbp, code, i;
208  uint8_t *coded_val;
209  uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
210 
211  if (s->pict_type == AV_PICTURE_TYPE_P) {
212  if (s->use_skip_mb_code) {
213  if (get_bits1(&s->gb)) {
214  /* skip mb */
215  s->mb_intra = 0;
216  for(i=0;i<6;i++)
217  s->block_last_index[i] = -1;
218  s->mv_dir = MV_DIR_FORWARD;
219  s->mv_type = MV_TYPE_16X16;
220  s->mv[0][0][0] = 0;
221  s->mv[0][0][1] = 0;
222  s->mb_skipped = 1;
223  *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
224 
225  return 0;
226  }
227  }
228 
229  code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
230  if (code < 0)
231  return -1;
232  //s->mb_intra = (code & 0x40) ? 0 : 1;
233  s->mb_intra = (~code & 0x40) >> 6;
234 
235  cbp = code & 0x3f;
236  } else {
237  s->mb_intra = 1;
239  if (code < 0)
240  return -1;
241  /* predict coded block pattern */
242  cbp = 0;
243  for(i=0;i<6;i++) {
244  int val = ((code >> (5 - i)) & 1);
245  if (i < 4) {
246  int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
247  val = val ^ pred;
248  *coded_val = val;
249  }
250  cbp |= val << (5 - i);
251  }
252  }
253 
254  if (!s->mb_intra) {
255  int mx, my;
256  if(s->per_mb_rl_table && cbp){
257  s->rl_table_index = decode012(&s->gb);
259  }
260  ff_h263_pred_motion(s, 0, 0, &mx, &my);
261  if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
262  return -1;
263  s->mv_dir = MV_DIR_FORWARD;
264  s->mv_type = MV_TYPE_16X16;
265  s->mv[0][0][0] = mx;
266  s->mv[0][0][1] = my;
267  *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
268  } else {
269  ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
270  ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
271  show_bits(&s->gb, 24));
272  s->ac_pred = get_bits1(&s->gb);
273  *mb_type_ptr = MB_TYPE_INTRA;
274  if(s->inter_intra_pred){
275  s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
276  ff_dlog(s, "%d%d %d %d/",
277  s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
278  }
279  if(s->per_mb_rl_table && cbp){
280  s->rl_table_index = decode012(&s->gb);
282  }
283  }
284 
285  s->bdsp.clear_blocks(s->block[0]);
286  for (i = 0; i < 6; i++) {
287  if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
288  {
289  av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
290  return -1;
291  }
292  }
293 
294  return 0;
295 }
296 
297 /* init all vlc decoding tables */
299 {
300  MpegEncContext *s = avctx->priv_data;
301  static volatile int done = 0;
302  int i, ret;
303  MVTable *mv;
304 
305  if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
306  return ret;
307 
308  if (ff_h263_decode_init(avctx) < 0)
309  return -1;
310 
312 
313  if (!done) {
314  for(i=0;i<NB_RL_TABLES;i++) {
316  }
317  INIT_VLC_RL(ff_rl_table[0], 642);
318  INIT_VLC_RL(ff_rl_table[1], 1104);
319  INIT_VLC_RL(ff_rl_table[2], 554);
320  INIT_VLC_RL(ff_rl_table[3], 940);
321  INIT_VLC_RL(ff_rl_table[4], 962);
322  INIT_VLC_RL(ff_rl_table[5], 554);
323 
324  mv = &ff_mv_tables[0];
325  INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
326  mv->table_mv_bits, 1, 1,
327  mv->table_mv_code, 2, 2, 3714);
328  mv = &ff_mv_tables[1];
329  INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
330  mv->table_mv_bits, 1, 1,
331  mv->table_mv_code, 2, 2, 2694);
332 
334  &ff_table0_dc_lum[0][1], 8, 4,
335  &ff_table0_dc_lum[0][0], 8, 4, 1158);
337  &ff_table0_dc_chroma[0][1], 8, 4,
338  &ff_table0_dc_chroma[0][0], 8, 4, 1118);
340  &ff_table1_dc_lum[0][1], 8, 4,
341  &ff_table1_dc_lum[0][0], 8, 4, 1476);
343  &ff_table1_dc_chroma[0][1], 8, 4,
344  &ff_table1_dc_chroma[0][0], 8, 4, 1216);
345 
346  INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
347  &ff_v2_dc_lum_table[0][1], 8, 4,
348  &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
349  INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
350  &ff_v2_dc_chroma_table[0][1], 8, 4,
351  &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
352 
353  INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
354  &ff_v2_intra_cbpc[0][1], 2, 1,
355  &ff_v2_intra_cbpc[0][0], 2, 1, 8);
356  INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
357  &ff_v2_mb_type[0][1], 2, 1,
358  &ff_v2_mb_type[0][0], 2, 1, 128);
359  INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
360  &ff_mvtab[0][1], 2, 1,
361  &ff_mvtab[0][0], 2, 1, 538);
362 
363  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
364  &ff_wmv2_inter_table[0][0][1], 8, 4,
365  &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
366  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
367  &ff_wmv2_inter_table[1][0][1], 8, 4,
368  &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
369  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
370  &ff_wmv2_inter_table[2][0][1], 8, 4,
371  &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
372  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
373  &ff_wmv2_inter_table[3][0][1], 8, 4,
374  &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
375 
377  &ff_msmp4_mb_i_table[0][1], 4, 2,
378  &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
379 
380  INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
381  &ff_table_inter_intra[0][1], 2, 1,
382  &ff_table_inter_intra[0][0], 2, 1, 8);
383  done = 1;
384  }
385 
386  switch(s->msmpeg4_version){
387  case 1:
388  case 2:
390  break;
391  case 3:
392  case 4:
394  break;
395  case 5:
396  if (CONFIG_WMV2_DECODER)
398  case 6:
399  //FIXME + TODO VC1 decode mb
400  break;
401  }
402 
403  s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
404 
405  return 0;
406 }
407 
409 {
410  int code;
411 
412  if(s->msmpeg4_version==1){
413  int start_code = get_bits_long(&s->gb, 32);
414  if(start_code!=0x00000100){
415  av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
416  return -1;
417  }
418 
419  skip_bits(&s->gb, 5); // frame number */
420  }
421 
422  s->pict_type = get_bits(&s->gb, 2) + 1;
423  if (s->pict_type != AV_PICTURE_TYPE_I &&
425  av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
426  return -1;
427  }
428  s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
429  if(s->qscale==0){
430  av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
431  return -1;
432  }
433 
434  if (s->pict_type == AV_PICTURE_TYPE_I) {
435  code = get_bits(&s->gb, 5);
436  if(s->msmpeg4_version==1){
437  if(code==0 || code>s->mb_height){
438  av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
439  return -1;
440  }
441 
442  s->slice_height = code;
443  }else{
444  /* 0x17: one slice, 0x18: two slices, ... */
445  if (code < 0x17){
446  av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
447  return -1;
448  }
449 
450  s->slice_height = s->mb_height / (code - 0x16);
451  }
452 
453  switch(s->msmpeg4_version){
454  case 1:
455  case 2:
456  s->rl_chroma_table_index = 2;
457  s->rl_table_index = 2;
458 
459  s->dc_table_index = 0; //not used
460  break;
461  case 3:
463  s->rl_table_index = decode012(&s->gb);
464 
465  s->dc_table_index = get_bits1(&s->gb);
466  break;
467  case 4:
468  ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
469 
471  else s->per_mb_rl_table= 0;
472 
473  if(!s->per_mb_rl_table){
475  s->rl_table_index = decode012(&s->gb);
476  }
477 
478  s->dc_table_index = get_bits1(&s->gb);
479  s->inter_intra_pred= 0;
480  break;
481  }
482  s->no_rounding = 1;
484  av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
485  s->qscale,
487  s->rl_table_index,
488  s->dc_table_index,
489  s->per_mb_rl_table,
490  s->slice_height);
491  } else {
492  switch(s->msmpeg4_version){
493  case 1:
494  case 2:
495  if(s->msmpeg4_version==1)
496  s->use_skip_mb_code = 1;
497  else
498  s->use_skip_mb_code = get_bits1(&s->gb);
499  s->rl_table_index = 2;
501  s->dc_table_index = 0; //not used
502  s->mv_table_index = 0;
503  break;
504  case 3:
505  s->use_skip_mb_code = get_bits1(&s->gb);
506  s->rl_table_index = decode012(&s->gb);
508 
509  s->dc_table_index = get_bits1(&s->gb);
510 
511  s->mv_table_index = get_bits1(&s->gb);
512  break;
513  case 4:
514  s->use_skip_mb_code = get_bits1(&s->gb);
515 
517  else s->per_mb_rl_table= 0;
518 
519  if(!s->per_mb_rl_table){
520  s->rl_table_index = decode012(&s->gb);
522  }
523 
524  s->dc_table_index = get_bits1(&s->gb);
525 
526  s->mv_table_index = get_bits1(&s->gb);
527  s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
528  break;
529  }
530 
532  av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
533  s->use_skip_mb_code,
534  s->rl_table_index,
536  s->dc_table_index,
537  s->mv_table_index,
538  s->per_mb_rl_table,
539  s->qscale);
540 
541  if(s->flipflop_rounding){
542  s->no_rounding ^= 1;
543  }else{
544  s->no_rounding = 0;
545  }
546  }
547  ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
548  s->inter_intra_pred, s->width, s->height);
549 
550  s->esc3_level_length= 0;
551  s->esc3_run_length= 0;
552 
553  return 0;
554 }
555 
557 {
558  int left= buf_size*8 - get_bits_count(&s->gb);
559  int length= s->msmpeg4_version>=3 ? 17 : 16;
560  /* the alt_bitstream reader could read over the end so we need to check it */
561  if(left>=length && left<length+8)
562  {
563  skip_bits(&s->gb, 5); /* fps */
564  s->bit_rate= get_bits(&s->gb, 11)*1024;
565  if(s->msmpeg4_version>=3)
566  s->flipflop_rounding= get_bits1(&s->gb);
567  else
568  s->flipflop_rounding= 0;
569  }
570  else if(left<length+8)
571  {
572  s->flipflop_rounding= 0;
573  if(s->msmpeg4_version != 2)
574  av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
575  }
576  else
577  {
578  av_log(s->avctx, AV_LOG_ERROR, "I-frame too long, ignoring ext header\n");
579  }
580 
581  return 0;
582 }
583 
584 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
585 {
586  int level, pred;
587 
588  if(s->msmpeg4_version<=2){
589  if (n < 4) {
590  level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
591  } else {
592  level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
593  }
594  if (level < 0) {
595  av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
596  *dir_ptr = 0;
597  return -1;
598  }
599  level-=256;
600  }else{ //FIXME optimize use unified tables & index
601  if (n < 4) {
603  } else {
605  }
606  if (level < 0){
607  av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
608  *dir_ptr = 0;
609  return -1;
610  }
611 
612  if (level == DC_MAX) {
613  level = get_bits(&s->gb, 8);
614  if (get_bits1(&s->gb))
615  level = -level;
616  } else if (level != 0) {
617  if (get_bits1(&s->gb))
618  level = -level;
619  }
620  }
621 
622  if(s->msmpeg4_version==1){
623  int32_t *dc_val;
624  pred = msmpeg4v1_pred_dc(s, n, &dc_val);
625  level += pred;
626 
627  /* update predictor */
628  *dc_val= level;
629  }else{
630  int16_t *dc_val;
631  pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
632  level += pred;
633 
634  /* update predictor */
635  if (n < 4) {
636  *dc_val = level * s->y_dc_scale;
637  } else {
638  *dc_val = level * s->c_dc_scale;
639  }
640  }
641 
642  return level;
643 }
644 
646  int n, int coded, const uint8_t *scan_table)
647 {
648  int level, i, last, run, run_diff;
649  int av_uninit(dc_pred_dir);
650  RLTable *rl;
651  RL_VLC_ELEM *rl_vlc;
652  int qmul, qadd;
653 
654  if (s->mb_intra) {
655  qmul=1;
656  qadd=0;
657 
658  /* DC coef */
659  level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
660 
661  if (level < 0){
662  av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
663  if(s->inter_intra_pred) level=0;
664  }
665  if (n < 4) {
666  rl = &ff_rl_table[s->rl_table_index];
667  if(level > 256*s->y_dc_scale){
668  av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
669  if(!s->inter_intra_pred) return -1;
670  }
671  } else {
672  rl = &ff_rl_table[3 + s->rl_chroma_table_index];
673  if(level > 256*s->c_dc_scale){
674  av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
675  if(!s->inter_intra_pred) return -1;
676  }
677  }
678  block[0] = level;
679 
680  run_diff = s->msmpeg4_version >= 4;
681  i = 0;
682  if (!coded) {
683  goto not_coded;
684  }
685  if (s->ac_pred) {
686  if (dc_pred_dir == 0)
687  scan_table = s->intra_v_scantable.permutated; /* left */
688  else
689  scan_table = s->intra_h_scantable.permutated; /* top */
690  } else {
691  scan_table = s->intra_scantable.permutated;
692  }
693  rl_vlc= rl->rl_vlc[0];
694  } else {
695  qmul = s->qscale << 1;
696  qadd = (s->qscale - 1) | 1;
697  i = -1;
698  rl = &ff_rl_table[3 + s->rl_table_index];
699 
700  if(s->msmpeg4_version==2)
701  run_diff = 0;
702  else
703  run_diff = 1;
704 
705  if (!coded) {
706  s->block_last_index[n] = i;
707  return 0;
708  }
709  if(!scan_table)
710  scan_table = s->inter_scantable.permutated;
711  rl_vlc= rl->rl_vlc[s->qscale];
712  }
713  {
714  OPEN_READER(re, &s->gb);
715  for(;;) {
716  UPDATE_CACHE(re, &s->gb);
717  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
718  if (level==0) {
719  int cache;
720  cache= GET_CACHE(re, &s->gb);
721  /* escape */
722  if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
723  if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
724  /* third escape */
725  if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
726  UPDATE_CACHE(re, &s->gb);
727  if(s->msmpeg4_version<=3){
728  last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
729  run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
730  level= SHOW_SBITS(re, &s->gb, 8);
731  SKIP_COUNTER(re, &s->gb, 1+6+8);
732  }else{
733  int sign;
734  last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
735  if(!s->esc3_level_length){
736  int ll;
737  ff_dlog(s->avctx, "ESC-3 %X at %d %d\n",
738  show_bits(&s->gb, 24), s->mb_x, s->mb_y);
739  if(s->qscale<8){
740  ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
741  if(ll==0){
742  ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
743  }
744  }else{
745  ll=2;
746  while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
747  ll++;
748  SKIP_BITS(re, &s->gb, 1);
749  }
750  if(ll<8) SKIP_BITS(re, &s->gb, 1);
751  }
752 
753  s->esc3_level_length= ll;
754  s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
755  UPDATE_CACHE(re, &s->gb);
756  }
757  run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
758  SKIP_BITS(re, &s->gb, s->esc3_run_length);
759 
760  sign= SHOW_UBITS(re, &s->gb, 1);
761  SKIP_BITS(re, &s->gb, 1);
762 
763  level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
764  SKIP_BITS(re, &s->gb, s->esc3_level_length);
765  if(sign) level= -level;
766  }
767 
768  //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
769  if (level>0) level= level * qmul + qadd;
770  else level= level * qmul - qadd;
771  i+= run + 1;
772  if(last) i+=192;
773  } else {
774  /* second escape */
775  SKIP_BITS(re, &s->gb, 2);
776  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
777  i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
778  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
779  LAST_SKIP_BITS(re, &s->gb, 1);
780  }
781  } else {
782  /* first escape */
783  SKIP_BITS(re, &s->gb, 1);
784  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
785  i+= run;
786  level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
787  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
788  LAST_SKIP_BITS(re, &s->gb, 1);
789  }
790  } else {
791  i+= run;
792  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
793  LAST_SKIP_BITS(re, &s->gb, 1);
794  }
795  if (i > 62){
796  i-= 192;
797  if(i&(~63)){
798  const int left= get_bits_left(&s->gb);
799  if (((i + 192 == 64 && level / qmul == -1) ||
801  left >= 0) {
802  av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
803  i = 63;
804  break;
805  }else{
806  av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
807  return -1;
808  }
809  }
810 
811  block[scan_table[i]] = level;
812  break;
813  }
814 
815  block[scan_table[i]] = level;
816  }
817  CLOSE_READER(re, &s->gb);
818  }
819  not_coded:
820  if (s->mb_intra) {
821  ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
822  if (s->ac_pred) {
823  i = 63; /* XXX: not optimal */
824  }
825  }
826  if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
827  s->block_last_index[n] = i;
828 
829  return 0;
830 }
831 
833  int *mx_ptr, int *my_ptr)
834 {
835  MVTable *mv;
836  int code, mx, my;
837 
838  mv = &ff_mv_tables[s->mv_table_index];
839 
840  code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
841  if (code < 0){
842  av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
843  return -1;
844  }
845  if (code == mv->n) {
846  mx = get_bits(&s->gb, 6);
847  my = get_bits(&s->gb, 6);
848  } else {
849  mx = mv->table_mvx[code];
850  my = mv->table_mvy[code];
851  }
852 
853  mx += *mx_ptr - 32;
854  my += *my_ptr - 32;
855  /* WARNING : they do not do exactly modulo encoding */
856  if (mx <= -64)
857  mx += 64;
858  else if (mx >= 64)
859  mx -= 64;
860 
861  if (my <= -64)
862  my += 64;
863  else if (my >= 64)
864  my -= 64;
865  *mx_ptr = mx;
866  *my_ptr = my;
867  return 0;
868 }
869 
871  .name = "msmpeg4v1",
872  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
873  .type = AVMEDIA_TYPE_VIDEO,
874  .id = AV_CODEC_ID_MSMPEG4V1,
875  .priv_data_size = sizeof(MpegEncContext),
877  .close = ff_h263_decode_end,
880  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
881  .max_lowres = 3,
882  .pix_fmts = (const enum AVPixelFormat[]) {
885  },
886 };
887 
889  .name = "msmpeg4v2",
890  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
891  .type = AVMEDIA_TYPE_VIDEO,
892  .id = AV_CODEC_ID_MSMPEG4V2,
893  .priv_data_size = sizeof(MpegEncContext),
895  .close = ff_h263_decode_end,
898  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
899  .max_lowres = 3,
900  .pix_fmts = (const enum AVPixelFormat[]) {
903  },
904 };
905 
907  .name = "msmpeg4",
908  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
909  .type = AVMEDIA_TYPE_VIDEO,
910  .id = AV_CODEC_ID_MSMPEG4V3,
911  .priv_data_size = sizeof(MpegEncContext),
913  .close = ff_h263_decode_end,
916  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
917  .max_lowres = 3,
918  .pix_fmts = (const enum AVPixelFormat[]) {
921  },
922 };
923 
925  .name = "wmv1",
926  .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
927  .type = AVMEDIA_TYPE_VIDEO,
928  .id = AV_CODEC_ID_WMV1,
929  .priv_data_size = sizeof(MpegEncContext),
931  .close = ff_h263_decode_end,
934  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
935  .max_lowres = 3,
936  .pix_fmts = (const enum AVPixelFormat[]) {
939  },
940 };
static VLC v2_mv_vlc
Definition: msmpeg4dec.c:69
#define DEFAULT_INTER_INDEX
Definition: msmpeg4dec.c:44
int inter_intra_pred
Definition: mpegvideo.h:442
#define NULL
Definition: coverity.c:32
#define MB_TYPE_SKIP
Definition: avcodec.h:1306
const char const char void * val
Definition: avisynth_c.h:771
const char * s
Definition: avisynth_c.h:768
ScanTable intra_v_scantable
Definition: mpegvideo.h:90
#define V2_MV_VLC_BITS
Definition: msmpeg4dec.c:41
static int shift(int a, int b)
Definition: sonic.c:82
static int msmpeg4v2_decode_motion(MpegEncContext *s, int pred, int f_code)
Definition: msmpeg4dec.c:73
int esc3_level_length
Definition: mpegvideo.h:438
VLC ff_mb_non_intra_vlc[4]
Definition: msmpeg4dec.c:64
VLC ff_inter_intra_vlc
Definition: msmpeg4dec.c:70
#define CBPY_VLC_BITS
Definition: h263.h:41
uint32_t ff_v2_dc_lum_table[512][2]
Definition: msmpeg4data.c:34
float re
Definition: fft.c:82
misc image utilities
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:261
const uint32_t ff_table0_dc_lum[120][2]
Definition: msmpeg4data.c:100
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
VLC ff_h263_intra_MCBPC_vlc
Definition: ituh263dec.c:98
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
Definition: vlc.h:75
static VLC v2_dc_lum_vlc
Definition: msmpeg4dec.c:65
uint32_t ff_v2_dc_chroma_table[512][2]
Definition: msmpeg4data.c:35
VLC ff_h263_cbpy_vlc
Definition: ituh263dec.c:100
#define SKIP_COUNTER(name, gb, num)
Definition: get_bits.h:167
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
Definition: mpegvideo.h:436
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
Definition: avcodec.h:3049
void(* clear_blocks)(int16_t *blocks)
Definition: blockdsp.h:37
#define MB_TYPE_INTRA
Definition: mpegutils.h:75
static VLC v2_dc_chroma_vlc
Definition: msmpeg4dec.c:66
#define TEX_VLC_BITS
Definition: msmpeg4dec.c:42
#define AV_EF_BITSTREAM
detect bitstream specification deviations
Definition: avcodec.h:3043
mpegvideo header.
#define NB_RL_TABLES
Definition: msmpeg4data.h:60
uint8_t permutated[64]
Definition: idctdsp.h:33
uint8_t run
Definition: svq3.c:206
AVCodec.
Definition: avcodec.h:3722
#define MB_NON_INTRA_VLC_BITS
Definition: msmpeg4.h:34
RLTable.
Definition: rl.h:39
int qscale
QP.
Definition: mpegvideo.h:201
av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
Definition: msmpeg4.c:109
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
Definition: h263.c:307
static int16_t block[64]
Definition: dct.c:115
int esc3_run_length
Definition: mpegvideo.h:439
int8_t * max_run[2]
encoding & decoding
Definition: rl.h:47
VC-1 tables.
const uint8_t ff_v2_intra_cbpc[4][2]
Definition: msmpeg4data.c:1791
uint8_t
#define av_cold
Definition: attributes.h:82
int ff_msmpeg4_decode_block(MpegEncContext *s, int16_t *block, int n, int coded, const uint8_t *scan_table)
Definition: msmpeg4dec.c:645
uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 *MAX_RUN+MAX_LEVEL+3]
Definition: msmpeg4data.c:36
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:2988
#define MBAC_BITRATE
Definition: msmpeg4.h:38
int no_rounding
apply no rounding to motion compensation (MPEG-4, msmpeg4, ...) for B-frames rounding mode is always ...
Definition: mpegvideo.h:284
static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
Definition: msmpeg4dec.c:104
Picture current_picture
copy of the current picture structure.
Definition: mpegvideo.h:177
MSMPEG4 data tables.
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:199
int8_t * max_level[2]
encoding & decoding
Definition: rl.h:46
#define ff_dlog(a,...)
const uint32_t ff_table0_dc_chroma[120][2]
Definition: msmpeg4data.c:133
int mb_height
number of MBs horizontally & vertically
Definition: mpegvideo.h:126
static int msmpeg4v1_pred_dc(MpegEncContext *s, int n, int32_t **dc_val_ptr)
Definition: msmpeg4dec.c:46
int flipflop_rounding
Definition: mpegvideo.h:435
#define av_log(a,...)
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:587
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:160
const uint16_t ff_msmp4_mb_i_table[64][2]
Definition: msmpeg4data.c:43
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int last_dc[3]
last DC values for MPEG-1
Definition: mpegvideo.h:182
static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
Definition: msmpeg4dec.c:205
int rl_chroma_table_index
Definition: mpegvideo.h:430
int ff_msmpeg4_decode_picture_header(MpegEncContext *s)
Definition: msmpeg4dec.c:408
int mb_skipped
MUST BE SET only during DECODING.
Definition: mpegvideo.h:192
void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir)
Predict the ac.
Definition: mpeg4videodec.c:63
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
#define DC_VLC_BITS
Definition: msmpeg4dec.c:37
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
int per_mb_rl_table
Definition: mpegvideo.h:437
#define INTER_MCBPC_VLC_BITS
Definition: h263.h:40
GLsizei GLsizei * length
Definition: opengl_enc.c:115
const char * name
Name of the codec implementation.
Definition: avcodec.h:3729
GetBitContext gb
Definition: mpegvideo.h:446
int(* decode_mb)(struct MpegEncContext *s, int16_t block[6][64])
Definition: mpegvideo.h:500
#define CLOSE_READER(name, gb)
Definition: get_bits.h:131
#define INIT_VLC_RL(rl, static_size)
Definition: rl.h:63
#define V2_INTRA_CBPC_VLC_BITS
Definition: msmpeg4dec.c:38
#define GET_RL_VLC(level, run, name, gb, table, bits,max_depth, need_update)
Definition: get_bits.h:509
Definition: vlc.h:26
#define SKIP_BITS(name, gb, num)
Definition: get_bits.h:175
int ff_h263_decode_init(AVCodecContext *avctx)
Definition: h263dec.c:62
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:281
VLC ff_h263_inter_MCBPC_vlc
Definition: ituh263dec.c:99
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: h263dec.c:409
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
Definition: avcodec.h:995
const uint8_t ff_v2_mb_type[8][2]
Definition: msmpeg4data.c:1786
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
Definition: msmpeg4.c:193
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:3034
const uint8_t * table_mvx
Definition: msmpeg4data.h:43
static const uint8_t start_code[]
Definition: h264dec.c:531
int width
picture width / height.
Definition: avcodec.h:1933
int32_t
const uint8_t * table_mv_bits
Definition: msmpeg4data.h:42
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:296
static int msmpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
Definition: msmpeg4dec.c:584
#define LAST_SKIP_BITS(name, gb, num)
Definition: get_bits.h:181
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:554
int block_last_index[12]
last non zero coefficient in block
Definition: mpegvideo.h:83
int n
Definition: avisynth_c.h:684
const uint32_t ff_table1_dc_chroma[120][2]
Definition: msmpeg4data.c:201
RL_VLC_ELEM * rl_vlc[32]
decoding only
Definition: rl.h:48
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:193
int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size)
Definition: msmpeg4dec.c:556
static const float pred[4]
Definition: siprdata.h:259
static const int8_t mv[256][2]
Definition: 4xm.c:77
AVCodec ff_msmpeg4v1_decoder
Definition: msmpeg4dec.c:870
#define MV_TYPE_16X16
1 vector for the whole mb
Definition: mpegvideo.h:266
Libavcodec external API header.
BlockDSPContext bdsp
Definition: mpegvideo.h:223
int debug
debug
Definition: avcodec.h:2987
const uint32_t(*const [WMV2_INTER_CBP_TABLE_COUNT] ff_wmv2_inter_table)[2]
Definition: msmpeg4data.c:1956
AVCodec ff_msmpeg4v2_decoder
Definition: msmpeg4dec.c:888
main external API structure.
Definition: avcodec.h:1746
static VLC v2_intra_cbpc_vlc
Definition: msmpeg4dec.c:67
ScanTable intra_scantable
Definition: mpegvideo.h:88
int height
picture size. must be a multiple of 16
Definition: mpegvideo.h:97
#define OPEN_READER(name, gb)
Definition: get_bits.h:120
const uint16_t * table_mv_code
Definition: msmpeg4data.h:41
av_cold int ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
Definition: rl.c:39
#define DC_MAX
Definition: msmpeg4.h:40
const uint32_t ff_table1_dc_lum[120][2]
Definition: msmpeg4data.c:168
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:313
#define V2_MB_TYPE_VLC_BITS
Definition: msmpeg4dec.c:39
ScanTable intra_h_scantable
Definition: mpegvideo.h:89
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:306
#define GET_CACHE(name, gb)
Definition: get_bits.h:197
#define MB_INTRA_VLC_BITS
Definition: msmpeg4.h:35
int slice_height
in macroblocks
Definition: mpegvideo.h:433
#define MB_TYPE_16x16
Definition: avcodec.h:1298
int use_skip_mb_code
Definition: mpegvideo.h:432
AVCodec ff_wmv1_decoder
Definition: msmpeg4dec.c:924
MVTable ff_mv_tables[2]
Definition: msmpeg4data.c:1773
#define SKIP_CACHE(name, gb, num)
Definition: get_bits.h:162
VLC vlc
Definition: msmpeg4data.h:46
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:346
#define MV_DIR_FORWARD
Definition: mpegvideo.h:262
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
Definition: mpegvideo.h:209
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define II_BITRATE
Definition: msmpeg4.h:37
RLTable ff_rl_table[NB_RL_TABLES]
Definition: msmpeg4data.c:601
static VLC v2_mb_type_vlc
Definition: msmpeg4dec.c:68
uint8_t level
Definition: svq3.c:207
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
Definition: mpegvideo.h:276
MpegEncContext.
Definition: mpegvideo.h:78
struct AVCodecContext * avctx
Definition: mpegvideo.h:95
#define SHOW_SBITS(name, gb, num)
Definition: get_bits.h:194
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
common internal api header.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
Definition: mpegvideo.h:127
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
Definition: internal.h:60
AVCodec ff_msmpeg4v3_decoder
Definition: msmpeg4dec.c:906
#define MV_VLC_BITS
Definition: msmpeg4dec.c:40
int ff_h263_decode_end(AVCodecContext *avctx)
Definition: h263dec.c:149
void * priv_data
Definition: avcodec.h:1788
int16_t(* block)[64]
points to one of the following blocks
Definition: mpegvideo.h:498
static int decode012(GetBitContext *gb)
Definition: get_bits.h:569
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
int64_t bit_rate
wanted bit rate
Definition: mpegvideo.h:100
int ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
Definition: msmpeg4dec.c:832
int rl_table_index
Definition: mpegvideo.h:429
int chroma_qscale
chroma QP
Definition: mpegvideo.h:202
#define av_uninit(x)
Definition: attributes.h:148
#define INTER_INTRA_VLC_BITS
Definition: msmpeg4.h:33
uint32_t * mb_type
types and macros are defined in mpegutils.h
Definition: mpegpicture.h:56
const uint8_t * table_mvy
Definition: msmpeg4data.h:44
VLC ff_msmp4_mb_i_vlc
Definition: msmpeg4data.c:38
ScanTable inter_scantable
if inter == intra then intra should be used to reduce the cache usage
Definition: mpegvideo.h:87
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
Definition: msmpeg4.c:153
int mv_table_index
Definition: mpegvideo.h:428
int h263_aic_dir
AIC direction: 0 = left, 1 = top.
Definition: mpegvideo.h:376
int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
Definition: wmv2dec.c:339
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:1001
const uint8_t ff_table_inter_intra[4][2]
Definition: msmpeg4data.c:1844
int dc_table_index
Definition: mpegvideo.h:431
VLC ff_msmp4_dc_luma_vlc[2]
Definition: msmpeg4data.c:39
#define MB_TYPE_L0
Definition: avcodec.h:1311
Predicted.
Definition: avutil.h:275
#define INTRA_MCBPC_VLC_BITS
Definition: h263.h:39
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
Definition: msmpeg4dec.c:298
VLC ff_msmp4_dc_chroma_vlc[2]
Definition: msmpeg4data.c:40
const uint8_t ff_mvtab[33][2]
Definition: h263data.c:90