Revision ce5e49b0 libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
313 313
    /* It might be nicer if the application would keep track of these
314 314
     * but it would require an API change. */
315 315
    memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
316
    s->prev_pict_types[0]= s->dropable ? FF_B_TYPE : s->pict_type;
317
    if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == FF_B_TYPE)
316
    s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type;
317
    if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == AV_PICTURE_TYPE_B)
318 318
        pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
319 319
    pic->owner2 = s;
320 320

  
......
527 527
        s->last_pict_type= s1->pict_type;
528 528
        if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->quality;
529 529

  
530
        if(s1->pict_type!=FF_B_TYPE){
530
        if(s1->pict_type!=AV_PICTURE_TYPE_B){
531 531
            s->last_non_b_pict_type= s1->pict_type;
532 532
        }
533 533
    }
......
1023 1023
    assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
1024 1024

  
1025 1025
    /* mark&release old frames */
1026
    if (s->pict_type != FF_B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
1026
    if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
1027 1027
      if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
1028 1028
          free_frame_buffer(s, s->last_picture_ptr);
1029 1029

  
......
1054 1054
        if (!s->dropable){
1055 1055
            if (s->codec_id == CODEC_ID_H264)
1056 1056
                pic->reference = s->picture_structure;
1057
            else if (s->pict_type != FF_B_TYPE)
1057
            else if (s->pict_type != AV_PICTURE_TYPE_B)
1058 1058
                pic->reference = 3;
1059 1059
        }
1060 1060

  
......
1077 1077
    s->current_picture_ptr->pict_type= s->pict_type;
1078 1078
//    if(s->flags && CODEC_FLAG_QSCALE)
1079 1079
  //      s->current_picture_ptr->quality= s->new_picture_ptr->quality;
1080
    s->current_picture_ptr->key_frame= s->pict_type == FF_I_TYPE;
1080
    s->current_picture_ptr->key_frame= s->pict_type == AV_PICTURE_TYPE_I;
1081 1081

  
1082 1082
    ff_copy_picture(&s->current_picture, s->current_picture_ptr);
1083 1083

  
1084
    if (s->pict_type != FF_B_TYPE) {
1084
    if (s->pict_type != AV_PICTURE_TYPE_B) {
1085 1085
        s->last_picture_ptr= s->next_picture_ptr;
1086 1086
        if(!s->dropable)
1087 1087
            s->next_picture_ptr= s->current_picture_ptr;
......
1093 1093
        s->pict_type, s->dropable);*/
1094 1094

  
1095 1095
    if(s->codec_id != CODEC_ID_H264){
1096
        if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && s->pict_type!=FF_I_TYPE){
1096
        if((s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && s->pict_type!=AV_PICTURE_TYPE_I){
1097 1097
            av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
1098 1098
            /* Allocate a dummy frame */
1099 1099
            i= ff_find_unused_picture(s, 0);
......
1103 1103
            ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0);
1104 1104
            ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 1);
1105 1105
        }
1106
        if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==FF_B_TYPE){
1106
        if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==AV_PICTURE_TYPE_B){
1107 1107
            /* Allocate a dummy frame */
1108 1108
            i= ff_find_unused_picture(s, 0);
1109 1109
            s->next_picture_ptr= &s->picture[i];
......
1117 1117
    if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr);
1118 1118
    if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr);
1119 1119

  
1120
    assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
1120
    assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
1121 1121

  
1122 1122
    if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){
1123 1123
        int i;
......
1185 1185

  
1186 1186
    s->last_pict_type    = s->pict_type;
1187 1187
    s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality;
1188
    if(s->pict_type!=FF_B_TYPE){
1188
    if(s->pict_type!=AV_PICTURE_TYPE_B){
1189 1189
        s->last_non_b_pict_type= s->pict_type;
1190 1190
    }
1191 1191
#if 0
......
1314 1314

  
1315 1315
        av_log(s->avctx,AV_LOG_DEBUG,"New frame, type: ");
1316 1316
        switch (pict->pict_type) {
1317
            case FF_I_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break;
1318
            case FF_P_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break;
1319
            case FF_B_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break;
1320
            case FF_S_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break;
1321
            case FF_SI_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break;
1322
            case FF_SP_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break;
1317
            case AV_PICTURE_TYPE_I: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break;
1318
            case AV_PICTURE_TYPE_P: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break;
1319
            case AV_PICTURE_TYPE_B: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break;
1320
            case AV_PICTURE_TYPE_S: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break;
1321
            case AV_PICTURE_TYPE_SI: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break;
1322
            case AV_PICTURE_TYPE_SP: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break;
1323 1323
        }
1324 1324
        for(y=0; y<s->mb_height; y++){
1325 1325
            for(x=0; x<s->mb_width; x++){
......
1415 1415
                  for(type=0; type<3; type++){
1416 1416
                    int direction = 0;
1417 1417
                    switch (type) {
1418
                      case 0: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_P_FOR)) || (pict->pict_type!=FF_P_TYPE))
1418
                      case 0: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_P_FOR)) || (pict->pict_type!=AV_PICTURE_TYPE_P))
1419 1419
                                continue;
1420 1420
                              direction = 0;
1421 1421
                              break;
1422
                      case 1: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_B_FOR)) || (pict->pict_type!=FF_B_TYPE))
1422
                      case 1: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_B_FOR)) || (pict->pict_type!=AV_PICTURE_TYPE_B))
1423 1423
                                continue;
1424 1424
                              direction = 0;
1425 1425
                              break;
1426
                      case 2: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_B_BACK)) || (pict->pict_type!=FF_B_TYPE))
1426
                      case 2: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_B_BACK)) || (pict->pict_type!=AV_PICTURE_TYPE_B))
1427 1427
                                continue;
1428 1428
                              direction = 1;
1429 1429
                              break;
......
1819 1819
                        ref_picture, pix_op,
1820 1820
                        s->mv[dir][1][0], s->mv[dir][1][1], block_s, mb_y);
1821 1821
        } else {
1822
            if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != FF_B_TYPE && !s->first_field){
1822
            if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){
1823 1823
                ref_picture= s->current_picture_ptr->data;
1824 1824
            }
1825 1825

  
......
1833 1833
        for(i=0; i<2; i++){
1834 1834
            uint8_t ** ref2picture;
1835 1835

  
1836
            if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == FF_B_TYPE || s->first_field){
1836
            if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){
1837 1837
                ref2picture= ref_picture;
1838 1838
            }else{
1839 1839
                ref2picture= s->current_picture_ptr->data;
......
2029 2029
    else if (!is_mpeg12 && (s->h263_pred || s->h263_aic))
2030 2030
        s->mbintra_table[mb_xy]=1;
2031 2031

  
2032
    if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==FF_B_TYPE) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
2032
    if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
2033 2033
        uint8_t *dest_y, *dest_cb, *dest_cr;
2034 2034
        int dct_linesize, dct_offset;
2035 2035
        op_pixels_func (*op_pix)[4];
2036 2036
        qpel_mc_func (*op_qpix)[16];
2037 2037
        const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
2038 2038
        const int uvlinesize= s->current_picture.linesize[1];
2039
        const int readable= s->pict_type != FF_B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
2039
        const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
2040 2040
        const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
2041 2041

  
2042 2042
        /* avoid copy if macroblock skipped in last frame too */
......
2049 2049

  
2050 2050
            if (s->mb_skipped) {
2051 2051
                s->mb_skipped= 0;
2052
                assert(s->pict_type!=FF_I_TYPE);
2052
                assert(s->pict_type!=AV_PICTURE_TYPE_I);
2053 2053

  
2054 2054
                (*mbskip_ptr) ++; /* indicate that this time we skipped it */
2055 2055
                if(*mbskip_ptr >99) *mbskip_ptr= 99;
......
2105 2105
                    }
2106 2106
                }else{
2107 2107
                    op_qpix= s->me.qpel_put;
2108
                    if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){
2108
                    if ((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
2109 2109
                        op_pix = s->dsp.put_pixels_tab;
2110 2110
                    }else{
2111 2111
                        op_pix = s->dsp.put_no_rnd_pixels_tab;
......
2123 2123

  
2124 2124
            /* skip dequant / idct if we are really late ;) */
2125 2125
            if(s->avctx->skip_idct){
2126
                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == FF_B_TYPE)
2127
                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != FF_I_TYPE)
2126
                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
2127
                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
2128 2128
                   || s->avctx->skip_idct >= AVDISCARD_ALL)
2129 2129
                    goto skip_idct;
2130 2130
            }
......
2287 2287
        AVFrame *src;
2288 2288
        int offset[4];
2289 2289

  
2290
        if(s->pict_type==FF_B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
2290
        if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
2291 2291
            src= (AVFrame*)s->current_picture_ptr;
2292 2292
        else if(s->last_picture_ptr)
2293 2293
            src= (AVFrame*)s->last_picture_ptr;
2294 2294
        else
2295 2295
            return;
2296 2296

  
2297
        if(s->pict_type==FF_B_TYPE && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
2297
        if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
2298 2298
            offset[0]=
2299 2299
            offset[1]=
2300 2300
            offset[2]=
......
2330 2330
    s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2331 2331
    s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2332 2332

  
2333
    if(!(s->pict_type==FF_B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
2333
    if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
2334 2334
    {
2335 2335
        if(s->picture_structure==PICT_FRAME){
2336 2336
        s->dest[0] += s->mb_y *   linesize << mb_size;
......
2609 2609

  
2610 2610
void MPV_report_decode_progress(MpegEncContext *s)
2611 2611
{
2612
    if (s->pict_type != FF_B_TYPE && !s->partitioned_frame)
2612
    if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame)
2613 2613
        ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_y, 0);
2614 2614
}

Also available in: Unified diff