46 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
68 for(j=1; j<=block_last_index; j++){
69 const int index= scantable[j];
73 if((level&(~127)) == 0){
135 int16_t *ac_val, *ac_val1;
145 if(s->
mb_y==0 || s->
qscale == qscale_table[xy] || n==2 || n==3){
167 if(s->
mb_x==0 || s->
qscale == qscale_table[xy] || n==1 || n==3){
188 if(block[n][ st[n][i] ])
break;
215 for(i=0; i<s->
mb_num; i++){
217 odd += qscale_table[mb_xy]&1;
220 if(2*odd > s->
mb_num) odd=1;
223 for(i=0; i<s->
mb_num; i++){
225 if((qscale_table[mb_xy]&1) != odd)
226 qscale_table[mb_xy]++;
227 if(qscale_table[mb_xy] > 31)
228 qscale_table[mb_xy]= 31;
231 for(i=1; i<s->
mb_num; i++){
278 level = (-
level) ^ ((1 << size) - 1);
301 int i, last_non_zero;
309 if(last_index<1)
return;
314 if(last_index<0)
return;
321 last_non_zero = i - 1;
322 for (; i < last_index; i++) {
323 int level = block[ scan_table[i] ];
325 int run = i - last_non_zero - 1;
327 if((level&(~127)) == 0){
329 put_bits(ac_pb, len_tab[index], bits_tab[index]);
331 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);
337 int level = block[ scan_table[i] ];
338 int run = i - last_non_zero - 1;
340 if((level&(~127)) == 0){
342 put_bits(ac_pb, len_tab[index], bits_tab[index]);
344 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);
352 int i, last_non_zero;
360 if(last_index<1)
return len;
364 if(last_index<0)
return 0;
370 last_non_zero = i - 1;
371 for (; i < last_index; i++) {
372 int level = block[ scan_table[i] ];
374 int run = i - last_non_zero - 1;
376 if((level&(~127)) == 0){
378 len += len_tab[
index];
380 len += 7+2+1+6+1+12+1;
386 int level = block[ scan_table[i] ];
387 int run = i - last_non_zero - 1;
389 if((level&(~127)) == 0){
391 len += len_tab[
index];
393 len += 7+2+1+6+1+12+1;
406 for (i = 0; i < 6; i++) {
411 for (i = 0; i < 6; i++) {
417 for (i = 0; i < 6; i++) {
422 for (i = 0; i < 6; i++) {
430 int motion_x,
int motion_y,
int mb_type)
438 for (i = 0; i < 6; i++)
446 if ((motion_x | motion_y | s->
dquant | mb_type) == 0)
449 zero_score *= lambda;
450 if (zero_score <= score)
454 for (i = 0; i < 6; i++) {
461 for (i = 0; i < 6; i++) {
473 int16_t
block[6][64],
474 int motion_x,
int motion_y)
476 int cbpc, cbpy, pred_x, pred_y;
486 static const int mb_type_table[8]= {-1, 3, 2, 1,-1,-1,-1, 0};
487 int mb_type= mb_type_table[s->
mv_dir];
516 cbp=
get_b_cbp(s, block, motion_x, motion_y, mb_type);
518 if ((cbp | motion_x | motion_y | mb_type) ==0) {
524 if(interleaved_stats){
552 if(interleaved_stats){
608 if(interleaved_stats){
614 if(interleaved_stats){
619 cbp=
get_p_cbp(s, block, motion_x, motion_y);
653 for(y1=0; y1<ye; y1++){
654 for(x1=0; x1<xe; x1++){
658 diff= diff*256/(xe*ye);
674 if(interleaved_stats){
704 if(interleaved_stats){
712 motion_y - pred_y, s->
f_code);
728 if(interleaved_stats){
740 s->
mv[0][0][1] - pred_y, s->
f_code);
742 s->
mv[0][1][1] - pred_y, s->
f_code);
755 if(interleaved_stats){
768 if(interleaved_stats){
774 if(interleaved_stats){
783 int zigzag_last_index[6];
800 for (i = 0; i < 6; i++) {
828 if(interleaved_stats){
834 if(interleaved_stats){
853 if(length)
put_bits(pbc, length, (1<<length)-1);
867 int hours, minutes, seconds;
880 minutes=
FFUDIV(seconds, 60); seconds =
FFUMOD(seconds, 60);
881 hours =
FFUDIV(minutes, 60); minutes =
FFUMOD(minutes, 60);
882 hours =
FFUMOD(hours , 24);
896 int profile_and_level_indication;
902 profile_and_level_indication= 0xF0;
904 profile_and_level_indication= 0x00;
908 profile_and_level_indication |= s->
avctx->
level;
910 profile_and_level_indication |= 1;
913 if(profile_and_level_indication>>4 == 0xF){
924 put_bits(&s->
pb, 8, profile_and_level_indication);
944 if (!CONFIG_MPEG4_ENCODER)
return;
1003 if (vo_ver_id == 1) {
1027 if (vo_ver_id != 1){
1047 int time_div, time_mod;
1101 int level, uni_code, uni_len;
1103 for(level=-256; level<256; level++){
1114 l= (-
level) ^ ((1 << size) - 1);
1123 uni_code<<=
size; uni_code|=l;
1126 uni_code<<=1; uni_code|=1;
1138 uni_code<<=
size; uni_code|=l;
1141 uni_code<<=1; uni_code|=1;
1154 int slevel,
run, last;
1159 for(slevel=-64; slevel<64; slevel++){
1160 if(slevel==0)
continue;
1161 for(run=0; run<64; run++){
1162 for(last=0; last<=1; last++){
1164 int level= slevel < 0 ? -slevel : slevel;
1165 int sign= slevel < 0 ? 1 : 0;
1169 len_tab[
index]= 100;
1175 bits=bits*2+sign; len++;
1177 if(code!=rl->
n && len < len_tab[index]){
1191 bits=bits*2+sign; len++;
1193 if(code!=rl->
n && len < len_tab[index]){
1201 bits=bits*4+2; len+=2;
1208 bits=bits*2+sign; len++;
1210 if(code!=rl->
n && len < len_tab[index]){
1218 bits=bits*4+3; len+=2;
1219 bits=bits*2+last; len++;
1220 bits=bits*64+
run; len+=6;
1221 bits=bits*2+1; len++;
1222 bits=bits*4096+(slevel&0xfff); len+=12;
1223 bits=bits*2+1; len++;
1225 if(len < len_tab[index]){
1238 static int done = 0;
1240 if (avctx->
width >= (1<<13) || avctx->
height >= (1<<13)) {
1291 int pb_size = (((intptr_t)start + size/3)&(~3)) - (intptr_t)start;
1292 int tex_size= (size - 2*pb_size)&(~3);
1338 #define OFFSET(x) offsetof(MpegEncContext, x)
1339 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1341 {
"data_partitioning",
"Use data partitioning.",
OFFSET(data_partitioning),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
1342 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(alternate_scan),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },