FFmpeg
msmpeg4enc.c
Go to the documentation of this file.
1 /*
2  * MSMPEG4 encoder backend
3  * Copyright (c) 2001 Fabrice Bellard
4  * Copyright (c) 2002-2004 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 /**
26  * @file
27  * MSMPEG4 encoder backend
28  */
29 
30 #include <stdint.h>
31 #include <string.h>
32 
33 #include "libavutil/attributes.h"
34 #include "libavutil/avutil.h"
35 #include "libavutil/mem.h"
36 #include "mpegvideo.h"
37 #include "h263.h"
38 #include "internal.h"
39 #include "mpeg4video.h"
40 #include "msmpeg4.h"
41 #include "msmpeg4data.h"
42 #include "put_bits.h"
43 #include "rl.h"
44 #include "vc1data.h"
45 
47 
48 /* build the table which associate a (x,y) motion vector to a vlc */
50 {
51  int i, x, y;
52 
53  tab->table_mv_index = av_malloc(sizeof(uint16_t) * 4096);
54  if (!tab->table_mv_index)
55  return AVERROR(ENOMEM);
56 
57  /* mark all entries as not used */
58  for(i=0;i<4096;i++)
59  tab->table_mv_index[i] = tab->n;
60 
61  for(i=0;i<tab->n;i++) {
62  x = tab->table_mvx[i];
63  y = tab->table_mvy[i];
64  tab->table_mv_index[(x << 6) | y] = i;
65  }
66 
67  return 0;
68 }
69 
71 {
72  if (n == 0) {
73  put_bits(pb, 1, 0);
74  } else {
75  put_bits(pb, 1, 1);
76  put_bits(pb, 1, (n >= 2));
77  }
78 }
79 
80 static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra){
81  int size=0;
82  int code;
83  int run_diff= intra ? 0 : 1;
84 
85  code = get_rl_index(rl, last, run, level);
86  size+= rl->table_vlc[code][1];
87  if (code == rl->n) {
88  int level1, run1;
89 
90  level1 = level - rl->max_level[last][run];
91  if (level1 < 1)
92  goto esc2;
93  code = get_rl_index(rl, last, run, level1);
94  if (code == rl->n) {
95  esc2:
96  size++;
97  if (level > MAX_LEVEL)
98  goto esc3;
99  run1 = run - rl->max_run[last][level] - run_diff;
100  if (run1 < 0)
101  goto esc3;
102  code = get_rl_index(rl, last, run1, level);
103  if (code == rl->n) {
104  esc3:
105  /* third escape */
106  size+=1+1+6+8;
107  } else {
108  /* second escape */
109  size+= 1+1+ rl->table_vlc[code][1];
110  }
111  } else {
112  /* first escape */
113  size+= 1+1+ rl->table_vlc[code][1];
114  }
115  } else {
116  size++;
117  }
118  return size;
119 }
120 
122 {
123  static int init_done=0;
124  int i, ret;
125 
127  if(s->msmpeg4_version>=4){
128  s->min_qcoeff= -255;
129  s->max_qcoeff= 255;
130  }
131 
132  if (!init_done) {
133  /* init various encoding tables */
134  init_done = 1;
135  if ((ret = init_mv_table(&ff_mv_tables[0])) < 0)
136  return ret;
137  if ((ret = init_mv_table(&ff_mv_tables[1])) < 0)
138  return ret;
139  for(i=0;i<NB_RL_TABLES;i++)
141 
142  for(i=0; i<NB_RL_TABLES; i++){
143  int level;
144  for (level = 1; level <= MAX_LEVEL; level++) {
145  int run;
146  for(run=0; run<=MAX_RUN; run++){
147  int last;
148  for(last=0; last<2; last++){
149  rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0);
150  }
151  }
152  }
153  }
154  }
155 
156  return 0;
157 }
158 
160 {
161  int i;
162  int best = 0, best_size = INT_MAX;
163  int chroma_best = 0, best_chroma_size = INT_MAX;
164 
165  for(i=0; i<3; i++){
166  int level;
167  int chroma_size=0;
168  int size=0;
169 
170  if(i>0){// ;)
171  size++;
172  chroma_size++;
173  }
174  for(level=0; level<=MAX_LEVEL; level++){
175  int run;
176  for(run=0; run<=MAX_RUN; run++){
177  int last;
178  const int last_size= size + chroma_size;
179  for(last=0; last<2; last++){
180  int inter_count = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last];
181  int intra_luma_count = s->ac_stats[1][0][level][run][last];
182  int intra_chroma_count= s->ac_stats[1][1][level][run][last];
183 
184  if(s->pict_type==AV_PICTURE_TYPE_I){
185  size += intra_luma_count *rl_length[i ][level][run][last];
186  chroma_size+= intra_chroma_count*rl_length[i+3][level][run][last];
187  }else{
188  size+= intra_luma_count *rl_length[i ][level][run][last]
189  +intra_chroma_count*rl_length[i+3][level][run][last]
190  +inter_count *rl_length[i+3][level][run][last];
191  }
192  }
193  if(last_size == size+chroma_size) break;
194  }
195  }
196  if(size<best_size){
197  best_size= size;
198  best= i;
199  }
200  if(chroma_size<best_chroma_size){
201  best_chroma_size= chroma_size;
202  chroma_best= i;
203  }
204  }
205 
206  if(s->pict_type==AV_PICTURE_TYPE_P) chroma_best= best;
207 
208  memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2);
209 
210  s->rl_table_index = best;
211  s->rl_chroma_table_index= chroma_best;
212 
213  if(s->pict_type != s->last_non_b_pict_type){
214  s->rl_table_index= 2;
215  if(s->pict_type==AV_PICTURE_TYPE_I)
216  s->rl_chroma_table_index= 1;
217  else
218  s->rl_chroma_table_index= 2;
219  }
220 
221 }
222 
223 /* write MSMPEG4 compatible frame header */
225 {
227 
228  avpriv_align_put_bits(&s->pb);
229  put_bits(&s->pb, 2, s->pict_type - 1);
230 
231  put_bits(&s->pb, 5, s->qscale);
232  if(s->msmpeg4_version<=2){
233  s->rl_table_index = 2;
234  s->rl_chroma_table_index = 2;
235  }
236 
237  s->dc_table_index = 1;
238  s->mv_table_index = 1; /* only if P-frame */
239  s->use_skip_mb_code = 1; /* only if P-frame */
240  s->per_mb_rl_table = 0;
241  if(s->msmpeg4_version==4)
242  s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
243  ff_dlog(s, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
244  s->inter_intra_pred, s->width, s->height);
245 
246  if (s->pict_type == AV_PICTURE_TYPE_I) {
247  s->slice_height= s->mb_height/1;
248  put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
249 
250  if(s->msmpeg4_version==4){
252  if(s->bit_rate>MBAC_BITRATE)
253  put_bits(&s->pb, 1, s->per_mb_rl_table);
254  }
255 
256  if(s->msmpeg4_version>2){
257  if(!s->per_mb_rl_table){
258  ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index);
259  ff_msmpeg4_code012(&s->pb, s->rl_table_index);
260  }
261 
262  put_bits(&s->pb, 1, s->dc_table_index);
263  }
264  } else {
265  put_bits(&s->pb, 1, s->use_skip_mb_code);
266 
267  if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE)
268  put_bits(&s->pb, 1, s->per_mb_rl_table);
269 
270  if(s->msmpeg4_version>2){
271  if(!s->per_mb_rl_table)
272  ff_msmpeg4_code012(&s->pb, s->rl_table_index);
273 
274  put_bits(&s->pb, 1, s->dc_table_index);
275 
276  put_bits(&s->pb, 1, s->mv_table_index);
277  }
278  }
279 
280  s->esc3_level_length= 0;
281  s->esc3_run_length= 0;
282 }
283 
285 {
286  unsigned fps = s->avctx->time_base.den / s->avctx->time_base.num / FFMAX(s->avctx->ticks_per_frame, 1);
287  put_bits(&s->pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
288 
289  put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
290 
291  if(s->msmpeg4_version>=3)
292  put_bits(&s->pb, 1, s->flipflop_rounding);
293  else
294  av_assert0(s->flipflop_rounding==0);
295 }
296 
298  int mx, int my)
299 {
300  int code;
301  MVTable *mv;
302 
303  /* modulo encoding */
304  /* WARNING : you cannot reach all the MVs even with the modulo
305  encoding. This is a somewhat strange compromise they took !!! */
306  if (mx <= -64)
307  mx += 64;
308  else if (mx >= 64)
309  mx -= 64;
310  if (my <= -64)
311  my += 64;
312  else if (my >= 64)
313  my -= 64;
314 
315  mx += 32;
316  my += 32;
317  mv = &ff_mv_tables[s->mv_table_index];
318 
319  code = mv->table_mv_index[(mx << 6) | my];
320  put_bits(&s->pb,
321  mv->table_mv_bits[code],
322  mv->table_mv_code[code]);
323  if (code == mv->n) {
324  /* escape : code literally */
325  put_bits(&s->pb, 6, mx);
326  put_bits(&s->pb, 6, my);
327  }
328 }
329 
331  if (s->mb_x == 0) {
332  if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
333  if(s->msmpeg4_version < 4){
335  }
336  s->first_slice_line = 1;
337  } else {
338  s->first_slice_line = 0;
339  }
340  }
341 }
342 
344 {
345  int range, bit_size, sign, code, bits;
346 
347  if (val == 0) {
348  /* zero vector */
349  code = 0;
350  put_bits(&s->pb, ff_mvtab[code][1], ff_mvtab[code][0]);
351  } else {
352  bit_size = s->f_code - 1;
353  range = 1 << bit_size;
354  if (val <= -64)
355  val += 64;
356  else if (val >= 64)
357  val -= 64;
358 
359  if (val >= 0) {
360  sign = 0;
361  } else {
362  val = -val;
363  sign = 1;
364  }
365  val--;
366  code = (val >> bit_size) + 1;
367  bits = val & (range - 1);
368 
369  put_bits(&s->pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
370  if (bit_size > 0) {
371  put_bits(&s->pb, bit_size, bits);
372  }
373  }
374 }
375 
377  int16_t block[6][64],
378  int motion_x, int motion_y)
379 {
380  int cbp, coded_cbp, i;
381  int pred_x, pred_y;
382  uint8_t *coded_block;
383 
385 
386  if (!s->mb_intra) {
387  /* compute cbp */
388  cbp = 0;
389  for (i = 0; i < 6; i++) {
390  if (s->block_last_index[i] >= 0)
391  cbp |= 1 << (5 - i);
392  }
393  if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
394  /* skip macroblock */
395  put_bits(&s->pb, 1, 1);
396  s->last_bits++;
397  s->misc_bits++;
398  s->skip_count++;
399 
400  return;
401  }
402  if (s->use_skip_mb_code)
403  put_bits(&s->pb, 1, 0); /* mb coded */
404 
405  if(s->msmpeg4_version<=2){
406  put_bits(&s->pb,
407  ff_v2_mb_type[cbp&3][1],
408  ff_v2_mb_type[cbp&3][0]);
409  if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
410  else coded_cbp= cbp;
411 
412  put_bits(&s->pb,
413  ff_h263_cbpy_tab[coded_cbp>>2][1],
414  ff_h263_cbpy_tab[coded_cbp>>2][0]);
415 
416  s->misc_bits += get_bits_diff(s);
417 
418  ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
419  msmpeg4v2_encode_motion(s, motion_x - pred_x);
420  msmpeg4v2_encode_motion(s, motion_y - pred_y);
421  }else{
422  put_bits(&s->pb,
423  ff_table_mb_non_intra[cbp + 64][1],
424  ff_table_mb_non_intra[cbp + 64][0]);
425 
426  s->misc_bits += get_bits_diff(s);
427 
428  /* motion vector */
429  ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
430  ff_msmpeg4_encode_motion(s, motion_x - pred_x,
431  motion_y - pred_y);
432  }
433 
434  s->mv_bits += get_bits_diff(s);
435 
436  for (i = 0; i < 6; i++) {
438  }
439  s->p_tex_bits += get_bits_diff(s);
440  } else {
441  /* compute cbp */
442  cbp = 0;
443  coded_cbp = 0;
444  for (i = 0; i < 6; i++) {
445  int val, pred;
446  val = (s->block_last_index[i] >= 1);
447  cbp |= val << (5 - i);
448  if (i < 4) {
449  /* predict value for close blocks only for luma */
450  pred = ff_msmpeg4_coded_block_pred(s, i, &coded_block);
451  *coded_block = val;
452  val = val ^ pred;
453  }
454  coded_cbp |= val << (5 - i);
455  }
456 
457  if(s->msmpeg4_version<=2){
458  if (s->pict_type == AV_PICTURE_TYPE_I) {
459  put_bits(&s->pb,
460  ff_v2_intra_cbpc[cbp&3][1], ff_v2_intra_cbpc[cbp&3][0]);
461  } else {
462  if (s->use_skip_mb_code)
463  put_bits(&s->pb, 1, 0); /* mb coded */
464  put_bits(&s->pb,
465  ff_v2_mb_type[(cbp&3) + 4][1],
466  ff_v2_mb_type[(cbp&3) + 4][0]);
467  }
468  put_bits(&s->pb, 1, 0); /* no AC prediction yet */
469  put_bits(&s->pb,
470  ff_h263_cbpy_tab[cbp>>2][1],
471  ff_h263_cbpy_tab[cbp>>2][0]);
472  }else{
473  if (s->pict_type == AV_PICTURE_TYPE_I) {
474  put_bits(&s->pb,
475  ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
476  } else {
477  if (s->use_skip_mb_code)
478  put_bits(&s->pb, 1, 0); /* mb coded */
479  put_bits(&s->pb,
480  ff_table_mb_non_intra[cbp][1],
481  ff_table_mb_non_intra[cbp][0]);
482  }
483  put_bits(&s->pb, 1, 0); /* no AC prediction yet */
484  if(s->inter_intra_pred){
485  s->h263_aic_dir=0;
486  put_bits(&s->pb, ff_table_inter_intra[s->h263_aic_dir][1], ff_table_inter_intra[s->h263_aic_dir][0]);
487  }
488  }
489  s->misc_bits += get_bits_diff(s);
490 
491  for (i = 0; i < 6; i++) {
493  }
494  s->i_tex_bits += get_bits_diff(s);
495  s->i_count++;
496  }
497 }
498 
499 static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
500 {
501  int sign, code;
502  int pred, av_uninit(extquant);
503  int extrabits = 0;
504 
505  int16_t *dc_val;
506  pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
507 
508  /* update predictor */
509  if (n < 4) {
510  *dc_val = level * s->y_dc_scale;
511  } else {
512  *dc_val = level * s->c_dc_scale;
513  }
514 
515  /* do the prediction */
516  level -= pred;
517 
518  if(s->msmpeg4_version<=2){
519  if (n < 4) {
520  put_bits(&s->pb,
521  ff_v2_dc_lum_table[level + 256][1],
522  ff_v2_dc_lum_table[level + 256][0]);
523  }else{
524  put_bits(&s->pb,
525  ff_v2_dc_chroma_table[level + 256][1],
526  ff_v2_dc_chroma_table[level + 256][0]);
527  }
528  }else{
529  sign = 0;
530  if (level < 0) {
531  level = -level;
532  sign = 1;
533  }
534  code = level;
535  if (code > DC_MAX)
536  code = DC_MAX;
537  else if( s->msmpeg4_version>=6 ) {
538  if( s->qscale == 1 ) {
539  extquant = (level + 3) & 0x3;
540  code = ((level+3)>>2);
541  } else if( s->qscale == 2 ) {
542  extquant = (level + 1) & 0x1;
543  code = ((level+1)>>1);
544  }
545  }
546 
547  if (s->dc_table_index == 0) {
548  if (n < 4) {
550  } else {
552  }
553  } else {
554  if (n < 4) {
556  } else {
558  }
559  }
560 
561  if(s->msmpeg4_version>=6 && s->qscale<=2)
562  extrabits = 3 - s->qscale;
563 
564  if (code == DC_MAX)
565  put_bits(&s->pb, 8 + extrabits, level);
566  else if(extrabits > 0)//== VC1 && s->qscale<=2
567  put_bits(&s->pb, extrabits, extquant);
568 
569  if (level != 0) {
570  put_bits(&s->pb, 1, sign);
571  }
572  }
573 }
574 
575 /* Encoding of a block; very similar to MPEG-4 except for a different
576  * escape coding (same as H.263) and more VLC tables. */
578 {
579  int level, run, last, i, j, last_index;
580  int last_non_zero, sign, slevel;
581  int code, run_diff, dc_pred_dir;
582  const RLTable *rl;
583  const uint8_t *scantable;
584 
585  if (s->mb_intra) {
586  msmpeg4_encode_dc(s, block[0], n, &dc_pred_dir);
587  i = 1;
588  if (n < 4) {
589  rl = &ff_rl_table[s->rl_table_index];
590  } else {
591  rl = &ff_rl_table[3 + s->rl_chroma_table_index];
592  }
593  run_diff = s->msmpeg4_version>=4;
594  scantable= s->intra_scantable.permutated;
595  } else {
596  i = 0;
597  rl = &ff_rl_table[3 + s->rl_table_index];
598  if(s->msmpeg4_version<=2)
599  run_diff = 0;
600  else
601  run_diff = 1;
602  scantable= s->inter_scantable.permutated;
603  }
604 
605  /* recalculate block_last_index for M$ wmv1 */
606  if(s->msmpeg4_version>=4 && s->msmpeg4_version<6 && s->block_last_index[n]>0){
607  for(last_index=63; last_index>=0; last_index--){
608  if(block[scantable[last_index]]) break;
609  }
610  s->block_last_index[n]= last_index;
611  }else
612  last_index = s->block_last_index[n];
613  /* AC coefs */
614  last_non_zero = i - 1;
615  for (; i <= last_index; i++) {
616  j = scantable[i];
617  level = block[j];
618  if (level) {
619  run = i - last_non_zero - 1;
620  last = (i == last_index);
621  sign = 0;
622  slevel = level;
623  if (level < 0) {
624  sign = 1;
625  level = -level;
626  }
627 
628  if(level<=MAX_LEVEL && run<=MAX_RUN){
629  s->ac_stats[s->mb_intra][n>3][level][run][last]++;
630  }
631 
632  s->ac_stats[s->mb_intra][n > 3][40][63][0]++; //esc3 like
633 
634  code = get_rl_index(rl, last, run, level);
635  put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
636  if (code == rl->n) {
637  int level1, run1;
638 
639  level1 = level - rl->max_level[last][run];
640  if (level1 < 1)
641  goto esc2;
642  code = get_rl_index(rl, last, run, level1);
643  if (code == rl->n) {
644  esc2:
645  put_bits(&s->pb, 1, 0);
646  if (level > MAX_LEVEL)
647  goto esc3;
648  run1 = run - rl->max_run[last][level] - run_diff;
649  if (run1 < 0)
650  goto esc3;
651  code = get_rl_index(rl, last, run1+1, level);
652  if (s->msmpeg4_version == 4 && code == rl->n)
653  goto esc3;
654  code = get_rl_index(rl, last, run1, level);
655  if (code == rl->n) {
656  esc3:
657  /* third escape */
658  put_bits(&s->pb, 1, 0);
659  put_bits(&s->pb, 1, last);
660  if(s->msmpeg4_version>=4){
661  if(s->esc3_level_length==0){
662  s->esc3_level_length=8;
663  s->esc3_run_length= 6;
664  //ESCLVLSZ + ESCRUNSZ
665  if(s->qscale<8)
666  put_bits(&s->pb, 6 + (s->msmpeg4_version>=6), 3);
667  else
668  put_bits(&s->pb, 8, 3);
669  }
670  put_bits(&s->pb, s->esc3_run_length, run);
671  put_bits(&s->pb, 1, sign);
672  put_bits(&s->pb, s->esc3_level_length, level);
673  }else{
674  put_bits(&s->pb, 6, run);
675  put_sbits(&s->pb, 8, slevel);
676  }
677  } else {
678  /* second escape */
679  put_bits(&s->pb, 1, 1);
680  put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
681  put_bits(&s->pb, 1, sign);
682  }
683  } else {
684  /* first escape */
685  put_bits(&s->pb, 1, 1);
686  put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
687  put_bits(&s->pb, 1, sign);
688  }
689  } else {
690  put_bits(&s->pb, 1, sign);
691  }
692  last_non_zero = i;
693  }
694  }
695 }
level
uint8_t level
Definition: svq3.c:207
AVERROR
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 they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
ff_msmpeg4_handle_slices
void ff_msmpeg4_handle_slices(MpegEncContext *s)
Definition: msmpeg4enc.c:330
n
int n
Definition: avisynth_c.h:760
ff_msmpeg4_encode_init
av_cold int ff_msmpeg4_encode_init(MpegEncContext *s)
Definition: msmpeg4enc.c:121
mv
static const int8_t mv[256][2]
Definition: 4xm.c:77
put_sbits
static void put_sbits(PutBitContext *pb, int n, int32_t value)
Definition: put_bits.h:240
MAX_RUN
#define MAX_RUN
Definition: rl.h:35
MBAC_BITRATE
#define MBAC_BITRATE
Definition: msmpeg4.h:38
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
internal.h
ff_msmpeg4_common_init
av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
Definition: msmpeg4.c:109
ff_msmpeg4_encode_mb
void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
Definition: msmpeg4enc.c:376
mpegvideo.h
ff_rl_table
RLTable ff_rl_table[NB_RL_TABLES]
Definition: msmpeg4data.c:601
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
ff_msmp4_mb_i_table
const uint16_t ff_msmp4_mb_i_table[64][2]
Definition: msmpeg4data.c:43
ff_h263_pred_motion
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
Definition: h263.c:307
RLTable
RLTable.
Definition: rl.h:39
tab
static const struct twinvq_data tab
Definition: twinvq_data.h:11135
NB_RL_TABLES
#define NB_RL_TABLES
Definition: msmpeg4data.h:60
RLTable::n
int n
number of entries of table_vlc minus 1
Definition: rl.h:40
av_cold
#define av_cold
Definition: attributes.h:84
msmpeg4data.h
RLTable::max_level
int8_t * max_level[2]
encoding & decoding
Definition: rl.h:46
s
#define s(width, name)
Definition: cbs_vp9.c:257
ff_table0_dc_chroma
const uint32_t ff_table0_dc_chroma[120][2]
Definition: msmpeg4data.c:133
get_rl_index
static int get_rl_index(const RLTable *rl, int last, int run, int level)
Definition: rl.h:76
bits
uint8_t bits
Definition: vp3data.h:202
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
PutBitContext
Definition: put_bits.h:35
ff_msmpeg4_encode_motion
void ff_msmpeg4_encode_motion(MpegEncContext *s, int mx, int my)
Definition: msmpeg4enc.c:297
ff_table1_dc_chroma
const uint32_t ff_table1_dc_chroma[120][2]
Definition: msmpeg4data.c:201
run
uint8_t run
Definition: svq3.c:206
RLTable::table_vlc
const uint16_t(* table_vlc)[2]
Definition: rl.h:42
ff_table_mb_non_intra
const uint32_t ff_table_mb_non_intra[128][2]
Definition: msmpeg4data.c:63
ff_v2_mb_type
const uint8_t ff_v2_mb_type[8][2]
Definition: msmpeg4data.c:1786
ff_v2_dc_lum_table
uint32_t ff_v2_dc_lum_table[512][2]
Definition: msmpeg4data.c:34
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
ff_table0_dc_lum
const uint32_t ff_table0_dc_lum[120][2]
Definition: msmpeg4data.c:100
ff_v2_dc_chroma_table
uint32_t ff_v2_dc_chroma_table[512][2]
Definition: msmpeg4data.c:35
DC_MAX
#define DC_MAX
Definition: msmpeg4.h:40
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:29
MAX_LEVEL
#define MAX_LEVEL
Definition: rl.h:36
avpriv_align_put_bits
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
Definition: bitstream.c:48
ff_mpeg4_clean_buffers
void ff_mpeg4_clean_buffers(MpegEncContext *s)
Definition: mpeg4video.c:45
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
ff_h263_cbpy_tab
const uint8_t ff_h263_cbpy_tab[16][2]
Definition: h263data.c:84
size
int size
Definition: twinvq_data.h:11134
ff_msmpeg4_encode_ext_header
void ff_msmpeg4_encode_ext_header(MpegEncContext *s)
Definition: msmpeg4enc.c:284
rl_length
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2]
Definition: msmpeg4enc.c:46
II_BITRATE
#define II_BITRATE
Definition: msmpeg4.h:37
get_size_of_code
static int get_size_of_code(MpegEncContext *s, RLTable *rl, int last, int run, int level, int intra)
Definition: msmpeg4enc.c:80
val
const char const char void * val
Definition: avisynth_c.h:863
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
vc1data.h
ff_msmpeg4_pred_dc
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
Definition: msmpeg4.c:193
ff_v2_intra_cbpc
const uint8_t ff_v2_intra_cbpc[4][2]
Definition: msmpeg4data.c:1791
attributes.h
msmpeg4_encode_dc
static void msmpeg4_encode_dc(MpegEncContext *s, int level, int n, int *dir_ptr)
Definition: msmpeg4enc.c:499
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
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
ff_mv_tables
MVTable ff_mv_tables[2]
Definition: msmpeg4data.c:1773
RLTable::max_run
int8_t * max_run[2]
encoding & decoding
Definition: rl.h:47
uint8_t
uint8_t
Definition: audio_convert.c:194
ff_msmpeg4_encode_picture_header
void ff_msmpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
Definition: msmpeg4enc.c:224
msmpeg4.h
av_uninit
#define av_uninit(x)
Definition: attributes.h:148
get_bits_diff
static int get_bits_diff(MpegEncContext *s)
Definition: mpegvideo.h:752
ret
ret
Definition: filter_design.txt:187
pred
static const float pred[4]
Definition: siprdata.h:259
ff_mvtab
const uint8_t ff_mvtab[33][2]
Definition: h263data.c:90
ff_msmpeg4_encode_block
void ff_msmpeg4_encode_block(MpegEncContext *s, int16_t *block, int n)
Definition: msmpeg4enc.c:577
ff_msmpeg4_code012
void ff_msmpeg4_code012(PutBitContext *pb, int n)
Definition: msmpeg4enc.c:70
mpeg4video.h
ff_table_inter_intra
const uint8_t ff_table_inter_intra[4][2]
Definition: msmpeg4data.c:1844
ff_rl_init
av_cold int ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
Definition: rl.c:39
ff_table1_dc_lum
const uint32_t ff_table1_dc_lum[120][2]
Definition: msmpeg4data.c:168
ff_static_rl_table_store
uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 *MAX_RUN+MAX_LEVEL+3]
Definition: msmpeg4data.c:36
MVTable
Definition: msmpeg4data.h:39
msmpeg4v2_encode_motion
static void msmpeg4v2_encode_motion(MpegEncContext *s, int val)
Definition: msmpeg4enc.c:343
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
avutil.h
mem.h
find_best_tables
static void find_best_tables(MpegEncContext *s)
Definition: msmpeg4enc.c:159
init_mv_table
static av_cold int init_mv_table(MVTable *tab)
Definition: msmpeg4enc.c:49
rl.h
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
put_bits.h
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:81
ff_msmpeg4_coded_block_pred
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
Definition: msmpeg4.c:153
h263.h