Bladeren bron

libobs, obs-ffmpeg, win-dshow: Fix FFmpeg 4.0 deprecation

Fixes FFmpeg 4.0 deprecation warnings.
jp9000 6 jaren geleden
bovenliggende
commit
68a5a40df9

+ 29 - 2
deps/libff/libff/ff-util.c

@@ -56,9 +56,11 @@ struct ff_codec_desc {
 
 void ff_init()
 {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	av_register_all();
 	//avdevice_register_all();
 	avcodec_register_all();
+#endif
 	avformat_network_init();
 }
 
@@ -101,11 +103,30 @@ static bool get_codecs(const AVCodecDescriptor ***descs, unsigned int *size)
 
 static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev)
 {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 9, 100)
+	const AVCodec *cur = NULL;
+	void *i = 0;
+	bool found_prev = false;
+
+	while ((cur = av_codec_iterate(&i)) != NULL) {
+		if (cur->id == id && av_codec_is_encoder(cur)) {
+			if (!prev) {
+				return cur;
+			} else if (!found_prev) {
+				if (cur == prev) {
+					found_prev = true;
+				}
+			} else {
+				return cur;
+			}
+		}
+	}
+#else
 	while ((prev = av_codec_next(prev)) != NULL) {
 		if (prev->id == id && av_codec_is_encoder(prev))
 			return prev;
 	}
-
+#endif
 	return NULL;
 }
 
@@ -286,11 +307,17 @@ static inline bool is_output_device(const AVClass *avclass)
 
 const struct ff_format_desc *ff_format_supported()
 {
-	AVOutputFormat *output_format = NULL;
+	const AVOutputFormat *output_format = NULL;
 	struct ff_format_desc *desc = NULL;
 	struct ff_format_desc *current = NULL;
 
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 9, 100)
+	void *i = 0;
+
+	while ((output_format = av_muxer_iterate(&i)) != NULL) {
+#else
 	while ((output_format = av_oformat_next(output_format)) != NULL) {
+#endif
 		struct ff_format_desc *d;
 		if (is_output_device(output_format->priv_class))
 			continue;

+ 3 - 1
deps/media-playback/media-playback/media.c

@@ -722,9 +722,11 @@ bool mp_media_init(mp_media_t *media, const struct mp_media_info *info)
 
 	static bool initialized = false;
 	if (!initialized) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 		av_register_all();
-		avdevice_register_all();
 		avcodec_register_all();
+#endif
+		avdevice_register_all();
 		avformat_network_init();
 		initialized = true;
 	}

+ 2 - 0
libobs/graphics/graphics-ffmpeg.c

@@ -202,7 +202,9 @@ fail:
 
 void gs_init_image_deps(void)
 {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	av_register_all();
+#endif
 }
 
 void gs_free_image_deps(void) {}

+ 2 - 0
libobs/media-io/media-remux.c

@@ -154,7 +154,9 @@ bool media_remux_job_create(media_remux_job_t *job, const char *in_filename,
 
 	init_size(*job, in_filename);
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	av_register_all();
+#endif
 
 	if (!init_input(*job, in_filename))
 		goto fail;

+ 2 - 0
plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c

@@ -566,7 +566,9 @@ static int ffmpeg_mux_init_internal(struct ffmpeg_mux *ffm, int argc,
 			calloc(1, sizeof(struct header) * ffm->params.tracks);
 	}
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	av_register_all();
+#endif
 
 	if (!ffmpeg_mux_get_extra_data(ffm))
 		return FFM_ERROR;

+ 2 - 0
plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c

@@ -190,7 +190,9 @@ static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder,
 	int bitrate = (int)obs_data_get_int(settings, "bitrate");
 	audio_t *audio = obs_encoder_audio(encoder);
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	avcodec_register_all();
+#endif
 
 	enc = bzalloc(sizeof(struct enc_encoder));
 	enc->encoder = encoder;

+ 2 - 0
plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c

@@ -265,7 +265,9 @@ static void *nvenc_create(obs_data_t *settings, obs_encoder_t *encoder)
 {
 	struct nvenc_encoder *enc;
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	avcodec_register_all();
+#endif
 
 	enc = bzalloc(sizeof(*enc));
 	enc->encoder = encoder;

+ 2 - 0
plugins/obs-ffmpeg/obs-ffmpeg-output.c

@@ -594,7 +594,9 @@ static bool ffmpeg_data_init(struct ffmpeg_data *data,
 	if (!config->url || !*config->url)
 		return false;
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	av_register_all();
+#endif
 	avformat_network_init();
 
 	is_rtmp = (astrcmpi_n(config->url, "rtmp://", 7) == 0);

+ 2 - 0
plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c

@@ -272,7 +272,9 @@ static void vaapi_destroy(void *data)
 static void *vaapi_create(obs_data_t *settings, obs_encoder_t *encoder)
 {
 	struct vaapi_encoder *enc;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	avcodec_register_all();
+#endif
 
 	enc = bzalloc(sizeof(*enc));
 	enc->encoder = encoder;

+ 2 - 0
plugins/obs-ffmpeg/obs-ffmpeg.c

@@ -147,7 +147,9 @@ extern bool load_nvenc_lib(void);
 
 static bool nvenc_supported(void)
 {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	av_register_all();
+#endif
 
 	profile_start(nvenc_check_name);
 

+ 2 - 0
plugins/win-dshow/ffmpeg-decode.c

@@ -73,7 +73,9 @@ int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id,
 {
 	int ret;
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
 	avcodec_register_all();
+#endif
 	memset(decode, 0, sizeof(*decode));
 
 	decode->codec = avcodec_find_decoder(id);