[SCM] transcode/master: Fix remaining issues with libav 9

sramacher at users.alioth.debian.org sramacher at users.alioth.debian.org
Wed Nov 20 19:44:38 UTC 2013


The following commit has been merged in the master branch:
commit 10be5a465c3d41424e637c89f0a62867ff74f379
Author: Sebastian Ramacher <sramacher at debian.org>
Date:   Mon Nov 11 00:34:29 2013 +0100

    Fix remaining issues with libav 9

diff --git a/debian/patches/08_libav9-opt.patch b/debian/patches/08_libav9-opt.patch
new file mode 100644
index 0000000..509a4d2
--- /dev/null
+++ b/debian/patches/08_libav9-opt.patch
@@ -0,0 +1,43 @@
+Description: Fix deprecated av_opt related calls
+Author: Sebastian Ramacher <sramacher at debian.org>
+Last-Update: 2013-11-11
+
+--- a/export/export_ffmpeg.c
++++ b/export/export_ffmpeg.c
+@@ -240,6 +240,15 @@
+     opt_codec(&subtitle_stream_copy, &subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, arg);
+ }
+ 
++static int av_set_string3_fallback(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)
++{
++    const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
++    if (o_out)
++        *o_out = o;
++    return av_opt_set(obj, name, val, 0);
++}
++
++
+ static
+ int opt_default(const char *opt, const char *arg){
+     int type;
+@@ -250,9 +259,9 @@
+     for(type=0; type<AVMEDIA_TYPE_NB && ret>= 0; type++){
+ 		/* GLUE: +if */
+ 		if (type == AVMEDIA_TYPE_VIDEO) {
+-        const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
++        const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0);
+         if(o2)
+-            ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
++            ret = av_set_string3_fallback(avcodec_opts[type], opt, arg, 1, &o);
+ 		/* GLUE: +if */
+ 		}
+     }
+@@ -267,7 +276,7 @@
+         if(opt[0] == 'a')
+             ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o);
+         else */ if(opt[0] == 'v')
+-            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o);
++            ret = av_set_string3_fallback(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o);
+ 		/* GLUE: disabling
+         else if(opt[0] == 's')
+             ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o);
diff --git a/debian/patches/09_libav9-arch.patch b/debian/patches/09_libav9-arch.patch
new file mode 100644
index 0000000..8feedd4
--- /dev/null
+++ b/debian/patches/09_libav9-arch.patch
@@ -0,0 +1,323 @@
+Description: Fix multiple issues with libav 9
+Origin: vendor,
+ https://projects.archlinux.org/svntogit/packages.git/tree/trunk/transcode-1.1.7-ffmpeg2.patch?h=packages/transcode
+Last-Update: 2013-11-11
+
+--- a/encode/encode_lavc.c
++++ b/encode/encode_lavc.c
+@@ -74,6 +74,9 @@
+     int lmin;
+     int lmax;
+     int me_method;
++    int luma_elim_threshold;
++    int chroma_elim_threshold;
++    int quantizer_noise_shaping;
+ 
+     /* same as above for flags */
+     struct {
+@@ -114,7 +117,7 @@
+ 
+     AVFrame ff_venc_frame;
+     AVCodecContext ff_vcontext;
+-    AVDictionary ** ff_opts;
++    AVDictionary * ff_opts;
+ 
+     AVCodec *ff_vcodec;
+ 
+@@ -165,6 +168,7 @@
+     TC_CODEC_ERROR
+ };
+ 
++#if LIBAVCODEC_VERSION_MAJOR < 55
+ static const enum CodecID tc_lavc_internal_codecs[] = {
+     CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO, CODEC_ID_MPEG4,
+     CODEC_ID_H263I, CODEC_ID_H263P,
+@@ -177,6 +181,20 @@
+     CODEC_ID_MSMPEG4V2, CODEC_ID_MSMPEG4V3,
+     CODEC_ID_NONE
+ };
++#else
++static const enum AVCodecID tc_lavc_internal_codecs[] = {
++    AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG4,
++    AV_CODEC_ID_H263I, AV_CODEC_ID_H263P,
++    AV_CODEC_ID_H264,
++    AV_CODEC_ID_WMV1, AV_CODEC_ID_WMV2,
++    AV_CODEC_ID_RV10,
++    AV_CODEC_ID_HUFFYUV, AV_CODEC_ID_FFV1,
++    AV_CODEC_ID_DVVIDEO,
++    AV_CODEC_ID_MJPEG, AV_CODEC_ID_LJPEG,
++    AV_CODEC_ID_MSMPEG4V2, AV_CODEC_ID_MSMPEG4V3,
++    AV_CODEC_ID_NONE
++};
++#endif
+ 
+ static const TCFormatID tc_lavc_formats[] = { TC_FORMAT_ERROR };
+ 
+@@ -938,7 +956,11 @@
+ static void tc_lavc_config_defaults(TCLavcPrivateData *pd)
+ {
+     /* first of all reinitialize lavc data */
++#if LIBAVCODEC_VERSION_MAJOR < 55
+     avcodec_get_context_defaults(&pd->ff_vcontext);
++#else
++    avcodec_get_context_defaults3(&pd->ff_vcontext, NULL);
++#endif
+ 
+     pd->confdata.thread_count = 1;
+ 
+@@ -978,8 +1000,8 @@
+     pd->ff_vcontext.mpeg_quant              = 0;
+     pd->ff_vcontext.rc_initial_cplx         = 0.0;
+     pd->ff_vcontext.rc_qsquish              = 1.0;
+-    pd->ff_vcontext.luma_elim_threshold     = 0;
+-    pd->ff_vcontext.chroma_elim_threshold   = 0;
++    pd->confdata.luma_elim_threshold     = 0;
++    pd->confdata.chroma_elim_threshold   = 0;
+     pd->ff_vcontext.strict_std_compliance   = 0;
+     pd->ff_vcontext.dct_algo                = FF_DCT_AUTO;
+     pd->ff_vcontext.idct_algo               = FF_IDCT_AUTO;
+@@ -1003,7 +1025,7 @@
+     pd->ff_vcontext.intra_quant_bias        = FF_DEFAULT_QUANT_BIAS;
+     pd->ff_vcontext.inter_quant_bias        = FF_DEFAULT_QUANT_BIAS;
+     pd->ff_vcontext.noise_reduction         = 0;
+-    pd->ff_vcontext.quantizer_noise_shaping = 0;
++    pd->confdata.quantizer_noise_shaping = 0;
+     pd->ff_vcontext.flags                   = 0;
+ }
+ 
+@@ -1035,7 +1057,6 @@
+ 
+     pd->ff_vcontext.flags = 0;
+     SET_FLAG(pd, mv0);
+-    SET_FLAG(pd, cbp);
+     SET_FLAG(pd, qpel);
+     SET_FLAG(pd, naq);
+     SET_FLAG(pd, ilme);
+@@ -1062,17 +1083,29 @@
+         pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
+     }
+     if (pd->confdata.flags.alt) {
+-        av_dict_set(pd->ff_opts, "alternate_scan", "1", 0);
++        av_dict_set(&(pd->ff_opts), "alternate_scan", "1", 0);
+     }
+     if (pd->confdata.flags.vdpart) {
+-        av_dict_set(pd->ff_opts, "data_partitioning", "1", 0);
++        av_dict_set(&(pd->ff_opts), "data_partitioning", "1", 0);
+     }
+     if (pd->confdata.flags.umv) {
+-        av_dict_set(pd->ff_opts, "umv", "1", 0);
++        av_dict_set(&(pd->ff_opts), "umv", "1", 0);
+     }
+     if (pd->confdata.flags.aiv) {
+-        av_dict_set(pd->ff_opts, "aiv", "1", 0);
++        av_dict_set(&(pd->ff_opts), "aiv", "1", 0);
+     }
++    if (pd->confdata.flags.cbp) {
++    	av_dict_set(&(pd->ff_opts), "mpv_flags", "+cbp_rd", 0);
++    }
++
++    char buf[1024];
++#define set_dict_opt(val, opt) \
++    snprintf(buf, sizeof(buf), "%i", pd->confdata.val);\
++    av_dict_set(&(pd->ff_opts), opt, buf, 0)
++
++    set_dict_opt(luma_elim_threshold, "luma_elim_threshold");
++    set_dict_opt(chroma_elim_threshold, "chroma_elim_threshold");
++    set_dict_opt(quantizer_noise_shaping, "quantizer_noise_shaping");
+ }
+ 
+ #undef SET_FLAG
+@@ -1159,8 +1192,8 @@
+         { "vrc_init_cplx", PCTX(rc_initial_cplx), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 9999999.0 },
+         //  { "vrc_init_occupancy",   }, // not yet supported
+         { "vqsquish", PCTX(rc_qsquish), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 99.0 },
+-        { "vlelim", PCTX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
+-        { "vcelim", PCTX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
++        { "vlelim", PAUX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
++        { "vcelim", PAUX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
+         { "vstrict", PCTX(strict_std_compliance), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
+         { "vpsize", PCTX(rtp_payload_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000 },
+         { "dct", PCTX(dct_algo), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
+@@ -1186,12 +1219,12 @@
+         { "ibias", PCTX(intra_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
+         { "pbias", PCTX(inter_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
+         { "nr", PCTX(noise_reduction), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
+-        { "qns", PCTX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
++        { "qns", PAUX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
+         { "inter_matrix_file", inter_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
+         { "intra_matrix_file", intra_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
+     
+         { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
+-        { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
++        { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, 1 },
+         { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
+         { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, 1 },
+         { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
+@@ -1354,6 +1387,8 @@
+ 
+     pd = self->userdata;
+ 
++    pd->ff_opts = NULL;
++
+     pd->flush_flag = vob->encoder_flush;
+     
+     /* FIXME: move into core? */
+@@ -1406,7 +1441,7 @@
+     }
+ 
+     TC_LOCK_LIBAVCODEC;
+-    ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, pd->ff_opts);
++    ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, &(pd->ff_opts));
+     TC_UNLOCK_LIBAVCODEC;
+ 
+     if (ret < 0) {
+--- a/export/export_ffmpeg.c
++++ b/export/export_ffmpeg.c
+@@ -122,7 +122,7 @@
+ static AVFrame             *lavc_convert_frame = NULL;
+ 
+ static AVCodec             *lavc_venc_codec = NULL;
+-static AVDictionary        **lavc_venc_opts = NULL;
++static AVDictionary        *lavc_venc_opts = NULL;
+ static AVFrame             *lavc_venc_frame = NULL;
+ static AVCodecContext      *lavc_venc_context;
+ static avi_t               *avifile = NULL;
+@@ -506,7 +506,7 @@
+ 		            codec->name, codec->fourCC, codec->comments);
+     }
+ 
+-    lavc_venc_context = avcodec_alloc_context();
++    lavc_venc_context = avcodec_alloc_context3(NULL);
+     lavc_venc_frame   = avcodec_alloc_frame();
+ 
+     lavc_convert_frame= avcodec_alloc_frame();
+@@ -858,8 +858,13 @@
+     lavc_venc_context->rc_strategy        = lavc_param_vrc_strategy;
+     lavc_venc_context->b_frame_strategy   = lavc_param_vb_strategy;
+     lavc_venc_context->b_quant_offset     = lavc_param_vb_qoffset;
+-    lavc_venc_context->luma_elim_threshold= lavc_param_luma_elim_threshold;
+-    lavc_venc_context->chroma_elim_threshold= lavc_param_chroma_elim_threshold;
++
++    char buf[1024];
++#define set_dict_opt(val, opt) \
++	snprintf(buf, sizeof(buf), "%i", val); \
++	av_dict_set(&lavc_venc_opts, opt, buf, 0)
++    set_dict_opt(lavc_param_luma_elim_threshold, "luma_elim_threshold");
++    set_dict_opt(lavc_param_chroma_elim_threshold, "chroma_elim_threshold");
+     lavc_venc_context->rtp_payload_size   = lavc_param_packet_size;
+ #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)   
+     if (lavc_param_packet_size)
+@@ -890,7 +895,7 @@
+     lavc_venc_context->context_model      = lavc_param_context;
+     lavc_venc_context->scenechange_threshold= lavc_param_sc_threshold;
+     lavc_venc_context->noise_reduction    = lavc_param_noise_reduction;
+-    lavc_venc_context->inter_threshold    = lavc_param_inter_threshold;
++    set_dict_opt(lavc_param_inter_threshold, "inter_threshold");
+     lavc_venc_context->intra_dc_precision = lavc_param_intra_dc_precision;
+     lavc_venc_context->skip_top           = lavc_param_skip_top;
+     lavc_venc_context->skip_bottom        = lavc_param_skip_bottom;
+@@ -1086,9 +1091,11 @@
+     lavc_venc_context->flags |= lavc_param_trunc;
+     lavc_venc_context->flags |= lavc_param_aic;
+     lavc_venc_context->flags |= lavc_param_v4mv;
+-    lavc_venc_context->flags |= lavc_param_cbp;
++    if(lavc_param_cbp)
++    	av_dict_set(&lavc_venc_opts, "mpv_flags", "+cbp_rd", 0);
+     lavc_venc_context->flags |= lavc_param_mv0;
+-    lavc_venc_context->flags |= lavc_param_qp_rd;
++    if(lavc_param_qp_rd)
++    	av_dict_set(&lavc_venc_opts, "mpv_flags", "+qp_rd", 0);
+     lavc_venc_context->flags |= lavc_param_ilme;
+ #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)   
+     lavc_venc_context->flags |= lavc_param_trell;
+@@ -1256,29 +1263,29 @@
+ 	}
+ 
+     if (lavc_param_scan_offset) {
+-      av_dict_set(lavc_venc_opts, "scan_offset", "1", 0);
++      av_dict_set(&lavc_venc_opts, "scan_offset", "1", 0);
+     }
+ 
+     if (lavc_param_ss) {
+-      av_dict_set(lavc_venc_opts, "structured_slices", "1", 0);
++      av_dict_set(&lavc_venc_opts, "structured_slices", "1", 0);
+     }
+ 
+     if (lavc_param_alt) {
+-      av_dict_set(lavc_venc_opts, "alternate_scan", "1", 0);
++      av_dict_set(&lavc_venc_opts, "alternate_scan", "1", 0);
+     }
+ 
+     if (lavc_param_umv) {
+-      av_dict_set(lavc_venc_opts, "umv", "1", 0);
++      av_dict_set(&lavc_venc_opts, "umv", "1", 0);
+     }
+ 
+     if (lavc_param_data_partitioning) {
+-      av_dict_set(lavc_venc_opts, "vdpart", "1", 0);
++      av_dict_set(&lavc_venc_opts, "vdpart", "1", 0);
+     }
+ 
+     //-- open codec --
+     //----------------
+     TC_LOCK_LIBAVCODEC;
+-    ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, lavc_venc_opts);
++    ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, &lavc_venc_opts);
+     TC_UNLOCK_LIBAVCODEC;
+     if (ret < 0) {
+       tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
+--- a/export/ffmpeg_cfg.c
++++ b/export/ffmpeg_cfg.c
+@@ -218,10 +218,10 @@
+     {"context", &lavc_param_context, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
+     {"intra_matrix", &lavc_param_intra_matrix, TCCONF_TYPE_STRING, 0, 0, 0},
+     {"inter_matrix", &lavc_param_inter_matrix, TCCONF_TYPE_STRING, 0, 0, 0},
+-    {"cbp", &lavc_param_cbp, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD},
++    {"cbp", &lavc_param_cbp, TCCONF_TYPE_FLAG, 0, 0, 1},
+     {"mv0", &lavc_param_mv0, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0},
+     {"nr", &lavc_param_noise_reduction, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
+-    {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QP_RD},
++    {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, 1},
+     {"threads", &lavc_param_threads, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16},
+     {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, 1},
+     {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, 1},
+--- a/export/aud_aux.c
++++ b/export/aud_aux.c
+@@ -346,7 +346,7 @@
+ 
+     //-- set parameters (bitrate, channels and sample-rate) --
+     //--------------------------------------------------------
+-    avcodec_get_context_defaults(&mpa_ctx);
++    avcodec_get_context_defaults3(&mpa_ctx, mpa_codec);
+ #if LIBAVCODEC_VERSION_MAJOR < 53
+     mpa_ctx.codec_type  = CODEC_TYPE_AUDIO;
+ #else
+@@ -359,7 +359,7 @@
+     //-- open codec --
+     //----------------
+     TC_LOCK_LIBAVCODEC;
+-    ret = avcodec_open(&mpa_ctx, mpa_codec);
++    ret = avcodec_open2(&mpa_ctx, mpa_codec, NULL);
+     TC_UNLOCK_LIBAVCODEC;
+     if (ret < 0) {
+         tc_warn("tc_audio_init_ffmpeg: could not open %s codec !",
+--- a/import/import_ffmpeg.c
++++ b/import/import_ffmpeg.c
+@@ -302,7 +302,7 @@
+ 
+     // Set these to the expected values so that ffmpeg's decoder can
+     // properly detect interlaced input.
+-    lavc_dec_context = avcodec_alloc_context();
++    lavc_dec_context = avcodec_alloc_context3(lavc_dec_codec);
+     if (lavc_dec_context == NULL) {
+       tc_log_error(MOD_NAME, "Could not allocate enough memory.");
+       return TC_IMPORT_ERROR;
+@@ -344,7 +344,7 @@
+     }
+ 
+     TC_LOCK_LIBAVCODEC;
+-    ret = avcodec_open(lavc_dec_context, lavc_dec_codec);
++    ret = avcodec_open2(lavc_dec_context, lavc_dec_codec, NULL);
+     TC_UNLOCK_LIBAVCODEC;
+     if (ret < 0) {
+       tc_log_warn(MOD_NAME, "Could not initialize the '%s' codec.",
diff --git a/debian/patches/series b/debian/patches/series
index 8c654b6..f62bfef 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,5 @@ ac3-audio-track-number.patch
 05-libav9-gentoo.patch
 06_libav9-jmm.patch
 07_libav9-preset.patch
+08_libav9-opt.patch
+09_libav9-arch.patch

-- 
transcode packaging



More information about the pkg-multimedia-commits mailing list