Revision ce5e49b0 libavcodec/mpegvideo_enc.c

View differences:

libavcodec/mpegvideo_enc.c
968 968
    assert(scale>=0 && scale <=3);
969 969

  
970 970
//    emms_c();
971
    p_lambda= s->last_lambda_for[FF_P_TYPE]; //s->next_picture_ptr->quality;
972
    b_lambda= s->last_lambda_for[FF_B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
971
    p_lambda= s->last_lambda_for[AV_PICTURE_TYPE_P]; //s->next_picture_ptr->quality;
972
    b_lambda= s->last_lambda_for[AV_PICTURE_TYPE_B]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
973 973
    if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else
974 974
    lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;
975 975

  
......
1024 1024

  
1025 1025
        c->error[0]= c->error[1]= c->error[2]= 0;
1026 1026

  
1027
        input[0].pict_type= FF_I_TYPE;
1027
        input[0].pict_type= AV_PICTURE_TYPE_I;
1028 1028
        input[0].quality= 1 * FF_QP2LAMBDA;
1029 1029
        out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[0]);
1030 1030
//        rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
......
1032 1032
        for(i=0; i<s->max_b_frames+1; i++){
1033 1033
            int is_p= i % (j+1) == j || i==s->max_b_frames;
1034 1034

  
1035
            input[i+1].pict_type= is_p ? FF_P_TYPE : FF_B_TYPE;
1035
            input[i+1].pict_type= is_p ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_B;
1036 1036
            input[i+1].quality= is_p ? p_lambda : b_lambda;
1037 1037
            out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]);
1038 1038
            rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3);
......
1074 1074
    if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
1075 1075
        if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
1076 1076
            s->reordered_input_picture[0]= s->input_picture[0];
1077
            s->reordered_input_picture[0]->pict_type= FF_I_TYPE;
1077
            s->reordered_input_picture[0]->pict_type= AV_PICTURE_TYPE_I;
1078 1078
            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
1079 1079
        }else{
1080 1080
            int b_frames;
......
1109 1109
                    if(pict_num >= s->rc_context.num_entries)
1110 1110
                        break;
1111 1111
                    if(!s->input_picture[i]){
1112
                        s->rc_context.entry[pict_num-1].new_pict_type = FF_P_TYPE;
1112
                        s->rc_context.entry[pict_num-1].new_pict_type = AV_PICTURE_TYPE_P;
1113 1113
                        break;
1114 1114
                    }
1115 1115

  
......
1153 1153

  
1154 1154
            for(i= b_frames - 1; i>=0; i--){
1155 1155
                int type= s->input_picture[i]->pict_type;
1156
                if(type && type != FF_B_TYPE)
1156
                if(type && type != AV_PICTURE_TYPE_B)
1157 1157
                    b_frames= i;
1158 1158
            }
1159
            if(s->input_picture[b_frames]->pict_type == FF_B_TYPE && b_frames == s->max_b_frames){
1159
            if(s->input_picture[b_frames]->pict_type == AV_PICTURE_TYPE_B && b_frames == s->max_b_frames){
1160 1160
                av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n");
1161 1161
            }
1162 1162

  
......
1166 1166
              }else{
1167 1167
                if(s->flags & CODEC_FLAG_CLOSED_GOP)
1168 1168
                    b_frames=0;
1169
                s->input_picture[b_frames]->pict_type= FF_I_TYPE;
1169
                s->input_picture[b_frames]->pict_type= AV_PICTURE_TYPE_I;
1170 1170
              }
1171 1171
            }
1172 1172

  
1173 1173
            if(   (s->flags & CODEC_FLAG_CLOSED_GOP)
1174 1174
               && b_frames
1175
               && s->input_picture[b_frames]->pict_type== FF_I_TYPE)
1175
               && s->input_picture[b_frames]->pict_type== AV_PICTURE_TYPE_I)
1176 1176
                b_frames--;
1177 1177

  
1178 1178
            s->reordered_input_picture[0]= s->input_picture[b_frames];
1179
            if(s->reordered_input_picture[0]->pict_type != FF_I_TYPE)
1180
                s->reordered_input_picture[0]->pict_type= FF_P_TYPE;
1179
            if(s->reordered_input_picture[0]->pict_type != AV_PICTURE_TYPE_I)
1180
                s->reordered_input_picture[0]->pict_type= AV_PICTURE_TYPE_P;
1181 1181
            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
1182 1182
            for(i=0; i<b_frames; i++){
1183 1183
                s->reordered_input_picture[i+1]= s->input_picture[i];
1184
                s->reordered_input_picture[i+1]->pict_type= FF_B_TYPE;
1184
                s->reordered_input_picture[i+1]->pict_type= AV_PICTURE_TYPE_B;
1185 1185
                s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++;
1186 1186
            }
1187 1187
        }
1188 1188
    }
1189 1189
no_output_pic:
1190 1190
    if(s->reordered_input_picture[0]){
1191
        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=FF_B_TYPE ? 3 : 0;
1191
        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=AV_PICTURE_TYPE_B ? 3 : 0;
1192 1192

  
1193 1193
        ff_copy_picture(&s->new_picture, s->reordered_input_picture[0]);
1194 1194

  
......
1296 1296
                        s->lambda_table[i]= FFMAX(s->lambda_table[i]+1, s->lambda_table[i]*(s->qscale+1) / s->qscale);
1297 1297
                }
1298 1298
                s->mb_skipped = 0;        //done in MPV_frame_start()
1299
                if(s->pict_type==FF_P_TYPE){ //done in encode_picture() so we must undo it
1299
                if(s->pict_type==AV_PICTURE_TYPE_P){ //done in encode_picture() so we must undo it
1300 1300
                    if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
1301 1301
                        s->no_rounding ^= 1;
1302 1302
                }
1303
                if(s->pict_type!=FF_B_TYPE){
1303
                if(s->pict_type!=AV_PICTURE_TYPE_B){
1304 1304
                    s->time_base= s->last_time_base;
1305 1305
                    s->last_non_b_time= s->time - s->pp_time;
1306 1306
                }
......
1528 1528

  
1529 1529
                if(s->codec_id==CODEC_ID_MPEG4){
1530 1530
                    if(!s->mb_intra){
1531
                        if(s->pict_type == FF_B_TYPE){
1531
                        if(s->pict_type == AV_PICTURE_TYPE_B){
1532 1532
                            if(s->dquant&1 || s->mv_dir&MV_DIRECT)
1533 1533
                                s->dquant= 0;
1534 1534
                        }
......
1605 1605
        dest_cb = s->dest[1];
1606 1606
        dest_cr = s->dest[2];
1607 1607

  
1608
        if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){
1608
        if ((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
1609 1609
            op_pix = s->dsp.put_pixels_tab;
1610 1610
            op_qpix= s->dsp.put_qpel_pixels_tab;
1611 1611
        }else{
......
1995 1995
            s->block_index[3]+=2;
1996 1996

  
1997 1997
            /* compute motion vector & mb_type and store in context */
1998
            if(s->pict_type==FF_B_TYPE)
1998
            if(s->pict_type==AV_PICTURE_TYPE_B)
1999 1999
                ff_estimate_b_frame_motion(s, s->mb_x, s->mb_y);
2000 2000
            else
2001 2001
                ff_estimate_p_frame_motion(s, s->mb_x, s->mb_y);
......
2393 2393
                        s->mv[1][0][0] = best_s.mv[1][0][0];
2394 2394
                        s->mv[1][0][1] = best_s.mv[1][0][1];
2395 2395

  
2396
                        qpi = s->pict_type == FF_B_TYPE ? 2 : 0;
2396
                        qpi = s->pict_type == AV_PICTURE_TYPE_B ? 2 : 0;
2397 2397
                        for(; qpi<4; qpi++){
2398 2398
                            int dquant= dquant_tab[qpi];
2399 2399
                            qp= last_qp + dquant;
......
2495 2495
                s->last_bits= put_bits_count(&s->pb);
2496 2496

  
2497 2497
                if (CONFIG_H263_ENCODER &&
2498
                    s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
2498
                    s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
2499 2499
                    ff_h263_update_motion_val(s);
2500 2500

  
2501 2501
                if(next_block==0){ //FIXME 16 vs linesize16
......
2622 2622
                s->last_mv_dir = s->mv_dir;
2623 2623

  
2624 2624
                if (CONFIG_H263_ENCODER &&
2625
                    s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
2625
                    s->out_format == FMT_H263 && s->pict_type!=AV_PICTURE_TYPE_B)
2626 2626
                    ff_h263_update_motion_val(s);
2627 2627

  
2628 2628
                MPV_decode_mb(s, s->block);
......
2660 2660
    }
2661 2661

  
2662 2662
    //not beautiful here but we must write it before flushing so it has to be here
2663
    if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)
2663
    if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == AV_PICTURE_TYPE_I)
2664 2664
        msmpeg4_encode_ext_header(s);
2665 2665

  
2666 2666
    write_slice_end(s);
......
2758 2758
    assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
2759 2759
    s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
2760 2760

  
2761
    if(s->pict_type==FF_B_TYPE){
2761
    if(s->pict_type==AV_PICTURE_TYPE_B){
2762 2762
        s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
2763 2763
        assert(s->pb_time > 0 && s->pb_time < s->pp_time);
2764 2764
    }else{
......
2791 2791

  
2792 2792
//    s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME rate distortion
2793 2793

  
2794
    if(s->pict_type==FF_I_TYPE){
2794
    if(s->pict_type==AV_PICTURE_TYPE_I){
2795 2795
        if(s->msmpeg4_version >= 3) s->no_rounding=1;
2796 2796
        else                        s->no_rounding=0;
2797
    }else if(s->pict_type!=FF_B_TYPE){
2797
    }else if(s->pict_type!=AV_PICTURE_TYPE_B){
2798 2798
        if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
2799 2799
            s->no_rounding ^= 1;
2800 2800
    }
......
2804 2804
            return -1;
2805 2805
        ff_get_2pass_fcode(s);
2806 2806
    }else if(!(s->flags & CODEC_FLAG_QSCALE)){
2807
        if(s->pict_type==FF_B_TYPE)
2807
        if(s->pict_type==AV_PICTURE_TYPE_B)
2808 2808
            s->lambda= s->last_lambda_for[s->pict_type];
2809 2809
        else
2810 2810
            s->lambda= s->last_lambda_for[s->last_non_b_pict_type];
......
2820 2820
        return -1;
2821 2821

  
2822 2822
    /* Estimate motion for every MB */
2823
    if(s->pict_type != FF_I_TYPE){
2823
    if(s->pict_type != AV_PICTURE_TYPE_I){
2824 2824
        s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
2825 2825
        s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
2826
        if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){
2827
            if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){
2826
        if(s->pict_type != AV_PICTURE_TYPE_B && s->avctx->me_threshold==0){
2827
            if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){
2828 2828
                s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
2829 2829
            }
2830 2830
        }
2831 2831

  
2832 2832
        s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
2833
    }else /* if(s->pict_type == FF_I_TYPE) */{
2833
    }else /* if(s->pict_type == AV_PICTURE_TYPE_I) */{
2834 2834
        /* I-Frame */
2835 2835
        for(i=0; i<s->mb_stride*s->mb_height; i++)
2836 2836
            s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
......
2847 2847
    s->current_picture.   mb_var_sum= s->current_picture_ptr->   mb_var_sum= s->me.   mb_var_sum_temp;
2848 2848
    emms_c();
2849 2849

  
2850
    if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == FF_P_TYPE){
2851
        s->pict_type= FF_I_TYPE;
2850
    if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){
2851
        s->pict_type= AV_PICTURE_TYPE_I;
2852 2852
        for(i=0; i<s->mb_stride*s->mb_height; i++)
2853 2853
            s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
2854 2854
//printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
2855 2855
    }
2856 2856

  
2857 2857
    if(!s->umvplus){
2858
        if(s->pict_type==FF_P_TYPE || s->pict_type==FF_S_TYPE) {
2858
        if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
2859 2859
            s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
2860 2860

  
2861 2861
            if(s->flags & CODEC_FLAG_INTERLACED_ME){
......
2877 2877
            }
2878 2878
        }
2879 2879

  
2880
        if(s->pict_type==FF_B_TYPE){
2880
        if(s->pict_type==AV_PICTURE_TYPE_B){
2881 2881
            int a, b;
2882 2882

  
2883 2883
            a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
......
2911 2911
    if (estimate_qp(s, 0) < 0)
2912 2912
        return -1;
2913 2913

  
2914
    if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==FF_I_TYPE && !(s->flags & CODEC_FLAG_QSCALE))
2914
    if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==AV_PICTURE_TYPE_I && !(s->flags & CODEC_FLAG_QSCALE))
2915 2915
        s->qscale= 3; //reduce clipping problems
2916 2916

  
2917 2917
    if (s->out_format == FMT_MJPEG) {
......
2931 2931

  
2932 2932
    //FIXME var duplication
2933 2933
    s->current_picture_ptr->key_frame=
2934
    s->current_picture.key_frame= s->pict_type == FF_I_TYPE; //FIXME pic_ptr
2934
    s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I; //FIXME pic_ptr
2935 2935
    s->current_picture_ptr->pict_type=
2936 2936
    s->current_picture.pict_type= s->pict_type;
2937 2937

  

Also available in: Unified diff