64 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
67 1, 2, 3, 5, 4, 10, 9, 8,
68 11, 15, 17, 16, 23, 22, 21, 20,
69 19, 18, 25, 24, 27, 26, 11, 7,
70 6, 1, 2, 13, 2, 2, 2, 2,
71 6, 12, 3, 9, 1, 3, 4, 3,
72 7, 4, 1, 1, 5, 5, 14, 6,
73 1, 7, 1, 8, 1, 1, 1, 1,
74 10, 1, 1, 5, 9, 17, 25, 24,
75 29, 33, 32, 41, 2, 23, 28, 31,
76 3, 22, 30, 4, 27, 40, 8, 26,
77 6, 39, 7, 38, 16, 37, 15, 10,
78 11, 12, 13, 14, 1, 21, 20, 18,
103 int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref;
104 int best_clock_code=1;
106 int best_error= INT_MAX;
112 div= av_clip(div, 1, 127);
114 if(error < best_error){
121 s->
custom_pcf= best_clock_code!=1 || best_divisor!=60;
122 coded_frame_rate= 1800000;
123 coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
278 for(i=1; i<s->
mb_num; i++){
282 for(i=s->
mb_num-2; i>=0; i--){
288 for(i=1; i<s->
mb_num; i++){
307 int level,
run, last, i, j, last_index, last_non_zero, sign, slevel, code;
320 else if (level < 1) {
336 int inter_vlc_bits=0;
341 last_non_zero = i - 1;
342 for (; i <= last_index; i++) {
346 run = i - last_non_zero - 1;
347 last = (i == last_index);
349 if(level<0) level= -
level;
353 inter_vlc_bits += rl->
table_vlc[code][1]+1;
357 inter_vlc_bits += 1+6+8-1;
360 aic_vlc_bits += 1+6+8-1;
361 wrong_pos += run + 1;
368 if(aic_vlc_bits < inter_vlc_bits && wrong_pos > 63)
375 last_non_zero = i - 1;
376 for (; i <= last_index; i++) {
380 run = i - last_non_zero - 1;
381 last = (i == last_index);
391 if(!CONFIG_FLV_ENCODER || s->
h263_flv <= 1){
433 sval = ((val < 0) ? (
short)(-
val):(
short)
val);
436 while (temp_val != 0) {
437 temp_val = temp_val >> 1;
443 tcode = (sval & (1 << (i-1))) >> (i-1);
444 tcode = (tcode << 1) | 1;
445 code = (code << 2) | tcode;
448 code = ((code << 1) | (val < 0)) << 1;
454 int16_t
block[6][64],
455 int motion_x,
int motion_y)
457 int cbpc, cbpy, i, cbp, pred_x, pred_y;
459 int16_t rec_intradc[6];
465 cbp=
get_p_cbp(s, block, motion_x, motion_y);
470 if(interleaved_stats){
494 if(interleaved_stats){
503 motion_y - pred_y, 1);
508 if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
520 if(interleaved_stats){
532 motion_y - pred_y, 1);
537 if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
544 if(interleaved_stats){
554 int16_t
level = block[i][0];
564 level = (level + (scale>>1))/
scale;
566 level = (level - (scale>>1))/
scale;
575 else if (level > 127)
581 rec_intradc[i] = scale*level + pred_dc;
587 if (rec_intradc[i] < 0)
589 else if (rec_intradc[i] > 2047)
590 rec_intradc[i] = 2047;
593 *dc_ptr[i] = rec_intradc[i];
627 if(interleaved_stats){
638 block[i][0] = rec_intradc[i];
643 if(interleaved_stats){
656 int range, bit_size, sign, code,
bits;
663 bit_size = f_code - 1;
664 range = 1 << bit_size;
668 val= (val^sign)-sign;
672 code = (val >> bit_size) + 1;
673 bits = val & (range - 1);
687 for(f_code=1; f_code<=
MAX_FCODE; f_code++){
693 int val, bit_size, code;
695 bit_size = f_code - 1;
701 code = (val >> bit_size) + 1;
703 len=
ff_mvtab[code][1] + 1 + bit_size;
713 for(f_code=
MAX_FCODE; f_code>0; f_code--){
714 for(mv=-(16<<f_code); mv<(16<<f_code); mv++){
719 for(mv=0; mv<
MAX_MV*2+1; mv++){
727 int slevel,
run, last;
732 for(slevel=-64; slevel<64; slevel++){
733 if(slevel==0)
continue;
734 for(run=0; run<64; run++){
735 for(last=0; last<=1; last++){
737 int level= slevel < 0 ? -slevel : slevel;
738 int sign= slevel < 0 ? 1 : 0;
747 bits=bits*2+sign; len++;
749 if(code!=rl->
n && len < len_tab[index]){
756 bits=bits*2+last; len++;
757 bits=bits*64+
run; len+=6;
758 bits=bits*256+(level&0xff); len+=8;
760 if(len < len_tab[index]){