* Fix compatibility with libav9 (Closes: #720790)

Author: Moritz Muehlenhoff <jmm@debian.org>
Bug-Debian: http://bugs.debian.org/720790

--- forked-daapd-0.19gcd.orig/src/artwork.c
+++ forked-daapd-0.19gcd/src/artwork.c
@@ -138,7 +138,7 @@ artwork_rescale(AVFormatContext *src_ctx
       return -1;
     }
 
-  ret = avcodec_open(src, img_decoder);
+  ret = avcodec_open2(src, img_decoder, NULL);
   if (ret < 0)
     {
       DPRINTF(E_LOG, L_ART, "Could not open codec for decoding: %s\n", strerror(AVUNERROR(ret)));
@@ -211,7 +211,7 @@ artwork_rescale(AVFormatContext *src_ctx
     }
 #endif
 
-  dst_st = av_new_stream(dst_ctx, 0);
+  dst_st = avformat_new_stream(dst_ctx, NULL);
   if (!dst_st)
     {
       DPRINTF(E_LOG, L_ART, "Out of memory for new output stream\n");
@@ -222,11 +222,7 @@ artwork_rescale(AVFormatContext *src_ctx
 
   dst = dst_st->codec;
 
-#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64)
-  avcodec_get_context_defaults2(dst, AVMEDIA_TYPE_VIDEO);
-#else
-  avcodec_get_context_defaults2(dst, CODEC_TYPE_VIDEO);
-#endif
+  avcodec_get_context_defaults3(dst, NULL);
 
   if (dst_fmt->flags & AVFMT_GLOBALHEADER)
     dst->flags |= CODEC_FLAG_GLOBAL_HEADER;
@@ -276,7 +272,7 @@ artwork_rescale(AVFormatContext *src_ctx
 #endif
 
   /* Open encoder */
-  ret = avcodec_open(dst, img_encoder);
+  ret = avcodec_open2(dst, img_encoder, NULL);
   if (ret < 0)
     {
       DPRINTF(E_LOG, L_ART, "Could not open codec for encoding: %s\n", strerror(AVUNERROR(ret)));
@@ -519,7 +515,7 @@ artwork_get(char *filename, int max_w, i
       return -1;
     }
 
-  ret = av_find_stream_info(src_ctx);
+  ret = avformat_find_stream_info(src_ctx, NULL);
   if (ret < 0)
     {
       DPRINTF(E_WARN, L_ART, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret)));
--- forked-daapd-0.19gcd.orig/src/filescanner_ffmpeg.c
+++ forked-daapd-0.19gcd/src/filescanner_ffmpeg.c
@@ -341,7 +341,7 @@ scan_metadata_ffmpeg(char *file, struct
       return -1;
     }
 
-  ret = av_find_stream_info(ctx);
+  ret = avformat_find_stream_info(ctx, NULL);
   if (ret < 0)
     {
       DPRINTF(E_WARN, L_SCAN, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret)));
--- forked-daapd-0.19gcd.orig/src/main.c
+++ forked-daapd-0.19gcd/src/main.c
@@ -515,9 +515,6 @@ main(int argc, char **argv)
 
   DPRINTF(E_LOG, L_MAIN, "Forked Media Server Version %s taking off\n", VERSION);
 
-  /* Initialize ffmpeg */
-  avcodec_init();
-
   ret = av_lockmgr_register(ffmpeg_lockmgr);
   if (ret < 0)
     {
--- forked-daapd-0.19gcd.orig/src/transcode.c
+++ forked-daapd-0.19gcd/src/transcode.c
@@ -366,7 +366,7 @@ transcode_setup(struct media_file_info *
       return NULL;
     }
 
-  ret = av_find_stream_info(ctx->fmtctx);
+  ret = avformat_find_stream_info(ctx->fmtctx, NULL);
   if (ret < 0)
     {
       DPRINTF(E_WARN, L_XCODE, "Could not find stream info: %s\n", strerror(AVUNERROR(ret)));
@@ -409,7 +409,7 @@ transcode_setup(struct media_file_info *
   if (ctx->adecoder->capabilities & CODEC_CAP_TRUNCATED)
     ctx->acodec->flags |= CODEC_FLAG_TRUNCATED;
 
-  ret = avcodec_open(ctx->acodec, ctx->adecoder);
+  ret = avcodec_open2(ctx->acodec, ctx->adecoder, NULL);
   if (ret != 0)
     {
       DPRINTF(E_WARN, L_XCODE, "Could not open codec: %s\n", strerror(AVUNERROR(ret)));
@@ -425,7 +425,7 @@ transcode_setup(struct media_file_info *
       goto setup_fail_codec;
     }
 
-  if ((ctx->acodec->sample_fmt != SAMPLE_FMT_S16)
+  if ((ctx->acodec->sample_fmt != AV_SAMPLE_FMT_S16)
       || (ctx->acodec->channels != 2)
       || (ctx->acodec->sample_rate != 44100))
     {
@@ -433,7 +433,7 @@ transcode_setup(struct media_file_info *
 
       ctx->resample_ctx = av_audio_resample_init(2,              ctx->acodec->channels,
 						 44100,          ctx->acodec->sample_rate,
-						 SAMPLE_FMT_S16, ctx->acodec->sample_fmt,
+						 AV_SAMPLE_FMT_S16, ctx->acodec->sample_fmt,
 						 16, 10, 0, 0.8);
 
       if (!ctx->resample_ctx)
