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  if(s->msmpeg4_version==2){
173  s->ac_pred = get_bits1(&s->gb);
174  cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
175  } else{
176  s->ac_pred = 0;
177  cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
178  if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
179  }
180  *mb_type_ptr = MB_TYPE_INTRA;
181  }
182 
183  s->bdsp.clear_blocks(s->block[0]);
184  for (i = 0; i < 6; i++) {
185  if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
186  {
187  av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
188  return -1;
189  }
190  }
191  return 0;
192 }
193 
194 static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
195 {
196  int cbp, code, i;
197  uint8_t *coded_val;
198  uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
199 
200  if (s->pict_type == AV_PICTURE_TYPE_P) {
201  if (s->use_skip_mb_code) {
202  if (get_bits1(&s->gb)) {
203  /* skip mb */
204  s->mb_intra = 0;
205  for(i=0;i<6;i++)
206  s->block_last_index[i] = -1;
207  s->mv_dir = MV_DIR_FORWARD;
208  s->mv_type = MV_TYPE_16X16;
209  s->mv[0][0][0] = 0;
210  s->mv[0][0][1] = 0;
211  s->mb_skipped = 1;
212  *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
213 
214  return 0;
215  }
216  }
217 
218  code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
219  if (code < 0)
220  return -1;
221  //s->mb_intra = (code & 0x40) ? 0 : 1;
222  s->mb_intra = (~code & 0x40) >> 6;
223 
224  cbp = code & 0x3f;
225  } else {
226  s->mb_intra = 1;
228  if (code < 0)
229  return -1;
230  /* predict coded block pattern */
231  cbp = 0;
232  for(i=0;i<6;i++) {
233  int val = ((code >> (5 - i)) & 1);
234  if (i < 4) {
235  int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
236  val = val ^ pred;
237  *coded_val = val;
238  }
239  cbp |= val << (5 - i);
240  }
241  }
242 
243  if (!s->mb_intra) {
244  int mx, my;
245  if(s->per_mb_rl_table && cbp){
246  s->rl_table_index = decode012(&s->gb);
248  }
249  ff_h263_pred_motion(s, 0, 0, &mx, &my);
250  if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
251  return -1;
252  s->mv_dir = MV_DIR_FORWARD;
253  s->mv_type = MV_TYPE_16X16;
254  s->mv[0][0][0] = mx;
255  s->mv[0][0][1] = my;
256  *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
257  } else {
258  ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
259  ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
260  show_bits(&s->gb, 24));
261  s->ac_pred = get_bits1(&s->gb);
262  *mb_type_ptr = MB_TYPE_INTRA;
263  if(s->inter_intra_pred){
264  s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
265  ff_dlog(s, "%d%d %d %d/",
266  s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
267  }
268  if(s->per_mb_rl_table && cbp){
269  s->rl_table_index = decode012(&s->gb);
271  }
272  }
273 
274  s->bdsp.clear_blocks(s->block[0]);
275  for (i = 0; i < 6; i++) {
276  if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
277  {
278  av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
279  return -1;
280  }
281  }
282 
283  return 0;
284 }
285 
286 /* init all vlc decoding tables */
288 {
289  MpegEncContext *s = avctx->priv_data;
290  static volatile int done = 0;
291  int i, ret;
292  MVTable *mv;
293 
294  if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
295  return ret;
296 
297  if (ff_h263_decode_init(avctx) < 0)
298  return -1;
299 
301 
302  if (!done) {
303  for(i=0;i<NB_RL_TABLES;i++) {
305  }
306  INIT_VLC_RL(ff_rl_table[0], 642);
307  INIT_VLC_RL(ff_rl_table[1], 1104);
308  INIT_VLC_RL(ff_rl_table[2], 554);
309  INIT_VLC_RL(ff_rl_table[3], 940);
310  INIT_VLC_RL(ff_rl_table[4], 962);
311  INIT_VLC_RL(ff_rl_table[5], 554);
312 
313  mv = &ff_mv_tables[0];
314  INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
315  mv->table_mv_bits, 1, 1,
316  mv->table_mv_code, 2, 2, 3714);
317  mv = &ff_mv_tables[1];
318  INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
319  mv->table_mv_bits, 1, 1,
320  mv->table_mv_code, 2, 2, 2694);
321 
323  &ff_table0_dc_lum[0][1], 8, 4,
324  &ff_table0_dc_lum[0][0], 8, 4, 1158);
326  &ff_table0_dc_chroma[0][1], 8, 4,
327  &ff_table0_dc_chroma[0][0], 8, 4, 1118);
329  &ff_table1_dc_lum[0][1], 8, 4,
330  &ff_table1_dc_lum[0][0], 8, 4, 1476);
332  &ff_table1_dc_chroma[0][1], 8, 4,
333  &ff_table1_dc_chroma[0][0], 8, 4, 1216);
334 
335  INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
336  &ff_v2_dc_lum_table[0][1], 8, 4,
337  &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
338  INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
339  &ff_v2_dc_chroma_table[0][1], 8, 4,
340  &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
341 
342  INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
343  &ff_v2_intra_cbpc[0][1], 2, 1,
344  &ff_v2_intra_cbpc[0][0], 2, 1, 8);
345  INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
346  &ff_v2_mb_type[0][1], 2, 1,
347  &ff_v2_mb_type[0][0], 2, 1, 128);
348  INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
349  &ff_mvtab[0][1], 2, 1,
350  &ff_mvtab[0][0], 2, 1, 538);
351 
352  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
353  &ff_wmv2_inter_table[0][0][1], 8, 4,
354  &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
355  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
356  &ff_wmv2_inter_table[1][0][1], 8, 4,
357  &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
358  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
359  &ff_wmv2_inter_table[2][0][1], 8, 4,
360  &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
361  INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
362  &ff_wmv2_inter_table[3][0][1], 8, 4,
363  &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
364 
366  &ff_msmp4_mb_i_table[0][1], 4, 2,
367  &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
368 
369  INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
370  &ff_table_inter_intra[0][1], 2, 1,
371  &ff_table_inter_intra[0][0], 2, 1, 8);
372  done = 1;
373  }
374 
375  switch(s->msmpeg4_version){
376  case 1:
377  case 2:
379  break;
380  case 3:
381  case 4:
383  break;
384  case 5:
385  if (CONFIG_WMV2_DECODER)
387  case 6:
388  //FIXME + TODO VC1 decode mb
389  break;
390  }
391 
392  s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
393 
394  return 0;
395 }
396 
398 {
399  int code;
400 
401  if(s->msmpeg4_version==1){
402  int start_code = get_bits_long(&s->gb, 32);
403  if(start_code!=0x00000100){
404  av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
405  return -1;
406  }
407 
408  skip_bits(&s->gb, 5); // frame number */
409  }
410 
411  s->pict_type = get_bits(&s->gb, 2) + 1;
412  if (s->pict_type != AV_PICTURE_TYPE_I &&
414  av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
415  return -1;
416  }
417 #if 0
418 {
419  static int had_i=0;
420  if(s->pict_type == AV_PICTURE_TYPE_I) had_i=1;
421  if(!had_i) return -1;
422 }
423 #endif
424  s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
425  if(s->qscale==0){
426  av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
427  return -1;
428  }
429 
430  if (s->pict_type == AV_PICTURE_TYPE_I) {
431  code = get_bits(&s->gb, 5);
432  if(s->msmpeg4_version==1){
433  if(code==0 || code>s->mb_height){
434  av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
435  return -1;
436  }
437 
438  s->slice_height = code;
439  }else{
440  /* 0x17: one slice, 0x18: two slices, ... */
441  if (code < 0x17){
442  av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
443  return -1;
444  }
445 
446  s->slice_height = s->mb_height / (code - 0x16);
447  }
448 
449  switch(s->msmpeg4_version){
450  case 1:
451  case 2:
452  s->rl_chroma_table_index = 2;
453  s->rl_table_index = 2;
454 
455  s->dc_table_index = 0; //not used
456  break;
457  case 3:
459  s->rl_table_index = decode012(&s->gb);
460 
461  s->dc_table_index = get_bits1(&s->gb);
462  break;
463  case 4:
464  ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
465 
467  else s->per_mb_rl_table= 0;
468 
469  if(!s->per_mb_rl_table){
471  s->rl_table_index = decode012(&s->gb);
472  }
473 
474  s->dc_table_index = get_bits1(&s->gb);
475  s->inter_intra_pred= 0;
476  break;
477  }
478  s->no_rounding = 1;
480  av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
481  s->qscale,
483  s->rl_table_index,
484  s->dc_table_index,
485  s->per_mb_rl_table,
486  s->slice_height);
487  } else {
488  switch(s->msmpeg4_version){
489  case 1:
490  case 2:
491  if(s->msmpeg4_version==1)
492  s->use_skip_mb_code = 1;
493  else
494  s->use_skip_mb_code = get_bits1(&s->gb);
495  s->rl_table_index = 2;
497  s->dc_table_index = 0; //not used
498  s->mv_table_index = 0;
499  break;
500  case 3:
501  s->use_skip_mb_code = get_bits1(&s->gb);
502  s->rl_table_index = decode012(&s->gb);
504 
505  s->dc_table_index = get_bits1(&s->gb);
506 
507  s->mv_table_index = get_bits1(&s->gb);
508  break;
509  case 4:
510  s->use_skip_mb_code = get_bits1(&s->gb);
511 
513  else s->per_mb_rl_table= 0;
514 
515  if(!s->per_mb_rl_table){
516  s->rl_table_index = decode012(&s->gb);
518  }
519 
520  s->dc_table_index = get_bits1(&s->gb);
521 
522  s->mv_table_index = get_bits1(&s->gb);
523  s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
524  break;
525  }
526 
528  av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
529  s->use_skip_mb_code,
530  s->rl_table_index,
532  s->dc_table_index,
533  s->mv_table_index,
534  s->per_mb_rl_table,
535  s->qscale);
536 
537  if(s->flipflop_rounding){
538  s->no_rounding ^= 1;
539  }else{
540  s->no_rounding = 0;
541  }
542  }
543  ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
544  s->inter_intra_pred, s->width, s->height);
545 
546  s->esc3_level_length= 0;
547  s->esc3_run_length= 0;
548 
549  return 0;
550 }
551 
553 {
554  int left= buf_size*8 - get_bits_count(&s->gb);
555  int length= s->msmpeg4_version>=3 ? 17 : 16;
556  /* the alt_bitstream reader could read over the end so we need to check it */
557  if(left>=length && left<length+8)
558  {
559  skip_bits(&s->gb, 5); /* fps */
560  s->bit_rate= get_bits(&s->gb, 11)*1024;
561  if(s->msmpeg4_version>=3)
562  s->flipflop_rounding= get_bits1(&s->gb);
563  else
564  s->flipflop_rounding= 0;
565  }
566  else if(left<length+8)
567  {
568  s->flipflop_rounding= 0;
569  if(s->msmpeg4_version != 2)
570  av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
571  }
572  else
573  {
574  av_log(s->avctx, AV_LOG_ERROR, "I-frame too long, ignoring ext header\n");
575  }
576 
577  return 0;
578 }
579 
580 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
581 {
582  int level, pred;
583 
584  if(s->msmpeg4_version<=2){
585  if (n < 4) {
586  level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
587  } else {
588  level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
589  }
590  if (level < 0) {
591  av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
592  *dir_ptr = 0;
593  return -1;
594  }
595  level-=256;
596  }else{ //FIXME optimize use unified tables & index
597  if (n < 4) {
599  } else {
601  }
602  if (level < 0){
603  av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
604  *dir_ptr = 0;
605  return -1;
606  }
607 
608  if (level == DC_MAX) {
609  level = get_bits(&s->gb, 8);
610  if (get_bits1(&s->gb))
611  level = -level;
612  } else if (level != 0) {
613  if (get_bits1(&s->gb))
614  level = -level;
615  }
616  }
617 
618  if(s->msmpeg4_version==1){
619  int32_t *dc_val;
620  pred = msmpeg4v1_pred_dc(s, n, &dc_val);
621  level += pred;
622 
623  /* update predictor */
624  *dc_val= level;
625  }else{
626  int16_t *dc_val;
627  pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
628  level += pred;
629 
630  /* update predictor */
631  if (n < 4) {
632  *dc_val = level * s->y_dc_scale;
633  } else {
634  *dc_val = level * s->c_dc_scale;
635  }
636  }
637 
638  return level;
639 }
640 
641 //#define ERROR_DETAILS
643  int n, int coded, const uint8_t *scan_table)
644 {
645  int level, i, last, run, run_diff;
646  int av_uninit(dc_pred_dir);
647  RLTable *rl;
648  RL_VLC_ELEM *rl_vlc;
649  int qmul, qadd;
650 
651  if (s->mb_intra) {
652  qmul=1;
653  qadd=0;
654 
655  /* DC coef */
656  level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
657 
658  if (level < 0){
659  av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
660  if(s->inter_intra_pred) level=0;
661  }
662  if (n < 4) {
663  rl = &ff_rl_table[s->rl_table_index];
664  if(level > 256*s->y_dc_scale){
665  av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
666  if(!s->inter_intra_pred) return -1;
667  }
668  } else {
669  rl = &ff_rl_table[3 + s->rl_chroma_table_index];
670  if(level > 256*s->c_dc_scale){
671  av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
672  if(!s->inter_intra_pred) return -1;
673  }
674  }
675  block[0] = level;
676 
677  run_diff = s->msmpeg4_version >= 4;
678  i = 0;
679  if (!coded) {
680  goto not_coded;
681  }
682  if (s->ac_pred) {
683  if (dc_pred_dir == 0)
684  scan_table = s->intra_v_scantable.permutated; /* left */
685  else
686  scan_table = s->intra_h_scantable.permutated; /* top */
687  } else {
688  scan_table = s->intra_scantable.permutated;
689  }
690  rl_vlc= rl->rl_vlc[0];
691  } else {
692  qmul = s->qscale << 1;
693  qadd = (s->qscale - 1) | 1;
694  i = -1;
695  rl = &ff_rl_table[3 + s->rl_table_index];
696 
697  if(s->msmpeg4_version==2)
698  run_diff = 0;
699  else
700  run_diff = 1;
701 
702  if (!coded) {
703  s->block_last_index[n] = i;
704  return 0;
705  }
706  if(!scan_table)
707  scan_table = s->inter_scantable.permutated;
708  rl_vlc= rl->rl_vlc[s->qscale];
709  }
710  {
711  OPEN_READER(re, &s->gb);
712  for(;;) {
713  UPDATE_CACHE(re, &s->gb);
714  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
715  if (level==0) {
716  int cache;
717  cache= GET_CACHE(re, &s->gb);
718  /* escape */
719  if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
720  if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
721  /* third escape */
722  if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
723  UPDATE_CACHE(re, &s->gb);
724  if(s->msmpeg4_version<=3){
725  last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
726  run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
727  level= SHOW_SBITS(re, &s->gb, 8);
728  SKIP_COUNTER(re, &s->gb, 1+6+8);
729  }else{
730  int sign;
731  last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
732  if(!s->esc3_level_length){
733  int ll;
734  ff_dlog(s->avctx, "ESC-3 %X at %d %d\n",
735  show_bits(&s->gb, 24), s->mb_x, s->mb_y);
736  if(s->qscale<8){
737  ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
738  if(ll==0){
739  ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
740  }
741  }else{
742  ll=2;
743  while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
744  ll++;
745  SKIP_BITS(re, &s->gb, 1);
746  }
747  if(ll<8) SKIP_BITS(re, &s->gb, 1);
748  }
749 
750  s->esc3_level_length= ll;
751  s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
752  UPDATE_CACHE(re, &s->gb);
753  }
754  run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
755  SKIP_BITS(re, &s->gb, s->esc3_run_length);
756 
757  sign= SHOW_UBITS(re, &s->gb, 1);
758  SKIP_BITS(re, &s->gb, 1);
759 
760  level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
761  SKIP_BITS(re, &s->gb, s->esc3_level_length);
762  if(sign) level= -level;
763  }
764 
765 #if 0 // waste of time / this will detect very few errors
766  {
767  const int abs_level= FFABS(level);
768  const int run1= run - rl->max_run[last][abs_level] - run_diff;
769  if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
770  if(abs_level <= rl->max_level[last][run]){
771  av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
772  return DECODING_AC_LOST;
773  }
774  if(abs_level <= rl->max_level[last][run]*2){
775  av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
776  return DECODING_AC_LOST;
777  }
778  if(run1>=0 && abs_level <= rl->max_level[last][run1]){
779  av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
780  return DECODING_AC_LOST;
781  }
782  }
783  }
784 #endif
785  //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
786  if (level>0) level= level * qmul + qadd;
787  else level= level * qmul - qadd;
788 #if 0 // waste of time too :(
789  if(level>2048 || level<-2048){
790  av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc\n");
791  return DECODING_AC_LOST;
792  }
793 #endif
794  i+= run + 1;
795  if(last) i+=192;
796 #ifdef ERROR_DETAILS
797  if(run==66)
798  av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level);
799  else if((i>62 && i<192) || i>192+63)
800  av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
801 #endif
802  } else {
803  /* second escape */
804  SKIP_BITS(re, &s->gb, 2);
805  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
806  i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
807  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
808  LAST_SKIP_BITS(re, &s->gb, 1);
809 #ifdef ERROR_DETAILS
810  if(run==66)
811  av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level);
812  else if((i>62 && i<192) || i>192+63)
813  av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
814 #endif
815  }
816  } else {
817  /* first escape */
818  SKIP_BITS(re, &s->gb, 1);
819  GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
820  i+= run;
821  level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
822  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
823  LAST_SKIP_BITS(re, &s->gb, 1);
824 #ifdef ERROR_DETAILS
825  if(run==66)
826  av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level);
827  else if((i>62 && i<192) || i>192+63)
828  av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
829 #endif
830  }
831  } else {
832  i+= run;
833  level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
834  LAST_SKIP_BITS(re, &s->gb, 1);
835 #ifdef ERROR_DETAILS
836  if(run==66)
837  av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level);
838  else if((i>62 && i<192) || i>192+63)
839  av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level);
840 #endif
841  }
842  if (i > 62){
843  i-= 192;
844  if(i&(~63)){
845  const int left= get_bits_left(&s->gb);
846  if (((i + 192 == 64 && level / qmul == -1) ||
848  left >= 0) {
849  av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
850  i = 63;
851  break;
852  }else{
853  av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
854  return -1;
855  }
856  }
857 
858  block[scan_table[i]] = level;
859  break;
860  }
861 
862  block[scan_table[i]] = level;
863  }
864  CLOSE_READER(re, &s->gb);
865  }
866  not_coded:
867  if (s->mb_intra) {
868  ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
869  if (s->ac_pred) {
870  i = 63; /* XXX: not optimal */
871  }
872  }
873  if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
874  s->block_last_index[n] = i;
875 
876  return 0;
877 }
878 
880  int *mx_ptr, int *my_ptr)
881 {
882  MVTable *mv;
883  int code, mx, my;
884 
885  mv = &ff_mv_tables[s->mv_table_index];
886 
887  code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
888  if (code < 0){
889  av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
890  return -1;
891  }
892  if (code == mv->n) {
893  mx = get_bits(&s->gb, 6);
894  my = get_bits(&s->gb, 6);
895  } else {
896  mx = mv->table_mvx[code];
897  my = mv->table_mvy[code];
898  }
899 
900  mx += *mx_ptr - 32;
901  my += *my_ptr - 32;
902  /* WARNING : they do not do exactly modulo encoding */
903  if (mx <= -64)
904  mx += 64;
905  else if (mx >= 64)
906  mx -= 64;
907 
908  if (my <= -64)
909  my += 64;
910  else if (my >= 64)
911  my -= 64;
912  *mx_ptr = mx;
913  *my_ptr = my;
914  return 0;
915 }
916 
918  .name = "msmpeg4v1",
919  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
920  .type = AVMEDIA_TYPE_VIDEO,
921  .id = AV_CODEC_ID_MSMPEG4V1,
922  .priv_data_size = sizeof(MpegEncContext),
924  .close = ff_h263_decode_end,
927  .max_lowres = 3,
928  .pix_fmts = (const enum AVPixelFormat[]) {
931  },
932 };
933 
935  .name = "msmpeg4v2",
936  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
937  .type = AVMEDIA_TYPE_VIDEO,
938  .id = AV_CODEC_ID_MSMPEG4V2,
939  .priv_data_size = sizeof(MpegEncContext),
941  .close = ff_h263_decode_end,
944  .max_lowres = 3,
945  .pix_fmts = (const enum AVPixelFormat[]) {
948  },
949 };
950 
952  .name = "msmpeg4",
953  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
954  .type = AVMEDIA_TYPE_VIDEO,
955  .id = AV_CODEC_ID_MSMPEG4V3,
956  .priv_data_size = sizeof(MpegEncContext),
958  .close = ff_h263_decode_end,
961  .max_lowres = 3,
962  .pix_fmts = (const enum AVPixelFormat[]) {
965  },
966 };
967 
969  .name = "wmv1",
970  .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
971  .type = AVMEDIA_TYPE_VIDEO,
972  .id = AV_CODEC_ID_WMV1,
973  .priv_data_size = sizeof(MpegEncContext),
975  .close = ff_h263_decode_end,
978  .max_lowres = 3,
979  .pix_fmts = (const enum AVPixelFormat[]) {
982  },
983 };
static VLC v2_mv_vlc
Definition: msmpeg4dec.c:69
#define DEFAULT_INTER_INDEX
Definition: msmpeg4dec.c:44
int inter_intra_pred
Definition: mpegvideo.h:441
#define NULL
Definition: coverity.c:32
#define MB_TYPE_SKIP
Definition: avcodec.h:1251
const char const char void * val
Definition: avisynth_c.h:634
const char * s
Definition: avisynth_c.h:631
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:437
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:73
misc image utilities
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:247
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:57
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:435
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
Definition: avcodec.h:2951
void(* clear_blocks)(int16_t *blocks)
Definition: blockdsp.h:36
#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:2945
mpegvideo header.
#define NB_RL_TABLES
Definition: msmpeg4data.h:59
uint8_t permutated[64]
Definition: idctdsp.h:31
uint8_t run
Definition: svq3.c:192
AVCodec.
Definition: avcodec.h:3542
#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
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
Definition: h263.c:310
static int16_t block[64]
Definition: dct.c:113
int esc3_run_length
Definition: mpegvideo.h:438
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:642
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:2889
#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
#define MAX_LEVEL
Definition: rl.h:36
int flipflop_rounding
Definition: mpegvideo.h:434
#define av_log(a,...)
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:568
#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:194
int rl_chroma_table_index
Definition: mpegvideo.h:429
int ff_msmpeg4_decode_picture_header(MpegEncContext *s)
Definition: msmpeg4dec.c:397
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:176
#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:436
#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:3549
GetBitContext gb
Definition: mpegvideo.h:445
int(* decode_mb)(struct MpegEncContext *s, int16_t block[6][64])
Definition: mpegvideo.h:499
#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:490
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:251
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:950
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:2936
const uint8_t * table_mvx
Definition: msmpeg4data.h:42
int width
picture width / height.
Definition: avcodec.h:1836
int32_t
const uint8_t * table_mv_bits
Definition: msmpeg4data.h:41
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:282
static int msmpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
Definition: msmpeg4dec.c:580
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#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:535
int block_last_index[12]
last non zero coefficient in block
Definition: mpegvideo.h:83
int n
Definition: avisynth_c.h:547
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:552
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:917
#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:2888
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:934
main external API structure.
Definition: avcodec.h:1649
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:40
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:299
#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:292
#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:432
#define MB_TYPE_16x16
Definition: avcodec.h:1243
int use_skip_mb_code
Definition: mpegvideo.h:431
AVCodec ff_wmv1_decoder
Definition: msmpeg4dec.c:968
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:45
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:332
#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:262
static const uint8_t start_code[]
Definition: h264.c:806
#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:193
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
#define MAX_RUN
Definition: rl.h:35
struct AVCodecContext * avctx
Definition: mpegvideo.h:95
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:722
#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
AVCodec ff_msmpeg4v3_decoder
Definition: msmpeg4dec.c:951
#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:1691
int16_t(* block)[64]
points to one of the following blocks
Definition: mpegvideo.h:497
static int decode012(GetBitContext *gb)
Definition: get_bits.h:550
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:879
int rl_table_index
Definition: mpegvideo.h:428
int chroma_qscale
chroma QP
Definition: mpegvideo.h:202
#define av_uninit(x)
Definition: attributes.h:149
#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:43
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:427
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:956
const uint8_t ff_table_inter_intra[4][2]
Definition: msmpeg4data.c:1844
int dc_table_index
Definition: mpegvideo.h:430
VLC ff_msmp4_dc_luma_vlc[2]
Definition: msmpeg4data.c:39
#define MB_TYPE_L0
Definition: avcodec.h:1256
Predicted.
Definition: avutil.h:267
#define INTRA_MCBPC_VLC_BITS
Definition: h263.h:39
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
Definition: msmpeg4dec.c:287
VLC ff_msmp4_dc_chroma_vlc[2]
Definition: msmpeg4data.c:40
const uint8_t ff_mvtab[33][2]
Definition: h263data.c:90