You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
9.1 KiB

  1. --- a/src/plugins/thumbnailffmpeg_extractor.c
  2. +++ b/src/plugins/thumbnailffmpeg_extractor.c
  3. @@ -59,6 +59,20 @@
  4. #include <ffmpeg/swscale.h>
  5. #endif
  6. +#if USE_JPEG
  7. +#ifdef PIX_FMT_YUVJ420P
  8. +#define PIX_OUTPUT_FORMAT PIX_FMT_YUVJ420P
  9. +#else
  10. +#define PIX_OUTPUT_FORMAT AV_PIX_FMT_YUVJ420P
  11. +#endif
  12. +#else
  13. +#ifdef PIX_FMT_RGB24
  14. +#define PIX_OUTPUT_FORMAT PIX_FMT_RGB24
  15. +#else
  16. +#define PIX_OUTPUT_FORMAT AV_PIX_FMT_RGB24
  17. +#endif
  18. +#endif
  19. +
  20. /**
  21. * Set to 1 to enable debug output.
  22. */
  23. @@ -153,7 +167,7 @@
  24. static size_t
  25. create_thumbnail (int src_width, int src_height,
  26. int src_stride[],
  27. - enum PixelFormat src_pixfmt,
  28. + enum AVPixelFormat src_pixfmt,
  29. const uint8_t * const src_data[],
  30. int dst_width, int dst_height,
  31. uint8_t **output_data,
  32. @@ -189,7 +203,8 @@
  33. if (NULL ==
  34. (scaler_ctx =
  35. sws_getContext (src_width, src_height, src_pixfmt,
  36. - dst_width, dst_height, PIX_FMT_RGB24,
  37. + dst_width, dst_height,
  38. + PIX_OUTPUT_FORMAT,
  39. SWS_BILINEAR, NULL, NULL, NULL)))
  40. {
  41. #if DEBUG
  42. @@ -199,7 +214,12 @@
  43. return 0;
  44. }
  45. - if (NULL == (dst_frame = avcodec_alloc_frame ()))
  46. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  47. + dst_frame = av_frame_alloc ();
  48. +#else
  49. + dst_frame = avcodec_alloc_frame();
  50. +#endif
  51. + if (NULL == dst_frame)
  52. {
  53. #if DEBUG
  54. fprintf (stderr,
  55. @@ -209,18 +229,24 @@
  56. return 0;
  57. }
  58. if (NULL == (dst_buffer =
  59. - av_malloc (avpicture_get_size (PIX_FMT_RGB24, dst_width, dst_height))))
  60. + av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT,
  61. + dst_width, dst_height))))
  62. {
  63. #if DEBUG
  64. fprintf (stderr,
  65. "Failed to allocate the destination image buffer\n");
  66. #endif
  67. - av_free (dst_frame);
  68. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  69. + av_frame_free (&dst_frame);
  70. +#else
  71. + avcodec_free_frame (&dst_frame);
  72. +#endif
  73. sws_freeContext (scaler_ctx);
  74. return 0;
  75. }
  76. avpicture_fill ((AVPicture *) dst_frame, dst_buffer,
  77. - PIX_FMT_RGB24, dst_width, dst_height);
  78. + PIX_OUTPUT_FORMAT,
  79. + dst_width, dst_height);
  80. sws_scale (scaler_ctx,
  81. src_data,
  82. src_stride,
  83. @@ -236,7 +262,11 @@
  84. "Failed to allocate the encoder output buffer\n");
  85. #endif
  86. av_free (dst_buffer);
  87. - av_free (dst_frame);
  88. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  89. + av_frame_free (&dst_frame);
  90. +#else
  91. + avcodec_free_frame (&dst_frame);
  92. +#endif
  93. sws_freeContext (scaler_ctx);
  94. return 0;
  95. }
  96. @@ -249,13 +279,17 @@
  97. #endif
  98. av_free (encoder_output_buffer);
  99. av_free (dst_buffer);
  100. - av_free (dst_frame);
  101. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  102. + av_frame_free (&dst_frame);
  103. +#else
  104. + avcodec_free_frame (&dst_frame);
  105. +#endif
  106. sws_freeContext (scaler_ctx);
  107. return 0;
  108. }
  109. encoder_codec_ctx->width = dst_width;
  110. encoder_codec_ctx->height = dst_height;
  111. - encoder_codec_ctx->pix_fmt = PIX_FMT_RGB24;
  112. + encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT;
  113. opts = NULL;
  114. if (avcodec_open2 (encoder_codec_ctx, encoder_codec, &opts) < 0)
  115. {
  116. @@ -263,10 +297,14 @@
  117. fprintf (stderr,
  118. "Failed to open the encoder\n");
  119. #endif
  120. - av_free (encoder_codec_ctx);
  121. + avcodec_free_context (&encoder_codec_ctx);
  122. av_free (encoder_output_buffer);
  123. av_free (dst_buffer);
  124. - av_free (dst_frame);
  125. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  126. + av_frame_free (&dst_frame);
  127. +#else
  128. + avcodec_free_frame (&dst_frame);
  129. +#endif
  130. sws_freeContext (scaler_ctx);
  131. return 0;
  132. }
  133. @@ -295,9 +333,13 @@
  134. cleanup:
  135. av_dict_free (&opts);
  136. avcodec_close (encoder_codec_ctx);
  137. - av_free (encoder_codec_ctx);
  138. + avcodec_free_context (&encoder_codec_ctx);
  139. av_free (dst_buffer);
  140. - av_free (dst_frame);
  141. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  142. + av_frame_free (&dst_frame);
  143. +#else
  144. + avcodec_free_frame (&dst_frame);
  145. +#endif
  146. sws_freeContext (scaler_ctx);
  147. *output_data = encoder_output_buffer;
  148. @@ -406,18 +448,23 @@
  149. fprintf (stderr,
  150. "Failed to open image codec\n");
  151. #endif
  152. - av_free (codec_ctx);
  153. + avcodec_free_context (&codec_ctx);
  154. return;
  155. }
  156. av_dict_free (&opts);
  157. - if (NULL == (frame = avcodec_alloc_frame ()))
  158. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  159. + frame = av_frame_alloc ();
  160. +#else
  161. + frame = avcodec_alloc_frame();
  162. +#endif
  163. + if (NULL == frame)
  164. {
  165. #if DEBUG
  166. fprintf (stderr,
  167. "Failed to allocate frame\n");
  168. #endif
  169. avcodec_close (codec_ctx);
  170. - av_free (codec_ctx);
  171. + avcodec_free_context (&codec_ctx);
  172. return;
  173. }
  174. @@ -441,9 +488,13 @@
  175. fprintf (stderr,
  176. "Failed to decode a complete frame\n");
  177. #endif
  178. - av_free (frame);
  179. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  180. + av_frame_free (&frame);
  181. +#else
  182. + avcodec_free_frame (&frame);
  183. +#endif
  184. avcodec_close (codec_ctx);
  185. - av_free (codec_ctx);
  186. + avcodec_free_context (&codec_ctx);
  187. return;
  188. }
  189. calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height,
  190. @@ -467,9 +518,13 @@
  191. err);
  192. av_free (encoded_thumbnail);
  193. }
  194. - av_free (frame);
  195. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  196. + av_frame_free (&frame);
  197. +#else
  198. + avcodec_free_frame (&frame);
  199. +#endif
  200. avcodec_close (codec_ctx);
  201. - av_free (codec_ctx);
  202. + avcodec_free_context (&codec_ctx);
  203. }
  204. @@ -563,7 +618,12 @@
  205. return;
  206. }
  207. - if (NULL == (frame = avcodec_alloc_frame ()))
  208. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  209. + frame = av_frame_alloc ();
  210. +#else
  211. + frame = avcodec_alloc_frame();
  212. +#endif
  213. + if (NULL == frame)
  214. {
  215. #if DEBUG
  216. fprintf (stderr,
  217. @@ -616,7 +676,11 @@
  218. fprintf (stderr,
  219. "Failed to decode a complete frame\n");
  220. #endif
  221. - av_free (frame);
  222. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  223. + av_frame_free (&frame);
  224. +#else
  225. + avcodec_free_frame (&frame);
  226. +#endif
  227. avcodec_close (codec_ctx);
  228. avformat_close_input (&format_ctx);
  229. av_free (io_ctx);
  230. @@ -643,7 +707,11 @@
  231. err);
  232. av_free (encoded_thumbnail);
  233. }
  234. - av_free (frame);
  235. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  236. + av_frame_free (&frame);
  237. +#else
  238. + avcodec_free_frame (&frame);
  239. +#endif
  240. avcodec_close (codec_ctx);
  241. avformat_close_input (&format_ctx);
  242. av_free (io_ctx);
  243. --- a/src/plugins/previewopus_extractor.c
  244. +++ b/src/plugins/previewopus_extractor.c
  245. @@ -296,7 +296,12 @@
  246. /** Initialize one audio frame for reading from the input file */
  247. static int init_input_frame(AVFrame **frame)
  248. {
  249. - if (!(*frame = avcodec_alloc_frame())) {
  250. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  251. + *frame = av_frame_alloc ();
  252. +#else
  253. + *frame = avcodec_alloc_frame();
  254. +#endif
  255. + if (NULL == *frame) {
  256. #if DEBUG
  257. fprintf(stderr, "Could not allocate input frame\n");
  258. #endif
  259. @@ -655,7 +660,11 @@
  260. av_freep(&converted_input_samples[0]);
  261. free(converted_input_samples);
  262. }
  263. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  264. + av_frame_free (&input_frame);
  265. +#else
  266. avcodec_free_frame(&input_frame);
  267. +#endif
  268. return ret;
  269. }
  270. @@ -671,7 +680,12 @@
  271. int error;
  272. /** Create a new frame to store the audio samples. */
  273. - if (!(*frame = avcodec_alloc_frame())) {
  274. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  275. + *frame = av_frame_alloc ();
  276. +#else
  277. + *frame = avcodec_alloc_frame();
  278. +#endif
  279. + if (NULL == *frame) {
  280. #if DEBUG
  281. fprintf(stderr, "Could not allocate output frame\n");
  282. #endif
  283. @@ -702,7 +716,11 @@
  284. #if DEBUG
  285. fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error));
  286. #endif
  287. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  288. + av_frame_free (frame);
  289. +#else
  290. avcodec_free_frame(frame);
  291. +#endif
  292. return error;
  293. }
  294. @@ -783,17 +801,29 @@
  295. #if DEBUG
  296. fprintf(stderr, "Could not read data from FIFO\n");
  297. #endif
  298. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  299. + av_frame_free (&output_frame);
  300. +#else
  301. avcodec_free_frame(&output_frame);
  302. +#endif
  303. return AVERROR_EXIT;
  304. }
  305. /** Encode one frame worth of audio samples. */
  306. if (encode_audio_frame(output_frame, output_format_context,
  307. output_codec_context, &data_written)) {
  308. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  309. + av_frame_free (&output_frame);
  310. +#else
  311. avcodec_free_frame(&output_frame);
  312. +#endif
  313. return AVERROR_EXIT;
  314. }
  315. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  316. + av_frame_free (&output_frame);
  317. +#else
  318. avcodec_free_frame(&output_frame);
  319. +#endif
  320. return 0;
  321. }
  322. /** Write the trailer of the output file container. */
  323. @@ -907,7 +937,12 @@
  324. return;
  325. }
  326. - if (NULL == (frame = avcodec_alloc_frame ()))
  327. +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
  328. + frame = av_frame_alloc ();
  329. +#else
  330. + frame = avcodec_alloc_frame();
  331. +#endif
  332. + if (NULL == frame)
  333. {
  334. #if DEBUG
  335. fprintf (stderr,