65 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
68 1, 2, 3, 5, 4, 10, 9, 8,
69 11, 15, 17, 16, 23, 22, 21, 20,
70 19, 18, 25, 24, 27, 26, 11, 7,
71 6, 1, 2, 13, 2, 2, 2, 2,
72 6, 12, 3, 9, 1, 3, 4, 3,
73 7, 4, 1, 1, 5, 5, 14, 6,
74 1, 7, 1, 8, 1, 1, 1, 1,
75 10, 1, 1, 5, 9, 17, 25, 24,
76 29, 33, 32, 41, 2, 23, 28, 31,
77 3, 22, 30, 4, 27, 40, 8, 26,
78 6, 39, 7, 38, 16, 37, 15, 10,
79 11, 12, 13, 14, 1, 21, 20, 18,
104 int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref;
105 int best_clock_code=1;
107 int best_error= INT_MAX;
113 div= av_clip(div, 1, 127);
115 if(error < best_error){
122 s->
custom_pcf= best_clock_code!=1 || best_divisor!=60;
123 coded_frame_rate= 1800000;
124 coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
271 for(i=1; i<s->
mb_num; i++){
275 for(i=s->
mb_num-2; i>=0; i--){
281 for(i=1; i<s->
mb_num; i++){
300 int level,
run, last, i, j, last_index, last_non_zero, sign, slevel, code;
313 else if (level < 1) {
329 int inter_vlc_bits=0;
334 last_non_zero = i - 1;
335 for (; i <= last_index; i++) {
339 run = i - last_non_zero - 1;
340 last = (i == last_index);
342 if(level<0) level= -
level;
346 inter_vlc_bits += rl->
table_vlc[code][1]+1;
350 inter_vlc_bits += 1+6+8-1;
353 aic_vlc_bits += 1+6+8-1;
354 wrong_pos += run + 1;
361 if(aic_vlc_bits < inter_vlc_bits && wrong_pos > 63)
368 last_non_zero = i - 1;
369 for (; i <= last_index; i++) {
373 run = i - last_non_zero - 1;
374 last = (i == last_index);
384 if(!CONFIG_FLV_ENCODER || s->
h263_flv <= 1){
426 sval = ((val < 0) ? (
short)(-
val):(
short)
val);
429 while (temp_val != 0) {
430 temp_val = temp_val >> 1;
436 tcode = (sval & (1 << (i-1))) >> (i-1);
437 tcode = (tcode << 1) | 1;
438 code = (code << 2) | tcode;
441 code = ((code << 1) | (val < 0)) << 1;
447 int16_t
block[6][64],
448 int motion_x,
int motion_y)
450 int cbpc, cbpy, i, cbp, pred_x, pred_y;
452 int16_t rec_intradc[6];
458 cbp=
get_p_cbp(s, block, motion_x, motion_y);
463 if(interleaved_stats){
487 if(interleaved_stats){
496 motion_y - pred_y, 1);
501 if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
513 if(interleaved_stats){
525 motion_y - pred_y, 1);
530 if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
537 if(interleaved_stats){
547 int16_t
level = block[i][0];
557 level = (level + (scale>>1))/scale;
559 level = (level - (scale>>1))/scale;
564 else if (level > 127)
570 rec_intradc[i] = scale*level +
pred_dc;
576 if (rec_intradc[i] < 0)
578 else if (rec_intradc[i] > 2047)
579 rec_intradc[i] = 2047;
582 *dc_ptr[i] = rec_intradc[i];
618 if(interleaved_stats){
629 block[i][0] = rec_intradc[i];
634 if(interleaved_stats){
647 int range, bit_size, sign, code,
bits;
654 bit_size = f_code - 1;
655 range = 1 << bit_size;
659 val= (val^sign)-sign;
663 code = (val >> bit_size) + 1;
664 bits = val & (range - 1);
678 for(f_code=1; f_code<=
MAX_FCODE; f_code++){
684 int val, bit_size, code;
686 bit_size = f_code - 1;
692 code = (val >> bit_size) + 1;
694 len=
ff_mvtab[code][1] + 1 + bit_size;
704 for(f_code=
MAX_FCODE; f_code>0; f_code--){
705 for(mv=-(16<<f_code); mv<(16<<f_code); mv++){
710 for(mv=0; mv<
MAX_MV*2+1; mv++){
718 int slevel,
run, last;
723 for(slevel=-64; slevel<64; slevel++){
724 if(slevel==0)
continue;
725 for(run=0; run<64; run++){
726 for(last=0; last<=1; last++){
728 int level= slevel < 0 ? -slevel : slevel;
729 int sign= slevel < 0 ? 1 : 0;
738 bits=bits*2+sign; len++;
740 if(code!=rl->
n && len < len_tab[index]){
747 bits=bits*2+last; len++;
748 bits=bits*64+
run; len+=6;
749 bits=bits*256+(level&0xff); len+=8;
751 if(len < len_tab[index]){