FFmpeg
ituh263enc.c
Go to the documentation of this file.
1 /*
2  * ITU H.263 bitstream encoder
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 bitstream encoder.
28  */
29 
30 #include "config_components.h"
31 
32 #include <limits.h>
33 #include <string.h>
34 
35 #include "libavutil/attributes.h"
36 #include "libavutil/thread.h"
37 #include "avcodec.h"
38 #include "codec_internal.h"
39 #include "mpegvideo.h"
40 #include "flvenc.h"
41 #include "mpegvideoenc.h"
42 #include "h263.h"
43 #include "h263enc.h"
44 #include "h263data.h"
45 #include "h263dsp.h"
46 #include "mathops.h"
47 #include "mpegutils.h"
48 #include "internal.h"
49 
50 /**
51  * Table of number of bits a motion vector component needs.
52  */
53 static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV*2+1];
54 
55 /**
56  * Minimal fcode that a motion vector component would need in umv.
57  * All entries in this table are 1.
58  */
59 static uint8_t umv_fcode_tab[MAX_MV*2+1];
60 
61 //unified encoding tables for run length encoding of coefficients
62 //unified in the sense that the specification specifies the encoding in several steps.
63 static uint8_t uni_h263_intra_aic_rl_len [64*64*2*2];
64 static uint8_t uni_h263_inter_rl_len [64*64*2*2];
65 //#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128 + (run)*256 + (level))
66 //#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run) + (level)*64)
67 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
68 
70 {
71  for (int f_code = 1; f_code <= MAX_FCODE; f_code++) {
72  for (int mv = -MAX_DMV; mv <= MAX_DMV; mv++) {
73  int len;
74 
75  if (mv == 0) len = 1; // ff_mvtab[0][1]
76  else {
77  int val, bit_size, code;
78 
79  bit_size = f_code - 1;
80 
81  val = mv;
82  if (val < 0)
83  val = -val;
84  val--;
85  code = (val >> bit_size) + 1;
86  if (code < 33) {
87  len = ff_mvtab[code][1] + 1 + bit_size;
88  } else {
89  len = 12 /* ff_mvtab[32][1] */ + av_log2(code>>5) + 2 + bit_size;
90  }
91  }
92 
93  mv_penalty[f_code][mv + MAX_DMV] = len;
94  }
95  }
96 
97  memset(umv_fcode_tab, 1, sizeof(umv_fcode_tab));
98 }
99 
100 static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab)
101 {
102  av_assert0(MAX_LEVEL >= 64);
103  av_assert0(MAX_RUN >= 63);
104 
105  for (int slevel = -64; slevel < 64; slevel++) {
106  if (slevel == 0) continue;
107  for (int run = 0; run < 64; run++) {
108  for (int last = 0; last <= 1; last++) {
109  const int index = UNI_MPEG4_ENC_INDEX(last, run, slevel + 64);
110  int level = slevel < 0 ? -slevel : slevel;
111  int sign = slevel < 0 ? 1 : 0;
112  int bits, len, code;
113 
114  len_tab[index] = 100;
115 
116  /* ESC0 */
117  code = get_rl_index(rl, last, run, level);
118  bits = rl->table_vlc[code][0];
119  len = rl->table_vlc[code][1];
120  bits = bits * 2 + sign;
121  len++;
122 
123  if (code != rl->n && len < len_tab[index])
124  len_tab[index] = len;
125 
126  /* ESC */
127  bits = rl->table_vlc[rl->n][0];
128  len = rl->table_vlc[rl->n][1];
129  bits = bits * 2 + last; len++;
130  bits = bits * 64 + run; len += 6;
131  bits = bits * 256 + (level & 0xff); len += 8;
132 
133  if (len < len_tab[index])
134  len_tab[index] = len;
135  }
136  }
137  }
138 }
139 
141 {
142  static uint8_t rl_intra_table[2][2 * MAX_RUN + MAX_LEVEL + 3];
143 
144  ff_rl_init(&ff_rl_intra_aic, rl_intra_table);
146 
149 
151 }
152 
153 av_cold const uint8_t (*ff_h263_get_mv_penalty(void))[MAX_DMV*2+1]
154 {
155  static AVOnce init_static_once = AV_ONCE_INIT;
156 
157  ff_thread_once(&init_static_once, h263_encode_init_static);
158 
159  return mv_penalty;
160 }
161 
162 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code)
163 {
164  if (val == 0) {
165  /* zero vector -- corresponds to ff_mvtab[0] */
166  put_bits(pb, 1, 1);
167  } else {
168  int sign, code, bits;
169  int bit_size = f_code - 1;
170  int range = 1 << bit_size;
171  /* modulo encoding */
172  val = sign_extend(val, 6 + bit_size);
173  sign = val>>31;
174  val= (val^sign)-sign;
175  sign&=1;
176 
177  val--;
178  code = (val >> bit_size) + 1;
179  bits = val & (range - 1);
180 
181  put_bits(pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
182  if (bit_size > 0) {
183  put_bits(pb, bit_size, bits);
184  }
185  }
186 }
187 
188 #if CONFIG_H263_ENCODER // Snow and SVQ1 need the above
189 static const uint8_t wrong_run[102] = {
190  1, 2, 3, 5, 4, 10, 9, 8,
191 11, 15, 17, 16, 23, 22, 21, 20,
192 19, 18, 25, 24, 27, 26, 11, 7,
193  6, 1, 2, 13, 2, 2, 2, 2,
194  6, 12, 3, 9, 1, 3, 4, 3,
195  7, 4, 1, 1, 5, 5, 14, 6,
196  1, 7, 1, 8, 1, 1, 1, 1,
197 10, 1, 1, 5, 9, 17, 25, 24,
198 29, 33, 32, 41, 2, 23, 28, 31,
199  3, 22, 30, 4, 27, 40, 8, 26,
200  6, 39, 7, 38, 16, 37, 15, 10,
201 11, 12, 13, 14, 1, 21, 20, 18,
202 19, 2, 1, 34, 35, 36
203 };
204 
205 /**
206  * Return the 4 bit value that specifies the given aspect ratio.
207  * This may be one of the standard aspect ratios or it specifies
208  * that the aspect will be stored explicitly later.
209  */
211  int i;
212 
213  if(aspect.num==0 || aspect.den==0) aspect= (AVRational){1,1};
214 
215  for(i=1; i<6; i++){
216  if(av_cmp_q(ff_h263_pixel_aspect[i], aspect) == 0){
217  return i;
218  }
219  }
220 
221  return FF_ASPECT_EXTENDED;
222 }
223 
225 {
226  int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref;
227  int best_clock_code=1;
228  int best_divisor=60;
229  int best_error= INT_MAX;
230  int custom_pcf;
231 
232  if(s->h263_plus){
233  for(i=0; i<2; i++){
234  int div, error;
235  div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den);
236  div= av_clip(div, 1, 127);
237  error= FFABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div);
238  if(error < best_error){
239  best_error= error;
240  best_divisor= div;
241  best_clock_code= i;
242  }
243  }
244  }
245  custom_pcf = best_clock_code != 1 || best_divisor != 60;
246  coded_frame_rate= 1800000;
247  coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
248 
249  align_put_bits(&s->pb);
250 
251  /* Update the pointer to last GOB */
252  s->ptr_lastgob = put_bits_ptr(&s->pb);
253  put_bits(&s->pb, 22, 0x20); /* PSC */
254  temp_ref= s->picture_number * (int64_t)coded_frame_rate * s->avctx->time_base.num / //FIXME use timestamp
255  (coded_frame_rate_base * (int64_t)s->avctx->time_base.den);
256  put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */
257 
258  put_bits(&s->pb, 1, 1); /* marker */
259  put_bits(&s->pb, 1, 0); /* H.263 id */
260  put_bits(&s->pb, 1, 0); /* split screen off */
261  put_bits(&s->pb, 1, 0); /* camera off */
262  put_bits(&s->pb, 1, 0); /* freeze picture release off */
263 
265  if (!s->h263_plus) {
266  /* H.263v1 */
267  put_bits(&s->pb, 3, format);
268  put_bits(&s->pb, 1, (s->pict_type == AV_PICTURE_TYPE_P));
269  /* By now UMV IS DISABLED ON H.263v1, since the restrictions
270  of H.263v1 UMV implies to check the predicted MV after
271  calculation of the current MB to see if we're on the limits */
272  put_bits(&s->pb, 1, 0); /* Unrestricted Motion Vector: off */
273  put_bits(&s->pb, 1, 0); /* SAC: off */
274  put_bits(&s->pb, 1, s->obmc); /* Advanced Prediction */
275  put_bits(&s->pb, 1, 0); /* only I/P-frames, no PB-frame */
276  put_bits(&s->pb, 5, s->qscale);
277  put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
278  } else {
279  int ufep=1;
280  /* H.263v2 */
281  /* H.263 Plus PTYPE */
282 
283  put_bits(&s->pb, 3, 7);
284  put_bits(&s->pb,3,ufep); /* Update Full Extended PTYPE */
285  if (format == 8)
286  put_bits(&s->pb,3,6); /* Custom Source Format */
287  else
288  put_bits(&s->pb, 3, format);
289 
290  put_bits(&s->pb,1, custom_pcf);
291  put_bits(&s->pb,1, s->umvplus); /* Unrestricted Motion Vector */
292  put_bits(&s->pb,1,0); /* SAC: off */
293  put_bits(&s->pb,1,s->obmc); /* Advanced Prediction Mode */
294  put_bits(&s->pb,1,s->h263_aic); /* Advanced Intra Coding */
295  put_bits(&s->pb,1,s->loop_filter); /* Deblocking Filter */
296  put_bits(&s->pb,1,s->h263_slice_structured); /* Slice Structured */
297  put_bits(&s->pb,1,0); /* Reference Picture Selection: off */
298  put_bits(&s->pb,1,0); /* Independent Segment Decoding: off */
299  put_bits(&s->pb,1,s->alt_inter_vlc); /* Alternative Inter VLC */
300  put_bits(&s->pb,1,s->modified_quant); /* Modified Quantization: */
301  put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
302  put_bits(&s->pb,3,0); /* Reserved */
303 
304  put_bits(&s->pb, 3, s->pict_type == AV_PICTURE_TYPE_P);
305 
306  put_bits(&s->pb,1,0); /* Reference Picture Resampling: off */
307  put_bits(&s->pb,1,0); /* Reduced-Resolution Update: off */
308  put_bits(&s->pb,1,s->no_rounding); /* Rounding Type */
309  put_bits(&s->pb,2,0); /* Reserved */
310  put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
311 
312  /* This should be here if PLUSPTYPE */
313  put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
314 
315  if (format == 8) {
316  /* Custom Picture Format (CPFMT) */
317  unsigned aspect_ratio_info = ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
318 
319  put_bits(&s->pb,4, aspect_ratio_info);
320  put_bits(&s->pb,9,(s->width >> 2) - 1);
321  put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
322  put_bits(&s->pb,9,(s->height >> 2));
323  if (aspect_ratio_info == FF_ASPECT_EXTENDED){
324  put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
325  put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
326  }
327  }
328  if (custom_pcf) {
329  if(ufep){
330  put_bits(&s->pb, 1, best_clock_code);
331  put_bits(&s->pb, 7, best_divisor);
332  }
333  put_sbits(&s->pb, 2, temp_ref>>8);
334  }
335 
336  /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
337  if (s->umvplus)
338 // put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
339 //FIXME check actual requested range
340  put_bits(&s->pb,2,1); /* unlimited */
341  if(s->h263_slice_structured)
342  put_bits(&s->pb,2,0); /* no weird submodes */
343 
344  put_bits(&s->pb, 5, s->qscale);
345  }
346 
347  put_bits(&s->pb, 1, 0); /* no PEI */
348 
349  if(s->h263_slice_structured){
350  put_bits(&s->pb, 1, 1);
351 
352  av_assert1(s->mb_x == 0 && s->mb_y == 0);
354 
355  put_bits(&s->pb, 1, 1);
356  }
357 }
358 
359 /**
360  * Encode a group of blocks header.
361  */
362 void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line)
363 {
364  put_bits(&s->pb, 17, 1); /* GBSC */
365 
366  if(s->h263_slice_structured){
367  put_bits(&s->pb, 1, 1);
368 
370 
371  if(s->mb_num > 1583)
372  put_bits(&s->pb, 1, 1);
373  put_bits(&s->pb, 5, s->qscale); /* GQUANT */
374  put_bits(&s->pb, 1, 1);
375  put_bits(&s->pb, 2, s->pict_type == AV_PICTURE_TYPE_I); /* GFID */
376  }else{
377  int gob_number= mb_line / s->gob_index;
378 
379  put_bits(&s->pb, 5, gob_number); /* GN */
380  put_bits(&s->pb, 2, s->pict_type == AV_PICTURE_TYPE_I); /* GFID */
381  put_bits(&s->pb, 5, s->qscale); /* GQUANT */
382  }
383 }
384 
385 /**
386  * modify qscale so that encoding is actually possible in H.263 (limit difference to -2..2)
387  */
389  int i;
390  int8_t * const qscale_table = s->cur_pic.qscale_table;
391 
392  for(i=1; i<s->mb_num; i++){
393  if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2)
394  qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2;
395  }
396  for(i=s->mb_num-2; i>=0; i--){
397  if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i+1] ] >2)
398  qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i+1] ]+2;
399  }
400 
401  if(s->codec_id != AV_CODEC_ID_H263P){
402  for(i=1; i<s->mb_num; i++){
403  int mb_xy= s->mb_index2xy[i];
404 
405  if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){
406  s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER;
407  }
408  }
409  }
410 }
411 
412 static const int dquant_code[5]= {1,0,9,2,3};
413 
414 /**
415  * Encode an 8x8 block.
416  * @param block the 8x8 block
417  * @param n block index (0-3 are luma, 4-5 are chroma)
418  */
419 static void h263_encode_block(MpegEncContext * s, int16_t * block, int n)
420 {
421  int level, run, last, i, j, last_index, last_non_zero, sign, slevel, code;
422  const RLTable *rl;
423 
424  rl = &ff_h263_rl_inter;
425  if (s->mb_intra && !s->h263_aic) {
426  /* DC coef */
427  level = block[0];
428  /* 255 cannot be represented, so we clamp */
429  if (level > 254) {
430  level = 254;
431  block[0] = 254;
432  }
433  /* 0 cannot be represented also */
434  else if (level < 1) {
435  level = 1;
436  block[0] = 1;
437  }
438  if (level == 128) //FIXME check rv10
439  put_bits(&s->pb, 8, 0xff);
440  else
441  put_bits(&s->pb, 8, level);
442  i = 1;
443  } else {
444  i = 0;
445  if (s->h263_aic && s->mb_intra)
446  rl = &ff_rl_intra_aic;
447 
448  if(s->alt_inter_vlc && !s->mb_intra){
449  int aic_vlc_bits=0;
450  int inter_vlc_bits=0;
451  int wrong_pos=-1;
452  int aic_code;
453 
454  last_index = s->block_last_index[n];
455  last_non_zero = i - 1;
456  for (; i <= last_index; i++) {
457  j = s->intra_scantable.permutated[i];
458  level = block[j];
459  if (level) {
460  run = i - last_non_zero - 1;
461  last = (i == last_index);
462 
463  if(level<0) level= -level;
464 
465  code = get_rl_index(rl, last, run, level);
466  aic_code = get_rl_index(&ff_rl_intra_aic, last, run, level);
467  inter_vlc_bits += rl->table_vlc[code][1]+1;
468  aic_vlc_bits += ff_rl_intra_aic.table_vlc[aic_code][1]+1;
469 
470  if (code == rl->n) {
471  inter_vlc_bits += 1+6+8-1;
472  }
473  if (aic_code == ff_rl_intra_aic.n) {
474  aic_vlc_bits += 1+6+8-1;
475  wrong_pos += run + 1;
476  }else
477  wrong_pos += wrong_run[aic_code];
478  last_non_zero = i;
479  }
480  }
481  i = 0;
482  if(aic_vlc_bits < inter_vlc_bits && wrong_pos > 63)
483  rl = &ff_rl_intra_aic;
484  }
485  }
486 
487  /* AC coefs */
488  last_index = s->block_last_index[n];
489  last_non_zero = i - 1;
490  for (; i <= last_index; i++) {
491  j = s->intra_scantable.permutated[i];
492  level = block[j];
493  if (level) {
494  run = i - last_non_zero - 1;
495  last = (i == last_index);
496  sign = 0;
497  slevel = level;
498  if (level < 0) {
499  sign = 1;
500  level = -level;
501  }
502  code = get_rl_index(rl, last, run, level);
503  put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
504  if (code == rl->n) {
505  if(!CONFIG_FLV_ENCODER || s->h263_flv <= 1){
506  put_bits(&s->pb, 1, last);
507  put_bits(&s->pb, 6, run);
508 
509  av_assert2(slevel != 0);
510 
511  if(level < 128)
512  put_sbits(&s->pb, 8, slevel);
513  else{
514  put_bits(&s->pb, 8, 128);
515  put_sbits(&s->pb, 5, slevel);
516  put_sbits(&s->pb, 6, slevel>>5);
517  }
518  }else{
519  ff_flv2_encode_ac_esc(&s->pb, slevel, level, run, last);
520  }
521  } else {
522  put_bits(&s->pb, 1, sign);
523  }
524  last_non_zero = i;
525  }
526  }
527 }
528 
529 /* Encode MV differences on H.263+ with Unrestricted MV mode */
530 static void h263p_encode_umotion(PutBitContext *pb, int val)
531 {
532  short sval = 0;
533  short i = 0;
534  short n_bits = 0;
535  short temp_val;
536  int code = 0;
537  int tcode;
538 
539  if ( val == 0)
540  put_bits(pb, 1, 1);
541  else if (val == 1)
542  put_bits(pb, 3, 0);
543  else if (val == -1)
544  put_bits(pb, 3, 2);
545  else {
546 
547  sval = ((val < 0) ? (short)(-val):(short)val);
548  temp_val = sval;
549 
550  while (temp_val != 0) {
551  temp_val = temp_val >> 1;
552  n_bits++;
553  }
554 
555  i = n_bits - 1;
556  while (i > 0) {
557  tcode = (sval & (1 << (i-1))) >> (i-1);
558  tcode = (tcode << 1) | 1;
559  code = (code << 2) | tcode;
560  i--;
561  }
562  code = ((code << 1) | (val < 0)) << 1;
563  put_bits(pb, (2*n_bits)+1, code);
564  }
565 }
566 
567 static int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
568 {
569  int x, y, wrap, a, c, pred_dc;
570  int16_t *dc_val;
571 
572  /* find prediction */
573  if (n < 4) {
574  x = 2 * s->mb_x + (n & 1);
575  y = 2 * s->mb_y + ((n & 2) >> 1);
576  wrap = s->b8_stride;
577  dc_val = s->dc_val[0];
578  } else {
579  x = s->mb_x;
580  y = s->mb_y;
581  wrap = s->mb_stride;
582  dc_val = s->dc_val[n - 4 + 1];
583  }
584  /* B C
585  * A X
586  */
587  a = dc_val[(x - 1) + (y) * wrap];
588  c = dc_val[(x) + (y - 1) * wrap];
589 
590  /* No prediction outside GOB boundary */
591  if (s->first_slice_line && n != 3) {
592  if (n != 2) c = 1024;
593  if (n != 1 && s->mb_x == s->resync_mb_x) a = 1024;
594  }
595  /* just DC prediction */
596  if (a != 1024 && c != 1024)
597  pred_dc = (a + c) >> 1;
598  else if (a != 1024)
599  pred_dc = a;
600  else
601  pred_dc = c;
602 
603  /* we assume pred is positive */
604  *dc_val_ptr = &dc_val[x + y * wrap];
605  return pred_dc;
606 }
607 
609  int16_t block[6][64],
610  int motion_x, int motion_y)
611 {
612  int cbpc, cbpy, i, cbp, pred_x, pred_y;
613  int16_t pred_dc;
614  int16_t rec_intradc[6];
615  int16_t *dc_ptr[6];
616  const int interleaved_stats = s->avctx->flags & AV_CODEC_FLAG_PASS1;
617 
618  if (!s->mb_intra) {
619  /* compute cbp */
620  cbp= get_p_cbp(s, block, motion_x, motion_y);
621 
622  if ((cbp | motion_x | motion_y | s->dquant | (s->mv_type - MV_TYPE_16X16)) == 0) {
623  /* skip macroblock */
624  put_bits(&s->pb, 1, 1);
625  if(interleaved_stats){
626  s->misc_bits++;
627  s->last_bits++;
628  }
629 
630  return;
631  }
632  put_bits(&s->pb, 1, 0); /* mb coded */
633 
634  cbpc = cbp & 3;
635  cbpy = cbp >> 2;
636  if(s->alt_inter_vlc==0 || cbpc!=3)
637  cbpy ^= 0xF;
638  if(s->dquant) cbpc+= 8;
639  if(s->mv_type==MV_TYPE_16X16){
640  put_bits(&s->pb,
643 
644  put_bits(&s->pb, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
645  if(s->dquant)
646  put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
647 
648  if(interleaved_stats){
649  s->misc_bits+= get_bits_diff(s);
650  }
651 
652  /* motion vectors: 16x16 mode */
653  ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
654 
655  if (!s->umvplus) {
656  ff_h263_encode_motion_vector(s, motion_x - pred_x,
657  motion_y - pred_y, 1);
658  }
659  else {
660  h263p_encode_umotion(&s->pb, motion_x - pred_x);
661  h263p_encode_umotion(&s->pb, motion_y - pred_y);
662  if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
663  /* To prevent Start Code emulation */
664  put_bits(&s->pb,1,1);
665  }
666  }else{
667  put_bits(&s->pb,
668  ff_h263_inter_MCBPC_bits[cbpc+16],
669  ff_h263_inter_MCBPC_code[cbpc+16]);
670  put_bits(&s->pb, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
671  if(s->dquant)
672  put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
673 
674  if(interleaved_stats){
675  s->misc_bits+= get_bits_diff(s);
676  }
677 
678  for(i=0; i<4; i++){
679  /* motion vectors: 8x8 mode*/
680  ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
681 
682  motion_x = s->cur_pic.motion_val[0][s->block_index[i]][0];
683  motion_y = s->cur_pic.motion_val[0][s->block_index[i]][1];
684  if (!s->umvplus) {
685  ff_h263_encode_motion_vector(s, motion_x - pred_x,
686  motion_y - pred_y, 1);
687  }
688  else {
689  h263p_encode_umotion(&s->pb, motion_x - pred_x);
690  h263p_encode_umotion(&s->pb, motion_y - pred_y);
691  if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
692  /* To prevent Start Code emulation */
693  put_bits(&s->pb,1,1);
694  }
695  }
696  }
697 
698  if(interleaved_stats){
699  s->mv_bits+= get_bits_diff(s);
700  }
701  } else {
702  av_assert2(s->mb_intra);
703 
704  cbp = 0;
705  if (s->h263_aic) {
706  /* Predict DC */
707  for(i=0; i<6; i++) {
708  int16_t level = block[i][0];
709  int scale;
710 
711  if(i<4) scale= s->y_dc_scale;
712  else scale= s->c_dc_scale;
713 
714  pred_dc = h263_pred_dc(s, i, &dc_ptr[i]);
715  level -= pred_dc;
716  /* Quant */
717  if (level >= 0)
718  level = (level + (scale>>1))/scale;
719  else
720  level = (level - (scale>>1))/scale;
721 
722  if(!s->modified_quant){
723  if (level < -127)
724  level = -127;
725  else if (level > 127)
726  level = 127;
727  }
728 
729  block[i][0] = level;
730  /* Reconstruction */
731  rec_intradc[i] = scale*level + pred_dc;
732  /* Oddify */
733  rec_intradc[i] |= 1;
734  //if ((rec_intradc[i] % 2) == 0)
735  // rec_intradc[i]++;
736  /* Clipping */
737  if (rec_intradc[i] < 0)
738  rec_intradc[i] = 0;
739  else if (rec_intradc[i] > 2047)
740  rec_intradc[i] = 2047;
741 
742  /* Update AC/DC tables */
743  *dc_ptr[i] = rec_intradc[i];
744  /* AIC can change CBP */
745  if (s->block_last_index[i] > 0 ||
746  (s->block_last_index[i] == 0 && level !=0))
747  cbp |= 1 << (5 - i);
748  }
749  }else{
750  for(i=0; i<6; i++) {
751  /* compute cbp */
752  if (s->block_last_index[i] >= 1)
753  cbp |= 1 << (5 - i);
754  }
755  }
756 
757  cbpc = cbp & 3;
758  if (s->pict_type == AV_PICTURE_TYPE_I) {
759  if(s->dquant) cbpc+=4;
760  put_bits(&s->pb,
763  } else {
764  if(s->dquant) cbpc+=8;
765  put_bits(&s->pb, 1, 0); /* mb coded */
766  put_bits(&s->pb,
767  ff_h263_inter_MCBPC_bits[cbpc + 4],
768  ff_h263_inter_MCBPC_code[cbpc + 4]);
769  }
770  if (s->h263_aic) {
771  /* XXX: currently, we do not try to use ac prediction */
772  put_bits(&s->pb, 1, 0); /* no AC prediction */
773  }
774  cbpy = cbp >> 2;
775  put_bits(&s->pb, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
776  if(s->dquant)
777  put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
778 
779  if(interleaved_stats){
780  s->misc_bits+= get_bits_diff(s);
781  }
782  }
783 
784  for(i=0; i<6; i++) {
785  /* encode each block */
786  h263_encode_block(s, block[i], i);
787 
788  /* Update INTRADC for decoding */
789  if (s->h263_aic && s->mb_intra) {
790  block[i][0] = rec_intradc[i];
791 
792  }
793  }
794 
795  if(interleaved_stats){
796  if (!s->mb_intra) {
797  s->p_tex_bits+= get_bits_diff(s);
798  }else{
799  s->i_tex_bits+= get_bits_diff(s);
800  s->i_count++;
801  }
802  }
803 }
804 
806 {
807  const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
808 
809  if (s->cur_pic.mbskip_table)
810  s->cur_pic.mbskip_table[mb_xy] = s->mb_skipped;
811 
812  if (s->mv_type == MV_TYPE_8X8)
813  s->cur_pic.mb_type[mb_xy] = MB_TYPE_FORWARD_MV | MB_TYPE_8x8;
814  else if(s->mb_intra)
815  s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA;
816  else
817  s->cur_pic.mb_type[mb_xy] = MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
818 
820 }
821 
823 {
824  s->me.mv_penalty = ff_h263_get_mv_penalty(); // FIXME exact table for MSMPEG4 & H.263+
825 
826  s->intra_ac_vlc_length =s->inter_ac_vlc_length = uni_h263_inter_rl_len;
827  s->intra_ac_vlc_last_length=s->inter_ac_vlc_last_length= uni_h263_inter_rl_len + 128*64;
828  if(s->h263_aic){
829  s->intra_ac_vlc_length = uni_h263_intra_aic_rl_len;
830  s->intra_ac_vlc_last_length= uni_h263_intra_aic_rl_len + 128*64;
831 
832  s->y_dc_scale_table =
833  s->c_dc_scale_table = ff_aic_dc_scale_table;
834  }
835  s->ac_esc_length= 7+1+6+8;
836 
837  if (s->modified_quant)
838  s->chroma_qscale_table = ff_h263_chroma_qscale_table;
839 
840  // use fcodes >1 only for MPEG-4 & H.263 & H.263+ FIXME
841  switch(s->codec_id){
842  case AV_CODEC_ID_MPEG4:
843  break;
844  case AV_CODEC_ID_H263P:
845  if(s->umvplus)
846  s->fcode_tab = umv_fcode_tab + MAX_MV;
847  if(s->modified_quant){
848  s->min_qcoeff= -2047;
849  s->max_qcoeff= 2047;
850  }else{
851  s->min_qcoeff= -127;
852  s->max_qcoeff= 127;
853  }
854  break;
855  // Note for MPEG-4 & H.263 the dc-scale table will be set per frame as needed later
856  case AV_CODEC_ID_FLV1:
857  if (s->h263_flv > 1) {
858  s->min_qcoeff= -1023;
859  s->max_qcoeff= 1023;
860  } else {
861  s->min_qcoeff= -127;
862  s->max_qcoeff= 127;
863  }
864  break;
865  default: //nothing needed - default table already set in mpegvideo.c
866  s->min_qcoeff= -127;
867  s->max_qcoeff= 127;
868  }
869 
870  ff_h263dsp_init(&s->h263dsp);
871 }
872 
874 {
875  int i, mb_pos;
876 
877  for(i=0; i<6; i++){
878  if(s->mb_num-1 <= ff_mba_max[i]) break;
879  }
880  mb_pos= s->mb_x + s->mb_width*s->mb_y;
881  put_bits(&s->pb, ff_mba_length[i], mb_pos);
882 }
883 
884 #define OFFSET(x) offsetof(MpegEncContext, x)
885 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
886 static const AVOption h263_options[] = {
887  { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
888  { "mb_info", "emit macroblock info for RFC 2190 packetization, the parameter value is the maximum payload size", OFFSET(mb_info), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
891  { NULL },
892 };
893 
894 static const AVClass h263_class = {
895  .class_name = "H.263 encoder",
896  .item_name = av_default_item_name,
897  .option = h263_options,
898  .version = LIBAVUTIL_VERSION_INT,
899 };
900 
901 const FFCodec ff_h263_encoder = {
902  .p.name = "h263",
903  CODEC_LONG_NAME("H.263 / H.263-1996"),
904  .p.type = AVMEDIA_TYPE_VIDEO,
905  .p.id = AV_CODEC_ID_H263,
907  .color_ranges = AVCOL_RANGE_MPEG,
908  .p.priv_class = &h263_class,
910  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
911  .priv_data_size = sizeof(MpegEncContext),
914  .close = ff_mpv_encode_end,
915 };
916 
917 static const AVOption h263p_options[] = {
918  { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
919  { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
920  { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
921  { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
924  { NULL },
925 };
926 static const AVClass h263p_class = {
927  .class_name = "H.263p encoder",
928  .item_name = av_default_item_name,
929  .option = h263p_options,
930  .version = LIBAVUTIL_VERSION_INT,
931 };
932 
933 const FFCodec ff_h263p_encoder = {
934  .p.name = "h263p",
935  CODEC_LONG_NAME("H.263+ / H.263-1998 / H.263 version 2"),
936  .p.type = AVMEDIA_TYPE_VIDEO,
937  .p.id = AV_CODEC_ID_H263P,
939  .color_ranges = AVCOL_RANGE_MPEG,
940  .p.priv_class = &h263p_class,
941  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS |
943  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
944  .priv_data_size = sizeof(MpegEncContext),
947  .close = ff_mpv_encode_end,
948 };
949 #endif
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
CODEC_PIXFMTS
#define CODEC_PIXFMTS(...)
Definition: codec_internal.h:386
MV_TYPE_16X16
#define MV_TYPE_16X16
1 vector for the whole mb
Definition: mpegvideo.h:264
ff_h263_encode_mba
void ff_h263_encode_mba(MpegEncContext *s)
h263data.h
FF_ASPECT_EXTENDED
#define FF_ASPECT_EXTENDED
Definition: h263.h:26
level
uint8_t level
Definition: svq3.c:205
av_clip
#define av_clip
Definition: common.h:100
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
get_bits_diff
static int get_bits_diff(MpegEncContext *s)
Definition: mpegvideoenc.h:160
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:435
uni_h263_inter_rl_len
static uint8_t uni_h263_inter_rl_len[64 *64 *2 *2]
Definition: ituh263enc.c:64
UNI_MPEG4_ENC_INDEX
#define UNI_MPEG4_ENC_INDEX(last, run, level)
Definition: ituh263enc.c:67
MAX_FCODE
#define MAX_FCODE
Definition: mpegvideoenc.h:36
thread.h
mpegvideoenc.h
int64_t
long long int64_t
Definition: coverity.c:34
mv
static const int8_t mv[256][2]
Definition: 4xm.c:81
put_sbits
static void put_sbits(PutBitContext *pb, int n, int32_t value)
Definition: put_bits.h:281
MAX_RUN
#define MAX_RUN
Definition: rl.h:35
h263enc.h
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:64
CANDIDATE_MB_TYPE_INTER
#define CANDIDATE_MB_TYPE_INTER
Definition: mpegvideoenc.h:42
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:223
MAX_DMV
#define MAX_DMV
Definition: motion_est.h:38
internal.h
av_const
#define av_const
Definition: attributes.h:84
h263dsp.h
AVOption
AVOption.
Definition: opt.h:429
MB_TYPE_16x16
#define MB_TYPE_16x16
Definition: mpegutils.h:41
FFCodec
Definition: codec_internal.h:127
init_uni_h263_rl_tab
static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab)
Definition: ituh263enc.c:100
mpegvideo.h
mpegutils.h
FF_MPV_COMMON_MOTION_EST_OPTS
#define FF_MPV_COMMON_MOTION_EST_OPTS
Definition: mpegvideoenc.h:129
ff_mpv_encode_picture
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
Definition: mpegvideo_enc.c:1867
FF_MPV_COMMON_OPTS
#define FF_MPV_COMMON_OPTS
Definition: mpegvideoenc.h:86
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
ff_match_2uint16
int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
Definition: utils.c:829
ff_h263_pred_motion
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
Definition: h263.c:179
wrap
#define wrap(func)
Definition: neontest.h:65
ff_h263_pixel_aspect
const AVRational ff_h263_pixel_aspect[16]
Definition: h263data.c:273
RLTable
RLTable.
Definition: rl.h:39
mv_penalty
static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV *2+1]
Table of number of bits a motion vector component needs.
Definition: ituh263enc.c:53
val
static double val(void *priv, double ch)
Definition: aeval.c:77
ff_h263_encode_motion_vector
static void ff_h263_encode_motion_vector(MpegEncContext *s, int x, int y, int f_code)
Definition: h263enc.h:42
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:353
ff_h263_update_motion_val
void ff_h263_update_motion_val(MpegEncContext *s)
Definition: h263.c:53
AVRational::num
int num
Numerator.
Definition: rational.h:59
dquant_code
static const int dquant_code[5]
Definition: mpeg4videoenc.c:489
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:205
ff_h263_encode_motion
void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code)
Definition: ituh263enc.c:162
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
MAX_MV
#define MAX_MV
Definition: motion_est.h:36
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:198
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
get_rl_index
static int get_rl_index(const RLTable *rl, int last, int run, int level)
Definition: rl.h:101
get_p_cbp
static int get_p_cbp(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
Definition: h263enc.h:49
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
bits
uint8_t bits
Definition: vp3data.h:128
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
limits.h
ff_h263_get_mv_penalty
const av_cold uint8_t(* ff_h263_get_mv_penalty(void))[MAX_DMV *2+1]
Definition: ituh263enc.c:153
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
PutBitContext
Definition: put_bits.h:50
ff_rl_init
av_cold void ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
Initialize index_run, max_level and max_run from n, last, table_vlc, table_run and table_level.
Definition: rl.c:43
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:203
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
init_mv_penalty_and_fcode
static av_cold void init_mv_penalty_and_fcode(void)
Definition: ituh263enc.c:69
run
uint8_t run
Definition: svq3.c:204
RLTable::table_vlc
const uint16_t(* table_vlc)[2]
Definition: rl.h:42
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
MB_TYPE_8x8
#define MB_TYPE_8x8
Definition: mpegutils.h:44
uni_h263_intra_aic_rl_len
static uint8_t uni_h263_intra_aic_rl_len[64 *64 *2 *2]
Definition: ituh263enc.c:63
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:239
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
mathops.h
ff_mba_max
const uint16_t ff_mba_max[6]
Definition: h263data.c:265
ff_mpv_encode_end
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
Definition: mpegvideo_enc.c:1040
AVOnce
#define AVOnce
Definition: thread.h:202
index
int index
Definition: gxfenc.c:90
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_clean_h263_qscales
void ff_clean_h263_qscales(MpegEncContext *s)
MV_TYPE_8X8
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
Definition: mpegvideo.h:265
MAX_LEVEL
#define MAX_LEVEL
Definition: rl.h:36
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
ff_h263_rl_inter
RLTable ff_h263_rl_inter
Definition: h263data.c:159
codec_internal.h
AV_CODEC_ID_H263
@ AV_CODEC_ID_H263
Definition: codec_id.h:56
ff_h263_cbpy_tab
const uint8_t ff_h263_cbpy_tab[16][2]
Definition: h263data.c:82
ff_h263p_encoder
const FFCodec ff_h263p_encoder
ff_rl_intra_aic
RLTable ff_rl_intra_aic
Definition: h263data.c:228
ff_h263dsp_init
av_cold void ff_h263dsp_init(H263DSPContext *ctx)
Definition: h263dsp.c:117
range
enum AVColorRange range
Definition: mediacodec_wrapper.c:2594
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
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
attributes.h
ff_h263_encode_mb
void ff_h263_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
ff_h263_inter_MCBPC_bits
const uint8_t ff_h263_inter_MCBPC_bits[28]
Definition: h263data.c:47
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: pred_template.c:391
CANDIDATE_MB_TYPE_INTER4V
#define CANDIDATE_MB_TYPE_INTER4V
Definition: mpegvideoenc.h:43
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:67
ff_h263_encoder
const FFCodec ff_h263_encoder
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
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
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
ff_h263_encode_init
void ff_h263_encode_init(MpegEncContext *s)
ff_h263_format
const uint16_t ff_h263_format[8][2]
Definition: h263data.c:236
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
ff_h263_aspect_to_info
av_const int ff_h263_aspect_to_info(AVRational aspect)
len
int len
Definition: vorbis_enc_data.h:426
ff_h263_encode_gob_header
void ff_h263_encode_gob_header(MpegEncContext *s, int mb_line)
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:733
ff_flv2_encode_ac_esc
void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, int last)
Definition: flvenc.c:66
avcodec.h
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
h263_encode_init_static
static av_cold void h263_encode_init_static(void)
Definition: ituh263enc.c:140
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
ff_aic_dc_scale_table
const uint8_t ff_aic_dc_scale_table[32]
Definition: h263data.c:245
ff_mvtab
const uint8_t ff_mvtab[33][2]
Definition: h263data.c:88
ff_h263_intra_MCBPC_bits
const uint8_t ff_h263_intra_MCBPC_bits[9]
Definition: h263data.c:33
OFFSET
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your see the OFFSET() macro
AV_CODEC_ID_H263P
@ AV_CODEC_ID_H263P
Definition: codec_id.h:71
put_bits_ptr
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
Definition: put_bits.h:392
ff_h263_intra_MCBPC_code
const uint8_t ff_h263_intra_MCBPC_code[9]
Definition: h263data.c:32
AVRational::den
int den
Denominator.
Definition: rational.h:60
umv_fcode_tab
static uint8_t umv_fcode_tab[MAX_MV *2+1]
Minimal fcode that a motion vector component would need in umv.
Definition: ituh263enc.c:59
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
sign_extend
static av_const int sign_extend(int val, unsigned bits)
Definition: mathops.h:131
ff_mba_length
const uint8_t ff_mba_length[7]
Definition: h263data.c:269
flvenc.h
ff_h263_inter_MCBPC_code
const uint8_t ff_h263_inter_MCBPC_code[28]
Definition: h263data.c:38
ff_h263_encode_picture_header
void ff_h263_encode_picture_header(MpegEncContext *s)
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:280
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_mpv_encode_init
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
Definition: mpegvideo_enc.c:420
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
ff_h263_update_mb
void ff_h263_update_mb(MpegEncContext *s)
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
VE
#define VE
Definition: amfenc_av1.c:30
ff_h263_init_rl_inter
av_cold void ff_h263_init_rl_inter(void)
Definition: h263.c:47
AV_CODEC_ID_FLV1
@ AV_CODEC_ID_FLV1
Definition: codec_id.h:73
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:73
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
mb_info
Definition: cinepakenc.c:87
MB_TYPE_FORWARD_MV
#define MB_TYPE_FORWARD_MV
Definition: mpegutils.h:49
MB_TYPE_INTRA
#define MB_TYPE_INTRA
Definition: mpegutils.h:64
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:310
h263.h