Annotation of pkgsrc/multimedia/transcode/patches/patch-encode_encode_lavc.c, revision 1.2
1.1 markd 1: $NetBSD$
2:
1.2 ! adam 3: Fixes building against FFmpeg version >= 2.0.0 (gentoo patch).
1.1 markd 4:
5: --- encode/encode_lavc.c.orig 2011-11-19 16:50:27.000000000 +0000
6: +++ encode/encode_lavc.c
1.2 ! adam 7: @@ -74,6 +74,9 @@ struct tclavcconfigdata_ {
! 8: int lmin;
! 9: int lmax;
! 10: int me_method;
! 11: + int luma_elim_threshold;
! 12: + int chroma_elim_threshold;
! 13: + int quantizer_noise_shaping;
! 14:
! 15: /* same as above for flags */
! 16: struct {
! 17: @@ -114,6 +117,7 @@ struct tclavcprivatedata_ {
1.1 markd 18:
19: AVFrame ff_venc_frame;
20: AVCodecContext ff_vcontext;
1.2 ! adam 21: + AVDictionary * ff_opts;
1.1 markd 22:
23: AVCodec *ff_vcodec;
24:
1.2 ! adam 25: @@ -164,6 +168,7 @@ static const TCCodecID tc_lavc_codecs_ou
! 26: TC_CODEC_ERROR
! 27: };
! 28:
! 29: +#if LIBAVCODEC_VERSION_MAJOR < 55
! 30: static const enum CodecID tc_lavc_internal_codecs[] = {
! 31: CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO, CODEC_ID_MPEG4,
! 32: CODEC_ID_H263I, CODEC_ID_H263P,
! 33: @@ -176,6 +181,20 @@ static const enum CodecID tc_lavc_intern
! 34: CODEC_ID_MSMPEG4V2, CODEC_ID_MSMPEG4V3,
! 35: CODEC_ID_NONE
! 36: };
! 37: +#else
! 38: +static const enum AVCodecID tc_lavc_internal_codecs[] = {
! 39: + AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG4,
! 40: + AV_CODEC_ID_H263I, AV_CODEC_ID_H263P,
! 41: + AV_CODEC_ID_H264,
! 42: + AV_CODEC_ID_WMV1, AV_CODEC_ID_WMV2,
! 43: + AV_CODEC_ID_RV10,
! 44: + AV_CODEC_ID_HUFFYUV, AV_CODEC_ID_FFV1,
! 45: + AV_CODEC_ID_DVVIDEO,
! 46: + AV_CODEC_ID_MJPEG, AV_CODEC_ID_LJPEG,
! 47: + AV_CODEC_ID_MSMPEG4V2, AV_CODEC_ID_MSMPEG4V3,
! 48: + AV_CODEC_ID_NONE
! 49: +};
! 50: +#endif
! 51:
! 52: static const TCFormatID tc_lavc_formats[] = { TC_FORMAT_ERROR };
! 53:
! 54: @@ -937,7 +956,11 @@ static int tc_lavc_settings_from_vob(TCL
! 55: static void tc_lavc_config_defaults(TCLavcPrivateData *pd)
! 56: {
! 57: /* first of all reinitialize lavc data */
! 58: +#if LIBAVCODEC_VERSION_MAJOR < 55
! 59: avcodec_get_context_defaults(&pd->ff_vcontext);
! 60: +#else
! 61: + avcodec_get_context_defaults3(&pd->ff_vcontext, NULL);
! 62: +#endif
! 63:
! 64: pd->confdata.thread_count = 1;
! 65:
! 66: @@ -955,8 +978,6 @@ static void tc_lavc_config_defaults(TCLa
! 67: /*
! 68: * context *transcode* (not libavcodec) defaults
! 69: */
! 70: - pd->ff_vcontext.mb_qmin = 2;
! 71: - pd->ff_vcontext.mb_qmax = 31;
! 72: pd->ff_vcontext.max_qdiff = 3;
! 73: pd->ff_vcontext.max_b_frames = 0;
! 74: pd->ff_vcontext.me_range = 0;
! 75: @@ -977,8 +998,8 @@ static void tc_lavc_config_defaults(TCLa
! 76: pd->ff_vcontext.mpeg_quant = 0;
! 77: pd->ff_vcontext.rc_initial_cplx = 0.0;
! 78: pd->ff_vcontext.rc_qsquish = 1.0;
! 79: - pd->ff_vcontext.luma_elim_threshold = 0;
! 80: - pd->ff_vcontext.chroma_elim_threshold = 0;
! 81: + pd->confdata.luma_elim_threshold = 0;
! 82: + pd->confdata.chroma_elim_threshold = 0;
! 83: pd->ff_vcontext.strict_std_compliance = 0;
! 84: pd->ff_vcontext.dct_algo = FF_DCT_AUTO;
! 85: pd->ff_vcontext.idct_algo = FF_IDCT_AUTO;
! 86: @@ -1002,7 +1023,7 @@ static void tc_lavc_config_defaults(TCLa
! 87: pd->ff_vcontext.intra_quant_bias = FF_DEFAULT_QUANT_BIAS;
! 88: pd->ff_vcontext.inter_quant_bias = FF_DEFAULT_QUANT_BIAS;
! 89: pd->ff_vcontext.noise_reduction = 0;
! 90: - pd->ff_vcontext.quantizer_noise_shaping = 0;
! 91: + pd->confdata.quantizer_noise_shaping = 0;
! 92: pd->ff_vcontext.flags = 0;
! 93: }
! 94:
! 95: @@ -1034,16 +1055,11 @@ static void tc_lavc_dispatch_settings(TC
! 96:
! 97: pd->ff_vcontext.flags = 0;
1.1 markd 98: SET_FLAG(pd, mv0);
1.2 ! adam 99: - SET_FLAG(pd, cbp);
1.1 markd 100: SET_FLAG(pd, qpel);
101: - SET_FLAG(pd, alt);
102: - SET_FLAG(pd, vdpart);
103: SET_FLAG(pd, naq);
104: SET_FLAG(pd, ilme);
105: SET_FLAG(pd, ildct);
106: SET_FLAG(pd, aic);
107: - SET_FLAG(pd, aiv);
108: - SET_FLAG(pd, umv);
109: SET_FLAG(pd, psnr);
110: SET_FLAG(pd, trell);
111: SET_FLAG(pd, gray);
1.2 ! adam 112: @@ -1064,6 +1080,30 @@ static void tc_lavc_dispatch_settings(TC
1.1 markd 113: pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_DCT;
114: pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
115: }
116: + if (pd->confdata.flags.alt) {
1.2 ! adam 117: + av_dict_set(&(pd->ff_opts), "alternate_scan", "1", 0);
1.1 markd 118: + }
119: + if (pd->confdata.flags.vdpart) {
1.2 ! adam 120: + av_dict_set(&(pd->ff_opts), "data_partitioning", "1", 0);
1.1 markd 121: + }
122: + if (pd->confdata.flags.umv) {
1.2 ! adam 123: + av_dict_set(&(pd->ff_opts), "umv", "1", 0);
1.1 markd 124: + }
125: + if (pd->confdata.flags.aiv) {
1.2 ! adam 126: + av_dict_set(&(pd->ff_opts), "aiv", "1", 0);
1.1 markd 127: + }
1.2 ! adam 128: + if (pd->confdata.flags.cbp) {
! 129: + av_dict_set(&(pd->ff_opts), "mpv_flags", "+cbp_rd", 0);
! 130: + }
! 131: +
! 132: + char buf[1024];
! 133: +#define set_dict_opt(val, opt) \
! 134: + snprintf(buf, sizeof(buf), "%i", pd->confdata.val);\
! 135: + av_dict_set(&(pd->ff_opts), opt, buf, 0)
! 136: +
! 137: + set_dict_opt(luma_elim_threshold, "luma_elim_threshold");
! 138: + set_dict_opt(chroma_elim_threshold, "chroma_elim_threshold");
! 139: + set_dict_opt(quantizer_noise_shaping, "quantizer_noise_shaping");
1.1 markd 140: }
141:
142: #undef SET_FLAG
1.2 ! adam 143: @@ -1116,8 +1156,6 @@ static int tc_lavc_read_config(TCLavcPri
! 144: // handled by transcode core
! 145: // { "vqmax", PCTX(qmax), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
! 146: // handled by transcode core
! 147: - { "mbqmin", PCTX(mb_qmin), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
! 148: - { "mbqmax", PCTX(mb_qmax), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
! 149: { "lmin", PAUX(lmin), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.01, 255.0 },
! 150: { "lmax", PAUX(lmax), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.01, 255.0 },
! 151: { "vqdiff", PCTX(max_qdiff), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31 },
! 152: @@ -1150,8 +1188,8 @@ static int tc_lavc_read_config(TCLavcPri
! 153: { "vrc_init_cplx", PCTX(rc_initial_cplx), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 9999999.0 },
! 154: // { "vrc_init_occupancy", }, // not yet supported
! 155: { "vqsquish", PCTX(rc_qsquish), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 99.0 },
! 156: - { "vlelim", PCTX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
! 157: - { "vcelim", PCTX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
! 158: + { "vlelim", PAUX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
! 159: + { "vcelim", PAUX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
! 160: { "vstrict", PCTX(strict_std_compliance), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
! 161: { "vpsize", PCTX(rtp_payload_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000 },
! 162: { "dct", PCTX(dct_algo), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
! 163: @@ -1177,25 +1215,25 @@ static int tc_lavc_read_config(TCLavcPri
! 164: { "ibias", PCTX(intra_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
! 165: { "pbias", PCTX(inter_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
! 166: { "nr", PCTX(noise_reduction), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
! 167: - { "qns", PCTX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
! 168: + { "qns", PAUX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
! 169: { "inter_matrix_file", inter_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
! 170: { "intra_matrix_file", intra_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
! 171:
1.1 markd 172: { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
1.2 ! adam 173: - { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
! 174: + { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, 1 },
1.1 markd 175: { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
176: - { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN },
177: + { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, 1 },
178: { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
179: { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_DCT },
180: { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_NORMALIZE_AQP },
181: - { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART },
182: + { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, 1 },
183: #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
184: { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC },
185: #else
186: { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED },
187: #endif
188: - { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIV },
189: - { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV },
190: + { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, 1 },
191: + { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, 1 },
192: { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR },
193: #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
194: { "trell", PAUX(flags.trell), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT },
1.2 ! adam 195: @@ -1345,6 +1383,8 @@ static int tc_lavc_configure(TCModuleIns
! 196:
! 197: pd = self->userdata;
! 198:
! 199: + pd->ff_opts = NULL;
! 200: +
! 201: pd->flush_flag = vob->encoder_flush;
! 202:
! 203: /* FIXME: move into core? */
! 204: @@ -1387,7 +1427,7 @@ static int tc_lavc_configure(TCModuleIns
1.1 markd 205: pd->confdata.thread_count,
206: (pd->confdata.thread_count > 1) ?"s" :"");
207: }
208: - avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
209: + pd->ff_vcontext.thread_count = pd->confdata.thread_count;
210:
211: pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
212: if (pd->ff_vcodec == NULL) {
1.2 ! adam 213: @@ -1397,11 +1437,11 @@ static int tc_lavc_configure(TCModuleIns
1.1 markd 214: }
215:
216: TC_LOCK_LIBAVCODEC;
217: - ret = avcodec_open(&pd->ff_vcontext, pd->ff_vcodec);
1.2 ! adam 218: + ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, &(pd->ff_opts));
1.1 markd 219: TC_UNLOCK_LIBAVCODEC;
220:
221: if (ret < 0) {
222: - tc_log_error(MOD_NAME, "avcodec_open() failed");
223: + tc_log_error(MOD_NAME, "avcodec_open2() failed");
224: goto failed;
225: }
226: /* finally, pass up the extradata, if any */
CVSweb <webmaster@jp.NetBSD.org>