| 2757 | } |
| 2758 | |
| 2759 | static int encode_picture(MpegEncContext *s, int picture_number) |
| 2760 | { |
| 2761 | int i; |
| 2762 | int bits; |
| 2763 | |
| 2764 | s->picture_number = picture_number; |
| 2765 | |
| 2766 | /* Reset the average MB variance */ |
| 2767 | s->me.mb_var_sum_temp = |
| 2768 | s->me.mc_mb_var_sum_temp = 0; |
| 2769 | |
| 2770 | /* we need to initialize some time vars before we can encode b-frames */ |
| 2771 | // RAL: Condition added for MPEG1VIDEO |
| 2772 | if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4)) |
| 2773 | set_frame_distances(s); |
| 2774 | if(CONFIG_MPEG4_ENCODER && s->codec_id == CODEC_ID_MPEG4) |
| 2775 | ff_set_mpeg4_time(s); |
| 2776 | |
| 2777 | s->me.scene_change_score=0; |
| 2778 | |
| 2779 | // s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME rate distortion |
| 2780 | |
| 2781 | if(s->pict_type==FF_I_TYPE){ |
| 2782 | if(s->msmpeg4_version >= 3) s->no_rounding=1; |
| 2783 | else s->no_rounding=0; |
| 2784 | }else if(s->pict_type!=FF_B_TYPE){ |
| 2785 | if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4) |
| 2786 | s->no_rounding ^= 1; |
| 2787 | } |
| 2788 | |
| 2789 | if(s->flags & CODEC_FLAG_PASS2){ |
| 2790 | if (estimate_qp(s,1) < 0) |
| 2791 | return -1; |
| 2792 | ff_get_2pass_fcode(s); |
| 2793 | }else if(!(s->flags & CODEC_FLAG_QSCALE)){ |
| 2794 | if(s->pict_type==FF_B_TYPE) |
| 2795 | s->lambda= s->last_lambda_for[s->pict_type]; |
| 2796 | else |
| 2797 | s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; |
| 2798 | update_qscale(s); |
| 2799 | } |
| 2800 | |
| 2801 | s->mb_intra=0; //for the rate distortion & bit compare functions |
| 2802 | for(i=1; i<s->avctx->thread_count; i++){ |
| 2803 | ff_update_duplicate_context(s->thread_context[i], s); |
| 2804 | } |
| 2805 | |
| 2806 | if(ff_init_me(s)<0) |
| 2807 | return -1; |
| 2808 | |
| 2809 | /* Estimate motion for every MB */ |
| 2810 | if(s->pict_type != FF_I_TYPE){ |
| 2811 | s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; |
| 2812 | s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; |
| 2813 | if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){ |
| 2814 | if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){ |
| 2815 | s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*)); |
| 2816 | } |
no test coverage detected