From 3f33f33310a2c53bafeba45ff4d1616c251aa3ba Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sun, 12 Jan 2014 22:34:57 +0100 Subject: [PATCH] Add preprocessor macro FFMPEG_INCOMPATIBLE_API and use it, so we use avcodec_find_best_pix_fmt_of_list for ffmpeg. Also rearrange ffmpeg/libav libraries according to ffmpeg FAQ. --- configure.in | 9 ++++++--- src/artwork.c | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index ceabb49d..b36f6ce0 100644 --- a/configure.in +++ b/configure.in @@ -131,14 +131,17 @@ AC_LANG_POP([C]) LIBS="$save_LIBS" PKG_CHECK_EXISTS([libavresample], [ - PKG_CHECK_MODULES(LIBAV, [ libavcodec libavformat libswscale libavutil libavresample ]) + PKG_CHECK_MODULES(LIBAV, [ libavformat libavcodec libswscale libavresample libavutil ]) ], [ - PKG_CHECK_MODULES(LIBAV, [ libavcodec libavformat libswscale libavutil ]) + PKG_CHECK_MODULES(LIBAV, [ libavformat libavcodec libswscale libavutil ]) ]) -dnl Check for av_lock_manager (ffmpeg >= 0.5.1) save_LIBS="$LIBS" +dnl Check for av_lock_manager (ffmpeg >= 0.5.1) AC_CHECK_LIB([avcodec], [av_lockmgr_register], , AC_MSG_ERROR([libav (ffmpeg) >= 0.5.1 required])) +dnl Check for avcodec_find_best_pix_fmt_of_list (is only in ffmpeg, not libav) +AC_CHECK_LIB([avcodec], [avcodec_find_best_pix_fmt_of_list], + AC_DEFINE(FFMPEG_INCOMPATIBLE_API, 1, [Define to 1 if you have ffmpeg (and not libav).])) LIBS="$save_LIBS" # Check for libavformat >= 53; url -> avio switch diff --git a/src/artwork.c b/src/artwork.c index 57fe4718..b0ec29e9 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -293,7 +293,11 @@ artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int forma #endif #if LIBAVCODEC_VERSION_MAJOR >= 55 || (LIBAVCODEC_VERSION_MAJOR == 54 && LIBAVCODEC_VERSION_MINOR >= 35) +# ifndef FFMPEG_INCOMPATIBLE_API dst->pix_fmt = avcodec_find_best_pix_fmt2((enum AVPixelFormat *)img_encoder->pix_fmts, src->pix_fmt, 1, NULL); +# else + dst->pix_fmt = avcodec_find_best_pix_fmt_of_list((enum AVPixelFormat *)img_encoder->pix_fmts, src->pix_fmt, 1, NULL); +# endif #else const enum PixelFormat *pix_fmts; int64_t pix_fmt_mask = 0;