FFmpeg
ituh263dec.c
Go to the documentation of this file.
1 /*
2  * ITU H.263 bitstream decoder
3  * Copyright (c) 2000,2001 Fabrice Bellard
4  * H.263+ support.
5  * Copyright (c) 2001 Juan J. Sierralta P
6  * Copyright (c) 2002-2004 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 /**
26  * @file
27  * H.263 decoder.
28  */
29 
30 #define UNCHECKED_BITSTREAM_READER 1
31 
32 #include "config_components.h"
33 
34 #include "libavutil/attributes.h"
35 #include "libavutil/imgutils.h"
36 #include "libavutil/internal.h"
37 #include "libavutil/mathematics.h"
38 #include "libavutil/mem_internal.h"
39 #include "libavutil/thread.h"
40 #include "avcodec.h"
41 #include "mpegvideo.h"
42 #include "h263.h"
43 #include "h263data.h"
44 #include "h263dec.h"
45 #include "mathops.h"
46 #include "mpegutils.h"
47 #include "unary.h"
48 #include "rv10dec.h"
49 #include "mpeg4video.h"
50 #include "mpegvideodata.h"
51 #include "mpeg4videodec.h"
52 
53 // The defines below define the number of bits that are read at once for
54 // reading vlc values. Changing these may improve speed and data cache needs
55 // be aware though that decreasing them may need the number of stages that is
56 // passed to get_vlc* to be increased.
57 #define H263_MBTYPE_B_VLC_BITS 6
58 #define CBPC_B_VLC_BITS 3
59 
60 static const int h263_mb_type_b_map[15]= {
73  0, //stuffing
76 };
77 
79  if(s->avctx->debug&FF_DEBUG_PICT_INFO){
80  av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
81  s->qscale, av_get_picture_type_char(s->pict_type),
82  s->gb.size_in_bits, 1-s->no_rounding,
83  s->obmc ? " AP" : "",
84  s->umvplus ? " UMV" : "",
85  s->h263_long_vectors ? " LONG" : "",
86  s->h263_plus ? " +" : "",
87  s->h263_aic ? " AIC" : "",
88  s->alt_inter_vlc ? " AIV" : "",
89  s->modified_quant ? " MQ" : "",
90  s->loop_filter ? " LOOP" : "",
91  s->h263_slice_structured ? " SS" : "",
92  s->avctx->framerate.num, s->avctx->framerate.den
93  );
94  }
95 }
96 
97 /***********************************************/
98 /* decoding */
99 
106 
107 /* init vlcs */
108 
109 static av_cold void h263_decode_init_vlc(void)
110 {
113  ff_h263_intra_MCBPC_code, 1, 1, 72);
116  ff_h263_inter_MCBPC_code, 1, 1, 198);
118  &ff_h263_cbpy_tab[0][1], 2, 1,
119  &ff_h263_cbpy_tab[0][0], 2, 1, 64);
121  &ff_mvtab[0][1], 2, 1,
122  &ff_mvtab[0][0], 2, 1, 538);
127  &ff_h263_mbtype_b_tab[0][1], 2, 1,
128  &ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
130  &ff_cbpc_b_tab[0][1], 2, 1,
131  &ff_cbpc_b_tab[0][0], 2, 1, 8);
132 }
133 
135 {
136  static AVOnce init_static_once = AV_ONCE_INIT;
137  ff_thread_once(&init_static_once, h263_decode_init_vlc);
138 }
139 
141 {
142  int i, mb_pos;
143 
144  for (i = 0; i < 6; i++)
145  if (s->mb_num - 1 <= ff_mba_max[i])
146  break;
147  mb_pos = get_bits(&s->gb, ff_mba_length[i]);
148  s->mb_x = mb_pos % s->mb_width;
149  s->mb_y = mb_pos / s->mb_width;
150 
151  return mb_pos;
152 }
153 
154 /**
155  * Decode the group of blocks header or slice header.
156  * @return <0 if an error occurred
157  */
159 {
160  unsigned int val, gob_number;
161  int left;
162 
163  /* Check for GOB Start Code */
164  val = show_bits(&s->gb, 16);
165  if(val)
166  return -1;
167 
168  /* We have a GBSC probably with GSTUFF */
169  skip_bits(&s->gb, 16); /* Drop the zeros */
170  left= get_bits_left(&s->gb);
171  left = FFMIN(left, 32);
172  //MN: we must check the bits left or we might end in an infinite loop (or segfault)
173  for(;left>13; left--){
174  if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
175  }
176  if(left<=13)
177  return -1;
178 
179  if(s->h263_slice_structured){
180  if(check_marker(s->avctx, &s->gb, "before MBA")==0)
181  return -1;
182 
184 
185  if(s->mb_num > 1583)
186  if(check_marker(s->avctx, &s->gb, "after MBA")==0)
187  return -1;
188 
189  s->qscale = get_bits(&s->gb, 5); /* SQUANT */
190  if(check_marker(s->avctx, &s->gb, "after SQUANT")==0)
191  return -1;
192  skip_bits(&s->gb, 2); /* GFID */
193  }else{
194  gob_number = get_bits(&s->gb, 5); /* GN */
195  s->mb_x= 0;
196  s->mb_y= s->gob_index* gob_number;
197  skip_bits(&s->gb, 2); /* GFID */
198  s->qscale = get_bits(&s->gb, 5); /* GQUANT */
199  }
200 
201  if(s->mb_y >= s->mb_height)
202  return -1;
203 
204  if(s->qscale==0)
205  return -1;
206 
207  return 0;
208 }
209 
210 /**
211  * Decode the group of blocks / video packet header / slice header (MPEG-4 Studio).
212  * @return bit position of the resync_marker, or <0 if none was found
213  */
215  int left, pos, ret;
216 
217  /* In MPEG-4 studio mode look for a new slice startcode
218  * and decode slice header */
219  if(s->codec_id==AV_CODEC_ID_MPEG4 && s->studio_profile) {
220  align_get_bits(&s->gb);
221 
222  while (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb, 32) != SLICE_STARTCODE) {
223  get_bits(&s->gb, 8);
224  }
225 
226  if (get_bits_left(&s->gb) >= 32 && show_bits_long(&s->gb, 32) == SLICE_STARTCODE)
227  return get_bits_count(&s->gb);
228  else
229  return -1;
230  }
231 
232  if(s->codec_id==AV_CODEC_ID_MPEG4){
233  skip_bits1(&s->gb);
234  align_get_bits(&s->gb);
235  }
236 
237  if(show_bits(&s->gb, 16)==0){
238  pos= get_bits_count(&s->gb);
239  if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
240  ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
241  else
243  if(ret>=0)
244  return pos;
245  }
246  //OK, it's not where it is supposed to be ...
247  s->gb= s->last_resync_gb;
248  align_get_bits(&s->gb);
249  left= get_bits_left(&s->gb);
250 
251  for(;left>16+1+5+5; left-=8){
252  if(show_bits(&s->gb, 16)==0){
253  GetBitContext bak= s->gb;
254 
255  pos= get_bits_count(&s->gb);
256  if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
257  ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
258  else
260  if(ret>=0)
261  return pos;
262 
263  s->gb= bak;
264  }
265  skip_bits(&s->gb, 8);
266  }
267 
268  return -1;
269 }
270 
272 {
273  int code, val, sign, shift;
275 
276  if (code == 0)
277  return pred;
278  if (code < 0)
279  return 0xffff;
280 
281  sign = get_bits1(&s->gb);
282  shift = f_code - 1;
283  val = code;
284  if (shift) {
285  val = (val - 1) << shift;
286  val |= get_bits(&s->gb, shift);
287  val++;
288  }
289  if (sign)
290  val = -val;
291  val += pred;
292 
293  /* modulo decoding */
294  if (!s->h263_long_vectors) {
295  val = sign_extend(val, 5 + f_code);
296  } else {
297  /* horrible H.263 long vector mode */
298  if (pred < -31 && val < -63)
299  val += 64;
300  if (pred > 32 && val > 63)
301  val -= 64;
302 
303  }
304  return val;
305 }
306 
307 
308 /* Decode RVLC of H.263+ UMV */
310 {
311  int code = 0, sign;
312 
313  if (get_bits1(&s->gb)) /* Motion difference = 0 */
314  return pred;
315 
316  code = 2 + get_bits1(&s->gb);
317 
318  while (get_bits1(&s->gb))
319  {
320  code <<= 1;
321  code += get_bits1(&s->gb);
322  if (code >= 32768) {
323  avpriv_request_sample(s->avctx, "Huge DMV");
324  return 0xffff;
325  }
326  }
327  sign = code & 1;
328  code >>= 1;
329 
330  code = (sign) ? (pred - code) : (pred + code);
331  ff_tlog(s->avctx,"H.263+ UMV Motion = %d\n", code);
332  return code;
333 
334 }
335 
336 /**
337  * read the next MVs for OBMC. yes this is an ugly hack, feel free to send a patch :)
338  */
340  GetBitContext gb= s->gb;
341 
342  int cbpc, i, pred_x, pred_y, mx, my;
343  int16_t *mot_val;
344  const int xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
345  const int stride= s->b8_stride*2;
346 
347  for(i=0; i<4; i++)
348  s->block_index[i]+= 2;
349  for(i=4; i<6; i++)
350  s->block_index[i]+= 1;
351  s->mb_x++;
352 
353  av_assert2(s->pict_type == AV_PICTURE_TYPE_P);
354 
355  do{
356  if (get_bits1(&s->gb)) {
357  /* skip mb */
358  mot_val = s->current_picture.motion_val[0][s->block_index[0]];
359  mot_val[0 ]= mot_val[2 ]=
360  mot_val[0+stride]= mot_val[2+stride]= 0;
361  mot_val[1 ]= mot_val[3 ]=
362  mot_val[1+stride]= mot_val[3+stride]= 0;
363 
364  s->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
365  goto end;
366  }
368  }while(cbpc == 20);
369 
370  if(cbpc & 4){
371  s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
372  }else{
374  if (cbpc & 8) {
375  if(s->modified_quant){
376  if(get_bits1(&s->gb)) skip_bits(&s->gb, 1);
377  else skip_bits(&s->gb, 5);
378  }else
379  skip_bits(&s->gb, 2);
380  }
381 
382  if ((cbpc & 16) == 0) {
383  s->current_picture.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
384  /* 16x16 motion prediction */
385  mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
386  if (s->umvplus)
387  mx = h263p_decode_umotion(s, pred_x);
388  else
389  mx = ff_h263_decode_motion(s, pred_x, 1);
390 
391  if (s->umvplus)
392  my = h263p_decode_umotion(s, pred_y);
393  else
394  my = ff_h263_decode_motion(s, pred_y, 1);
395 
396  mot_val[0 ]= mot_val[2 ]=
397  mot_val[0+stride]= mot_val[2+stride]= mx;
398  mot_val[1 ]= mot_val[3 ]=
399  mot_val[1+stride]= mot_val[3+stride]= my;
400  } else {
401  s->current_picture.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
402  for(i=0;i<4;i++) {
403  mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
404  if (s->umvplus)
405  mx = h263p_decode_umotion(s, pred_x);
406  else
407  mx = ff_h263_decode_motion(s, pred_x, 1);
408 
409  if (s->umvplus)
410  my = h263p_decode_umotion(s, pred_y);
411  else
412  my = ff_h263_decode_motion(s, pred_y, 1);
413  if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
414  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
415  mot_val[0] = mx;
416  mot_val[1] = my;
417  }
418  }
419  }
420 end:
421 
422  for(i=0; i<4; i++)
423  s->block_index[i]-= 2;
424  for(i=4; i<6; i++)
425  s->block_index[i]-= 1;
426  s->mb_x--;
427 
428  s->gb= gb;
429 }
430 
432  static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
433 
434  if(s->modified_quant){
435  if(get_bits1(&s->gb))
436  s->qscale= ff_modified_quant_tab[get_bits1(&s->gb)][ s->qscale ];
437  else
438  s->qscale= get_bits(&s->gb, 5);
439  }else
440  s->qscale += quant_tab[get_bits(&s->gb, 2)];
441  ff_set_qscale(s, s->qscale);
442 }
443 
444 static void h263_pred_acdc(MpegEncContext * s, int16_t *block, int n)
445 {
446  int x, y, wrap, a, c, pred_dc, scale;
447  int16_t *dc_val, *ac_val, *ac_val1;
448 
449  /* find prediction */
450  if (n < 4) {
451  x = 2 * s->mb_x + (n & 1);
452  y = 2 * s->mb_y + (n>> 1);
453  wrap = s->b8_stride;
454  dc_val = s->dc_val[0];
455  ac_val = s->ac_val[0][0];
456  scale = s->y_dc_scale;
457  } else {
458  x = s->mb_x;
459  y = s->mb_y;
460  wrap = s->mb_stride;
461  dc_val = s->dc_val[n - 4 + 1];
462  ac_val = s->ac_val[n - 4 + 1][0];
463  scale = s->c_dc_scale;
464  }
465 
466  ac_val += ((y) * wrap + (x)) * 16;
467  ac_val1 = ac_val;
468 
469  /* B C
470  * A X
471  */
472  a = dc_val[(x - 1) + (y) * wrap];
473  c = dc_val[(x) + (y - 1) * wrap];
474 
475  /* No prediction outside GOB boundary */
476  if (s->first_slice_line && n != 3) {
477  if (n != 2) c= 1024;
478  if (n != 1 && s->mb_x == s->resync_mb_x) a= 1024;
479  }
480 
481  if (s->ac_pred) {
482  pred_dc = 1024;
483  if (s->h263_aic_dir) {
484  /* left prediction */
485  if (a != 1024) {
486  ac_val -= 16;
487  for (int i = 1; i < 8; i++) {
488  block[s->idsp.idct_permutation[i << 3]] += ac_val[i];
489  }
490  pred_dc = a;
491  }
492  } else {
493  /* top prediction */
494  if (c != 1024) {
495  ac_val -= 16 * wrap;
496  for (int i = 1; i < 8; i++) {
497  block[s->idsp.idct_permutation[i]] += ac_val[i + 8];
498  }
499  pred_dc = c;
500  }
501  }
502  } else {
503  /* just DC prediction */
504  if (a != 1024 && c != 1024)
505  pred_dc = (a + c) >> 1;
506  else if (a != 1024)
507  pred_dc = a;
508  else
509  pred_dc = c;
510  }
511 
512  /* we assume pred is positive */
513  block[0] = block[0] * scale + pred_dc;
514 
515  if (block[0] < 0)
516  block[0] = 0;
517  else
518  block[0] |= 1;
519 
520  /* Update AC/DC tables */
521  dc_val[(x) + (y) * wrap] = block[0];
522 
523  /* left copy */
524  for (int i = 1; i < 8; i++)
525  ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];
526  /* top copy */
527  for (int i = 1; i < 8; i++)
528  ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];
529 }
530 
531 static int h263_decode_block(MpegEncContext * s, int16_t * block,
532  int n, int coded)
533 {
534  int level, i, j, run;
535  RLTable *rl = &ff_h263_rl_inter;
536  const uint8_t *scan_table;
537  GetBitContext gb= s->gb;
538 
539  scan_table = s->intra_scantable.permutated;
540  if (s->h263_aic && s->mb_intra) {
541  rl = &ff_rl_intra_aic;
542  i = 0;
543  if (s->ac_pred) {
544  if (s->h263_aic_dir)
545  scan_table = s->intra_v_scantable.permutated; /* left */
546  else
547  scan_table = s->intra_h_scantable.permutated; /* top */
548  }
549  } else if (s->mb_intra) {
550  /* DC coef */
551  if (CONFIG_RV10_DECODER && s->codec_id == AV_CODEC_ID_RV10) {
552  if (s->rv10_version == 3 && s->pict_type == AV_PICTURE_TYPE_I) {
553  int component, diff;
554  component = (n <= 3 ? 0 : n - 4 + 1);
555  level = s->last_dc[component];
556  if (s->rv10_first_dc_coded[component]) {
557  diff = ff_rv_decode_dc(s, n);
558  if (diff < 0)
559  return -1;
560  level += diff;
561  level = level & 0xff; /* handle wrap round */
562  s->last_dc[component] = level;
563  } else {
564  s->rv10_first_dc_coded[component] = 1;
565  }
566  } else {
567  level = get_bits(&s->gb, 8);
568  if (level == 255)
569  level = 128;
570  }
571  }else{
572  level = get_bits(&s->gb, 8);
573  if((level&0x7F) == 0){
574  av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
575  if (s->avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))
576  return -1;
577  }
578  if (level == 255)
579  level = 128;
580  }
581  block[0] = level;
582  i = 1;
583  } else {
584  i = 0;
585  }
586  if (!coded) {
587  if (s->mb_intra && s->h263_aic)
588  goto not_coded;
589  s->block_last_index[n] = i - 1;
590  return 0;
591  }
592 retry:
593  {
594  OPEN_READER(re, &s->gb);
595  i--; // offset by -1 to allow direct indexing of scan_table
596  for(;;) {
597  UPDATE_CACHE(re, &s->gb);
598  GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
599  if (run == 66) {
600  if (level){
601  CLOSE_READER(re, &s->gb);
602  av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
603  return -1;
604  }
605  /* escape */
606  if (CONFIG_FLV_DECODER && s->h263_flv > 1) {
607  int is11 = SHOW_UBITS(re, &s->gb, 1);
608  SKIP_CACHE(re, &s->gb, 1);
609  run = SHOW_UBITS(re, &s->gb, 7) + 1;
610  if (is11) {
611  SKIP_COUNTER(re, &s->gb, 1 + 7);
612  UPDATE_CACHE(re, &s->gb);
613  level = SHOW_SBITS(re, &s->gb, 11);
614  SKIP_COUNTER(re, &s->gb, 11);
615  } else {
616  SKIP_CACHE(re, &s->gb, 7);
617  level = SHOW_SBITS(re, &s->gb, 7);
618  SKIP_COUNTER(re, &s->gb, 1 + 7 + 7);
619  }
620  } else {
621  run = SHOW_UBITS(re, &s->gb, 7) + 1;
622  SKIP_CACHE(re, &s->gb, 7);
623  level = (int8_t)SHOW_UBITS(re, &s->gb, 8);
624  SKIP_COUNTER(re, &s->gb, 7 + 8);
625  if(level == -128){
626  UPDATE_CACHE(re, &s->gb);
627  if (s->codec_id == AV_CODEC_ID_RV10) {
628  /* XXX: should patch encoder too */
629  level = SHOW_SBITS(re, &s->gb, 12);
630  SKIP_COUNTER(re, &s->gb, 12);
631  }else{
632  level = SHOW_UBITS(re, &s->gb, 5);
633  SKIP_CACHE(re, &s->gb, 5);
634  level |= SHOW_SBITS(re, &s->gb, 6) * (1<<5);
635  SKIP_COUNTER(re, &s->gb, 5 + 6);
636  }
637  }
638  }
639  } else {
640  if (SHOW_UBITS(re, &s->gb, 1))
641  level = -level;
642  SKIP_COUNTER(re, &s->gb, 1);
643  }
644  i += run;
645  if (i >= 64){
646  CLOSE_READER(re, &s->gb);
647  // redo update without last flag, revert -1 offset
648  i = i - run + ((run-1)&63) + 1;
649  if (i < 64) {
650  // only last marker, no overrun
651  block[scan_table[i]] = level;
652  break;
653  }
654  if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){
655  //Looks like a hack but no, it's the way it is supposed to work ...
656  rl = &ff_rl_intra_aic;
657  i = 0;
658  s->gb= gb;
659  s->bdsp.clear_block(block);
660  goto retry;
661  }
662  av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", s->mb_x, s->mb_y, s->mb_intra);
663  return -1;
664  }
665  j = scan_table[i];
666  block[j] = level;
667  }
668  }
669 not_coded:
670  if (s->mb_intra && s->h263_aic) {
671  h263_pred_acdc(s, block, n);
672  i = 63;
673  }
674  s->block_last_index[n] = i;
675  return 0;
676 }
677 
678 static int h263_skip_b_part(MpegEncContext *s, int cbp)
679 {
680  LOCAL_ALIGNED_32(int16_t, dblock, [64]);
681  int i, mbi;
682  int bli[6];
683 
684  /* we have to set s->mb_intra to zero to decode B-part of PB-frame correctly
685  * but real value should be restored in order to be used later (in OBMC condition)
686  */
687  mbi = s->mb_intra;
688  memcpy(bli, s->block_last_index, sizeof(bli));
689  s->mb_intra = 0;
690  for (i = 0; i < 6; i++) {
691  if (h263_decode_block(s, dblock, i, cbp&32) < 0)
692  return -1;
693  cbp+=cbp;
694  }
695  s->mb_intra = mbi;
696  memcpy(s->block_last_index, bli, sizeof(bli));
697  return 0;
698 }
699 
700 static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
701 {
702  int c, mv = 1;
703 
704  if (pb_frame < 3) { // h.263 Annex G and i263 PB-frame
705  c = get_bits1(gb);
706  if (pb_frame == 2 && c)
707  mv = !get_bits1(gb);
708  } else { // h.263 Annex M improved PB-frame
709  mv = get_unary(gb, 0, 4) + 1;
710  c = mv & 1;
711  mv = !!(mv & 2);
712  }
713  if(c)
714  *cbpb = get_bits(gb, 6);
715  return mv;
716 }
717 
718 #define tab_size ((signed)FF_ARRAY_ELEMS(s->direct_scale_mv[0]))
719 #define tab_bias (tab_size / 2)
720 static inline void set_one_direct_mv(MpegEncContext *s, Picture *p, int i)
721 {
722  int xy = s->block_index[i];
723  uint16_t time_pp = s->pp_time;
724  uint16_t time_pb = s->pb_time;
725  int p_mx, p_my;
726 
727  p_mx = p->motion_val[0][xy][0];
728  if ((unsigned)(p_mx + tab_bias) < tab_size) {
729  s->mv[0][i][0] = s->direct_scale_mv[0][p_mx + tab_bias];
730  s->mv[1][i][0] = s->direct_scale_mv[1][p_mx + tab_bias];
731  } else {
732  s->mv[0][i][0] = p_mx * time_pb / time_pp;
733  s->mv[1][i][0] = p_mx * (time_pb - time_pp) / time_pp;
734  }
735  p_my = p->motion_val[0][xy][1];
736  if ((unsigned)(p_my + tab_bias) < tab_size) {
737  s->mv[0][i][1] = s->direct_scale_mv[0][p_my + tab_bias];
738  s->mv[1][i][1] = s->direct_scale_mv[1][p_my + tab_bias];
739  } else {
740  s->mv[0][i][1] = p_my * time_pb / time_pp;
741  s->mv[1][i][1] = p_my * (time_pb - time_pp) / time_pp;
742  }
743 }
744 
745 /**
746  * @return the mb_type
747  */
749 {
750  const int mb_index = s->mb_x + s->mb_y * s->mb_stride;
751  Picture *p = &s->next_picture;
752  int colocated_mb_type = p->mb_type[mb_index];
753  int i;
754 
755  if (s->codec_tag == AV_RL32("U263") && p->f->pict_type == AV_PICTURE_TYPE_I) {
756  p = &s->last_picture;
757  colocated_mb_type = p->mb_type[mb_index];
758  }
759 
760  if (IS_8X8(colocated_mb_type)) {
761  s->mv_type = MV_TYPE_8X8;
762  for (i = 0; i < 4; i++)
763  set_one_direct_mv(s, p, i);
765  } else {
766  set_one_direct_mv(s, p, 0);
767  s->mv[0][1][0] =
768  s->mv[0][2][0] =
769  s->mv[0][3][0] = s->mv[0][0][0];
770  s->mv[0][1][1] =
771  s->mv[0][2][1] =
772  s->mv[0][3][1] = s->mv[0][0][1];
773  s->mv[1][1][0] =
774  s->mv[1][2][0] =
775  s->mv[1][3][0] = s->mv[1][0][0];
776  s->mv[1][1][1] =
777  s->mv[1][2][1] =
778  s->mv[1][3][1] = s->mv[1][0][1];
779  s->mv_type = MV_TYPE_8X8;
780  // Note see prev line
782  }
783 }
784 
786  int16_t block[6][64])
787 {
788  int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
789  int16_t *mot_val;
790  const int xy= s->mb_x + s->mb_y * s->mb_stride;
791  int cbpb = 0, pb_mv_count = 0;
792 
793  av_assert2(!s->h263_pred);
794 
795  if (s->pict_type == AV_PICTURE_TYPE_P) {
796  do{
797  if (get_bits1(&s->gb)) {
798  /* skip mb */
799  s->mb_intra = 0;
800  for(i=0;i<6;i++)
801  s->block_last_index[i] = -1;
802  s->mv_dir = MV_DIR_FORWARD;
803  s->mv_type = MV_TYPE_16X16;
804  s->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
805  s->mv[0][0][0] = 0;
806  s->mv[0][0][1] = 0;
807  s->mb_skipped = !(s->obmc | s->loop_filter);
808  goto end;
809  }
811  if (cbpc < 0){
812  av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
813  return SLICE_ERROR;
814  }
815  }while(cbpc == 20);
816 
817  s->bdsp.clear_blocks(s->block[0]);
818 
819  dquant = cbpc & 8;
820  s->mb_intra = ((cbpc & 4) != 0);
821  if (s->mb_intra) goto intra;
822 
823  if(s->pb_frame && get_bits1(&s->gb))
824  pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
825  cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
826 
827  if (cbpy < 0) {
828  av_log(s->avctx, AV_LOG_ERROR, "cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
829  return SLICE_ERROR;
830  }
831 
832  if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
833  cbpy ^= 0xF;
834 
835  cbp = (cbpc & 3) | (cbpy << 2);
836  if (dquant) {
838  }
839 
840  s->mv_dir = MV_DIR_FORWARD;
841  if ((cbpc & 16) == 0) {
842  s->current_picture.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
843  /* 16x16 motion prediction */
844  s->mv_type = MV_TYPE_16X16;
845  ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
846  if (s->umvplus)
847  mx = h263p_decode_umotion(s, pred_x);
848  else
849  mx = ff_h263_decode_motion(s, pred_x, 1);
850 
851  if (mx >= 0xffff)
852  return SLICE_ERROR;
853 
854  if (s->umvplus)
855  my = h263p_decode_umotion(s, pred_y);
856  else
857  my = ff_h263_decode_motion(s, pred_y, 1);
858 
859  if (my >= 0xffff)
860  return SLICE_ERROR;
861  s->mv[0][0][0] = mx;
862  s->mv[0][0][1] = my;
863 
864  if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
865  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
866  } else {
867  s->current_picture.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
868  s->mv_type = MV_TYPE_8X8;
869  for(i=0;i<4;i++) {
870  mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
871  if (s->umvplus)
872  mx = h263p_decode_umotion(s, pred_x);
873  else
874  mx = ff_h263_decode_motion(s, pred_x, 1);
875  if (mx >= 0xffff)
876  return SLICE_ERROR;
877 
878  if (s->umvplus)
879  my = h263p_decode_umotion(s, pred_y);
880  else
881  my = ff_h263_decode_motion(s, pred_y, 1);
882  if (my >= 0xffff)
883  return SLICE_ERROR;
884  s->mv[0][i][0] = mx;
885  s->mv[0][i][1] = my;
886  if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
887  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
888  mot_val[0] = mx;
889  mot_val[1] = my;
890  }
891  }
892  } else if(s->pict_type==AV_PICTURE_TYPE_B) {
893  int mb_type;
894  const int stride= s->b8_stride;
895  int16_t *mot_val0 = s->current_picture.motion_val[0][2 * (s->mb_x + s->mb_y * stride)];
896  int16_t *mot_val1 = s->current_picture.motion_val[1][2 * (s->mb_x + s->mb_y * stride)];
897 // const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
898 
899  //FIXME ugly
900  mot_val0[0 ]= mot_val0[2 ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
901  mot_val0[1 ]= mot_val0[3 ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
902  mot_val1[0 ]= mot_val1[2 ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
903  mot_val1[1 ]= mot_val1[3 ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
904 
905  do{
907  if (mb_type < 0){
908  av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
909  return SLICE_ERROR;
910  }
911 
912  mb_type= h263_mb_type_b_map[ mb_type ];
913  }while(!mb_type);
914 
915  s->mb_intra = IS_INTRA(mb_type);
916  if(HAS_CBP(mb_type)){
917  s->bdsp.clear_blocks(s->block[0]);
918  cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
919  if(s->mb_intra){
920  dquant = IS_QUANT(mb_type);
921  goto intra;
922  }
923 
924  cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
925 
926  if (cbpy < 0){
927  av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
928  return SLICE_ERROR;
929  }
930 
931  if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
932  cbpy ^= 0xF;
933 
934  cbp = (cbpc & 3) | (cbpy << 2);
935  }else
936  cbp=0;
937 
938  av_assert2(!s->mb_intra);
939 
940  if(IS_QUANT(mb_type)){
942  }
943 
944  if(IS_DIRECT(mb_type)){
946  mb_type |= set_direct_mv(s);
947  }else{
948  s->mv_dir = 0;
949  s->mv_type= MV_TYPE_16X16;
950 //FIXME UMV
951 
952  if(USES_LIST(mb_type, 0)){
953  int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
954  s->mv_dir = MV_DIR_FORWARD;
955 
956  if (s->umvplus)
957  mx = h263p_decode_umotion(s, pred_x);
958  else
959  mx = ff_h263_decode_motion(s, pred_x, 1);
960  if (mx >= 0xffff)
961  return SLICE_ERROR;
962 
963  if (s->umvplus)
964  my = h263p_decode_umotion(s, pred_y);
965  else
966  my = ff_h263_decode_motion(s, pred_y, 1);
967  if (my >= 0xffff)
968  return SLICE_ERROR;
969 
970  if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
971  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
972 
973  s->mv[0][0][0] = mx;
974  s->mv[0][0][1] = my;
975  mot_val[0 ]= mot_val[2 ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
976  mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
977  }
978 
979  if(USES_LIST(mb_type, 1)){
980  int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &pred_x, &pred_y);
981  s->mv_dir |= MV_DIR_BACKWARD;
982 
983  if (s->umvplus)
984  mx = h263p_decode_umotion(s, pred_x);
985  else
986  mx = ff_h263_decode_motion(s, pred_x, 1);
987  if (mx >= 0xffff)
988  return SLICE_ERROR;
989 
990  if (s->umvplus)
991  my = h263p_decode_umotion(s, pred_y);
992  else
993  my = ff_h263_decode_motion(s, pred_y, 1);
994  if (my >= 0xffff)
995  return SLICE_ERROR;
996 
997  if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
998  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
999 
1000  s->mv[1][0][0] = mx;
1001  s->mv[1][0][1] = my;
1002  mot_val[0 ]= mot_val[2 ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
1003  mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
1004  }
1005  }
1006 
1007  s->current_picture.mb_type[xy] = mb_type;
1008  } else { /* I-Frame */
1009  do{
1011  if (cbpc < 0){
1012  av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
1013  return SLICE_ERROR;
1014  }
1015  }while(cbpc == 8);
1016 
1017  s->bdsp.clear_blocks(s->block[0]);
1018 
1019  dquant = cbpc & 4;
1020  s->mb_intra = 1;
1021 intra:
1022  s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
1023  if (s->h263_aic) {
1024  s->ac_pred = get_bits1(&s->gb);
1025  if(s->ac_pred){
1026  s->current_picture.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
1027 
1028  s->h263_aic_dir = get_bits1(&s->gb);
1029  }
1030  }else
1031  s->ac_pred = 0;
1032 
1033  if(s->pb_frame && get_bits1(&s->gb))
1034  pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
1035  cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1036  if(cbpy<0){
1037  av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
1038  return SLICE_ERROR;
1039  }
1040  cbp = (cbpc & 3) | (cbpy << 2);
1041  if (dquant) {
1043  }
1044 
1045  pb_mv_count += !!s->pb_frame;
1046  }
1047 
1048  while(pb_mv_count--){
1049  ff_h263_decode_motion(s, 0, 1);
1050  ff_h263_decode_motion(s, 0, 1);
1051  }
1052 
1053  /* decode each block */
1054  for (i = 0; i < 6; i++) {
1055  if (h263_decode_block(s, block[i], i, cbp&32) < 0)
1056  return -1;
1057  cbp+=cbp;
1058  }
1059 
1060  if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
1061  return -1;
1062  if(s->obmc && !s->mb_intra){
1063  if(s->pict_type == AV_PICTURE_TYPE_P && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
1064  preview_obmc(s);
1065  }
1066 end:
1067 
1068  if (get_bits_left(&s->gb) < 0)
1069  return AVERROR_INVALIDDATA;
1070 
1071  /* per-MB end of slice check */
1072  {
1073  int v= show_bits(&s->gb, 16);
1074 
1075  if (get_bits_left(&s->gb) < 16) {
1076  v >>= 16 - get_bits_left(&s->gb);
1077  }
1078 
1079  if(v==0)
1080  return SLICE_END;
1081  }
1082 
1083  return SLICE_OK;
1084 }
1085 
1086 /* Most is hardcoded; should extend to handle all H.263 streams. */
1088 {
1089  int format, width, height, i, ret;
1090  uint32_t startcode;
1091 
1092  align_get_bits(&s->gb);
1093 
1094  if (show_bits(&s->gb, 2) == 2 && s->avctx->frame_number == 0) {
1095  av_log(s->avctx, AV_LOG_WARNING, "Header looks like RTP instead of H.263\n");
1096  }
1097 
1098  startcode= get_bits(&s->gb, 22-8);
1099 
1100  for(i= get_bits_left(&s->gb); i>24; i-=8) {
1101  startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
1102 
1103  if(startcode == 0x20)
1104  break;
1105  }
1106 
1107  if (startcode != 0x20) {
1108  av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
1109  return -1;
1110  }
1111  /* temporal reference */
1112  i = get_bits(&s->gb, 8); /* picture timestamp */
1113 
1114  i -= (i - (s->picture_number & 0xFF) + 128) & ~0xFF;
1115 
1116  s->picture_number= (s->picture_number&~0xFF) + i;
1117 
1118  /* PTYPE starts here */
1119  if (check_marker(s->avctx, &s->gb, "in PTYPE") != 1) {
1120  return -1;
1121  }
1122  if (get_bits1(&s->gb) != 0) {
1123  av_log(s->avctx, AV_LOG_ERROR, "Bad H.263 id\n");
1124  return -1; /* H.263 id */
1125  }
1126  skip_bits1(&s->gb); /* split screen off */
1127  skip_bits1(&s->gb); /* camera off */
1128  skip_bits1(&s->gb); /* freeze picture release off */
1129 
1130  format = get_bits(&s->gb, 3);
1131  /*
1132  0 forbidden
1133  1 sub-QCIF
1134  10 QCIF
1135  7 extended PTYPE (PLUSPTYPE)
1136  */
1137 
1138  if (format != 7 && format != 6) {
1139  s->h263_plus = 0;
1140  /* H.263v1 */
1141  width = ff_h263_format[format][0];
1143  if (!width)
1144  return -1;
1145 
1146  s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
1147 
1148  s->h263_long_vectors = get_bits1(&s->gb);
1149 
1150  if (get_bits1(&s->gb) != 0) {
1151  av_log(s->avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");
1152  return -1; /* SAC: off */
1153  }
1154  s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
1155 
1156  s->pb_frame = get_bits1(&s->gb);
1157  s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
1158  skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
1159 
1160  s->width = width;
1161  s->height = height;
1162  s->avctx->sample_aspect_ratio= (AVRational){12,11};
1163  s->avctx->framerate = (AVRational){ 30000, 1001 };
1164  } else {
1165  int ufep;
1166 
1167  /* H.263v2 */
1168  s->h263_plus = 1;
1169  ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */
1170 
1171  /* ufep other than 0 and 1 are reserved */
1172  if (ufep == 1) {
1173  /* OPPTYPE */
1174  format = get_bits(&s->gb, 3);
1175  ff_dlog(s->avctx, "ufep=1, format: %d\n", format);
1176  s->custom_pcf= get_bits1(&s->gb);
1177  s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */
1178  if (get_bits1(&s->gb) != 0) {
1179  av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
1180  }
1181  s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
1182  s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
1183  s->loop_filter= get_bits1(&s->gb);
1184  if(s->avctx->lowres)
1185  s->loop_filter = 0;
1186 
1187  s->h263_slice_structured= get_bits1(&s->gb);
1188  if (get_bits1(&s->gb) != 0) {
1189  av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
1190  }
1191  if (get_bits1(&s->gb) != 0) {
1192  av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
1193  }
1194  s->alt_inter_vlc= get_bits1(&s->gb);
1195  s->modified_quant= get_bits1(&s->gb);
1196  if(s->modified_quant)
1197  s->chroma_qscale_table= ff_h263_chroma_qscale_table;
1198 
1199  skip_bits(&s->gb, 1); /* Prevent start code emulation */
1200 
1201  skip_bits(&s->gb, 3); /* Reserved */
1202  } else if (ufep != 0) {
1203  av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
1204  return -1;
1205  }
1206 
1207  /* MPPTYPE */
1208  s->pict_type = get_bits(&s->gb, 3);
1209  switch(s->pict_type){
1210  case 0: s->pict_type= AV_PICTURE_TYPE_I;break;
1211  case 1: s->pict_type= AV_PICTURE_TYPE_P;break;
1212  case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break;
1213  case 3: s->pict_type= AV_PICTURE_TYPE_B;break;
1214  case 7: s->pict_type= AV_PICTURE_TYPE_I;break; //ZYGO
1215  default:
1216  return -1;
1217  }
1218  skip_bits(&s->gb, 2);
1219  s->no_rounding = get_bits1(&s->gb);
1220  skip_bits(&s->gb, 4);
1221 
1222  /* Get the picture dimensions */
1223  if (ufep) {
1224  if (format == 6) {
1225  /* Custom Picture Format (CPFMT) */
1226  int aspect_ratio_info = get_bits(&s->gb, 4);
1227  ff_dlog(s->avctx, "aspect: %d\n", aspect_ratio_info);
1228  /* aspect ratios:
1229  0 - forbidden
1230  1 - 1:1
1231  2 - 12:11 (CIF 4:3)
1232  3 - 10:11 (525-type 4:3)
1233  4 - 16:11 (CIF 16:9)
1234  5 - 40:33 (525-type 16:9)
1235  6-14 - reserved
1236  */
1237  width = (get_bits(&s->gb, 9) + 1) * 4;
1238  check_marker(s->avctx, &s->gb, "in dimensions");
1239  height = get_bits(&s->gb, 9) * 4;
1240  ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
1241  if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
1242  /* expected dimensions */
1243  s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
1244  s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
1245  }else{
1246  s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[aspect_ratio_info];
1247  }
1248  } else {
1249  width = ff_h263_format[format][0];
1251  s->avctx->sample_aspect_ratio= (AVRational){12,11};
1252  }
1253  s->avctx->sample_aspect_ratio.den <<= s->ehc_mode;
1254  if ((width == 0) || (height == 0))
1255  return -1;
1256  s->width = width;
1257  s->height = height;
1258 
1259  if(s->custom_pcf){
1260  int gcd;
1261  s->avctx->framerate.num = 1800000;
1262  s->avctx->framerate.den = 1000 + get_bits1(&s->gb);
1263  s->avctx->framerate.den *= get_bits(&s->gb, 7);
1264  if(s->avctx->framerate.den == 0){
1265  av_log(s, AV_LOG_ERROR, "zero framerate\n");
1266  return -1;
1267  }
1268  gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num);
1269  s->avctx->framerate.den /= gcd;
1270  s->avctx->framerate.num /= gcd;
1271  }else{
1272  s->avctx->framerate = (AVRational){ 30000, 1001 };
1273  }
1274  }
1275 
1276  if(s->custom_pcf){
1277  skip_bits(&s->gb, 2); //extended Temporal reference
1278  }
1279 
1280  if (ufep) {
1281  if (s->umvplus) {
1282  if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
1283  skip_bits1(&s->gb);
1284  }
1285  if(s->h263_slice_structured){
1286  if (get_bits1(&s->gb) != 0) {
1287  av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
1288  }
1289  if (get_bits1(&s->gb) != 0) {
1290  av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n");
1291  }
1292  }
1293  if (s->pict_type == AV_PICTURE_TYPE_B) {
1294  skip_bits(&s->gb, 4); //ELNUM
1295  if (ufep == 1) {
1296  skip_bits(&s->gb, 4); // RLNUM
1297  }
1298  }
1299  }
1300 
1301  s->qscale = get_bits(&s->gb, 5);
1302  }
1303 
1304  if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0)
1305  return ret;
1306 
1307  if (!(s->avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
1308  if ((s->width * s->height / 256 / 8) > get_bits_left(&s->gb))
1309  return AVERROR_INVALIDDATA;
1310  }
1311 
1312  s->mb_width = (s->width + 15) / 16;
1313  s->mb_height = (s->height + 15) / 16;
1314  s->mb_num = s->mb_width * s->mb_height;
1315 
1316  if (s->pb_frame) {
1317  skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */
1318  if (s->custom_pcf)
1319  skip_bits(&s->gb, 2); //extended Temporal reference
1320  skip_bits(&s->gb, 2); /* Quantization information for B-pictures */
1321  }
1322 
1323  if (s->pict_type!=AV_PICTURE_TYPE_B) {
1324  s->time = s->picture_number;
1325  s->pp_time = s->time - s->last_non_b_time;
1326  s->last_non_b_time = s->time;
1327  }else{
1328  s->time = s->picture_number;
1329  s->pb_time = s->pp_time - (s->last_non_b_time - s->time);
1330  if (s->pp_time <=s->pb_time ||
1331  s->pp_time <= s->pp_time - s->pb_time ||
1332  s->pp_time <= 0){
1333  s->pp_time = 2;
1334  s->pb_time = 1;
1335  }
1337  }
1338 
1339  /* PEI */
1340  if (skip_1stop_8data_bits(&s->gb) < 0)
1341  return AVERROR_INVALIDDATA;
1342 
1343  if(s->h263_slice_structured){
1344  if (check_marker(s->avctx, &s->gb, "SEPB1") != 1) {
1345  return -1;
1346  }
1347 
1349 
1350  if (check_marker(s->avctx, &s->gb, "SEPB2") != 1) {
1351  return -1;
1352  }
1353  }
1354  s->f_code = 1;
1355 
1356  if (s->pict_type == AV_PICTURE_TYPE_B)
1357  s->low_delay = 0;
1358 
1359  if(s->h263_aic){
1360  s->y_dc_scale_table=
1361  s->c_dc_scale_table= ff_aic_dc_scale_table;
1362  }else{
1363  s->y_dc_scale_table=
1364  s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
1365  }
1366 
1368  if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO") && get_bits_left(&s->gb) >= 85 + 13*3*16 + 50){
1369  int i,j;
1370  for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
1371  av_log(s->avctx, AV_LOG_DEBUG, "\n");
1372  for(i=0; i<13; i++){
1373  for(j=0; j<3; j++){
1374  int v= get_bits(&s->gb, 8);
1375  v |= get_sbits(&s->gb, 8) * (1 << 8);
1376  av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
1377  }
1378  av_log(s->avctx, AV_LOG_DEBUG, "\n");
1379  }
1380  for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
1381  }
1382 
1383  return 0;
1384 }
IS_8X8
#define IS_8X8(a)
Definition: mpegutils.h:82
MB_TYPE_L0
#define MB_TYPE_L0
Definition: mpegutils.h:60
MV_TYPE_16X16
#define MV_TYPE_16X16
1 vector for the whole mb
Definition: mpegvideo.h:248
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
h263data.h
FF_ASPECT_EXTENDED
#define FF_ASPECT_EXTENDED
Definition: h263.h:26
level
uint8_t level
Definition: svq3.c:206
show_bits_long
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
Definition: get_bits.h:603
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:850
h263_pred_acdc
static void h263_pred_acdc(MpegEncContext *s, int16_t *block, int n)
Definition: ituh263dec.c:444
ff_h263_show_pict_info
void ff_h263_show_pict_info(MpegEncContext *s)
Print picture info if FF_DEBUG_PICT_INFO is set.
Definition: ituh263dec.c:78
mem_internal.h
thread.h
ff_mpeg1_dc_scale_table
const uint8_t ff_mpeg1_dc_scale_table[128]
Definition: mpegvideodata.c:33
mpeg4videodec.h
INIT_VLC_STATIC
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
Definition: vlc.h:120
mv
static const int8_t mv[256][2]
Definition: 4xm.c:80
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:220
MV_DIRECT
#define MV_DIRECT
bidirectional mode where the difference equals the MV of the last P/S/I-Frame (MPEG-4)
Definition: mpegvideo.h:246
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:62
h263_decode_init_vlc
static av_cold void h263_decode_init_vlc(void)
Definition: ituh263dec.c:109
MB_TYPE_INTRA4x4
#define MB_TYPE_INTRA4x4
Definition: mpegutils.h:44
MB_TYPE_16x16
#define MB_TYPE_16x16
Definition: mpegutils.h:47
h263_decode_dquant
static void h263_decode_dquant(MpegEncContext *s)
Definition: ituh263dec.c:431
get_vlc2
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:798
h263_mb_type_b_map
static const int h263_mb_type_b_map[15]
Definition: ituh263dec.c:60
mpegvideo.h
AV_EF_COMPLIANT
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
Definition: avcodec.h:1359
mathematics.h
MB_TYPE_L1
#define MB_TYPE_L1
Definition: mpegutils.h:61
UPDATE_CACHE
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:179
Picture
Picture.
Definition: mpegpicture.h:46
h263_decode_block
static int h263_decode_block(MpegEncContext *s, int16_t *block, int n, int coded)
Definition: ituh263dec.c:531
ff_h263_decode_mba
int ff_h263_decode_mba(MpegEncContext *s)
Definition: ituh263dec.c:140
mpegutils.h
FF_DEBUG_PICT_INFO
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:1323
MV_DIR_BACKWARD
#define MV_DIR_BACKWARD
Definition: mpegvideo.h:245
av_gcd
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:468
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:380
SKIP_CACHE
#define SKIP_CACHE(name, gb, num)
Definition: get_bits.h:181
ff_h263_decode_mb
int ff_h263_decode_mb(MpegEncContext *s, int16_t block[6][64])
Definition: ituh263dec.c:785
ff_h263_pred_motion
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
Definition: h263.c:190
wrap
#define wrap(func)
Definition: neontest.h:65
ff_h263_pixel_aspect
const AVRational ff_h263_pixel_aspect[16]
Definition: h263data.c:273
preview_obmc
static void preview_obmc(MpegEncContext *s)
read the next MVs for OBMC.
Definition: ituh263dec.c:339
RLTable
RLTable.
Definition: rl.h:39
GetBitContext
Definition: get_bits.h:62
USES_LIST
#define USES_LIST(a, list)
Definition: mpegutils.h:92
MB_TYPE_CBP
#define MB_TYPE_CBP
Definition: mpegutils.h:64
val
static double val(void *priv, double ch)
Definition: aeval.c:77
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1388
SLICE_END
#define SLICE_END
end marker found
Definition: mpegvideo.h:474
HAS_CBP
#define HAS_CBP(a)
Definition: mpegutils.h:94
AV_EF_BITSTREAM
#define AV_EF_BITSTREAM
detect bitstream specification deviations
Definition: avcodec.h:1353
ff_cbpc_b_tab
const uint8_t ff_cbpc_b_tab[4][2]
Definition: h263data.c:75
ff_thread_once
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:179
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
INIT_FIRST_VLC_RL
#define INIT_FIRST_VLC_RL(rl, static_size)
Definition: rl.h:83
h263dec.h
av_cold
#define av_cold
Definition: attributes.h:90
cbpc_b_vlc
static VLC cbpc_b_vlc
Definition: ituh263dec.c:105
MB_TYPE_ACPRED
#define MB_TYPE_ACPRED
Definition: mpegutils.h:53
h263_decode_gob_header
static int h263_decode_gob_header(MpegEncContext *s)
Decode the group of blocks header or slice header.
Definition: ituh263dec.c:158
CLOSE_READER
#define CLOSE_READER(name, gb)
Definition: get_bits.h:150
ff_h263_decode_init_vlc
av_cold void ff_h263_decode_init_vlc(void)
Definition: ituh263dec.c:134
width
#define width
ff_h263_chroma_qscale_table
const uint8_t ff_h263_chroma_qscale_table[32]
Definition: h263data.c:260
s
#define s(width, name)
Definition: cbs_vp9.c:256
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
SHOW_SBITS
#define SHOW_SBITS(name, gb, num)
Definition: get_bits.h:213
set_one_direct_mv
static void set_one_direct_mv(MpegEncContext *s, Picture *p, int i)
Definition: ituh263dec.c:720
get_sbits
static int get_sbits(GetBitContext *s, int n)
Definition: get_bits.h:360
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
IS_INTRA
#define IS_INTRA(x, y)
ff_h263_resync
int ff_h263_resync(MpegEncContext *s)
Decode the group of blocks / video packet header / slice header (MPEG-4 Studio).
Definition: ituh263dec.c:214
tab_size
#define tab_size
Definition: ituh263dec.c:718
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:177
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:136
run
uint8_t run
Definition: svq3.c:205
tab_bias
#define tab_bias
Definition: ituh263dec.c:719
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
MB_TYPE_8x8
#define MB_TYPE_8x8
Definition: mpegutils.h:50
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:499
ff_set_qscale
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
Definition: mpegvideo.c:1707
mathops.h
ff_mba_max
const uint16_t ff_mba_max[6]
Definition: h263data.c:265
MB_TYPE_QUANT
#define MB_TYPE_QUANT
Definition: mpegutils.h:63
ff_h263_decode_picture_header
int ff_h263_decode_picture_header(MpegEncContext *s)
Definition: ituh263dec.c:1087
ff_h263_inter_MCBPC_vlc
VLC ff_h263_inter_MCBPC_vlc
Definition: ituh263dec.c:101
AVOnce
#define AVOnce
Definition: thread.h:176
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_h263_intra_MCBPC_vlc
VLC ff_h263_intra_MCBPC_vlc
Definition: ituh263dec.c:100
get_unary
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
Definition: unary.h:46
MV_TYPE_8X8
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
Definition: mpegvideo.h:249
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:28
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:422
ff_h263_rl_inter
RLTable ff_h263_rl_inter
Definition: h263data.c:159
ff_h263_mv_vlc
VLC ff_h263_mv_vlc
Definition: ituh263dec.c:103
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
ff_h263_cbpy_tab
const uint8_t ff_h263_cbpy_tab[16][2]
Definition: h263data.c:82
ff_rl_intra_aic
RLTable ff_rl_intra_aic
Definition: h263data.c:228
CBPY_VLC_BITS
#define CBPY_VLC_BITS
Definition: h263dec.h:33
MB_TYPE_SKIP
#define MB_TYPE_SKIP
Definition: mpegutils.h:55
h263_mbtype_b_vlc
static VLC h263_mbtype_b_vlc
Definition: ituh263dec.c:104
OPEN_READER
#define OPEN_READER(name, gb)
Definition: get_bits.h:139
height
#define height
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
mpegvideodata.h
attributes.h
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:539
Picture::motion_val
int16_t(*[2] motion_val)[2]
Definition: mpegpicture.h:54
ff_h263_inter_MCBPC_bits
const uint8_t ff_h263_inter_MCBPC_bits[28]
Definition: h263data.c:47
IS_DIRECT
#define IS_DIRECT(a)
Definition: mpegutils.h:77
unary.h
H263_MBTYPE_B_VLC_BITS
#define H263_MBTYPE_B_VLC_BITS
Definition: ituh263dec.c:57
ff_rv_decode_dc
int ff_rv_decode_dc(MpegEncContext *s, int n)
Definition: rv10.c:84
av_get_picture_type_char
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
Definition: utils.c:40
MB_TYPE_L0L1
#define MB_TYPE_L0L1
Definition: mpegutils.h:62
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
AV_CODEC_ID_RV10
@ AV_CODEC_ID_RV10
Definition: codec_id.h:55
SKIP_COUNTER
#define SKIP_COUNTER(name, gb, num)
Definition: get_bits.h:186
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
show_bits
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:447
internal.h
ff_mpeg4_decode_video_packet_header
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
Decode the next video packet.
Definition: mpeg4videodec.c:516
INTRA_MCBPC_VLC_BITS
#define INTRA_MCBPC_VLC_BITS
Definition: h263dec.h:31
IS_QUANT
#define IS_QUANT(a)
Definition: mpegutils.h:88
h263_skip_b_part
static int h263_skip_b_part(MpegEncContext *s, int cbp)
Definition: ituh263dec.c:678
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_h263_format
const uint16_t ff_h263_format[8][2]
Definition: h263data.c:236
CBPC_B_VLC_BITS
#define CBPC_B_VLC_BITS
Definition: ituh263dec.c:58
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
GET_RL_VLC
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
Definition: get_bits.h:739
ret
ret
Definition: filter_design.txt:187
SLICE_OK
#define SLICE_OK
Definition: mpegvideo.h:472
pred
static const float pred[4]
Definition: siprdata.h:259
ff_aic_dc_scale_table
const uint8_t ff_aic_dc_scale_table[32]
Definition: h263data.c:245
align_get_bits
static const uint8_t * align_get_bits(GetBitContext *s)
Definition: get_bits.h:694
TEX_VLC_BITS
#define TEX_VLC_BITS
Definition: dvdec.c:133
pos
unsigned int pos
Definition: spdifenc.c:412
ff_mpeg4_init_direct_mv
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
Definition: mpeg4video.c:83
ff_mvtab
const uint8_t ff_mvtab[33][2]
Definition: h263data.c:88
left
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
Definition: snow.txt:386
AV_CODEC_FLAG2_CHUNKS
#define AV_CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
Definition: avcodec.h:312
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ff_h263_intra_MCBPC_bits
const uint8_t ff_h263_intra_MCBPC_bits[9]
Definition: h263data.c:33
skip_1stop_8data_bits
static int skip_1stop_8data_bits(GetBitContext *gb)
Definition: get_bits.h:855
Picture::mb_type
uint32_t * mb_type
types and macros are defined in mpegutils.h
Definition: mpegpicture.h:57
ff_h263_intra_MCBPC_code
const uint8_t ff_h263_intra_MCBPC_code[9]
Definition: h263data.c:32
SHOW_UBITS
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:212
AV_PICTURE_TYPE_B
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition: avutil.h:276
mpeg4video.h
Picture::f
struct AVFrame * f
Definition: mpegpicture.h:47
VLC
Definition: vlc.h:26
sign_extend
static av_const int sign_extend(int val, unsigned bits)
Definition: mathops.h:132
ff_mba_length
const uint8_t ff_mba_length[7]
Definition: h263data.c:269
h263p_decode_umotion
static int h263p_decode_umotion(MpegEncContext *s, int pred)
Definition: ituh263dec.c:309
shift
static int shift(int a, int b)
Definition: sonic.c:88
ff_h263_inter_MCBPC_code
const uint8_t ff_h263_inter_MCBPC_code[28]
Definition: h263data.c:38
INIT_VLC_RL
#define INIT_VLC_RL(rl, static_size)
Definition: rl.h:73
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
set_direct_mv
static int set_direct_mv(MpegEncContext *s)
Definition: ituh263dec.c:748
ff_modified_quant_tab
const uint8_t ff_modified_quant_tab[2][32]
Definition: h263data.c:250
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
check_marker
static int check_marker(void *logctx, GetBitContext *s, const char *msg)
Definition: get_bits.h:613
SLICE_ERROR
#define SLICE_ERROR
Definition: mpegvideo.h:473
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:139
h263_get_modb
static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
Definition: ituh263dec.c:700
pred_dc
static void FUNC() pred_dc(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, ptrdiff_t stride, int log2_size, int c_idx)
Definition: hevcpred_template.c:390
ff_tlog
#define ff_tlog(ctx,...)
Definition: internal.h:204
MV_DIR_FORWARD
#define MV_DIR_FORWARD
Definition: mpegvideo.h:244
imgutils.h
MB_TYPE_DIRECT2
#define MB_TYPE_DIRECT2
Definition: mpegutils.h:52
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_h263_mbtype_b_tab
const uint8_t ff_h263_mbtype_b_tab[15][2]
Definition: h263data.c:57
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
av_image_check_size
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:318
H263_MV_VLC_BITS
#define H263_MV_VLC_BITS
Definition: h263dec.h:30
ff_h263_init_rl_inter
av_cold void ff_h263_init_rl_inter(void)
Definition: h263.c:47
ff_h263_decode_motion
int ff_h263_decode_motion(MpegEncContext *s, int pred, int f_code)
Definition: ituh263dec.c:271
ff_h263_cbpy_vlc
VLC ff_h263_cbpy_vlc
Definition: ituh263dec.c:102
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:64
VLC::table
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
SLICE_STARTCODE
#define SLICE_STARTCODE
Definition: mpeg4video.h:64
RLTable::rl_vlc
RL_VLC_ELEM * rl_vlc[32]
decoding only
Definition: rl.h:48
rv10dec.h
MB_TYPE_INTRA
#define MB_TYPE_INTRA
Definition: mpegutils.h:66
INTER_MCBPC_VLC_BITS
#define INTER_MCBPC_VLC_BITS
Definition: h263dec.h:32
re
float re
Definition: fft.c:79
h263.h