Mercurial > libavcodec.hg
comparison mpegvideo_enc.c @ 6481:493dc59d469a libavcodec
add FF_ prefix to all (frame)_TYPE usage
author | aurel |
---|---|
date | Sun, 09 Mar 2008 23:31:02 +0000 |
parents | 345cffb2c613 |
children | 3f96dc62c4b9 |
comparison
equal
deleted
inserted
replaced
6480:6f01a499e785 | 6481:493dc59d469a |
---|---|
937 int best_b_count= -1; | 937 int best_b_count= -1; |
938 | 938 |
939 assert(scale>=0 && scale <=3); | 939 assert(scale>=0 && scale <=3); |
940 | 940 |
941 // emms_c(); | 941 // emms_c(); |
942 p_lambda= s->last_lambda_for[P_TYPE]; //s->next_picture_ptr->quality; | 942 p_lambda= s->last_lambda_for[FF_P_TYPE]; //s->next_picture_ptr->quality; |
943 b_lambda= s->last_lambda_for[B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; | 943 b_lambda= s->last_lambda_for[FF_B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; |
944 if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else | 944 if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else |
945 lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT; | 945 lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT; |
946 | 946 |
947 c->width = s->width >> scale; | 947 c->width = s->width >> scale; |
948 c->height= s->height>> scale; | 948 c->height= s->height>> scale; |
993 if(!s->input_picture[j]) | 993 if(!s->input_picture[j]) |
994 break; | 994 break; |
995 | 995 |
996 c->error[0]= c->error[1]= c->error[2]= 0; | 996 c->error[0]= c->error[1]= c->error[2]= 0; |
997 | 997 |
998 input[0].pict_type= I_TYPE; | 998 input[0].pict_type= FF_I_TYPE; |
999 input[0].quality= 1 * FF_QP2LAMBDA; | 999 input[0].quality= 1 * FF_QP2LAMBDA; |
1000 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[0]); | 1000 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[0]); |
1001 // rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; | 1001 // rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; |
1002 | 1002 |
1003 for(i=0; i<s->max_b_frames+1; i++){ | 1003 for(i=0; i<s->max_b_frames+1; i++){ |
1004 int is_p= i % (j+1) == j || i==s->max_b_frames; | 1004 int is_p= i % (j+1) == j || i==s->max_b_frames; |
1005 | 1005 |
1006 input[i+1].pict_type= is_p ? P_TYPE : B_TYPE; | 1006 input[i+1].pict_type= is_p ? FF_P_TYPE : FF_B_TYPE; |
1007 input[i+1].quality= is_p ? p_lambda : b_lambda; | 1007 input[i+1].quality= is_p ? p_lambda : b_lambda; |
1008 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]); | 1008 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]); |
1009 rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3); | 1009 rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3); |
1010 } | 1010 } |
1011 | 1011 |
1043 | 1043 |
1044 /* set next picture type & ordering */ | 1044 /* set next picture type & ordering */ |
1045 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ | 1045 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ |
1046 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ | 1046 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ |
1047 s->reordered_input_picture[0]= s->input_picture[0]; | 1047 s->reordered_input_picture[0]= s->input_picture[0]; |
1048 s->reordered_input_picture[0]->pict_type= I_TYPE; | 1048 s->reordered_input_picture[0]->pict_type= FF_I_TYPE; |
1049 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; | 1049 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; |
1050 }else{ | 1050 }else{ |
1051 int b_frames; | 1051 int b_frames; |
1052 | 1052 |
1053 if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){ | 1053 if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){ |
1078 int pict_num= s->input_picture[0]->display_picture_number + i; | 1078 int pict_num= s->input_picture[0]->display_picture_number + i; |
1079 | 1079 |
1080 if(pict_num >= s->rc_context.num_entries) | 1080 if(pict_num >= s->rc_context.num_entries) |
1081 break; | 1081 break; |
1082 if(!s->input_picture[i]){ | 1082 if(!s->input_picture[i]){ |
1083 s->rc_context.entry[pict_num-1].new_pict_type = P_TYPE; | 1083 s->rc_context.entry[pict_num-1].new_pict_type = FF_P_TYPE; |
1084 break; | 1084 break; |
1085 } | 1085 } |
1086 | 1086 |
1087 s->input_picture[i]->pict_type= | 1087 s->input_picture[i]->pict_type= |
1088 s->rc_context.entry[pict_num].new_pict_type; | 1088 s->rc_context.entry[pict_num].new_pict_type; |
1122 //b_count+= b_frames; | 1122 //b_count+= b_frames; |
1123 //av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count); | 1123 //av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count); |
1124 | 1124 |
1125 for(i= b_frames - 1; i>=0; i--){ | 1125 for(i= b_frames - 1; i>=0; i--){ |
1126 int type= s->input_picture[i]->pict_type; | 1126 int type= s->input_picture[i]->pict_type; |
1127 if(type && type != B_TYPE) | 1127 if(type && type != FF_B_TYPE) |
1128 b_frames= i; | 1128 b_frames= i; |
1129 } | 1129 } |
1130 if(s->input_picture[b_frames]->pict_type == B_TYPE && b_frames == s->max_b_frames){ | 1130 if(s->input_picture[b_frames]->pict_type == FF_B_TYPE && b_frames == s->max_b_frames){ |
1131 av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n"); | 1131 av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n"); |
1132 } | 1132 } |
1133 | 1133 |
1134 if(s->picture_in_gop_number + b_frames >= s->gop_size){ | 1134 if(s->picture_in_gop_number + b_frames >= s->gop_size){ |
1135 if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){ | 1135 if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){ |
1136 b_frames= s->gop_size - s->picture_in_gop_number - 1; | 1136 b_frames= s->gop_size - s->picture_in_gop_number - 1; |
1137 }else{ | 1137 }else{ |
1138 if(s->flags & CODEC_FLAG_CLOSED_GOP) | 1138 if(s->flags & CODEC_FLAG_CLOSED_GOP) |
1139 b_frames=0; | 1139 b_frames=0; |
1140 s->input_picture[b_frames]->pict_type= I_TYPE; | 1140 s->input_picture[b_frames]->pict_type= FF_I_TYPE; |
1141 } | 1141 } |
1142 } | 1142 } |
1143 | 1143 |
1144 if( (s->flags & CODEC_FLAG_CLOSED_GOP) | 1144 if( (s->flags & CODEC_FLAG_CLOSED_GOP) |
1145 && b_frames | 1145 && b_frames |
1146 && s->input_picture[b_frames]->pict_type== I_TYPE) | 1146 && s->input_picture[b_frames]->pict_type== FF_I_TYPE) |
1147 b_frames--; | 1147 b_frames--; |
1148 | 1148 |
1149 s->reordered_input_picture[0]= s->input_picture[b_frames]; | 1149 s->reordered_input_picture[0]= s->input_picture[b_frames]; |
1150 if(s->reordered_input_picture[0]->pict_type != I_TYPE) | 1150 if(s->reordered_input_picture[0]->pict_type != FF_I_TYPE) |
1151 s->reordered_input_picture[0]->pict_type= P_TYPE; | 1151 s->reordered_input_picture[0]->pict_type= FF_P_TYPE; |
1152 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; | 1152 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; |
1153 for(i=0; i<b_frames; i++){ | 1153 for(i=0; i<b_frames; i++){ |
1154 s->reordered_input_picture[i+1]= s->input_picture[i]; | 1154 s->reordered_input_picture[i+1]= s->input_picture[i]; |
1155 s->reordered_input_picture[i+1]->pict_type= B_TYPE; | 1155 s->reordered_input_picture[i+1]->pict_type= FF_B_TYPE; |
1156 s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++; | 1156 s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++; |
1157 } | 1157 } |
1158 } | 1158 } |
1159 } | 1159 } |
1160 no_output_pic: | 1160 no_output_pic: |
1161 if(s->reordered_input_picture[0]){ | 1161 if(s->reordered_input_picture[0]){ |
1162 s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0; | 1162 s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=FF_B_TYPE ? 3 : 0; |
1163 | 1163 |
1164 copy_picture(&s->new_picture, s->reordered_input_picture[0]); | 1164 copy_picture(&s->new_picture, s->reordered_input_picture[0]); |
1165 | 1165 |
1166 if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size){ | 1166 if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size){ |
1167 // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable | 1167 // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable |
1261 int i; | 1261 int i; |
1262 for(i=0; i<s->mb_height*s->mb_stride; i++) | 1262 for(i=0; i<s->mb_height*s->mb_stride; i++) |
1263 s->lambda_table[i]= FFMAX(s->lambda_table[i]+1, s->lambda_table[i]*(s->qscale+1) / s->qscale); | 1263 s->lambda_table[i]= FFMAX(s->lambda_table[i]+1, s->lambda_table[i]*(s->qscale+1) / s->qscale); |
1264 } | 1264 } |
1265 s->mb_skipped = 0; //done in MPV_frame_start() | 1265 s->mb_skipped = 0; //done in MPV_frame_start() |
1266 if(s->pict_type==P_TYPE){ //done in encode_picture() so we must undo it | 1266 if(s->pict_type==FF_P_TYPE){ //done in encode_picture() so we must undo it |
1267 if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4) | 1267 if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4) |
1268 s->no_rounding ^= 1; | 1268 s->no_rounding ^= 1; |
1269 } | 1269 } |
1270 if(s->pict_type!=B_TYPE){ | 1270 if(s->pict_type!=FF_B_TYPE){ |
1271 s->time_base= s->last_time_base; | 1271 s->time_base= s->last_time_base; |
1272 s->last_non_b_time= s->time - s->pp_time; | 1272 s->last_non_b_time= s->time - s->pp_time; |
1273 } | 1273 } |
1274 // av_log(NULL, AV_LOG_ERROR, "R:%d ", s->next_lambda); | 1274 // av_log(NULL, AV_LOG_ERROR, "R:%d ", s->next_lambda); |
1275 for(i=0; i<avctx->thread_count; i++){ | 1275 for(i=0; i<avctx->thread_count; i++){ |
1482 if(s->out_format==FMT_H263){ | 1482 if(s->out_format==FMT_H263){ |
1483 s->dquant= av_clip(s->dquant, -2, 2); | 1483 s->dquant= av_clip(s->dquant, -2, 2); |
1484 | 1484 |
1485 if(s->codec_id==CODEC_ID_MPEG4){ | 1485 if(s->codec_id==CODEC_ID_MPEG4){ |
1486 if(!s->mb_intra){ | 1486 if(!s->mb_intra){ |
1487 if(s->pict_type == B_TYPE){ | 1487 if(s->pict_type == FF_B_TYPE){ |
1488 if(s->dquant&1 || s->mv_dir&MV_DIRECT) | 1488 if(s->dquant&1 || s->mv_dir&MV_DIRECT) |
1489 s->dquant= 0; | 1489 s->dquant= 0; |
1490 } | 1490 } |
1491 if(s->mv_type==MV_TYPE_8X8) | 1491 if(s->mv_type==MV_TYPE_8X8) |
1492 s->dquant=0; | 1492 s->dquant=0; |
1559 | 1559 |
1560 dest_y = s->dest[0]; | 1560 dest_y = s->dest[0]; |
1561 dest_cb = s->dest[1]; | 1561 dest_cb = s->dest[1]; |
1562 dest_cr = s->dest[2]; | 1562 dest_cr = s->dest[2]; |
1563 | 1563 |
1564 if ((!s->no_rounding) || s->pict_type==B_TYPE){ | 1564 if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){ |
1565 op_pix = s->dsp.put_pixels_tab; | 1565 op_pix = s->dsp.put_pixels_tab; |
1566 op_qpix= s->dsp.put_qpel_pixels_tab; | 1566 op_qpix= s->dsp.put_qpel_pixels_tab; |
1567 }else{ | 1567 }else{ |
1568 op_pix = s->dsp.put_no_rnd_pixels_tab; | 1568 op_pix = s->dsp.put_no_rnd_pixels_tab; |
1569 op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab; | 1569 op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab; |
1950 s->block_index[1]+=2; | 1950 s->block_index[1]+=2; |
1951 s->block_index[2]+=2; | 1951 s->block_index[2]+=2; |
1952 s->block_index[3]+=2; | 1952 s->block_index[3]+=2; |
1953 | 1953 |
1954 /* compute motion vector & mb_type and store in context */ | 1954 /* compute motion vector & mb_type and store in context */ |
1955 if(s->pict_type==B_TYPE) | 1955 if(s->pict_type==FF_B_TYPE) |
1956 ff_estimate_b_frame_motion(s, s->mb_x, s->mb_y); | 1956 ff_estimate_b_frame_motion(s, s->mb_x, s->mb_y); |
1957 else | 1957 else |
1958 ff_estimate_p_frame_motion(s, s->mb_x, s->mb_y); | 1958 ff_estimate_p_frame_motion(s, s->mb_x, s->mb_y); |
1959 } | 1959 } |
1960 s->first_slice_line=0; | 1960 s->first_slice_line=0; |
2347 s->mv[0][0][0] = best_s.mv[0][0][0]; | 2347 s->mv[0][0][0] = best_s.mv[0][0][0]; |
2348 s->mv[0][0][1] = best_s.mv[0][0][1]; | 2348 s->mv[0][0][1] = best_s.mv[0][0][1]; |
2349 s->mv[1][0][0] = best_s.mv[1][0][0]; | 2349 s->mv[1][0][0] = best_s.mv[1][0][0]; |
2350 s->mv[1][0][1] = best_s.mv[1][0][1]; | 2350 s->mv[1][0][1] = best_s.mv[1][0][1]; |
2351 | 2351 |
2352 qpi = s->pict_type == B_TYPE ? 2 : 0; | 2352 qpi = s->pict_type == FF_B_TYPE ? 2 : 0; |
2353 for(; qpi<4; qpi++){ | 2353 for(; qpi<4; qpi++){ |
2354 int dquant= dquant_tab[qpi]; | 2354 int dquant= dquant_tab[qpi]; |
2355 qp= last_qp + dquant; | 2355 qp= last_qp + dquant; |
2356 if(qp < s->avctx->qmin || qp > s->avctx->qmax) | 2356 if(qp < s->avctx->qmin || qp > s->avctx->qmax) |
2357 continue; | 2357 continue; |
2449 s->tex_pb= backup_s.tex_pb; | 2449 s->tex_pb= backup_s.tex_pb; |
2450 } | 2450 } |
2451 s->last_bits= put_bits_count(&s->pb); | 2451 s->last_bits= put_bits_count(&s->pb); |
2452 | 2452 |
2453 if (ENABLE_ANY_H263_ENCODER && | 2453 if (ENABLE_ANY_H263_ENCODER && |
2454 s->out_format == FMT_H263 && s->pict_type!=B_TYPE) | 2454 s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE) |
2455 ff_h263_update_motion_val(s); | 2455 ff_h263_update_motion_val(s); |
2456 | 2456 |
2457 if(next_block==0){ //FIXME 16 vs linesize16 | 2457 if(next_block==0){ //FIXME 16 vs linesize16 |
2458 s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16); | 2458 s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad , s->linesize ,16); |
2459 s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8); | 2459 s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize , s->uvlinesize, 8); |
2576 | 2576 |
2577 // RAL: Update last macroblock type | 2577 // RAL: Update last macroblock type |
2578 s->last_mv_dir = s->mv_dir; | 2578 s->last_mv_dir = s->mv_dir; |
2579 | 2579 |
2580 if (ENABLE_ANY_H263_ENCODER && | 2580 if (ENABLE_ANY_H263_ENCODER && |
2581 s->out_format == FMT_H263 && s->pict_type!=B_TYPE) | 2581 s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE) |
2582 ff_h263_update_motion_val(s); | 2582 ff_h263_update_motion_val(s); |
2583 | 2583 |
2584 MPV_decode_mb(s, s->block); | 2584 MPV_decode_mb(s, s->block); |
2585 } | 2585 } |
2586 | 2586 |
2614 //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb)); | 2614 //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb)); |
2615 } | 2615 } |
2616 } | 2616 } |
2617 | 2617 |
2618 //not beautiful here but we must write it before flushing so it has to be here | 2618 //not beautiful here but we must write it before flushing so it has to be here |
2619 if (ENABLE_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == I_TYPE) | 2619 if (ENABLE_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE) |
2620 msmpeg4_encode_ext_header(s); | 2620 msmpeg4_encode_ext_header(s); |
2621 | 2621 |
2622 write_slice_end(s); | 2622 write_slice_end(s); |
2623 | 2623 |
2624 /* Send the last GOB if RTP */ | 2624 /* Send the last GOB if RTP */ |
2710 /* must be called before writing the header */ | 2710 /* must be called before writing the header */ |
2711 static void set_frame_distances(MpegEncContext * s){ | 2711 static void set_frame_distances(MpegEncContext * s){ |
2712 assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE); | 2712 assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE); |
2713 s->time= s->current_picture_ptr->pts*s->avctx->time_base.num; | 2713 s->time= s->current_picture_ptr->pts*s->avctx->time_base.num; |
2714 | 2714 |
2715 if(s->pict_type==B_TYPE){ | 2715 if(s->pict_type==FF_B_TYPE){ |
2716 s->pb_time= s->pp_time - (s->last_non_b_time - s->time); | 2716 s->pb_time= s->pp_time - (s->last_non_b_time - s->time); |
2717 assert(s->pb_time > 0 && s->pb_time < s->pp_time); | 2717 assert(s->pb_time > 0 && s->pb_time < s->pp_time); |
2718 }else{ | 2718 }else{ |
2719 s->pp_time= s->time - s->last_non_b_time; | 2719 s->pp_time= s->time - s->last_non_b_time; |
2720 s->last_non_b_time= s->time; | 2720 s->last_non_b_time= s->time; |
2742 | 2742 |
2743 s->me.scene_change_score=0; | 2743 s->me.scene_change_score=0; |
2744 | 2744 |
2745 // s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME ratedistoration | 2745 // s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME ratedistoration |
2746 | 2746 |
2747 if(s->pict_type==I_TYPE){ | 2747 if(s->pict_type==FF_I_TYPE){ |
2748 if(s->msmpeg4_version >= 3) s->no_rounding=1; | 2748 if(s->msmpeg4_version >= 3) s->no_rounding=1; |
2749 else s->no_rounding=0; | 2749 else s->no_rounding=0; |
2750 }else if(s->pict_type!=B_TYPE){ | 2750 }else if(s->pict_type!=FF_B_TYPE){ |
2751 if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4) | 2751 if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4) |
2752 s->no_rounding ^= 1; | 2752 s->no_rounding ^= 1; |
2753 } | 2753 } |
2754 | 2754 |
2755 if(s->flags & CODEC_FLAG_PASS2){ | 2755 if(s->flags & CODEC_FLAG_PASS2){ |
2756 if (estimate_qp(s,1) < 0) | 2756 if (estimate_qp(s,1) < 0) |
2757 return -1; | 2757 return -1; |
2758 ff_get_2pass_fcode(s); | 2758 ff_get_2pass_fcode(s); |
2759 }else if(!(s->flags & CODEC_FLAG_QSCALE)){ | 2759 }else if(!(s->flags & CODEC_FLAG_QSCALE)){ |
2760 if(s->pict_type==B_TYPE) | 2760 if(s->pict_type==FF_B_TYPE) |
2761 s->lambda= s->last_lambda_for[s->pict_type]; | 2761 s->lambda= s->last_lambda_for[s->pict_type]; |
2762 else | 2762 else |
2763 s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; | 2763 s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; |
2764 update_qscale(s); | 2764 update_qscale(s); |
2765 } | 2765 } |
2770 } | 2770 } |
2771 | 2771 |
2772 ff_init_me(s); | 2772 ff_init_me(s); |
2773 | 2773 |
2774 /* Estimate motion for every MB */ | 2774 /* Estimate motion for every MB */ |
2775 if(s->pict_type != I_TYPE){ | 2775 if(s->pict_type != FF_I_TYPE){ |
2776 s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; | 2776 s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; |
2777 s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; | 2777 s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; |
2778 if(s->pict_type != B_TYPE && s->avctx->me_threshold==0){ | 2778 if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){ |
2779 if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){ | 2779 if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){ |
2780 s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); | 2780 s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); |
2781 } | 2781 } |
2782 } | 2782 } |
2783 | 2783 |
2784 s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); | 2784 s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); |
2785 }else /* if(s->pict_type == I_TYPE) */{ | 2785 }else /* if(s->pict_type == FF_I_TYPE) */{ |
2786 /* I-Frame */ | 2786 /* I-Frame */ |
2787 for(i=0; i<s->mb_stride*s->mb_height; i++) | 2787 for(i=0; i<s->mb_stride*s->mb_height; i++) |
2788 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; | 2788 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; |
2789 | 2789 |
2790 if(!s->fixed_qscale){ | 2790 if(!s->fixed_qscale){ |
2797 } | 2797 } |
2798 s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp; | 2798 s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp; |
2799 s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp; | 2799 s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp; |
2800 emms_c(); | 2800 emms_c(); |
2801 | 2801 |
2802 if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == P_TYPE){ | 2802 if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == FF_P_TYPE){ |
2803 s->pict_type= I_TYPE; | 2803 s->pict_type= FF_I_TYPE; |
2804 for(i=0; i<s->mb_stride*s->mb_height; i++) | 2804 for(i=0; i<s->mb_stride*s->mb_height; i++) |
2805 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; | 2805 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; |
2806 //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum); | 2806 //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum); |
2807 } | 2807 } |
2808 | 2808 |
2809 if(!s->umvplus){ | 2809 if(!s->umvplus){ |
2810 if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) { | 2810 if(s->pict_type==FF_P_TYPE || s->pict_type==FF_S_TYPE) { |
2811 s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER); | 2811 s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER); |
2812 | 2812 |
2813 if(s->flags & CODEC_FLAG_INTERLACED_ME){ | 2813 if(s->flags & CODEC_FLAG_INTERLACED_ME){ |
2814 int a,b; | 2814 int a,b; |
2815 a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select | 2815 a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select |
2827 s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0); | 2827 s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0); |
2828 } | 2828 } |
2829 } | 2829 } |
2830 } | 2830 } |
2831 | 2831 |
2832 if(s->pict_type==B_TYPE){ | 2832 if(s->pict_type==FF_B_TYPE){ |
2833 int a, b; | 2833 int a, b; |
2834 | 2834 |
2835 a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD); | 2835 a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD); |
2836 b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR); | 2836 b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR); |
2837 s->f_code = FFMAX(a, b); | 2837 s->f_code = FFMAX(a, b); |
2861 } | 2861 } |
2862 | 2862 |
2863 if (estimate_qp(s, 0) < 0) | 2863 if (estimate_qp(s, 0) < 0) |
2864 return -1; | 2864 return -1; |
2865 | 2865 |
2866 if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==I_TYPE && !(s->flags & CODEC_FLAG_QSCALE)) | 2866 if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==FF_I_TYPE && !(s->flags & CODEC_FLAG_QSCALE)) |
2867 s->qscale= 3; //reduce clipping problems | 2867 s->qscale= 3; //reduce clipping problems |
2868 | 2868 |
2869 if (s->out_format == FMT_MJPEG) { | 2869 if (s->out_format == FMT_MJPEG) { |
2870 /* for mjpeg, we do include qscale in the matrix */ | 2870 /* for mjpeg, we do include qscale in the matrix */ |
2871 s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0]; | 2871 s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0]; |
2879 s->qscale= 8; | 2879 s->qscale= 8; |
2880 } | 2880 } |
2881 | 2881 |
2882 //FIXME var duplication | 2882 //FIXME var duplication |
2883 s->current_picture_ptr->key_frame= | 2883 s->current_picture_ptr->key_frame= |
2884 s->current_picture.key_frame= s->pict_type == I_TYPE; //FIXME pic_ptr | 2884 s->current_picture.key_frame= s->pict_type == FF_I_TYPE; //FIXME pic_ptr |
2885 s->current_picture_ptr->pict_type= | 2885 s->current_picture_ptr->pict_type= |
2886 s->current_picture.pict_type= s->pict_type; | 2886 s->current_picture.pict_type= s->pict_type; |
2887 | 2887 |
2888 if(s->current_picture.key_frame) | 2888 if(s->current_picture.key_frame) |
2889 s->picture_in_gop_number=0; | 2889 s->picture_in_gop_number=0; |