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 (get_bits_left(&s->gb) <= 0)
212  return AVERROR_INVALIDDATA;
213 
214  if (s->pict_type == AV_PICTURE_TYPE_P) {
215  if (s->use_skip_mb_code) {
216  if (get_bits1(&s->gb)) {
217  /* skip mb */
218  s->mb_intra = 0;
219  for(i=0;i<6;i++)
220  s->block_last_index[i] = -1;
221  s->mv_dir = MV_DIR_FORWARD;
222  s->mv_type = MV_TYPE_16X16;
223  s->mv[0][0][0] = 0;
224  s->mv[0][0][1] = 0;
225  s->mb_skipped = 1;
226  *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
227 
228  return 0;
229  }
230  }
231 
232  code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
233  if (code < 0)
234  return -1;
235  //s->mb_intra = (code & 0x40) ? 0 : 1;
236  s->mb_intra = (~code & 0x40) >> 6;
237 
238  cbp = code & 0x3f;
239  } else {
240  s->mb_intra = 1;
242  if (code < 0)
243  return -1;
244  /* predict coded block pattern */
245  cbp = 0;
246  for(i=0;i<6;i++) {
247  int val = ((code >> (5 - i)) & 1);
248  if (i < 4) {
249  int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
250  val = val ^ pred;
251  *coded_val = val;
252  }
253  cbp |= val << (5 - i);
254  }
255  }
256 
257  if (!s->mb_intra) {
258  int mx, my;
259  if(s->per_mb_rl_table && cbp){
260  s->rl_table_index = decode012(&s->gb);
262  }
263  ff_h263_pred_motion(s, 0, 0, &mx, &my);
264  if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
265  return -1;
266  s->mv_dir = MV_DIR_FORWARD;
267  s->mv_type = MV_TYPE_16X16;
268  s->mv[0][0][0] = mx;
269  s->mv[0][0][1] = my;
270  *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
271  } else {
272  ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
273  ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
274  show_bits(&s->gb, 24));
275  s->ac_pred = get_bits1(&s->gb);
276  *mb_type_ptr = MB_TYPE_INTRA;
277  if(s->inter_intra_pred){
278  s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
279  ff_dlog(s, "%d%d %d %d/",
280  s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
281  }
282  if(s->per_mb_rl_table && cbp){
283  s->rl_table_index = decode012(&s->gb);
285  }
286  }
287 
288  s->bdsp.clear_blocks(s->block[0]);
289  for (i = 0; i < 6; i++) {
290  if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
291  {
292  av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
293  return -1;
294  }
295  }
296 
297  return 0;
298 }
299 
300 /* init all vlc decoding tables */
302 {
303  MpegEncContext *s = avctx->priv_data;
304  static volatile int done = 0;
305  int i, ret;
306  MVTable *mv;
307 
308  if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
309  return ret;
310 
311  if (ff_h263_decode_init(avctx) < 0)
312  return -1;
313 
315 
316  if (!done) {
317  for(i=0;i<NB_RL_TABLES;i++) {
319  }
320  INIT_VLC_RL(ff_rl_table[0], 642);
321  INIT_VLC_RL(ff_rl_table[1], 1104);
322  INIT_VLC_RL(ff_rl_table[2], 554);
323  INIT_VLC_RL(ff_rl_table[3], 940);
324  INIT_VLC_RL(ff_rl_table[4], 962);
325  INIT_VLC_RL(ff_rl_table[5], 554);
326 
327  mv = &ff_mv_tables[0];
328  INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
329  mv->table_mv_bits, 1, 1,
330  mv->table_mv_code, 2, 2, 3714);
331  mv = &ff_mv_tables[1];
332  INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
333  mv->table_mv_bits, 1, 1,
334  mv->table_mv_code, 2, 2, 2694);
335 
337  &ff_table0_dc_lum[0][1], 8, 4,
338  &ff_table0_dc_lum[0][0], 8, 4, 1158);
340  &ff_table0_dc_chroma[0][1], 8, 4,
341  &ff_table0_dc_chroma[0][0], 8, 4, 1118);
343  &ff_table1_dc_lum[0][1], 8, 4,
344  &ff_table1_dc_lum[0][0], 8, 4, 1476);
346  &ff_table1_dc_chroma[0][1], 8, 4,
347  &ff_table1_dc_chroma[0][0], 8, 4, 1216);
348 
349  INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
350  &ff_v2_dc_lum_table[0][1], 8, 4,
351  &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
352  INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
353  &ff_v2_dc_chroma_table[0][1], 8, 4,
354  &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
355 
356  INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
357  &ff_v2_intra_cbpc[0][1], 2, 1,
358  &ff_v2_intra_cbpc[0][0], 2, 1, 8);
359  INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
360  &ff_v2_mb_type[0][1], 2, 1,
361  &ff_v2_mb_type[0][0], 2, 1, 128);
362  INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
363  &ff_mvtab[0][1], 2, 1,
364  &ff_mvtab[0][0], 2, 1, 538);
365 
366  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
367  &ff_wmv2_inter_table[0][0][1], 8, 4,
368  &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
369  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
370  &ff_wmv2_inter_table[1][0][1], 8, 4,
371  &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
372  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
373  &ff_wmv2_inter_table[2][0][1], 8, 4,
374  &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
375  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
376  &ff_wmv2_inter_table[3][0][1], 8, 4,
377  &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
378 
380  &ff_msmp4_mb_i_table[0][1], 4, 2,
381  &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
382 
383  INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
384  &ff_table_inter_intra[0][1], 2, 1,
385  &ff_table_inter_intra[0][0], 2, 1, 8);
386  done = 1;
387  }
388 
389  switch(s->msmpeg4_version){
390  case 1:
391  case 2:
393  break;
394  case 3:
395  case 4:
397  break;
398  case 5:
399  if (CONFIG_WMV2_DECODER)
401  case 6:
402  //FIXME + TODO VC1 decode mb
403  break;
404  }
405 
406  s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
407 
408  return 0;
409 }
410 
412 {
413  int code;
414 
415  if(s->msmpeg4_version==1){
416  int start_code = get_bits_long(&s->gb, 32);
417  if(start_code!=0x00000100){
418  av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
419  return -1;
420  }
421 
422  skip_bits(&s->gb, 5); // frame number */
423  }
424 
425  s->pict_type = get_bits(&s->gb, 2) + 1;
426  if (s->pict_type != AV_PICTURE_TYPE_I &&
428  av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
429  return -1;
430  }
431  s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
432  if(s->qscale==0){
433  av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
434  return -1;
435  }
436 
437  if (s->pict_type == AV_PICTURE_TYPE_I) {
438  code = get_bits(&s->gb, 5);
439  if(s->msmpeg4_version==1){
440  if(code==0 || code>s->mb_height){
441  av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
442  return -1;
443  }
444 
445  s->slice_height = code;
446  }else{
447  /* 0x17: one slice, 0x18: two slices, ... */
448  if (code < 0x17){
449  av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
450  return -1;
451  }
452 
453  s->slice_height = s->mb_height / (code - 0x16);
454  }
455 
456  switch(s->msmpeg4_version){
457  case 1:
458  case 2:
459  s->rl_chroma_table_index = 2;
460  s->rl_table_index = 2;
461 
462  s->dc_table_index = 0; //not used
463  break;
464  case 3:
466  s->rl_table_index = decode012(&s->gb);
467 
468  s->dc_table_index = get_bits1(&s->gb);
469  break;
470  case 4:
471  ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
472 
474  else s->per_mb_rl_table= 0;
475 
476  if(!s->per_mb_rl_table){
478  s->rl_table_index = decode012(&s->gb);
479  }
480 
481  s->dc_table_index = get_bits1(&s->gb);
482  s->inter_intra_pred= 0;
483  break;
484  }
485  s->no_rounding = 1;
487  av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
488  s->qscale,
490  s->rl_table_index,
491  s->dc_table_index,
492  s->per_mb_rl_table,
493  s->slice_height);
494  } else {
495  switch(s->msmpeg4_version){
496  case 1:
497  case 2:
498  if(s->msmpeg4_version==1)
499  s->use_skip_mb_code = 1;
500  else
501  s->use_skip_mb_code = get_bits1(&s->gb);
502  s->rl_table_index = 2;
504  s->dc_table_index = 0; //not used
505  s->mv_table_index = 0;
506  break;
507  case 3:
508  s->use_skip_mb_code = get_bits1(&s->gb);
509  s->rl_table_index = decode012(&s->gb);
511 
512  s->dc_table_index = get_bits1(&s->gb);
513 
514  s->mv_table_index = get_bits1(&s->gb);
515  break;
516  case 4:
517  s->use_skip_mb_code = get_bits1(&s->gb);
518 
520  else s->per_mb_rl_table= 0;
521 
522  if(!s->per_mb_rl_table){
523  s->rl_table_index = decode012(&s->gb);
525  }
526 
527  s->dc_table_index = get_bits1(&s->gb);
528 
529  s->mv_table_index = get_bits1(&s->gb);
530  s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
531  break;
532  }
533 
535  av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
536  s->use_skip_mb_code,
537  s->rl_table_index,
539  s->dc_table_index,
540  s->mv_table_index,
541  s->per_mb_rl_table,
542  s->qscale);
543 
544  if(s->flipflop_rounding){
545  s->no_rounding ^= 1;
546  }else{
547  s->no_rounding = 0;
548  }
549  }
550  ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
551  s->inter_intra_pred, s->width, s->height);
552 
553  s->esc3_level_length= 0;
554  s->esc3_run_length= 0;
555 
556  return 0;
557 }
558 
560 {
561  int left= buf_size*8 - get_bits_count(&s->gb);
562  int length= s->msmpeg4_version>=3 ? 17 : 16;
563  /* the alt_bitstream reader could read over the end so we need to check it */
564  if(left>=length && left<length+8)
565  {
566  skip_bits(&s->gb, 5); /* fps */
567  s->bit_rate= get_bits(&s->gb, 11)*1024;
568  if(s->msmpeg4_version>=3)
569  s->flipflop_rounding= get_bits1(&s->gb);
570  else
571  s->flipflop_rounding= 0;
572  }
573  else if(left<length+8)
574  {
575  s->flipflop_rounding= 0;
576  if(s->msmpeg4_version != 2)
577  av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
578  }
579  else
580  {
581  av_log(s->avctx, AV_LOG_ERROR, "I-frame too long, ignoring ext header\n");
582  }
583 
584  return 0;
585 }
586 
587 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
588 {
589  int level, pred;
590 
591  if(s->msmpeg4_version<=2){
592  if (n < 4) {
593  level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
594  } else {
595  level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
596  }
597  if (level < 0) {
598  av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
599  *dir_ptr = 0;
600  return -1;
601  }
602  level-=256;
603  }else{ //FIXME optimize use unified tables & index
604  if (n < 4) {
606  } else {
608  }
609  if (level < 0){
610  av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
611  *dir_ptr = 0;
612  return -1;
613  }
614 
615  if (level == DC_MAX) {
616  level = get_bits(&s->gb, 8);
617  if (get_bits1(&s->gb))
618  level = -level;
619  } else if (level != 0) {
620  if (get_bits1(&s->gb))
621  level = -level;
622  }
623  }
624 
625  if(s->msmpeg4_version==1){
626  int32_t *dc_val;
627  pred = msmpeg4v1_pred_dc(s, n, &dc_val);
628  level += pred;
629 
630  /* update predictor */
631  *dc_val= level;
632  }else{
633  int16_t *dc_val;
634  pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
635  level += pred;
636 
637  /* update predictor */
638  if (n < 4) {
639  *dc_val = level * s->y_dc_scale;
640  } else {
641  *dc_val = level * s->c_dc_scale;
642  }
643  }
644 
645  return level;
646 }
647 
649  int n, int coded, const uint8_t *scan_table)
650 {
651  int level, i, last, run, run_diff;
652  int av_uninit(dc_pred_dir);
653  RLTable *rl;
654  RL_VLC_ELEM *rl_vlc;
655  int qmul, qadd;
656 
657  if (s->mb_intra) {
658  qmul=1;
659  qadd=0;
660 
661  /* DC coef */
662  level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
663 
664  if (level < 0){
665  av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
666  if(s->inter_intra_pred) level=0;
667  }
668  if (n < 4) {
669  rl = &ff_rl_table[s->rl_table_index];
670  if(level > 256*s->y_dc_scale){
671  av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
672  if(!s->inter_intra_pred) return -1;
673  }
674  } else {
675  rl = &ff_rl_table[3 + s->rl_chroma_table_index];
676  if(level > 256*s->c_dc_scale){
677  av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
678  if(!s->inter_intra_pred) return -1;
679  }
680  }
681  block[0] = level;
682 
683  run_diff = s->msmpeg4_version >= 4;
684  i = 0;
685  if (!coded) {
686  goto not_coded;
687  }
688  if (s->ac_pred) {
689  if (dc_pred_dir == 0)
690  scan_table = s->intra_v_scantable.permutated; /* left */
691  else
692  scan_table = s->intra_h_scantable.permutated; /* top */
693  } else {
694  scan_table = s->intra_scantable.permutated;
695  }
696  rl_vlc= rl->rl_vlc[0];
697  } else {
698  qmul = s->qscale << 1;
699  qadd = (s->qscale - 1) | 1;
700  i = -1;
701  rl = &ff_rl_table[3 + s->rl_table_index];
702 
703  if(s->msmpeg4_version==2)
704  run_diff = 0;
705  else
706  run_diff = 1;
707 
708  if (!coded) {
709  s->block_last_index[n] = i;
710  return 0;
711  }
712  if(!scan_table)
713  scan_table = s->inter_scantable.permutated;
714  rl_vlc= rl->rl_vlc[s->qscale];
715  }
716  {
717  OPEN_READER(re, &s->gb);
718  for(;;) {
719  UPDATE_CACHE(re, &s->gb);
720  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
721  if (level==0) {
722  int cache;
723  cache= GET_CACHE(re, &s->gb);
724  /* escape */
725  if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
726  if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
727  /* third escape */
728  if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
729  UPDATE_CACHE(re, &s->gb);
730  if(s->msmpeg4_version<=3){
731  last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
732  run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
733  level= SHOW_SBITS(re, &s->gb, 8);
734  SKIP_COUNTER(re, &s->gb, 1+6+8);
735  }else{
736  int sign;
737  last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
738  if(!s->esc3_level_length){
739  int ll;
740  ff_dlog(s->avctx, "ESC-3 %X at %d %d\n",
741  show_bits(&s->gb, 24), s->mb_x, s->mb_y);
742  if(s->qscale<8){
743  ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
744  if(ll==0){
745  ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
746  }
747  }else{
748  ll=2;
749  while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
750  ll++;
751  SKIP_BITS(re, &s->gb, 1);
752  }
753  if(ll<8) SKIP_BITS(re, &s->gb, 1);
754  }
755 
756  s->esc3_level_length= ll;
757  s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
758  UPDATE_CACHE(re, &s->gb);
759  }
760  run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
761  SKIP_BITS(re, &s->gb, s->esc3_run_length);
762 
763  sign= SHOW_UBITS(re, &s->gb, 1);
764  SKIP_BITS(re, &s->gb, 1);
765 
766  level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
767  SKIP_BITS(re, &s->gb, s->esc3_level_length);
768  if(sign) level= -level;
769  }
770 
771  //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
772  if (level>0) level= level * qmul + qadd;
773  else level= level * qmul - qadd;
774  i+= run + 1;
775  if(last) i+=192;
776  } else {
777  /* second escape */
778  SKIP_BITS(re, &s->gb, 2);
779  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
780  i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
781  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
782  LAST_SKIP_BITS(re, &s->gb, 1);
783  }
784  } else {
785  /* first escape */
786  SKIP_BITS(re, &s->gb, 1);
787  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
788  i+= run;
789  level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
790  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
791  LAST_SKIP_BITS(re, &s->gb, 1);
792  }
793  } else {
794  i+= run;
795  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
796  LAST_SKIP_BITS(re, &s->gb, 1);
797  }
798  if (i > 62){
799  i-= 192;
800  if(i&(~63)){
801  const int left= get_bits_left(&s->gb);
802  if (((i + 192 == 64 && level / qmul == -1) ||
804  left >= 0) {
805  av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
806  i = 63;
807  break;
808  }else{
809  av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
810  return -1;
811  }
812  }
813 
814  block[scan_table[i]] = level;
815  break;
816  }
817 
818  block[scan_table[i]] = level;
819  }
820  CLOSE_READER(re, &s->gb);
821  }
822  not_coded:
823  if (s->mb_intra) {
824  ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
825  if (s->ac_pred) {
826  i = 63; /* XXX: not optimal */
827  }
828  }
829  if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
830  s->block_last_index[n] = i;
831 
832  return 0;
833 }
834 
836  int *mx_ptr, int *my_ptr)
837 {
838  MVTable *mv;
839  int code, mx, my;
840 
841  mv = &ff_mv_tables[s->mv_table_index];
842 
843  code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
844  if (code < 0){
845  av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
846  return -1;
847  }
848  if (code == mv->n) {
849  mx = get_bits(&s->gb, 6);
850  my = get_bits(&s->gb, 6);
851  } else {
852  mx = mv->table_mvx[code];
853  my = mv->table_mvy[code];
854  }
855 
856  mx += *mx_ptr - 32;
857  my += *my_ptr - 32;
858  /* WARNING : they do not do exactly modulo encoding */
859  if (mx <= -64)
860  mx += 64;
861  else if (mx >= 64)
862  mx -= 64;
863 
864  if (my <= -64)
865  my += 64;
866  else if (my >= 64)
867  my -= 64;
868  *mx_ptr = mx;
869  *my_ptr = my;
870  return 0;
871 }
872 
874  .name = "msmpeg4v1",
875  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
876  .type = AVMEDIA_TYPE_VIDEO,
877  .id = AV_CODEC_ID_MSMPEG4V1,
878  .priv_data_size = sizeof(MpegEncContext),
880  .close = ff_h263_decode_end,
883  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
884  .max_lowres = 3,
885  .pix_fmts = (const enum AVPixelFormat[]) {
888  },
889 };
890 
892  .name = "msmpeg4v2",
893  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
894  .type = AVMEDIA_TYPE_VIDEO,
895  .id = AV_CODEC_ID_MSMPEG4V2,
896  .priv_data_size = sizeof(MpegEncContext),
898  .close = ff_h263_decode_end,
901  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
902  .max_lowres = 3,
903  .pix_fmts = (const enum AVPixelFormat[]) {
906  },
907 };
908 
910  .name = "msmpeg4",
911  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
912  .type = AVMEDIA_TYPE_VIDEO,
913  .id = AV_CODEC_ID_MSMPEG4V3,
914  .priv_data_size = sizeof(MpegEncContext),
916  .close = ff_h263_decode_end,
919  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
920  .max_lowres = 3,
921  .pix_fmts = (const enum AVPixelFormat[]) {
924  },
925 };
926 
928  .name = "wmv1",
929  .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
930  .type = AVMEDIA_TYPE_VIDEO,
931  .id = AV_CODEC_ID_WMV1,
932  .priv_data_size = sizeof(MpegEncContext),
934  .close = ff_h263_decode_end,
937  .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
938  .max_lowres = 3,
939  .pix_fmts = (const enum AVPixelFormat[]) {
942  },
943 };
static VLC v2_mv_vlc
Definition: msmpeg4dec.c:69
#define DEFAULT_INTER_INDEX
Definition: msmpeg4dec.c:44
int inter_intra_pred
Definition: mpegvideo.h:444
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:771
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
ScanTable intra_v_scantable
Definition: mpegvideo.h:93
#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:440
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:39
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:381
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:185
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
Definition: mpegvideo.h:438
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
Definition: avcodec.h:2673
void(* clear_blocks)(int16_t *blocks)
Definition: blockdsp.h:37
#define MB_TYPE_INTRA
Definition: mpegutils.h:73
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:2667
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:3424
#define MB_NON_INTRA_VLC_BITS
Definition: msmpeg4.h:34
RLTable.
Definition: rl.h:39
int qscale
QP.
Definition: mpegvideo.h:204
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:441
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:648
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:2615
#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
#define MB_TYPE_16x16
Definition: mpegutils.h:54
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:180
MSMPEG4 data tables.
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
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:129
static int msmpeg4v1_pred_dc(MpegEncContext *s, int n, int32_t **dc_val_ptr)
Definition: msmpeg4dec.c:46
int flipflop_rounding
Definition: mpegvideo.h:437
#define av_log(a,...)
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:814
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:178
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:185
static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
Definition: msmpeg4dec.c:205
int rl_chroma_table_index
Definition: mpegvideo.h:432
int ff_msmpeg4_decode_picture_header(MpegEncContext *s)
Definition: msmpeg4dec.c:411
int mb_skipped
MUST BE SET only during DECODING.
Definition: mpegvideo.h:195
void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir)
Predict the ac.
Definition: mpeg4videodec.c:69
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#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:439
#define INTER_MCBPC_VLC_BITS
Definition: h263.h:38
GLsizei GLsizei * length
Definition: opengl_enc.c:115
const char * name
Name of the codec implementation.
Definition: avcodec.h:3431
GetBitContext gb
Definition: mpegvideo.h:448
#define CLOSE_READER(name, gb)
Definition: get_bits.h:149
#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:703
Definition: vlc.h:26
#define SKIP_BITS(name, gb, num)
Definition: get_bits.h:193
int ff_h263_decode_init(AVCodecContext *avctx)
Definition: h263dec.c:68
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:282
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:421
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
Definition: avcodec.h:962
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:2658
const uint8_t * table_mvx
Definition: msmpeg4data.h:43
int width
picture width / height.
Definition: avcodec.h:1706
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:443
static int msmpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
Definition: msmpeg4dec.c:587
#define s(width, name)
Definition: cbs_vp9.c:257
#define LAST_SKIP_BITS(name, gb, num)
Definition: get_bits.h:199
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:762
int block_last_index[12]
last non zero coefficient in block
Definition: mpegvideo.h:86
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:211
int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size)
Definition: msmpeg4dec.c:559
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:873
#define MV_TYPE_16X16
1 vector for the whole mb
Definition: mpegvideo.h:266
Libavcodec external API header.
BlockDSPContext bdsp
Definition: mpegvideo.h:226
int debug
debug
Definition: avcodec.h:2614
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:891
main external API structure.
Definition: avcodec.h:1533
static VLC v2_intra_cbpc_vlc
Definition: msmpeg4dec.c:67
ScanTable intra_scantable
Definition: mpegvideo.h:91
int height
picture size. must be a multiple of 16
Definition: mpegvideo.h:100
#define OPEN_READER(name, gb)
Definition: get_bits.h:138
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:487
#define V2_MB_TYPE_VLC_BITS
Definition: msmpeg4dec.c:39
ScanTable intra_h_scantable
Definition: mpegvideo.h:92
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:460
#define GET_CACHE(name, gb)
Definition: get_bits.h:215
#define MB_INTRA_VLC_BITS
Definition: msmpeg4.h:35
int slice_height
in macroblocks
Definition: mpegvideo.h:435
int use_skip_mb_code
Definition: mpegvideo.h:434
AVCodec ff_wmv1_decoder
Definition: msmpeg4dec.c:927
MVTable ff_mv_tables[2]
Definition: msmpeg4data.c:1773
#define SKIP_CACHE(name, gb, num)
Definition: get_bits.h:180
VLC vlc
Definition: msmpeg4data.h:46
#define MB_TYPE_SKIP
Definition: mpegutils.h:62
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:531
#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:212
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:81
struct AVCodecContext * avctx
Definition: mpegvideo.h:98
#define SHOW_SBITS(name, gb, num)
Definition: get_bits.h:212
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
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:130
#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:909
#define MV_VLC_BITS
Definition: msmpeg4dec.c:40
int ff_h263_decode_end(AVCodecContext *avctx)
Definition: h263dec.c:155
void * priv_data
Definition: avcodec.h:1560
int16_t(* block)[64]
points to one of the following blocks
Definition: mpegvideo.h:507
static int decode012(GetBitContext *gb)
Definition: get_bits.h:796
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
int64_t bit_rate
wanted bit rate
Definition: mpegvideo.h:103
int ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
Definition: msmpeg4dec.c:835
int rl_table_index
Definition: mpegvideo.h:431
int chroma_qscale
chroma QP
Definition: mpegvideo.h:205
#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:90
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
Definition: msmpeg4.c:153
static const uint8_t start_code[]
int(* decode_mb)(struct MpegEncContext *s, int16_t block[12][64])
Definition: mpegvideo.h:509
int mv_table_index
Definition: mpegvideo.h:430
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:364
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:968
const uint8_t ff_table_inter_intra[4][2]
Definition: msmpeg4data.c:1844
int dc_table_index
Definition: mpegvideo.h:433
#define MB_TYPE_L0
Definition: mpegutils.h:67
VLC ff_msmp4_dc_luma_vlc[2]
Definition: msmpeg4data.c:39
Predicted.
Definition: avutil.h:275
#define INTRA_MCBPC_VLC_BITS
Definition: h263.h:37
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
Definition: msmpeg4dec.c:301
VLC ff_msmp4_dc_chroma_vlc[2]
Definition: msmpeg4data.c:40
const uint8_t ff_mvtab[33][2]
Definition: h263data.c:90