git: cfdbf52043a2 - main - emulators/emu64: Fix build with ffmpeg 6
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 Mar 2023 15:31:56 UTC
The branch main has been updated by zirias: URL: https://cgit.FreeBSD.org/ports/commit/?id=cfdbf52043a2305d000bd30799b098b1b30afe28 commit cfdbf52043a2305d000bd30799b098b1b30afe28 Author: Felix Palmen <zirias@FreeBSD.org> AuthorDate: 2023-03-20 09:28:55 +0000 Commit: Felix Palmen <zirias@FreeBSD.org> CommitDate: 2023-03-20 15:31:28 +0000 emulators/emu64: Fix build with ffmpeg 6 While here, also add missing dependency on Qt5Network and switch from PORTVERSION to preferred DISTVERSION. PR: 270200 Approved by: tcberner (mentor) Differential Revision: https://reviews.freebsd.org/D39175 --- emulators/emu64/Makefile | 8 +-- emulators/emu64/files/patch-ffmpeg6 | 120 ++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 4 deletions(-) diff --git a/emulators/emu64/Makefile b/emulators/emu64/Makefile index 320aa792b7d7..0a8e610bbf3c 100644 --- a/emulators/emu64/Makefile +++ b/emulators/emu64/Makefile @@ -1,6 +1,6 @@ PORTNAME= emu64 -PORTVERSION= 5.0.19 -PORTREVISION= 2 +DISTVERSION= 5.0.19 +PORTREVISION= 3 CATEGORIES= emulators MAINTAINER= zirias@FreeBSD.org @@ -17,9 +17,9 @@ LIB_DEPENDS= libquazip1-qt5.so:archivers/quazip@qt5 \ USES= compiler:c++11-lang desktop-file-utils dos2unix gl pkgconfig \ qmake:outsource qt:5 sdl USE_GL= gl glu -USE_QT= core gui widgets buildtools:build linguisttools:build +USE_QT= core gui network widgets buildtools:build linguisttools:build -DOS2UNIX_FILES= src/widget_file_browse.h +DOS2UNIX_GLOB= *.cpp *.h USE_SDL= sdl2 image2 USE_GITHUB= yes diff --git a/emulators/emu64/files/patch-ffmpeg6 b/emulators/emu64/files/patch-ffmpeg6 new file mode 100644 index 000000000000..80f143f39389 --- /dev/null +++ b/emulators/emu64/files/patch-ffmpeg6 @@ -0,0 +1,120 @@ +From e09e645a88f37fa2a81d754cb9c86c4a584941a1 Mon Sep 17 00:00:00 2001 +From: Felix Palmen <felix@palmen-it.de> +Date: Mon, 20 Mar 2023 09:42:43 +0100 +Subject: [PATCH] Fix build with ffmpeg 6 + +This doesn't attempt to replace deprecated functions, it only replaces +functions that are gone (avcodec_encode_[audio|video]2) with +straight-forward replacement code. + +It fixes the build with the latest 6.0 release and still builds fine +with ffmpeg 4.4 +--- src/video_capture_class.cpp.orig 2021-07-08 16:55:15 UTC ++++ src/video_capture_class.cpp +@@ -87,7 +87,9 @@ bool VideoCaptureClass::StartCapture(const char *filen + + int ret; + ++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) + av_register_all(); ++#endif + + // + avformat_alloc_output_context2(&format_ctx, nullptr, nullptr, filename); +@@ -267,7 +269,7 @@ int VideoCaptureClass::GetRecordedFrameCount() + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +-void VideoCaptureClass::AddStream(OutputStream *ost, AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id) ++void VideoCaptureClass::AddStream(OutputStream *ost, AVFormatContext *oc, const AVCodec **codec, enum AVCodecID codec_id) + { + AVCodecContext *c; + int i; +@@ -363,7 +365,7 @@ void VideoCaptureClass::CloseStream(OutputStream *ost) + swr_free(&ost->swr_ctx); + } + +-bool VideoCaptureClass::OpenVideo(AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) ++bool VideoCaptureClass::OpenVideo(const AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) + { + int ret; + AVCodecContext *c = ost->enc; +@@ -431,7 +433,7 @@ AVFrame* VideoCaptureClass::AllocPicture(enum AVPixelF + return picture; + } + +-bool VideoCaptureClass::OpenAudio(AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) ++bool VideoCaptureClass::OpenAudio(const AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) + { + AVCodecContext *c; + int nb_samples; +@@ -532,7 +534,10 @@ int VideoCaptureClass::WriteVideoFrame(AVFormatContext + av_init_packet(&pkt); + + /* encode the image */ +- ret = avcodec_encode_video2(c, &pkt, frame, &got_packet); ++ ret = avcodec_receive_packet(c, &pkt); ++ if (ret == 0) got_packet = 1; ++ if (ret == AVERROR(EAGAIN)) ret = 0; ++ if (ret == 0) ret = avcodec_send_frame(c, frame); + if (ret < 0) + { + char err_msg[AV_ERROR_MAX_STRING_SIZE]; +@@ -562,7 +567,7 @@ int VideoCaptureClass::WriteAudioFrame(AVFormatContext + AVPacket pkt = {}; // data and size must be 0; + AVFrame *frame; + int64_t ret; +- int got_packet; ++ int got_packet = 0; + int64_t dst_nb_samples; + av_init_packet(&pkt); + c = ost->enc; +@@ -595,7 +600,10 @@ int VideoCaptureClass::WriteAudioFrame(AVFormatContext + frame->pts = av_rescale_q(ost->samples_count, AVRational{1, c->sample_rate}, c->time_base); + ost->samples_count += dst_nb_samples; + } +- ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet); ++ ret = avcodec_receive_packet(c, &pkt); ++ if (ret == 0) got_packet = 1; ++ if (ret == AVERROR(EAGAIN)) ret = 0; ++ if (ret == 0) ret = avcodec_send_frame(c, frame); + + if (ret < 0) + { +--- src/video_capture_class.h.orig 2021-07-08 16:55:15 UTC ++++ src/video_capture_class.h +@@ -31,6 +31,7 @@ using namespace std; + + extern "C" + { ++ #include <libavcodec/avcodec.h> + #include <libavutil/avassert.h> + #include <libavutil/channel_layout.h> + #include <libavutil/opt.h> +@@ -84,11 +85,11 @@ class VideoCaptureClass (public) + bool mutex_01; + + private: +- void AddStream(OutputStream *ost, AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id); ++ void AddStream(OutputStream *ost, AVFormatContext *oc, const AVCodec **codec, enum AVCodecID codec_id); + void CloseStream(OutputStream *ost); +- bool OpenVideo(AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg); ++ bool OpenVideo(const AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg); + AVFrame* AllocPicture(enum AVPixelFormat pix_fmt, int width, int height); +- bool OpenAudio(AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg); ++ bool OpenAudio(const AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg); + AVFrame* AllocAudioFrame(enum AVSampleFormat sample_fmt, uint64_t channel_layout, int sample_rate, int nb_samples); + int WriteFrame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt); + +@@ -110,9 +111,9 @@ class VideoCaptureClass (public) + int video_bitrate, audio_bitrate; + + +- AVOutputFormat *output_format; ++ const AVOutputFormat *output_format; + OutputStream audio_stream; +- AVCodec *video_codec, *audio_codec; ++ const AVCodec *video_codec, *audio_codec; + AVDictionary *options; + + uint8_t* source_video_data;