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