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