45 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
67 for(j=1; j<=block_last_index; j++){
68 const int index= scantable[j];
72 if((level&(~127)) == 0){
134 int16_t *ac_val, *ac_val1;
144 if(s->
mb_y==0 || s->
qscale == qscale_table[xy] || n==2 || n==3){
166 if(s->
mb_x==0 || s->
qscale == qscale_table[xy] || n==1 || n==3){
187 if(block[n][ st[n][i] ])
break;
214 for(i=0; i<s->
mb_num; i++){
216 odd += qscale_table[mb_xy]&1;
219 if(2*odd > s->
mb_num) odd=1;
222 for(i=0; i<s->
mb_num; i++){
224 if((qscale_table[mb_xy]&1) != odd)
225 qscale_table[mb_xy]++;
226 if(qscale_table[mb_xy] > 31)
227 qscale_table[mb_xy]= 31;
230 for(i=1; i<s->
mb_num; i++){
277 level = (-
level) ^ ((1 << size) - 1);
300 int i, last_non_zero;
308 if(last_index<1)
return;
313 if(last_index<0)
return;
320 last_non_zero = i - 1;
321 for (; i < last_index; i++) {
322 int level = block[ scan_table[i] ];
324 int run = i - last_non_zero - 1;
326 if((level&(~127)) == 0){
328 put_bits(ac_pb, len_tab[index], bits_tab[index]);
330 put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(0<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1);
336 int level = block[ scan_table[i] ];
337 int run = i - last_non_zero - 1;
339 if((level&(~127)) == 0){
341 put_bits(ac_pb, len_tab[index], bits_tab[index]);
343 put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(1<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1);
351 int i, last_non_zero;
359 if(last_index<1)
return len;
363 if(last_index<0)
return 0;
369 last_non_zero = i - 1;
370 for (; i < last_index; i++) {
371 int level = block[ scan_table[i] ];
373 int run = i - last_non_zero - 1;
375 if((level&(~127)) == 0){
377 len += len_tab[
index];
379 len += 7+2+1+6+1+12+1;
385 int level = block[ scan_table[i] ];
386 int run = i - last_non_zero - 1;
388 if((level&(~127)) == 0){
390 len += len_tab[
index];
392 len += 7+2+1+6+1+12+1;
405 for (i = 0; i < 6; i++) {
410 for (i = 0; i < 6; i++) {
416 for (i = 0; i < 6; i++) {
421 for (i = 0; i < 6; i++) {
429 int motion_x,
int motion_y,
int mb_type)
437 for (i = 0; i < 6; i++)
445 if ((motion_x | motion_y | s->
dquant | mb_type) == 0)
448 zero_score *= lambda;
449 if (zero_score <= score)
453 for (i = 0; i < 6; i++) {
460 for (i = 0; i < 6; i++) {
473 int motion_x,
int motion_y)
475 int cbpc, cbpy, pred_x, pred_y;
485 static const int mb_type_table[8]= {-1, 3, 2, 1,-1,-1,-1, 0};
486 int mb_type= mb_type_table[s->
mv_dir];
515 cbp=
get_b_cbp(s, block, motion_x, motion_y, mb_type);
517 if ((cbp | motion_x | motion_y | mb_type) ==0) {
523 if(interleaved_stats){
551 if(interleaved_stats){
607 if(interleaved_stats){
613 if(interleaved_stats){
618 cbp=
get_p_cbp(s, block, motion_x, motion_y);
652 for(y1=0; y1<ye; y1++){
653 for(x1=0; x1<xe; x1++){
657 diff= diff*256/(xe*ye);
673 if(interleaved_stats){
703 if(interleaved_stats){
711 motion_y - pred_y, s->
f_code);
727 if(interleaved_stats){
739 s->
mv[0][0][1] - pred_y, s->
f_code);
741 s->
mv[0][1][1] - pred_y, s->
f_code);
754 if(interleaved_stats){
767 if(interleaved_stats){
773 if(interleaved_stats){
782 int zigzag_last_index[6];
799 for (i = 0; i < 6; i++) {
827 if(interleaved_stats){
833 if(interleaved_stats){
852 if(length)
put_bits(pbc, length, (1<<length)-1);
866 int hours, minutes, seconds;
879 minutes=
FFUDIV(seconds, 60); seconds =
FFUMOD(seconds, 60);
880 hours =
FFUDIV(minutes, 60); minutes =
FFUMOD(minutes, 60);
881 hours =
FFUMOD(hours , 24);
895 int profile_and_level_indication;
901 profile_and_level_indication= 0xF0;
903 profile_and_level_indication= 0x00;
907 profile_and_level_indication |= s->
avctx->
level;
909 profile_and_level_indication |= 1;
912 if(profile_and_level_indication>>4 == 0xF){
923 put_bits(&s->
pb, 8, profile_and_level_indication);
943 if (!CONFIG_MPEG4_ENCODER)
return;
1002 if (vo_ver_id == 1) {
1026 if (vo_ver_id != 1){
1046 int time_div, time_mod;
1100 int level, uni_code, uni_len;
1102 for(level=-256; level<256; level++){
1113 l= (-
level) ^ ((1 << size) - 1);
1122 uni_code<<=
size; uni_code|=l;
1125 uni_code<<=1; uni_code|=1;
1137 uni_code<<=
size; uni_code|=l;
1140 uni_code<<=1; uni_code|=1;
1151 int slevel,
run, last;
1156 for(slevel=-64; slevel<64; slevel++){
1157 if(slevel==0)
continue;
1158 for(run=0; run<64; run++){
1159 for(last=0; last<=1; last++){
1161 int level= slevel < 0 ? -slevel : slevel;
1162 int sign= slevel < 0 ? 1 : 0;
1166 len_tab[
index]= 100;
1172 bits=bits*2+sign; len++;
1174 if(code!=rl->
n && len < len_tab[index]){
1188 bits=bits*2+sign; len++;
1190 if(code!=rl->
n && len < len_tab[index]){
1198 bits=bits*4+2; len+=2;
1205 bits=bits*2+sign; len++;
1207 if(code!=rl->
n && len < len_tab[index]){
1215 bits=bits*4+3; len+=2;
1216 bits=bits*2+last; len++;
1217 bits=bits*64+
run; len+=6;
1218 bits=bits*2+1; len++;
1219 bits=bits*4096+(slevel&0xfff); len+=12;
1220 bits=bits*2+1; len++;
1222 if(len < len_tab[index]){
1235 static int done = 0;
1282 int size= end - start;
1283 int pb_size = (((intptr_t)start + size/3)&(~3)) - (intptr_t)start;
1284 int tex_size= (size - 2*pb_size)&(~3);
1330 #define OFFSET(x) offsetof(MpegEncContext, x)
1331 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1333 {
"data_partitioning",
"Use data partitioning.",
OFFSET(data_partitioning),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
1334 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(alternate_scan),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },