Description: Fix build against newer FFmpeg5
 in order to use LIBAVCODEC_VERSION_INT we must include libavcodec/version.h
 there are also some deprecation warning, which i got rid of
Author: IOhannes m zmölnig
Bug: <URL to the upstream bug report if any, implies patch has been forwarded, optional>
Last-Update: 2022-08-31
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- gmerlin-avdecoder.orig/include/avdec_private.h
+++ gmerlin-avdecoder/include/avdec_private.h
@@ -22,6 +22,7 @@
 #include "config.h"
 
 #include <avdec.h>
+#include <libavcodec/version.h>
 #include <gavl/gavf.h>
 #include <gavl/log.h>
 
--- gmerlin-avdecoder.orig/lib/demux_ffmpeg.c
+++ gmerlin-avdecoder/lib/demux_ffmpeg.c
@@ -82,7 +82,7 @@
 
 typedef struct
   {
-  AVInputFormat *avif;
+  const AVInputFormat *avif;
   AVFormatContext *avfc;
 #ifdef NEW_IO_API
 #define BUFFER_SIZE 1024 * 4
@@ -170,7 +170,7 @@
 
 /* Demuxer functions */
 
-static AVInputFormat * get_format(bgav_input_context_t * input)
+static const AVInputFormat * get_format(bgav_input_context_t * input)
   {
   uint8_t data[PROBE_SIZE];
   AVProbeData avpd;
@@ -189,7 +189,7 @@
 
 static int probe_ffmpeg(bgav_input_context_t * input)
   {
-  AVInputFormat * format;
+  const AVInputFormat * format;
   /* This sucks */
   format= get_format(input);
   
@@ -541,12 +541,22 @@
   if(!s->data.audio.block_align &&
      map->bits)
     {
-    s->data.audio.block_align = ((map->bits + 7) / 8) * params->channels;
+    s->data.audio.block_align = ((map->bits + 7) / 8) *
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 24, 100)
+            params->ch_layout.nb_channels;
+#else
+            params->channels;
+#endif
     }
   
   s->timescale = st->time_base.den;
   
-  s->data.audio.format->num_channels = params->channels;
+  s->data.audio.format->num_channels =
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 24, 100)
+            params->ch_layout.nb_channels;
+#else
+            params->channels;
+#endif
   s->data.audio.format->samplerate = params->sample_rate;
   
   bgav_stream_set_extradata(s, params->extradata, params->extradata_size);
@@ -827,7 +837,9 @@
   int i_tmp;
   uint32_t * pal_i;
 
-#if LIBAVCODEC_VERSION_MAJOR >= 54
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 130, 100)
+  size_t pal_i_len;
+#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 0, 0)
   int pal_i_len;
 #else
   const int pal_i_len = AVPALETTE_COUNT;
