1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
From: Debian Multimedia Maintainers <debian-multimedia@lists.debian.org>
Date: Tue, 13 Aug 2024 09:45:27 +0200
Subject: Fix FTBFS with FFmpeg-5.0
Origin: Debian
Forwarded: no
Last-Update: 2022-02-15
Last-Update: 2022-02-15
---
plugins/ffmpeg/codec.c | 32 +++++++++++++++-----------------
plugins/ffmpeg/codecs.c | 14 +++-----------
plugins/ffmpeg/ffmpeg_common.c | 23 +++++++++++++++--------
plugins/ffmpeg/ffmpeg_common.h | 1 +
4 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/plugins/ffmpeg/codec.c b/plugins/ffmpeg/codec.c
index 9a63bfb..5686154 100644
--- a/plugins/ffmpeg/codec.c
+++ b/plugins/ffmpeg/codec.c
@@ -59,8 +59,15 @@ static int find_encoder(bg_ffmpeg_codec_context_t * ctx)
return 0;
}
- /* Set codec deftaults */
- avcodec_get_context_defaults3(ctx->avctx, ctx->codec);
+ /* Set codec defaults */
+ avcodec_free_context(&ctx->avctx);
+ if(!(ctx->avctx = avcodec_alloc_context3 (ctx->codec)))
+ {
+ gavl_log(GAVL_LOG_ERROR, LOG_DOMAIN,
+ "Context for Codec %s could not be initialized",
+ bg_ffmpeg_get_codec_name(ctx->id));
+ return 0;
+ }
return 1;
}
@@ -86,12 +93,13 @@ bg_ffmpeg_codec_context_t * bg_ffmpeg_codec_create(int type,
ret->type = type;
/* Create private codec context */
- ret->avctx_priv = avcodec_alloc_context3(NULL);
- ret->avctx = ret->avctx_priv;
+ ret->avctx_priv = NULL;
+ ret->avctx = NULL;
if(!find_encoder(ret))
{
- av_free(ret->avctx_priv);
+ if(ret->avctx)
+ avcodec_free_context(&ret->avctx);
free(ret);
return NULL;
}
@@ -826,20 +834,10 @@ void bg_ffmpeg_codec_destroy(bg_ffmpeg_codec_context_t * ctx)
if(!(ctx->flags & FLAG_FLUSHED))
bg_ffmpeg_codec_flush(ctx);
- /* Close */
-
- if(ctx->avctx->stats_in)
- {
- free(ctx->avctx->stats_in);
- ctx->avctx->stats_in = NULL;
- }
-// if(ctx->flags & FLAG_INITIALIZED)
- avcodec_close(ctx->avctx);
-
/* Destroy */
- if(ctx->avctx_priv)
- av_free(ctx->avctx_priv);
+ if(ctx->avctx)
+ avcodec_free_context(&ctx->avctx);
if(ctx->pc)
bg_encoder_pts_cache_destroy(ctx->pc);
diff --git a/plugins/ffmpeg/codecs.c b/plugins/ffmpeg/codecs.c
index 3f5c0e0..28547a5 100644
--- a/plugins/ffmpeg/codecs.c
+++ b/plugins/ffmpeg/codecs.c
@@ -26,6 +26,8 @@
#include <gmerlin/utils.h>
#include <gmerlin/translation.h>
#include <gmerlin/log.h>
+#include <libavutil/channel_layout.h>
+#include <libavutil/opt.h>
#define LOG_DOMAIN "ffmpeg.codecs"
@@ -1110,13 +1112,6 @@ typedef struct
} \
}
-static const enum_t prediction_method[] =
- {
- { "Left", FF_PRED_LEFT },
- { "Plane", FF_PRED_PLANE },
- { "Median", FF_PRED_MEDIAN }
- };
-
static const enum_t compare_func[] =
{
{ "SAD", FF_CMP_SAD },
@@ -1283,10 +1278,7 @@ bg_ffmpeg_set_codec_parameter(AVCodecContext * ctx,
if(!strcmp(name, "tga_rle"))
{
- if(val->v.i)
- ctx->coder_type = FF_CODER_TYPE_RLE;
- else
- ctx->coder_type = FF_CODER_TYPE_RAW;
+ av_opt_set_int(ctx->priv_data, "rle", !!(val->v.i), 0);
}
PARAM_DICT_STRING("libvpx_deadline", "deadline");
diff --git a/plugins/ffmpeg/ffmpeg_common.c b/plugins/ffmpeg/ffmpeg_common.c
index 6bb4181..e9365a6 100644
--- a/plugins/ffmpeg/ffmpeg_common.c
+++ b/plugins/ffmpeg/ffmpeg_common.c
@@ -242,6 +242,17 @@ static void set_chapters(AVFormatContext * ctx,
#endif
}
+static char*ffmpeg_string(char*instr)
+{
+ size_t len = strlen(instr);
+ char*outstr = av_malloc(len+1);
+ if(outstr) {
+ strcpy(outstr, instr);
+ outstr[len] = 0;
+ }
+ return outstr;
+}
+
static int ffmpeg_open(void * data, const char * filename,
gavf_io_t * io,
const gavl_dictionary_t * metadata)
@@ -270,8 +281,7 @@ static int ffmpeg_open(void * data, const char * filename,
priv->format->name);
return 0;
}
- strncpy(priv->ctx->filename,
- "pipe:", sizeof(priv->ctx->filename));
+ priv->ctx->url = ffmpeg_string("pipe:");
}
else
{
@@ -284,10 +294,7 @@ static int ffmpeg_open(void * data, const char * filename,
free(tmp_string);
return 0;
}
-
- strncpy(priv->ctx->filename,
- tmp_string, sizeof(priv->ctx->filename));
-
+ priv->ctx->url = ffmpeg_string(tmp_string);
free(tmp_string);
}
}
@@ -820,7 +827,7 @@ int bg_ffmpeg_start(void * data)
io_write,
gavf_io_can_seek(priv->io) ? io_seek : NULL);
}
- else if(avio_open(&priv->ctx->pb, priv->ctx->filename, AVIO_FLAG_WRITE) < 0)
+ else if(avio_open(&priv->ctx->pb, priv->ctx->url, AVIO_FLAG_WRITE) < 0)
return 0;
#if LIBAVFORMAT_VERSION_MAJOR < 54
@@ -956,7 +963,7 @@ int bg_ffmpeg_close(void * data, int do_delete)
}
if(do_delete && !priv->io)
- remove(priv->ctx->filename);
+ remove(priv->ctx->url);
if(priv->io_buffer)
av_free(priv->io_buffer);
diff --git a/plugins/ffmpeg/ffmpeg_common.h b/plugins/ffmpeg/ffmpeg_common.h
index 0fe7bba..718006c 100644
--- a/plugins/ffmpeg/ffmpeg_common.h
+++ b/plugins/ffmpeg/ffmpeg_common.h
@@ -22,6 +22,7 @@
#include <config.h>
#include <libavformat/avformat.h>
+#include <libavcodec/avcodec.h>
#include <gmerlin/plugin.h>
#include <gmerlin/pluginfuncs.h>
|