transcode-1.1.7-ffmpeg-0.11.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. Fix build with ffmpeg 0.11.
  2. https://bugs.gentoo.org/show_bug.cgi?id=419551
  3. Author: Brennan Shacklett
  4. diff -urN transcode-1.1.7-orig/encode/encode_lavc.c transcode-1.1.7/encode/encode_lavc.c
  5. --- transcode-1.1.7-orig/encode/encode_lavc.c 2011-11-19 08:50:27.000000000 -0800
  6. +++ transcode-1.1.7/encode/encode_lavc.c 2012-07-03 10:47:03.528009149 -0700
  7. @@ -114,6 +114,7 @@
  8. AVFrame ff_venc_frame;
  9. AVCodecContext ff_vcontext;
  10. + AVDictionary ** ff_opts;
  11. AVCodec *ff_vcodec;
  12. @@ -1036,14 +1037,10 @@
  13. SET_FLAG(pd, mv0);
  14. SET_FLAG(pd, cbp);
  15. SET_FLAG(pd, qpel);
  16. - SET_FLAG(pd, alt);
  17. - SET_FLAG(pd, vdpart);
  18. SET_FLAG(pd, naq);
  19. SET_FLAG(pd, ilme);
  20. SET_FLAG(pd, ildct);
  21. SET_FLAG(pd, aic);
  22. - SET_FLAG(pd, aiv);
  23. - SET_FLAG(pd, umv);
  24. SET_FLAG(pd, psnr);
  25. SET_FLAG(pd, trell);
  26. SET_FLAG(pd, gray);
  27. @@ -1064,6 +1061,18 @@
  28. pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_DCT;
  29. pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
  30. }
  31. + if (pd->confdata.flags.alt) {
  32. + av_dict_set(pd->ff_opts, "alternate_scan", "1", 0);
  33. + }
  34. + if (pd->confdata.flags.vdpart) {
  35. + av_dict_set(pd->ff_opts, "data_partitioning", "1", 0);
  36. + }
  37. + if (pd->confdata.flags.umv) {
  38. + av_dict_set(pd->ff_opts, "umv", "1", 0);
  39. + }
  40. + if (pd->confdata.flags.aiv) {
  41. + av_dict_set(pd->ff_opts, "aiv", "1", 0);
  42. + }
  43. }
  44. #undef SET_FLAG
  45. @@ -1184,18 +1193,18 @@
  46. { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
  47. { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
  48. { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
  49. - { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN },
  50. + { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, 1 },
  51. { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
  52. { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_DCT },
  53. { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_NORMALIZE_AQP },
  54. - { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART },
  55. + { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, 1 },
  56. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  57. { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC },
  58. #else
  59. { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED },
  60. #endif
  61. - { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIV },
  62. - { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV },
  63. + { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, 1 },
  64. + { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, 1 },
  65. { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR },
  66. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  67. { "trell", PAUX(flags.trell), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT },
  68. @@ -1387,7 +1396,7 @@
  69. pd->confdata.thread_count,
  70. (pd->confdata.thread_count > 1) ?"s" :"");
  71. }
  72. - avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
  73. + pd->ff_vcontext.thread_count = pd->confdata.thread_count;
  74. pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
  75. if (pd->ff_vcodec == NULL) {
  76. @@ -1397,11 +1406,11 @@
  77. }
  78. TC_LOCK_LIBAVCODEC;
  79. - ret = avcodec_open(&pd->ff_vcontext, pd->ff_vcodec);
  80. + ret = avcodec_open2(&pd->ff_vcontext, pd->ff_vcodec, pd->ff_opts);
  81. TC_UNLOCK_LIBAVCODEC;
  82. if (ret < 0) {
  83. - tc_log_error(MOD_NAME, "avcodec_open() failed");
  84. + tc_log_error(MOD_NAME, "avcodec_open2() failed");
  85. goto failed;
  86. }
  87. /* finally, pass up the extradata, if any */
  88. diff -urN transcode-1.1.7-orig/export/export_ffmpeg.c transcode-1.1.7/export/export_ffmpeg.c
  89. --- transcode-1.1.7-orig/export/export_ffmpeg.c 2011-11-19 08:50:27.000000000 -0800
  90. +++ transcode-1.1.7/export/export_ffmpeg.c 2012-07-03 13:15:23.918019415 -0700
  91. @@ -122,6 +122,7 @@
  92. static AVFrame *lavc_convert_frame = NULL;
  93. static AVCodec *lavc_venc_codec = NULL;
  94. +static AVDictionary **lavc_venc_opts = NULL;
  95. static AVFrame *lavc_venc_frame = NULL;
  96. static AVCodecContext *lavc_venc_context;
  97. static avi_t *avifile = NULL;
  98. @@ -180,7 +181,7 @@
  99. /* START: COPIED FROM ffmpeg-0.5_p22846(ffmpeg.c, cmdutils.c) */
  100. -#include <libavcodec/opt.h>
  101. +#include <libavutil/opt.h>
  102. #include <libavutil/avstring.h>
  103. #include <libswscale/swscale.h>
  104. @@ -470,7 +471,6 @@
  105. }
  106. TC_LOCK_LIBAVCODEC;
  107. - avcodec_init();
  108. avcodec_register_all();
  109. TC_UNLOCK_LIBAVCODEC;
  110. @@ -634,7 +634,7 @@
  111. lavc_param_rc_max_rate = 2516;
  112. lavc_param_rc_buffer_size = 224 * 8;
  113. lavc_param_rc_buffer_aggressivity = 99;
  114. - lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
  115. + lavc_param_scan_offset = 1;
  116. break;
  117. @@ -674,7 +674,7 @@
  118. lavc_param_rc_buffer_size = 224 * 8;
  119. lavc_param_rc_buffer_aggressivity = 99;
  120. - lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
  121. + lavc_param_scan_offset = 1;
  122. break;
  123. @@ -887,7 +887,7 @@
  124. lavc_venc_context->thread_count);
  125. }
  126. - avcodec_thread_init(lavc_venc_context, lavc_param_threads);
  127. + lavc_venc_context->thread_count = lavc_param_threads;
  128. if (lavc_param_intra_matrix) {
  129. char *tmp;
  130. @@ -1065,15 +1065,10 @@
  131. lavc_venc_context->flags |= lavc_param_closedgop;
  132. lavc_venc_context->flags |= lavc_param_trunc;
  133. lavc_venc_context->flags |= lavc_param_aic;
  134. - lavc_venc_context->flags |= lavc_param_umv;
  135. lavc_venc_context->flags |= lavc_param_v4mv;
  136. - lavc_venc_context->flags |= lavc_param_data_partitioning;
  137. lavc_venc_context->flags |= lavc_param_cbp;
  138. lavc_venc_context->flags |= lavc_param_mv0;
  139. lavc_venc_context->flags |= lavc_param_qp_rd;
  140. - lavc_venc_context->flags |= lavc_param_scan_offset;
  141. - lavc_venc_context->flags |= lavc_param_ss;
  142. - lavc_venc_context->flags |= lavc_param_alt;
  143. lavc_venc_context->flags |= lavc_param_ilme;
  144. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  145. lavc_venc_context->flags |= lavc_param_trell;
  146. @@ -1203,7 +1198,6 @@
  147. lavc_venc_context->me_method = ME_ZERO + lavc_param_vme;
  148. -
  149. /* FIXME: transcode itself contains "broken ffmpeg default settings", thus we need to override them! */
  150. if (lavc_param_video_preset) {
  151. avcodec_opts[AVMEDIA_TYPE_VIDEO] = lavc_venc_context;
  152. @@ -1241,20 +1235,39 @@
  153. }
  154. }
  155. + if (lavc_param_scan_offset) {
  156. + av_dict_set(lavc_venc_opts, "scan_offset", "1", 0);
  157. + }
  158. +
  159. + if (lavc_param_ss) {
  160. + av_dict_set(lavc_venc_opts, "structured_slices", "1", 0);
  161. + }
  162. +
  163. + if (lavc_param_alt) {
  164. + av_dict_set(lavc_venc_opts, "alternate_scan", "1", 0);
  165. + }
  166. +
  167. + if (lavc_param_umv) {
  168. + av_dict_set(lavc_venc_opts, "umv", "1", 0);
  169. + }
  170. +
  171. + if (lavc_param_data_partitioning) {
  172. + av_dict_set(lavc_venc_opts, "vdpart", "1", 0);
  173. + }
  174. //-- open codec --
  175. //----------------
  176. TC_LOCK_LIBAVCODEC;
  177. - ret = avcodec_open(lavc_venc_context, lavc_venc_codec);
  178. + ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, lavc_venc_opts);
  179. TC_UNLOCK_LIBAVCODEC;
  180. if (ret < 0) {
  181. tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
  182. return TC_EXPORT_ERROR;
  183. }
  184. - if (lavc_venc_context->codec->encode == NULL) {
  185. + if (av_codec_is_encoder(lavc_venc_context->codec) == 0) {
  186. tc_log_warn(MOD_NAME, "could not open FFMPEG codec "
  187. - "(lavc_venc_context->codec->encode == NULL)");
  188. + "(av_codec_is_encoder(lavc_venc_context->codec) == 0)");
  189. return TC_EXPORT_ERROR;
  190. }
  191. diff -urN transcode-1.1.7-orig/export/ffmpeg_cfg.c transcode-1.1.7/export/ffmpeg_cfg.c
  192. --- transcode-1.1.7-orig/export/ffmpeg_cfg.c 2011-11-19 08:50:27.000000000 -0800
  193. +++ transcode-1.1.7/export/ffmpeg_cfg.c 2012-07-03 10:09:25.011003254 -0700
  194. @@ -160,9 +160,9 @@
  195. {"vcelim", &lavc_param_chroma_elim_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
  196. {"vpsize", &lavc_param_packet_size, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000},
  197. {"vstrict", &lavc_param_strict, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99},
  198. - {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
  199. + {"vdpart", &lavc_param_data_partitioning, TCCONF_TYPE_FLAG, 0, 0, 1},
  200. // {"keyint", &lavc_param_keyint, TCCONF_TYPE_INT, 0, 0, 0},
  201. - {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART},
  202. + {"gray", &lavc_param_gray, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_GRAY},
  203. {"mpeg_quant", &lavc_param_mpeg_quant, TCCONF_TYPE_FLAG, 0, 0, 1},
  204. {"vi_qfactor", &lavc_param_vi_qfactor, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0},
  205. {"vi_qoffset", &lavc_param_vi_qoffset, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0},
  206. @@ -211,7 +211,7 @@
  207. #else
  208. {"aic", &lavc_param_aic, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED},
  209. #endif
  210. - {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV},
  211. + {"umv", &lavc_param_umv, TCCONF_TYPE_FLAG, 0, 0, 1},
  212. {"ibias", &lavc_param_ibias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
  213. {"pbias", &lavc_param_pbias, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512},
  214. {"coder", &lavc_param_coder, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10},
  215. @@ -223,9 +223,9 @@
  216. {"nr", &lavc_param_noise_reduction, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
  217. {"qprd", &lavc_param_qp_rd, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QP_RD},
  218. {"threads", &lavc_param_threads, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16},
  219. - {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_SLICE_STRUCT},
  220. - {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_SVCD_SCAN_OFFSET},
  221. - {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN},
  222. + {"ss", &lavc_param_ss, TCCONF_TYPE_FLAG, 0, 0, 1},
  223. + {"svcd_sof", &lavc_param_scan_offset, TCCONF_TYPE_FLAG, 0, 0, 1},
  224. + {"alt", &lavc_param_alt, TCCONF_TYPE_FLAG, 0, 0, 1},
  225. {"ilme", &lavc_param_ilme, TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME},
  226. {"inter_threshold", &lavc_param_inter_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
  227. {"sc_threshold", &lavc_param_sc_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000},
  228. diff -urN transcode-1.1.7-orig/import/decode_lavc.c transcode-1.1.7/import/decode_lavc.c
  229. --- transcode-1.1.7-orig/import/decode_lavc.c 2011-11-19 08:50:27.000000000 -0800
  230. +++ transcode-1.1.7/import/decode_lavc.c 2012-07-03 10:21:46.085005182 -0700
  231. @@ -181,7 +181,7 @@
  232. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  233. lavc_dec_context->error_resilience = 2;
  234. #else
  235. - lavc_dec_context->error_recognition = 2;
  236. + lavc_dec_context->err_recognition = 2;
  237. #endif
  238. lavc_dec_context->error_concealment = 3;
  239. lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
  240. diff -urN transcode-1.1.7-orig/import/import_ffmpeg.c transcode-1.1.7/import/import_ffmpeg.c
  241. --- transcode-1.1.7-orig/import/import_ffmpeg.c 2011-11-19 08:50:27.000000000 -0800
  242. +++ transcode-1.1.7/import/import_ffmpeg.c 2012-07-03 10:19:36.936004841 -0700
  243. @@ -314,7 +314,7 @@
  244. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  245. lavc_dec_context->error_resilience = 2;
  246. #else
  247. - lavc_dec_context->error_recognition = 2;
  248. + lavc_dec_context->err_recognition = 2;
  249. #endif
  250. lavc_dec_context->error_concealment = 3;
  251. lavc_dec_context->workaround_bugs = FF_BUG_AUTODETECT;
  252. diff -urN transcode-1.1.7-orig/import/probe_ffmpeg.c transcode-1.1.7/import/probe_ffmpeg.c
  253. --- transcode-1.1.7-orig/import/probe_ffmpeg.c 2011-11-19 08:50:27.000000000 -0800
  254. +++ transcode-1.1.7/import/probe_ffmpeg.c 2012-07-03 10:41:42.782008306 -0700
  255. @@ -99,8 +99,8 @@
  256. TC_INIT_LIBAVCODEC;
  257. - ret = av_open_input_file(&lavf_dmx_context, ipipe->name,
  258. - NULL, 0, NULL);
  259. + ret = avformat_open_input(&lavf_dmx_context, ipipe->name,
  260. + NULL, NULL);
  261. if (ret != 0) {
  262. tc_log_error(__FILE__, "unable to open '%s'"
  263. " (libavformat failure)",
  264. diff -urN transcode-1.1.7-orig/libtc/tcavcodec.h transcode-1.1.7/libtc/tcavcodec.h
  265. --- transcode-1.1.7-orig/libtc/tcavcodec.h 2011-11-19 08:50:27.000000000 -0800
  266. +++ transcode-1.1.7/libtc/tcavcodec.h 2012-07-03 10:34:43.648007213 -0700
  267. @@ -53,7 +53,6 @@
  268. #define TC_INIT_LIBAVCODEC do { \
  269. TC_LOCK_LIBAVCODEC; \
  270. - avcodec_init(); \
  271. avcodec_register_all(); \
  272. TC_UNLOCK_LIBAVCODEC; \
  273. } while (0)