Revision 49fb20cb libavcodec/mpegvideo_enc.c

View differences:

libavcodec/mpegvideo_enc.c
518 518
        s->mjpeg_hsample[0] = 2;
519 519
        s->mjpeg_hsample[1] = 2>>chroma_h_shift;
520 520
        s->mjpeg_hsample[2] = 2>>chroma_h_shift;
521
        if (!(ENABLE_MJPEG_ENCODER || ENABLE_LJPEG_ENCODER)
521
        if (!(CONFIG_MJPEG_ENCODER || CONFIG_LJPEG_ENCODER)
522 522
            || ff_mjpeg_encode_init(s) < 0)
523 523
            return -1;
524 524
        avctx->delay=0;
525 525
        s->low_delay=1;
526 526
        break;
527 527
    case CODEC_ID_H261:
528
        if (!ENABLE_H261_ENCODER)  return -1;
528
        if (!CONFIG_H261_ENCODER)  return -1;
529 529
        if (ff_h261_get_picture_format(s->width, s->height) < 0) {
530 530
            av_log(avctx, AV_LOG_ERROR, "The specified picture size of %dx%d is not valid for the H.261 codec.\nValid sizes are 176x144, 352x288\n", s->width, s->height);
531 531
            return -1;
......
535 535
        s->low_delay=1;
536 536
        break;
537 537
    case CODEC_ID_H263:
538
        if (!ENABLE_H263_ENCODER)  return -1;
538
        if (!CONFIG_H263_ENCODER)  return -1;
539 539
        if (h263_get_picture_format(s->width, s->height) == 7) {
540 540
            av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height);
541 541
            return -1;
......
661 661
    if(avctx->trellis)
662 662
        s->dct_quantize = dct_quantize_trellis_c;
663 663

  
664
    if((ENABLE_H263P_ENCODER || ENABLE_RV20_ENCODER) && s->modified_quant)
664
    if((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
665 665
        s->chroma_qscale_table= ff_h263_chroma_qscale_table;
666 666
    s->progressive_frame=
667 667
    s->progressive_sequence= !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME|CODEC_FLAG_ALT_SCAN));
......
670 670
    ff_set_cmp(&s->dsp, s->dsp.ildct_cmp, s->avctx->ildct_cmp);
671 671
    ff_set_cmp(&s->dsp, s->dsp.frame_skip_cmp, s->avctx->frame_skip_cmp);
672 672

  
673
    if (ENABLE_H261_ENCODER && s->out_format == FMT_H261)
673
    if (CONFIG_H261_ENCODER && s->out_format == FMT_H261)
674 674
        ff_h261_encode_init(s);
675
    if (ENABLE_ANY_H263_ENCODER && s->out_format == FMT_H263)
675
    if (CONFIG_ANY_H263_ENCODER && s->out_format == FMT_H263)
676 676
        h263_encode_init(s);
677
    if (ENABLE_MSMPEG4_ENCODER && s->msmpeg4_version)
677
    if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version)
678 678
        ff_msmpeg4_encode_init(s);
679
    if ((ENABLE_MPEG1VIDEO_ENCODER || ENABLE_MPEG2VIDEO_ENCODER)
679
    if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
680 680
        && s->out_format == FMT_MPEG1)
681 681
        ff_mpeg1_encode_init(s);
682 682

  
683 683
    /* init q matrix */
684 684
    for(i=0;i<64;i++) {
685 685
        int j= s->dsp.idct_permutation[i];
686
        if(ENABLE_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
686
        if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
687 687
            s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
688 688
            s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
689 689
        }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
......
722 722
    ff_rate_control_uninit(s);
723 723

  
724 724
    MPV_common_end(s);
725
    if ((ENABLE_MJPEG_ENCODER || ENABLE_LJPEG_ENCODER) && s->out_format == FMT_MJPEG)
725
    if ((CONFIG_MJPEG_ENCODER || CONFIG_LJPEG_ENCODER) && s->out_format == FMT_MJPEG)
726 726
        ff_mjpeg_encode_close(s);
727 727

  
728 728
    av_freep(&avctx->extradata);
......
1226 1226

  
1227 1227
        MPV_frame_end(s);
1228 1228

  
1229
        if (ENABLE_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
1229
        if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
1230 1230
            ff_mjpeg_encode_picture_trailer(s);
1231 1231

  
1232 1232
        if(avctx->rc_buffer_size){
......
1687 1687
    switch(s->codec_id){ //FIXME funct ptr could be slightly faster
1688 1688
    case CODEC_ID_MPEG1VIDEO:
1689 1689
    case CODEC_ID_MPEG2VIDEO:
1690
        if (ENABLE_MPEG1VIDEO_ENCODER || ENABLE_MPEG2VIDEO_ENCODER)
1690
        if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
1691 1691
            mpeg1_encode_mb(s, s->block, motion_x, motion_y);
1692 1692
        break;
1693 1693
    case CODEC_ID_MPEG4:
1694
        if (ENABLE_MPEG4_ENCODER)
1694
        if (CONFIG_MPEG4_ENCODER)
1695 1695
            mpeg4_encode_mb(s, s->block, motion_x, motion_y);
1696 1696
        break;
1697 1697
    case CODEC_ID_MSMPEG4V2:
1698 1698
    case CODEC_ID_MSMPEG4V3:
1699 1699
    case CODEC_ID_WMV1:
1700
        if (ENABLE_MSMPEG4_ENCODER)
1700
        if (CONFIG_MSMPEG4_ENCODER)
1701 1701
            msmpeg4_encode_mb(s, s->block, motion_x, motion_y);
1702 1702
        break;
1703 1703
    case CODEC_ID_WMV2:
1704
        if (ENABLE_WMV2_ENCODER)
1704
        if (CONFIG_WMV2_ENCODER)
1705 1705
            ff_wmv2_encode_mb(s, s->block, motion_x, motion_y);
1706 1706
        break;
1707 1707
    case CODEC_ID_H261:
1708
        if (ENABLE_H261_ENCODER)
1708
        if (CONFIG_H261_ENCODER)
1709 1709
            ff_h261_encode_mb(s, s->block, motion_x, motion_y);
1710 1710
        break;
1711 1711
    case CODEC_ID_H263:
......
1713 1713
    case CODEC_ID_FLV1:
1714 1714
    case CODEC_ID_RV10:
1715 1715
    case CODEC_ID_RV20:
1716
        if (ENABLE_H263_ENCODER || ENABLE_H263P_ENCODER ||
1717
            ENABLE_FLV_ENCODER  || ENABLE_RV10_ENCODER  || ENABLE_RV20_ENCODER)
1716
        if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER ||
1717
            CONFIG_FLV_ENCODER  || CONFIG_RV10_ENCODER  || CONFIG_RV20_ENCODER)
1718 1718
            h263_encode_mb(s, s->block, motion_x, motion_y);
1719 1719
        break;
1720 1720
    case CODEC_ID_MJPEG:
1721
        if (ENABLE_MJPEG_ENCODER)
1721
        if (CONFIG_MJPEG_ENCODER)
1722 1722
            ff_mjpeg_encode_mb(s, s->block);
1723 1723
        break;
1724 1724
    default:
......
1965 1965
}
1966 1966

  
1967 1967
static void write_slice_end(MpegEncContext *s){
1968
    if(ENABLE_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4){
1968
    if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4){
1969 1969
        if(s->partitioned_frame){
1970 1970
            ff_mpeg4_merge_partitions(s);
1971 1971
        }
1972 1972

  
1973 1973
        ff_mpeg4_stuffing(&s->pb);
1974
    }else if(ENABLE_MJPEG_ENCODER && s->out_format == FMT_MJPEG){
1974
    }else if(CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG){
1975 1975
        ff_mjpeg_encode_stuffing(&s->pb);
1976 1976
    }
1977 1977

  
......
2028 2028
    case CODEC_ID_H263:
2029 2029
    case CODEC_ID_H263P:
2030 2030
    case CODEC_ID_FLV1:
2031
        if (ENABLE_H263_ENCODER || ENABLE_H263P_ENCODER || ENABLE_FLV_ENCODER)
2031
        if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER || CONFIG_FLV_ENCODER)
2032 2032
            s->gob_index = ff_h263_get_gob_height(s);
2033 2033
        break;
2034 2034
    case CODEC_ID_MPEG4:
2035
        if(ENABLE_MPEG4_ENCODER && s->partitioned_frame)
2035
        if(CONFIG_MPEG4_ENCODER && s->partitioned_frame)
2036 2036
            ff_mpeg4_init_partitions(s);
2037 2037
        break;
2038 2038
    }
......
2072 2072
            s->mb_y = mb_y;  // moved into loop, can get changed by H.261
2073 2073
            ff_update_block_index(s);
2074 2074

  
2075
            if(ENABLE_H261_ENCODER && s->codec_id == CODEC_ID_H261){
2075
            if(CONFIG_H261_ENCODER && s->codec_id == CODEC_ID_H261){
2076 2076
                ff_h261_reorder_mb_index(s);
2077 2077
                xy= s->mb_y*s->mb_stride + s->mb_x;
2078 2078
                mb_type= s->mb_type[xy];
......
2105 2105
                    if(s->start_mb_y != mb_y || mb_x!=0){
2106 2106
                        write_slice_end(s);
2107 2107

  
2108
                        if(ENABLE_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
2108
                        if(CONFIG_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
2109 2109
                            ff_mpeg4_init_partitions(s);
2110 2110
                        }
2111 2111
                    }
......
2132 2132

  
2133 2133
                    switch(s->codec_id){
2134 2134
                    case CODEC_ID_MPEG4:
2135
                        if (ENABLE_MPEG4_ENCODER) {
2135
                        if (CONFIG_MPEG4_ENCODER) {
2136 2136
                            ff_mpeg4_encode_video_packet_header(s);
2137 2137
                            ff_mpeg4_clean_buffers(s);
2138 2138
                        }
2139 2139
                    break;
2140 2140
                    case CODEC_ID_MPEG1VIDEO:
2141 2141
                    case CODEC_ID_MPEG2VIDEO:
2142
                        if (ENABLE_MPEG1VIDEO_ENCODER || ENABLE_MPEG2VIDEO_ENCODER) {
2142
                        if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) {
2143 2143
                            ff_mpeg1_encode_slice_header(s);
2144 2144
                            ff_mpeg1_clean_buffers(s);
2145 2145
                        }
2146 2146
                    break;
2147 2147
                    case CODEC_ID_H263:
2148 2148
                    case CODEC_ID_H263P:
2149
                        if (ENABLE_H263_ENCODER || ENABLE_H263P_ENCODER)
2149
                        if (CONFIG_H263_ENCODER || CONFIG_H263P_ENCODER)
2150 2150
                            h263_encode_gob_header(s, mb_y);
2151 2151
                    break;
2152 2152
                    }
......
2355 2355
                        }
2356 2356
                    }
2357 2357
                }
2358
                if(ENABLE_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
2358
                if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){
2359 2359
                    int mx= s->b_direct_mv_table[xy][0];
2360 2360
                    int my= s->b_direct_mv_table[xy][1];
2361 2361

  
......
2366 2366
                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
2367 2367
                                 &dmin, &next_block, mx, my);
2368 2368
                }
2369
                if(ENABLE_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
2369
                if(CONFIG_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){
2370 2370
                    backup_s.dquant = 0;
2371 2371
                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
2372 2372
                    s->mb_intra= 0;
......
2381 2381
                    if(coded){
2382 2382
                        int mx,my;
2383 2383
                        memcpy(s->mv, best_s.mv, sizeof(s->mv));
2384
                        if(ENABLE_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
2384
                        if(CONFIG_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){
2385 2385
                            mx=my=0; //FIXME find the one we actually used
2386 2386
                            ff_mpeg4_set_direct_mv(s, mx, my);
2387 2387
                        }else if(best_s.mv_dir&MV_DIR_BACKWARD){
......
2429 2429
                }
2430 2430
                s->last_bits= put_bits_count(&s->pb);
2431 2431

  
2432
                if (ENABLE_ANY_H263_ENCODER &&
2432
                if (CONFIG_ANY_H263_ENCODER &&
2433 2433
                    s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
2434 2434
                    ff_h263_update_motion_val(s);
2435 2435

  
......
2479 2479
                    }
2480 2480
                    break;
2481 2481
                case CANDIDATE_MB_TYPE_DIRECT:
2482
                    if (ENABLE_MPEG4_ENCODER) {
2482
                    if (CONFIG_MPEG4_ENCODER) {
2483 2483
                        s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
2484 2484
                        s->mb_intra= 0;
2485 2485
                        motion_x=s->b_direct_mv_table[xy][0];
......
2488 2488
                    }
2489 2489
                    break;
2490 2490
                case CANDIDATE_MB_TYPE_DIRECT0:
2491
                    if (ENABLE_MPEG4_ENCODER) {
2491
                    if (CONFIG_MPEG4_ENCODER) {
2492 2492
                        s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD|MV_DIRECT;
2493 2493
                        s->mb_intra= 0;
2494 2494
                        ff_mpeg4_set_direct_mv(s, 0, 0);
......
2556 2556
                // RAL: Update last macroblock type
2557 2557
                s->last_mv_dir = s->mv_dir;
2558 2558

  
2559
                if (ENABLE_ANY_H263_ENCODER &&
2559
                if (CONFIG_ANY_H263_ENCODER &&
2560 2560
                    s->out_format == FMT_H263 && s->pict_type!=FF_B_TYPE)
2561 2561
                    ff_h263_update_motion_val(s);
2562 2562

  
......
2587 2587
                    s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize);
2588 2588
            }
2589 2589
            if(s->loop_filter){
2590
                if(ENABLE_ANY_H263_ENCODER && s->out_format == FMT_H263)
2590
                if(CONFIG_ANY_H263_ENCODER && s->out_format == FMT_H263)
2591 2591
                    ff_h263_loop_filter(s);
2592 2592
            }
2593 2593
//printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb));
......
2595 2595
    }
2596 2596

  
2597 2597
    //not beautiful here but we must write it before flushing so it has to be here
2598
    if (ENABLE_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)
2598
    if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == FF_I_TYPE)
2599 2599
        msmpeg4_encode_ext_header(s);
2600 2600

  
2601 2601
    write_slice_end(s);
......
2666 2666
    if(s->adaptive_quant){
2667 2667
        switch(s->codec_id){
2668 2668
        case CODEC_ID_MPEG4:
2669
            if (ENABLE_MPEG4_ENCODER)
2669
            if (CONFIG_MPEG4_ENCODER)
2670 2670
                ff_clean_mpeg4_qscales(s);
2671 2671
            break;
2672 2672
        case CODEC_ID_H263:
2673 2673
        case CODEC_ID_H263P:
2674 2674
        case CODEC_ID_FLV1:
2675
            if (ENABLE_H263_ENCODER||ENABLE_H263P_ENCODER||ENABLE_FLV_ENCODER)
2675
            if (CONFIG_H263_ENCODER||CONFIG_H263P_ENCODER||CONFIG_FLV_ENCODER)
2676 2676
                ff_clean_h263_qscales(s);
2677 2677
            break;
2678 2678
        }
......
2716 2716
    // RAL: Condition added for MPEG1VIDEO
2717 2717
    if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4))
2718 2718
        set_frame_distances(s);
2719
    if(ENABLE_MPEG4_ENCODER && s->codec_id == CODEC_ID_MPEG4)
2719
    if(CONFIG_MPEG4_ENCODER && s->codec_id == CODEC_ID_MPEG4)
2720 2720
        ff_set_mpeg4_time(s);
2721 2721

  
2722 2722
    s->me.scene_change_score=0;
......
2871 2871
    s->last_bits= put_bits_count(&s->pb);
2872 2872
    switch(s->out_format) {
2873 2873
    case FMT_MJPEG:
2874
        if (ENABLE_MJPEG_ENCODER)
2874
        if (CONFIG_MJPEG_ENCODER)
2875 2875
            ff_mjpeg_encode_picture_header(s);
2876 2876
        break;
2877 2877
    case FMT_H261:
2878
        if (ENABLE_H261_ENCODER)
2878
        if (CONFIG_H261_ENCODER)
2879 2879
            ff_h261_encode_picture_header(s, picture_number);
2880 2880
        break;
2881 2881
    case FMT_H263:
2882
        if (ENABLE_WMV2_ENCODER && s->codec_id == CODEC_ID_WMV2)
2882
        if (CONFIG_WMV2_ENCODER && s->codec_id == CODEC_ID_WMV2)
2883 2883
            ff_wmv2_encode_picture_header(s, picture_number);
2884
        else if (ENABLE_MSMPEG4_ENCODER && s->h263_msmpeg4)
2884
        else if (CONFIG_MSMPEG4_ENCODER && s->h263_msmpeg4)
2885 2885
            msmpeg4_encode_picture_header(s, picture_number);
2886
        else if (ENABLE_MPEG4_ENCODER && s->h263_pred)
2886
        else if (CONFIG_MPEG4_ENCODER && s->h263_pred)
2887 2887
            mpeg4_encode_picture_header(s, picture_number);
2888
        else if (ENABLE_RV10_ENCODER && s->codec_id == CODEC_ID_RV10)
2888
        else if (CONFIG_RV10_ENCODER && s->codec_id == CODEC_ID_RV10)
2889 2889
            rv10_encode_picture_header(s, picture_number);
2890
        else if (ENABLE_RV20_ENCODER && s->codec_id == CODEC_ID_RV20)
2890
        else if (CONFIG_RV20_ENCODER && s->codec_id == CODEC_ID_RV20)
2891 2891
            rv20_encode_picture_header(s, picture_number);
2892
        else if (ENABLE_FLV_ENCODER && s->codec_id == CODEC_ID_FLV1)
2892
        else if (CONFIG_FLV_ENCODER && s->codec_id == CODEC_ID_FLV1)
2893 2893
            ff_flv_encode_picture_header(s, picture_number);
2894
        else if (ENABLE_ANY_H263_ENCODER)
2894
        else if (CONFIG_ANY_H263_ENCODER)
2895 2895
            h263_encode_picture_header(s, picture_number);
2896 2896
        break;
2897 2897
    case FMT_MPEG1:
2898
        if (ENABLE_MPEG1VIDEO_ENCODER || ENABLE_MPEG2VIDEO_ENCODER)
2898
        if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
2899 2899
            mpeg1_encode_picture_header(s, picture_number);
2900 2900
        break;
2901 2901
    case FMT_H264:

Also available in: Unified diff