Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
Re: UPDATE: FFmpeg 6.1.1
To:
Brad Smith <brad@comstyle.com>, Landry Breuil <landry@openbsd.org>
Cc:
ports <ports@openbsd.org>
Date:
Sat, 16 Nov 2024 09:07:13 +0100

Download raw body.

Thread
On Wed Sep 25, 2024 at 08:16:14AM +0200, Rafael Sadowski wrote:
> 
> > 
> > > telephony/linphone/mediastreamer2
> 

Here is a patch from mediastreamer2

diff --git a/telephony/linphone/mediastreamer2/Makefile b/telephony/linphone/mediastreamer2/Makefile
index eb3147f0d65..a9fade0ab8f 100644
--- a/telephony/linphone/mediastreamer2/Makefile
+++ b/telephony/linphone/mediastreamer2/Makefile
@@ -1,4 +1,5 @@
 COMMENT =	streaming engine for voice/video telephony applications
+REVISION =	0
 
 MODULE =	mediastreamer2
 
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_utils_ffmpeg-priv_c b/telephony/linphone/mediastreamer2/patches/patch-src_utils_ffmpeg-priv_c
new file mode 100644
index 00000000000..6478ff566a6
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_utils_ffmpeg-priv_c
@@ -0,0 +1,47 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/utils/ffmpeg-priv.c
+--- src/utils/ffmpeg-priv.c.orig
++++ src/utils/ffmpeg-priv.c
+@@ -23,29 +23,22 @@
+ 
+ #ifndef HAVE_FUN_avcodec_encode_video2
+ int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) {
+-	int error = avcodec_encode_video(avctx, avpkt->data, avpkt->size, frame);
+-	if (error < 0) {
+-		return error;
+-	} else {
+-		if (error > 0) {
+-			*got_packet_ptr = 1;
+-			avpkt->size = error;
+-		} else *got_packet_ptr = 0;
+-	}
+-	return 0;
+-}
+-#endif
++    int ret;
+ 
+-#ifndef HAVE_FUN_avcodec_get_context_defaults3 /**/
+-int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) {
+-	avcodec_get_context_defaults(s);
+-	return 0;
+-}
++    *got_packet_ptr = 0;
++ 
++    ret = avcodec_send_frame(avctx, frame);
++    if (ret < 0)
++        return ret;
+ 
+-AVCodecContext *avcodec_alloc_context3(AVCodec *codec) {
+-	return avcodec_alloc_context();
+-}
++    ret = avcodec_receive_packet(avctx, avpkt);
++    if (!ret)
++        *got_packet_ptr = 1;
++    if (ret == AVERROR(EAGAIN))
++        return 0;
+ 
++    return ret;
++}
+ #endif
+ 
+ #ifndef HAVE_FUN_avcodec_open2 /**/
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_utils_ffmpeg-priv_h b/telephony/linphone/mediastreamer2/patches/patch-src_utils_ffmpeg-priv_h
new file mode 100644
index 00000000000..850b015304c
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_utils_ffmpeg-priv_h
@@ -0,0 +1,46 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/utils/ffmpeg-priv.h
+--- src/utils/ffmpeg-priv.h.orig
++++ src/utils/ffmpeg-priv.h
+@@ -76,6 +76,29 @@ static inline int
+ avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) {
+ 	return avcodec_decode_video(avctx, picture, got_picture_ptr, avpkt->data, avpkt->size);
+ }
++#else
++static inline int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
++{
++    int ret;
++
++    *got_frame = 0;
++
++    if (pkt) {
++        ret = avcodec_send_packet(avctx, pkt);
++        // In particular, we don't expect AVERROR(EAGAIN), because we read all
++        // decoded frames with avcodec_receive_frame() until done.
++        if (ret < 0)
++            return ret == AVERROR_EOF ? 0 : ret;
++    }
++
++    ret = avcodec_receive_frame(avctx, frame);
++    if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
++        return ret;
++    if (ret >= 0)
++        *got_frame = 1;
++
++    return 0;
++}
+ #endif
+ #if HAVE_AVCODEC_OLD_CODEC_IDS
+ #include <libavcodec/old_codec_ids.h>
+@@ -114,11 +137,6 @@ extern "C" {
+ 
+ #ifndef HAVE_FUN_avcodec_encode_video2
+ int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr);
+-#endif
+-
+-#ifndef HAVE_FUN_avcodec_get_context_defaults3 /**/
+-int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
+-AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
+ #endif
+ 
+ #ifndef HAVE_FUN_avcodec_open2 /**/
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_utils_jpgloader-ffmpeg_c b/telephony/linphone/mediastreamer2/patches/patch-src_utils_jpgloader-ffmpeg_c
new file mode 100644
index 00000000000..e22eddcec0f
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_utils_jpgloader-ffmpeg_c
@@ -0,0 +1,12 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/utils/jpgloader-ffmpeg.c
+--- src/utils/jpgloader-ffmpeg.c.orig
++++ src/utils/jpgloader-ffmpeg.c
+@@ -76,7 +76,6 @@ mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideo
+ 		return NULL;
+ 	}
+ 
+-	avcodec_get_context_defaults3(&av_context, NULL);
+ 	if (avcodec_open2(&av_context, codec, NULL) < 0) {
+ 		ms_error("jpeg2yuv: avcodec_open failed");
+ 		return NULL;
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_ffmpegjpegwriter_c b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_ffmpegjpegwriter_c
new file mode 100644
index 00000000000..f84c78a8e9e
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_ffmpegjpegwriter_c
@@ -0,0 +1,13 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/videofilters/ffmpegjpegwriter.c
+--- src/videofilters/ffmpegjpegwriter.c.orig
++++ src/videofilters/ffmpegjpegwriter.c
+@@ -190,7 +190,7 @@ static void jpg_process_frame_task(void *obj) {
+ 		sws_freeContext(sws_ctx);
+ 
+ 		av_frame_unref(s->pict);
+-		avpicture_fill((AVPicture *)s->pict, (uint8_t *)jpegm->b_rptr, avctx->pix_fmt, avctx->width, avctx->height);
++    av_image_fill_arrays(s->pict->data,s->pict->linesize,(uint8_t*)jpegm->b_rptr,avctx->pix_fmt,avctx->width,avctx->height, 1);
+ 		packet.data = comp_buf;
+ 		packet.size = (int)comp_buf_sz;
+ 		packet.pts = frame_ts;
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_h264dec_cpp b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_h264dec_cpp
new file mode 100644
index 00000000000..f9f105dc156
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_h264dec_cpp
@@ -0,0 +1,32 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/videofilters/h264dec.cpp
+--- src/videofilters/h264dec.cpp.orig
++++ src/videofilters/h264dec.cpp
+@@ -66,17 +66,15 @@ typedef struct _DecData {
+ static void ffmpeg_init(void) {
+ 	static bool_t done = FALSE;
+ 	if (!done) {
+-		avcodec_register_all();
+ 		done = TRUE;
+ 	}
+ }
+ 
+ static void dec_open(DecData *d) {
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	int error;
+ 	codec = avcodec_find_decoder(CODEC_ID_H264);
+ 	if (codec == NULL) ms_fatal("Could not find H264 decoder in ffmpeg.");
+-	avcodec_get_context_defaults3(&d->av_context, NULL);
+ 	error = avcodec_open2(&d->av_context, codec, NULL);
+ 	if (error != 0) {
+ 		ms_fatal("avcodec_open() failed.");
+@@ -162,7 +160,7 @@ static mblk_t *get_as_yuvmsg(MSFilter *f, DecData *s, 
+ 		ms_error("%s: error in sws_scale().", f->desc->name);
+ 	}
+ #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(50, 43, 0) // backward compatibility with Debian Squeeze (6.0)
+-	mblk_set_timestamp_info(yuv_msg, (uint32_t)orig->pkt_pts);
++  mblk_set_timestamp_info(yuv_msg, (uint32_t)orig->pts);
+ #endif
+ 	return yuv_msg;
+ }
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_videodec_c b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_videodec_c
new file mode 100644
index 00000000000..3590250afa6
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_videodec_c
@@ -0,0 +1,21 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/videofilters/videodec.c
+--- src/videofilters/videodec.c.orig
++++ src/videofilters/videodec.c
+@@ -67,7 +67,6 @@ static void dec_init(MSFilter *f, enum CodecID cid) {
+ 	DecState *s = (DecState *)ms_new0(DecState, 1);
+ 	ms_ffmpeg_check_init();
+ 
+-	avcodec_get_context_defaults3(&s->av_context, NULL);
+ 	s->allocator = ms_yuv_buf_allocator_new();
+ 	s->av_codec = NULL;
+ 	s->codec = cid;
+@@ -591,7 +590,7 @@ static mblk_t *get_as_yuvmsg(MSFilter *f, DecState *s,
+ #endif
+ 		ms_error("%s: error in ms_sws_scale().", f->desc->name);
+ 	}
+-	mblk_set_timestamp_info(yuv_msg, (uint32_t)orig->pkt_pts);
++	mblk_set_timestamp_info(yuv_msg, (uint32_t)orig->pts);
+ 	return yuv_msg;
+ }
+ /* Bitmasks to select bits of a byte from low side */
diff --git a/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_videoenc_c b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_videoenc_c
new file mode 100644
index 00000000000..bec676955a7
--- /dev/null
+++ b/telephony/linphone/mediastreamer2/patches/patch-src_videofilters_videoenc_c
@@ -0,0 +1,37 @@
+https://build.opensuse.org/projects/openSUSE:Factory/packages/mediastreamer2/files/fix-build-ffmpeg5.patch
+Index: src/videofilters/videoenc.c
+--- src/videofilters/videoenc.c.orig
++++ src/videofilters/videoenc.c
+@@ -109,7 +109,6 @@ void ms_ffmpeg_log_callback(void *ptr, int level, cons
+ 
+ void ms_ffmpeg_check_init() {
+ 	if (!avcodec_initialized) {
+-		avcodec_register_all();
+ 		avcodec_initialized = TRUE;
+ #ifdef ENABLE_LOG_FFMPEG
+ 		av_log_set_level(AV_LOG_WARNING);
+@@ -250,7 +249,6 @@ static void prepare(EncState *s) {
+ 	AVCodecContext *c = &s->av_context;
+ 	const int max_br_vbv = 128000;
+ 
+-	avcodec_get_context_defaults3(c, NULL);
+ 	if (s->codec == CODEC_ID_MJPEG) {
+ 		ms_message("Codec bitrate set to %i", (int)c->bit_rate);
+ 		c->width = s->vconf.vsize.width;
+@@ -312,7 +310,6 @@ static void prepare_h263(EncState *s) {
+ #if LIBAVCODEC_VERSION_INT < ((52 << 16) + (0 << 8) + 0)
+ 	c->rtp_mode = 1;
+ #endif
+-	c->rtp_payload_size = s->mtu / 2;
+ 	if (s->profile == 0) {
+ 		s->codec = CODEC_ID_H263;
+ 	} else {
+@@ -787,7 +784,7 @@ static void process_frame(MSFilter *f, mblk_t *inm) {
+ 	ms_yuv_buf_init_from_mblk(&yuv, inm);
+ 	/* convert image if necessary */
+ 	av_frame_unref(s->pict);
+-	avpicture_fill((AVPicture *)s->pict, yuv.planes[0], c->pix_fmt, c->width, c->height);
++  av_image_fill_arrays(s->pict->data,s->pict->linesize,yuv.planes[0],c->pix_fmt,c->width,c->height,1);
+ 
+ 	/* timestamp used by ffmpeg, unset here */
+ 	s->pict->pts = AV_NOPTS_VALUE;