comparison mpegvideo.c @ 1159:13ea348d4cf2 libavcodec

simplify slice encoding (variance of packet size is practically identical)
author michaelni
date Sun, 30 Mar 2003 16:22:08 +0000
parents dde68a430ba9
children 9a5c29575902
comparison
equal deleted inserted replaced
1158:71d890b5c13b 1159:13ea348d4cf2
3041 3041
3042 s->resync_mb_x=0; 3042 s->resync_mb_x=0;
3043 s->resync_mb_y=0; 3043 s->resync_mb_y=0;
3044 s->first_slice_line = 1; 3044 s->first_slice_line = 1;
3045 s->ptr_lastgob = s->pb.buf; 3045 s->ptr_lastgob = s->pb.buf;
3046 s->ptr_last_mb_line = s->pb.buf;
3047 for(mb_y=0; mb_y < s->mb_height; mb_y++) { 3046 for(mb_y=0; mb_y < s->mb_height; mb_y++) {
3048 s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; 3047 s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
3049 s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; 3048 s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
3050 3049
3051 s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1; 3050 s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1;
3076 3075
3077 current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob; 3076 current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob;
3078 is_gob_start=0; 3077 is_gob_start=0;
3079 3078
3080 if(s->codec_id==CODEC_ID_MPEG4){ 3079 if(s->codec_id==CODEC_ID_MPEG4){
3081 if(current_packet_size + s->mb_line_avgsize/s->mb_width >= s->rtp_payload_size 3080 if(current_packet_size >= s->rtp_payload_size
3082 && s->mb_y + s->mb_x>0){ 3081 && s->mb_y + s->mb_x>0){
3083 3082
3084 if(s->partitioned_frame){ 3083 if(s->partitioned_frame){
3085 ff_mpeg4_merge_partitions(s); 3084 ff_mpeg4_merge_partitions(s);
3086 ff_mpeg4_init_partitions(s); 3085 ff_mpeg4_init_partitions(s);
3094 } 3093 }
3095 ff_mpeg4_clean_buffers(s); 3094 ff_mpeg4_clean_buffers(s);
3096 is_gob_start=1; 3095 is_gob_start=1;
3097 } 3096 }
3098 }else{ 3097 }else{
3099 if(current_packet_size + s->mb_line_avgsize*s->gob_index >= s->rtp_payload_size 3098 if(current_packet_size >= s->rtp_payload_size
3100 && s->mb_x==0 && s->mb_y>0 && s->mb_y%s->gob_index==0){ 3099 && s->mb_x==0 && s->mb_y>0 && s->mb_y%s->gob_index==0){
3101 3100
3102 h263_encode_gob_header(s, mb_y); 3101 h263_encode_gob_header(s, mb_y);
3103 is_gob_start=1; 3102 is_gob_start=1;
3104 } 3103 }
3409 s->current_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8, 3408 s->current_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
3410 w>>1, h>>1, s->uvlinesize); 3409 w>>1, h>>1, s->uvlinesize);
3411 } 3410 }
3412 //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_width, get_bit_count(&s->pb)); 3411 //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_width, get_bit_count(&s->pb));
3413 } 3412 }
3414
3415
3416 /* Obtain average mb_row size for RTP */
3417 if (s->rtp_mode) {
3418 if (mb_y==0)
3419 s->mb_line_avgsize = pbBufPtr(&s->pb) - s->ptr_last_mb_line;
3420 else {
3421 s->mb_line_avgsize = (s->mb_line_avgsize + pbBufPtr(&s->pb) - s->ptr_last_mb_line) >> 1;
3422 }
3423 s->ptr_last_mb_line = pbBufPtr(&s->pb);
3424 }
3425 } 3413 }
3426 emms_c(); 3414 emms_c();
3427 3415
3428 #ifdef CONFIG_RISKY 3416 #ifdef CONFIG_RISKY
3429 if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame) 3417 if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame)