Ticket #36606: patch-ffmpeg-0.11.diff

File patch-ffmpeg-0.11.diff, 12.3 KB (added by ak.ml@…, 12 years ago)
  • encode/encode_lavc.c

    Fix build with ffmpeg 0.11.
    https://bugs.gentoo.org/show_bug.cgi?id=419551
    Author: Brennan Shacklett
    
    old new struct tclavcprivatedata_ { 
    114114
    115115    AVFrame ff_venc_frame;
    116116    AVCodecContext ff_vcontext;
     117    AVDictionary ** ff_opts;
    117118
    118119    AVCodec *ff_vcodec;
    119120
    static void tc_lavc_dispatch_settings(TC 
    10361037    SET_FLAG(pd, mv0);
    10371038    SET_FLAG(pd, cbp);
    10381039    SET_FLAG(pd, qpel);
    1039     SET_FLAG(pd, alt);
    1040     SET_FLAG(pd, vdpart);
    10411040    SET_FLAG(pd, naq);
    10421041    SET_FLAG(pd, ilme);
    10431042    SET_FLAG(pd, ildct);
    10441043    SET_FLAG(pd, aic);
    1045     SET_FLAG(pd, aiv);
    1046     SET_FLAG(pd, umv);
    10471044    SET_FLAG(pd, psnr);
    10481045    SET_FLAG(pd, trell);
    10491046    SET_FLAG(pd, gray);
    static void tc_lavc_dispatch_settings(TC 
    10641061        pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_DCT;
    10651062        pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
    10661063    }
     1064    if (pd->confdata.flags.alt) {
     1065        av_dict_set(pd->ff_opts, "alternate_scan", "1", 0);
     1066    }
     1067    if (pd->confdata.flags.vdpart) {
     1068        av_dict_set(pd->ff_opts, "data_partitioning", "1", 0);
     1069    }
     1070    if (pd->confdata.flags.umv) {
     1071        av_dict_set(pd->ff_opts, "umv", "1", 0);
     1072    }
     1073    if (pd->confdata.flags.aiv) {
     1074        av_dict_set(pd->ff_opts, "aiv", "1", 0);
     1075    }
    10671076}
    10681077
    10691078#undef SET_FLAG
    static int tc_lavc_read_config(TCLavcPri 
    11841193        { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
    11851194        { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
    11861195        { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
    1187         { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN },
     1196        { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, 1 },
    11881197        { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
    11891198        { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_DCT },
    11901199        { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_NORMALIZE_AQP },
    1191         { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART },
     1200        { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, 1 },
    11921201#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    11931202        { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC },
    11941203#else       
    11951204        { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED },
    11961205#endif
    1197         { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIV },
    1198         { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV },
     1206        { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, 1 },
     1207        { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, 1 },
    11991208        { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR },
    12001209#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    12011210        { "trell", PAUX(flags.trell), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT },
    static int tc_lavc_configure(TCModuleIns 
    13871396                    pd->confdata.thread_count,
    13881397                    (pd->confdata.thread_count > 1) ?"s" :"");
    13891398    }
    1390     avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
     1399    pd->ff_vcontext.thread_count = pd->confdata.thread_count;
    13911400
    13921401    pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
    13931402    if (pd->ff_vcodec == NULL) {
    static int tc_lavc_configure(TCModuleIns 
    13971406    }
    13981407
    13991408    TC_LOCK_LIBAVCODEC;
    1400     ret = avcodec_open(&pd->ff_vcontext, pd->ff_vcodec);
     1409    ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, pd->ff_opts);
    14011410    TC_UNLOCK_LIBAVCODEC;
    14021411
    14031412    if (ret < 0) {
    1404         tc_log_error(MOD_NAME, "avcodec_open() failed");
     1413        tc_log_error(MOD_NAME, "avcodec_open2() failed");
    14051414        goto failed;
    14061415    }
    14071416    /* finally, pass up the extradata, if any */
  • export/export_ffmpeg.c

    old new static uint8_t *img_buffer = 
    122122static AVFrame             *lavc_convert_frame = NULL;
    123123
    124124static AVCodec             *lavc_venc_codec = NULL;
     125static AVDictionary        **lavc_venc_opts = NULL;
    125126static AVFrame             *lavc_venc_frame = NULL;
    126127static AVCodecContext      *lavc_venc_context;
    127128static avi_t               *avifile = NULL;
    static char *tc_strchrnul(const char *s, 
    180181
    181182
    182183/* START: COPIED FROM ffmpeg-0.5_p22846(ffmpeg.c, cmdutils.c) */
    183 #include <libavcodec/opt.h>
     184#include <libavutil/opt.h>
    184185#include <libavutil/avstring.h>
    185186#include <libswscale/swscale.h>
    186187
    MOD_init 
    470471    }
    471472
    472473    TC_LOCK_LIBAVCODEC;
    473     avcodec_init();
    474474    avcodec_register_all();
    475475    TC_UNLOCK_LIBAVCODEC;
    476476
    MOD_init 
    634634        lavc_param_rc_max_rate = 2516;
    635635        lavc_param_rc_buffer_size = 224 * 8;
    636636        lavc_param_rc_buffer_aggressivity = 99;
    637         lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
     637        lavc_param_scan_offset = 1;
    638638
    639639        break;
    640640
    MOD_init 
    674674
    675675        lavc_param_rc_buffer_size = 224 * 8;
    676676        lavc_param_rc_buffer_aggressivity = 99;
    677         lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
     677        lavc_param_scan_offset = 1;
    678678
    679679        break;
    680680
    MOD_init 
    887887                    lavc_venc_context->thread_count);
    888888    }
    889889
    890     avcodec_thread_init(lavc_venc_context, lavc_param_threads);
     890    lavc_venc_context->thread_count = lavc_param_threads;
    891891
    892892    if (lavc_param_intra_matrix) {
    893893        char *tmp;
    MOD_init 
    10651065    lavc_venc_context->flags |= lavc_param_closedgop;
    10661066    lavc_venc_context->flags |= lavc_param_trunc;
    10671067    lavc_venc_context->flags |= lavc_param_aic;
    1068     lavc_venc_context->flags |= lavc_param_umv;
    10691068    lavc_venc_context->flags |= lavc_param_v4mv;
    1070     lavc_venc_context->flags |= lavc_param_data_partitioning;
    10711069    lavc_venc_context->flags |= lavc_param_cbp;
    10721070    lavc_venc_context->flags |= lavc_param_mv0;
    10731071    lavc_venc_context->flags |= lavc_param_qp_rd;
    1074     lavc_venc_context->flags |= lavc_param_scan_offset;
    1075     lavc_venc_context->flags |= lavc_param_ss;
    1076     lavc_venc_context->flags |= lavc_param_alt;
    10771072    lavc_venc_context->flags |= lavc_param_ilme;
    10781073#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)   
    10791074    lavc_venc_context->flags |= lavc_param_trell;
    MOD_init 
    12031198
    12041199    lavc_venc_context->me_method = ME_ZERO + lavc_param_vme;
    12051200
    1206 
    12071201        /* FIXME: transcode itself contains "broken ffmpeg default settings", thus we need to override them! */
    12081202        if (lavc_param_video_preset) {
    12091203                avcodec_opts[AVMEDIA_TYPE_VIDEO] = lavc_venc_context;
    MOD_init 
    12411235                }
    12421236        }
    12431237
     1238    if (lavc_param_scan_offset) {
     1239      av_dict_set(lavc_venc_opts, "scan_offset", "1", 0);
     1240    }
     1241
     1242    if (lavc_param_ss) {
     1243      av_dict_set(lavc_venc_opts, "structured_slices", "1", 0);
     1244    }
     1245
     1246    if (lavc_param_alt) {
     1247      av_dict_set(lavc_venc_opts, "alternate_scan", "1", 0);
     1248    }
     1249
     1250    if (lavc_param_umv) {
     1251      av_dict_set(lavc_venc_opts, "umv", "1", 0);
     1252    }
     1253
     1254    if (lavc_param_data_partitioning) {
     1255      av_dict_set(lavc_venc_opts, "vdpart", "1", 0);
     1256    }
    12441257
    12451258    //-- open codec --
    12461259    //----------------
    12471260    TC_LOCK_LIBAVCODEC;
    1248     ret = avcodec_open(lavc_venc_context, lavc_venc_codec);
     1261    ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, lavc_venc_opts);
    12491262    TC_UNLOCK_LIBAVCODEC;
    12501263    if (ret < 0) {
    12511264      tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
    12521265      return TC_EXPORT_ERROR;
    12531266    }
    12541267
    1255     if (lavc_venc_context->codec->encode == NULL) {
     1268    if (av_codec_is_encoder(lavc_venc_context->codec) == 0) {
    12561269      tc_log_warn(MOD_NAME, "could not open FFMPEG codec "
    1257               "(lavc_venc_context->codec->encode == NULL)");
     1270              "(av_codec_is_encoder(lavc_venc_context->codec) == 0)");
    12581271      return TC_EXPORT_ERROR;
    12591272    }
    12601273
  • export/ffmpeg_cfg.c

    old new TCConfigEntry lavcopts_conf[]={ 
    160160    {"vcelim", &lavc_param_chroma_elim_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
    161161    {"vpsize", &lavc_param_packet_size, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000},
    162162    {"vstrict", &lavc_param_strict, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
    163     {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
     163    {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, 1},
    164164//    {"keyint", &lavc_param_keyint, TCCONF_TYPE_INT, 0, 0, 0},
    165     {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
     165    {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_GRAY},
    166166    {"mpeg_quant", &lavc_param_mpeg_quant, TCCONF_TYPE_FLAG, 0, 0, 1},
    167167    {"vi_qfactor", &lavc_param_vi_qfactor, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0},
    168168    {"vi_qoffset", &lavc_param_vi_qoffset, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0},
    TCConfigEntry lavcopts_conf[]={ 
    211211#else
    212212    {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED},
    213213#endif   
    214     {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV},
     214    {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, 1},
    215215    {"ibias", &lavc_param_ibias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
    216216    {"pbias", &lavc_param_pbias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
    217217    {"coder", &lavc_param_coder, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
    TCConfigEntry lavcopts_conf[]={ 
    223223    {"nr", &lavc_param_noise_reduction, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
    224224    {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QP_RD},
    225225    {"threads", &lavc_param_threads, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16},
    226     {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_SLICE_STRUCT},
    227     {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_SVCD_SCAN_OFFSET},
    228     {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN},
     226    {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, 1},
     227    {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, 1},
     228    {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, 1},
    229229    {"ilme", &lavc_param_ilme, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME},
    230230    {"inter_threshold", &lavc_param_inter_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
    231231    {"sc_threshold", &lavc_param_sc_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
  • import/decode_lavc.c

    old new void decode_lavc(decode_t *decode) 
    181181#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    182182  lavc_dec_context->error_resilience  = 2;
    183183#else
    184   lavc_dec_context->error_recognition = 2;
     184  lavc_dec_context->err_recognition = 2;
    185185#endif
    186186  lavc_dec_context->error_concealment = 3;
    187187  lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
  • import/import_ffmpeg.c

    old new do_avi: 
    314314#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
    315315    lavc_dec_context->error_resilience  = 2;
    316316#else
    317     lavc_dec_context->error_recognition = 2;
     317    lavc_dec_context->err_recognition = 2;
    318318#endif
    319319    lavc_dec_context->error_concealment = 3;
    320320    lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
  • import/probe_ffmpeg.c

    old new void probe_ffmpeg(info_t *ipipe) 
    9999
    100100    TC_INIT_LIBAVCODEC;
    101101
    102     ret = av_open_input_file(&lavf_dmx_context, ipipe->name,
    103                              NULL, 0, NULL);
     102    ret = avformat_open_input(&lavf_dmx_context, ipipe->name,
     103                             NULL, NULL);
    104104    if (ret != 0) {
    105105        tc_log_error(__FILE__, "unable to open '%s'"
    106106                               " (libavformat failure)",
  • libtc/tcavcodec.h

    old new extern pthread_mutex_t tc_libavcodec_mut 
    5353
    5454#define TC_INIT_LIBAVCODEC do { \
    5555    TC_LOCK_LIBAVCODEC; \
    56     avcodec_init(); \
    5756    avcodec_register_all(); \
    5857    TC_UNLOCK_LIBAVCODEC; \
    5958} while (0)