2 * ITU H263 bitstream encoder
3 * Copyright (c) 2000,2001 Fabrice Bellard
5 * Copyright (c) 2001 Juan J. Sierralta P
6 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
8 * This file is part of FFmpeg.
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.
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.
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
27 * h263 bitstream encoder.
32 #include "libavutil/attributes.h"
34 #include "mpegvideo.h"
35 #include "mpegvideodata.h"
39 #include "mpegutils.h"
42 #include "mpeg4video.h"
46 * Table of number of bits a motion vector component needs.
48 static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV*2+1];
51 * Minimal fcode that a motion vector component would need.
53 static uint8_t fcode_tab[MAX_MV*2+1];
56 * Minimal fcode that a motion vector component would need in umv.
57 * All entries in this table are 1.
59 static uint8_t umv_fcode_tab[MAX_MV*2+1];
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))
69 static const uint8_t wrong_run[102] = {
70 1, 2, 3, 5, 4, 10, 9, 8,
71 11, 15, 17, 16, 23, 22, 21, 20,
72 19, 18, 25, 24, 27, 26, 11, 7,
73 6, 1, 2, 13, 2, 2, 2, 2,
74 6, 12, 3, 9, 1, 3, 4, 3,
75 7, 4, 1, 1, 5, 5, 14, 6,
76 1, 7, 1, 8, 1, 1, 1, 1,
77 10, 1, 1, 5, 9, 17, 25, 24,
78 29, 33, 32, 41, 2, 23, 28, 31,
79 3, 22, 30, 4, 27, 40, 8, 26,
80 6, 39, 7, 38, 16, 37, 15, 10,
81 11, 12, 13, 14, 1, 21, 20, 18,
86 * Return the 4 bit value that specifies the given aspect ratio.
87 * This may be one of the standard aspect ratios or it specifies
88 * that the aspect will be stored explicitly later.
90 av_const int ff_h263_aspect_to_info(AVRational aspect){
93 if(aspect.num==0 || aspect.den==0) aspect= (AVRational){1,1};
96 if(av_cmp_q(ff_h263_pixel_aspect[i], aspect) == 0){
101 return FF_ASPECT_EXTENDED;
104 void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
106 int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref;
107 int best_clock_code=1;
109 int best_error= INT_MAX;
114 div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den);
115 div= av_clip(div, 1, 127);
116 error= FFABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div);
117 if(error < best_error){
124 s->custom_pcf= best_clock_code!=1 || best_divisor!=60;
125 coded_frame_rate= 1800000;
126 coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
128 avpriv_align_put_bits(&s->pb);
130 /* Update the pointer to last GOB */
131 s->ptr_lastgob = put_bits_ptr(&s->pb);
132 put_bits(&s->pb, 22, 0x20); /* PSC */
133 temp_ref= s->picture_number * (int64_t)coded_frame_rate * s->avctx->time_base.num / //FIXME use timestamp
134 (coded_frame_rate_base * (int64_t)s->avctx->time_base.den);
135 put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */
137 put_bits(&s->pb, 1, 1); /* marker */
138 put_bits(&s->pb, 1, 0); /* h263 id */
139 put_bits(&s->pb, 1, 0); /* split screen off */
140 put_bits(&s->pb, 1, 0); /* camera off */
141 put_bits(&s->pb, 1, 0); /* freeze picture release off */
143 format = ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format), s->width, s->height);
146 put_bits(&s->pb, 3, format);
147 put_bits(&s->pb, 1, (s->pict_type == AV_PICTURE_TYPE_P));
148 /* By now UMV IS DISABLED ON H.263v1, since the restrictions
149 of H.263v1 UMV implies to check the predicted MV after
150 calculation of the current MB to see if we're on the limits */
151 put_bits(&s->pb, 1, 0); /* Unrestricted Motion Vector: off */
152 put_bits(&s->pb, 1, 0); /* SAC: off */
153 put_bits(&s->pb, 1, s->obmc); /* Advanced Prediction */
154 put_bits(&s->pb, 1, 0); /* only I/P frames, no PB frame */
155 put_bits(&s->pb, 5, s->qscale);
156 put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
160 /* H.263 Plus PTYPE */
162 put_bits(&s->pb, 3, 7);
163 put_bits(&s->pb,3,ufep); /* Update Full Extended PTYPE */
165 put_bits(&s->pb,3,6); /* Custom Source Format */
167 put_bits(&s->pb, 3, format);
169 put_bits(&s->pb,1, s->custom_pcf);
170 put_bits(&s->pb,1, s->umvplus); /* Unrestricted Motion Vector */
171 put_bits(&s->pb,1,0); /* SAC: off */
172 put_bits(&s->pb,1,s->obmc); /* Advanced Prediction Mode */
173 put_bits(&s->pb,1,s->h263_aic); /* Advanced Intra Coding */
174 put_bits(&s->pb,1,s->loop_filter); /* Deblocking Filter */
175 put_bits(&s->pb,1,s->h263_slice_structured); /* Slice Structured */
176 put_bits(&s->pb,1,0); /* Reference Picture Selection: off */
177 put_bits(&s->pb,1,0); /* Independent Segment Decoding: off */
178 put_bits(&s->pb,1,s->alt_inter_vlc); /* Alternative Inter VLC */
179 put_bits(&s->pb,1,s->modified_quant); /* Modified Quantization: */
180 put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
181 put_bits(&s->pb,3,0); /* Reserved */
183 put_bits(&s->pb, 3, s->pict_type == AV_PICTURE_TYPE_P);
185 put_bits(&s->pb,1,0); /* Reference Picture Resampling: off */
186 put_bits(&s->pb,1,0); /* Reduced-Resolution Update: off */
187 put_bits(&s->pb,1,s->no_rounding); /* Rounding Type */
188 put_bits(&s->pb,2,0); /* Reserved */
189 put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
191 /* This should be here if PLUSPTYPE */
192 put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
195 /* Custom Picture Format (CPFMT) */
196 s->aspect_ratio_info= ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
198 put_bits(&s->pb,4,s->aspect_ratio_info);
199 put_bits(&s->pb,9,(s->width >> 2) - 1);
200 put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
201 put_bits(&s->pb,9,(s->height >> 2));
202 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
203 put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
204 put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
209 put_bits(&s->pb, 1, best_clock_code);
210 put_bits(&s->pb, 7, best_divisor);
212 put_sbits(&s->pb, 2, temp_ref>>8);
215 /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
217 // put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
218 //FIXME check actual requested range
219 put_bits(&s->pb,2,1); /* unlimited */
220 if(s->h263_slice_structured)
221 put_bits(&s->pb,2,0); /* no weird submodes */
223 put_bits(&s->pb, 5, s->qscale);
226 put_bits(&s->pb, 1, 0); /* no PEI */
228 if(s->h263_slice_structured){
229 put_bits(&s->pb, 1, 1);
231 av_assert1(s->mb_x == 0 && s->mb_y == 0);
232 ff_h263_encode_mba(s);
234 put_bits(&s->pb, 1, 1);
239 * Encode a group of blocks header.
241 void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line)
243 put_bits(&s->pb, 17, 1); /* GBSC */
245 if(s->h263_slice_structured){
246 put_bits(&s->pb, 1, 1);
248 ff_h263_encode_mba(s);
251 put_bits(&s->pb, 1, 1);
252 put_bits(&s->pb, 5, s->qscale); /* GQUANT */
253 put_bits(&s->pb, 1, 1);
254 put_bits(&s->pb, 2, s->pict_type == AV_PICTURE_TYPE_I); /* GFID */
256 int gob_number= mb_line / s->gob_index;
258 put_bits(&s->pb, 5, gob_number); /* GN */
259 put_bits(&s->pb, 2, s->pict_type == AV_PICTURE_TYPE_I); /* GFID */
260 put_bits(&s->pb, 5, s->qscale); /* GQUANT */
265 * modify qscale so that encoding is actually possible in h263 (limit difference to -2..2)
267 void ff_clean_h263_qscales(MpegEncContext *s){
269 int8_t * const qscale_table = s->current_picture.qscale_table;
271 ff_init_qscale_tab(s);
273 for(i=1; i<s->mb_num; i++){
274 if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2)
275 qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2;
277 for(i=s->mb_num-2; i>=0; i--){
278 if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i+1] ] >2)
279 qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i+1] ]+2;
282 if(s->codec_id != AV_CODEC_ID_H263P){
283 for(i=1; i<s->mb_num; i++){
284 int mb_xy= s->mb_index2xy[i];
286 if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){
287 s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER;
293 static const int dquant_code[5]= {1,0,9,2,3};
296 * Encode an 8x8 block.
297 * @param block the 8x8 block
298 * @param n block index (0-3 are luma, 4-5 are chroma)
300 static void h263_encode_block(MpegEncContext * s, int16_t * block, int n)
302 int level, run, last, i, j, last_index, last_non_zero, sign, slevel, code;
305 rl = &ff_h263_rl_inter;
306 if (s->mb_intra && !s->h263_aic) {
309 /* 255 cannot be represented, so we clamp */
314 /* 0 cannot be represented also */
315 else if (level < 1) {
319 if (level == 128) //FIXME check rv10
320 put_bits(&s->pb, 8, 0xff);
322 put_bits(&s->pb, 8, level);
326 if (s->h263_aic && s->mb_intra)
327 rl = &ff_rl_intra_aic;
329 if(s->alt_inter_vlc && !s->mb_intra){
331 int inter_vlc_bits=0;
335 last_index = s->block_last_index[n];
336 last_non_zero = i - 1;
337 for (; i <= last_index; i++) {
338 j = s->intra_scantable.permutated[i];
341 run = i - last_non_zero - 1;
342 last = (i == last_index);
344 if(level<0) level= -level;
346 code = get_rl_index(rl, last, run, level);
347 aic_code = get_rl_index(&ff_rl_intra_aic, last, run, level);
348 inter_vlc_bits += rl->table_vlc[code][1]+1;
349 aic_vlc_bits += ff_rl_intra_aic.table_vlc[aic_code][1]+1;
352 inter_vlc_bits += 1+6+8-1;
354 if (aic_code == ff_rl_intra_aic.n) {
355 aic_vlc_bits += 1+6+8-1;
356 wrong_pos += run + 1;
358 wrong_pos += wrong_run[aic_code];
363 if(aic_vlc_bits < inter_vlc_bits && wrong_pos > 63)
364 rl = &ff_rl_intra_aic;
369 last_index = s->block_last_index[n];
370 last_non_zero = i - 1;
371 for (; i <= last_index; i++) {
372 j = s->intra_scantable.permutated[i];
375 run = i - last_non_zero - 1;
376 last = (i == last_index);
383 code = get_rl_index(rl, last, run, level);
384 put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
386 if(!CONFIG_FLV_ENCODER || s->h263_flv <= 1){
387 put_bits(&s->pb, 1, last);
388 put_bits(&s->pb, 6, run);
390 av_assert2(slevel != 0);
393 put_sbits(&s->pb, 8, slevel);
395 put_bits(&s->pb, 8, 128);
396 put_sbits(&s->pb, 5, slevel);
397 put_sbits(&s->pb, 6, slevel>>5);
400 ff_flv2_encode_ac_esc(&s->pb, slevel, level, run, last);
403 put_bits(&s->pb, 1, sign);
410 /* Encode MV differences on H.263+ with Unrestricted MV mode */
411 static void h263p_encode_umotion(PutBitContext *pb, int val)
428 sval = ((val < 0) ? (short)(-val):(short)val);
431 while (temp_val != 0) {
432 temp_val = temp_val >> 1;
438 tcode = (sval & (1 << (i-1))) >> (i-1);
439 tcode = (tcode << 1) | 1;
440 code = (code << 2) | tcode;
443 code = ((code << 1) | (val < 0)) << 1;
444 put_bits(pb, (2*n_bits)+1, code);
448 void ff_h263_encode_mb(MpegEncContext * s,
449 int16_t block[6][64],
450 int motion_x, int motion_y)
452 int cbpc, cbpy, i, cbp, pred_x, pred_y;
454 int16_t rec_intradc[6];
456 const int interleaved_stats = s->avctx->flags & AV_CODEC_FLAG_PASS1;
460 cbp= get_p_cbp(s, block, motion_x, motion_y);
462 if ((cbp | motion_x | motion_y | s->dquant | (s->mv_type - MV_TYPE_16X16)) == 0) {
463 /* skip macroblock */
464 put_bits(&s->pb, 1, 1);
465 if(interleaved_stats){
473 put_bits(&s->pb, 1, 0); /* mb coded */
477 if(s->alt_inter_vlc==0 || cbpc!=3)
479 if(s->dquant) cbpc+= 8;
480 if(s->mv_type==MV_TYPE_16X16){
482 ff_h263_inter_MCBPC_bits[cbpc],
483 ff_h263_inter_MCBPC_code[cbpc]);
485 put_bits(&s->pb, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
487 put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
489 if(interleaved_stats){
490 s->misc_bits+= get_bits_diff(s);
493 /* motion vectors: 16x16 mode */
494 ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
497 ff_h263_encode_motion_vector(s, motion_x - pred_x,
498 motion_y - pred_y, 1);
501 h263p_encode_umotion(&s->pb, motion_x - pred_x);
502 h263p_encode_umotion(&s->pb, motion_y - pred_y);
503 if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
504 /* To prevent Start Code emulation */
505 put_bits(&s->pb,1,1);
509 ff_h263_inter_MCBPC_bits[cbpc+16],
510 ff_h263_inter_MCBPC_code[cbpc+16]);
511 put_bits(&s->pb, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
513 put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
515 if(interleaved_stats){
516 s->misc_bits+= get_bits_diff(s);
520 /* motion vectors: 8x8 mode*/
521 ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
523 motion_x = s->current_picture.motion_val[0][s->block_index[i]][0];
524 motion_y = s->current_picture.motion_val[0][s->block_index[i]][1];
526 ff_h263_encode_motion_vector(s, motion_x - pred_x,
527 motion_y - pred_y, 1);
530 h263p_encode_umotion(&s->pb, motion_x - pred_x);
531 h263p_encode_umotion(&s->pb, motion_y - pred_y);
532 if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
533 /* To prevent Start Code emulation */
534 put_bits(&s->pb,1,1);
539 if(interleaved_stats){
540 s->mv_bits+= get_bits_diff(s);
543 av_assert2(s->mb_intra);
549 int16_t level = block[i][0];
552 if(i<4) scale= s->y_dc_scale;
553 else scale= s->c_dc_scale;
555 pred_dc = ff_h263_pred_dc(s, i, &dc_ptr[i]);
559 level = (level + (scale>>1))/scale;
561 level = (level - (scale>>1))/scale;
563 if(!s->modified_quant){
566 else if (level > 127)
572 rec_intradc[i] = scale*level + pred_dc;
575 //if ((rec_intradc[i] % 2) == 0)
578 if (rec_intradc[i] < 0)
580 else if (rec_intradc[i] > 2047)
581 rec_intradc[i] = 2047;
583 /* Update AC/DC tables */
584 *dc_ptr[i] = rec_intradc[i];
585 /* AIC can change CBP */
586 if (s->block_last_index[i] > 0 ||
587 (s->block_last_index[i] == 0 && level !=0))
593 if (s->block_last_index[i] >= 1)
599 if (s->pict_type == AV_PICTURE_TYPE_I) {
600 if(s->dquant) cbpc+=4;
602 ff_h263_intra_MCBPC_bits[cbpc],
603 ff_h263_intra_MCBPC_code[cbpc]);
605 if(s->dquant) cbpc+=8;
606 put_bits(&s->pb, 1, 0); /* mb coded */
608 ff_h263_inter_MCBPC_bits[cbpc + 4],
609 ff_h263_inter_MCBPC_code[cbpc + 4]);
612 /* XXX: currently, we do not try to use ac prediction */
613 put_bits(&s->pb, 1, 0); /* no AC prediction */
616 put_bits(&s->pb, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
618 put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
620 if(interleaved_stats){
621 s->misc_bits+= get_bits_diff(s);
626 /* encode each block */
627 h263_encode_block(s, block[i], i);
629 /* Update INTRADC for decoding */
630 if (s->h263_aic && s->mb_intra) {
631 block[i][0] = rec_intradc[i];
636 if(interleaved_stats){
638 s->p_tex_bits+= get_bits_diff(s);
641 s->i_tex_bits+= get_bits_diff(s);
647 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code)
649 int range, bit_size, sign, code, bits;
654 put_bits(pb, ff_mvtab[code][1], ff_mvtab[code][0]);
656 bit_size = f_code - 1;
657 range = 1 << bit_size;
658 /* modulo encoding */
659 val = sign_extend(val, 6 + bit_size);
661 val= (val^sign)-sign;
665 code = (val >> bit_size) + 1;
666 bits = val & (range - 1);
668 put_bits(pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
670 put_bits(pb, bit_size, bits);
675 static av_cold void init_mv_penalty_and_fcode(MpegEncContext *s)
680 for(f_code=1; f_code<=MAX_FCODE; f_code++){
681 for(mv=-MAX_DMV; mv<=MAX_DMV; mv++){
684 if(mv==0) len= ff_mvtab[0][1];
686 int val, bit_size, code;
688 bit_size = f_code - 1;
694 code = (val >> bit_size) + 1;
696 len= ff_mvtab[code][1] + 1 + bit_size;
698 len= ff_mvtab[32][1] + av_log2(code>>5) + 2 + bit_size;
702 mv_penalty[f_code][mv+MAX_DMV]= len;
706 for(f_code=MAX_FCODE; f_code>0; f_code--){
707 for(mv=-(16<<f_code); mv<(16<<f_code); mv++){
708 fcode_tab[mv+MAX_MV]= f_code;
712 for(mv=0; mv<MAX_MV*2+1; mv++){
713 umv_fcode_tab[mv]= 1;
717 static av_cold void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab,
720 int slevel, run, last;
722 av_assert0(MAX_LEVEL >= 64);
723 av_assert0(MAX_RUN >= 63);
725 for(slevel=-64; slevel<64; slevel++){
726 if(slevel==0) continue;
727 for(run=0; run<64; run++){
728 for(last=0; last<=1; last++){
729 const int index= UNI_MPEG4_ENC_INDEX(last, run, slevel+64);
730 int level= slevel < 0 ? -slevel : slevel;
731 int sign= slevel < 0 ? 1 : 0;
737 code= get_rl_index(rl, last, run, level);
738 bits= rl->table_vlc[code][0];
739 len= rl->table_vlc[code][1];
740 bits=bits*2+sign; len++;
742 if(code!=rl->n && len < len_tab[index]){
743 if(bits_tab) bits_tab[index]= bits;
744 len_tab [index]= len;
747 bits= rl->table_vlc[rl->n][0];
748 len = rl->table_vlc[rl->n][1];
749 bits=bits*2+last; len++;
750 bits=bits*64+run; len+=6;
751 bits=bits*256+(level&0xff); len+=8;
753 if(len < len_tab[index]){
754 if(bits_tab) bits_tab[index]= bits;
755 len_tab [index]= len;
762 av_cold void ff_h263_encode_init(MpegEncContext *s)
769 ff_rl_init(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
770 ff_rl_init(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
772 init_uni_h263_rl_tab(&ff_rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
773 init_uni_h263_rl_tab(&ff_h263_rl_inter , NULL, uni_h263_inter_rl_len);
775 init_mv_penalty_and_fcode(s);
777 s->me.mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p
779 s->intra_ac_vlc_length =s->inter_ac_vlc_length = uni_h263_inter_rl_len;
780 s->intra_ac_vlc_last_length=s->inter_ac_vlc_last_length= uni_h263_inter_rl_len + 128*64;
782 s->intra_ac_vlc_length = uni_h263_intra_aic_rl_len;
783 s->intra_ac_vlc_last_length= uni_h263_intra_aic_rl_len + 128*64;
785 s->ac_esc_length= 7+1+6+8;
787 // use fcodes >1 only for mpeg4 & h263 & h263p FIXME
789 case AV_CODEC_ID_MPEG4:
790 s->fcode_tab= fcode_tab;
792 case AV_CODEC_ID_H263P:
794 s->fcode_tab= umv_fcode_tab;
795 if(s->modified_quant){
796 s->min_qcoeff= -2047;
803 //Note for mpeg4 & h263 the dc-scale table will be set per frame as needed later
804 case AV_CODEC_ID_FLV1:
805 if (s->h263_flv > 1) {
806 s->min_qcoeff= -1023;
813 default: //nothing needed - default table already set in mpegvideo.c
819 s->c_dc_scale_table= ff_aic_dc_scale_table;
822 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
826 void ff_h263_encode_mba(MpegEncContext *s)
831 if(s->mb_num-1 <= ff_mba_max[i]) break;
833 mb_pos= s->mb_x + s->mb_width*s->mb_y;
834 put_bits(&s->pb, ff_mba_length[i], mb_pos);