On Thursday, April 7, 2022, Andrea paz via Cin <[email protected]>
wrote:

> I changed the ram and now the build (and other problems) are gone. I
> compiled from git and tried loading a dpx sequence with the internal
> engine and it works without any problems. I created a dpx render with
> "ffmpeg first" and it works. This render loads in CinGG with both
> "ffmpeg first" and the internal engine.
> I've fallen behind on the mailing list, though. Are there any patches
> to test? Tests to run? (no termux or ppc64 patches, please!)


try  ffmpeg5 series? (i developing it slowly on termux, because its rolling
distro model forces me to adapt..)

https://lists.cinelerra-gg.org/pipermail/cin/2022-April/004861.html

most likely 0004 and 0006 from this email, and i lately added conditional
compilation around so it should work with both embedded ffmpeg 4.4 and
external 4.4/5.0

hopefully attached patches should be enough for making it work on top of
git.


I am glad replacing ram fixed your machine!


-- 
> Cin mailing list
> [email protected]
> https://lists.cinelerra-gg.org/mailman/listinfo/cin
>
From 904a646a881087f4205a29a126abdabf3c3f90ac Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 2 Apr 2022 16:26:36 +0300
Subject: [PATCH 44/71] experimental: switch python in guicast to python3
 unconditionally

---
 cinelerra-5.1/guicast/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cinelerra-5.1/guicast/Makefile b/cinelerra-5.1/guicast/Makefile
index 57cfb21f..8bc4633e 100644
--- a/cinelerra-5.1/guicast/Makefile
+++ b/cinelerra-5.1/guicast/Makefile
@@ -104,7 +104,7 @@ $(shell echo $(OBJS) > $(OBJDIR)/objs)
 all: $(OUTPUT) $(UTILS)
 
 $(BCXFER):	bccmdl.py bcxfer.C bcxfer.h
-	python < ./bccmdl.py
+	python3 < ./bccmdl.py
 	+$(MAKE) -C xfer
 
 $(OUTPUT): $(OBJS) $(BCXFER)
-- 
2.35.1

From d0bdc181a0e48adb06cb50e839f230ccafe9bbd6 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 2 Apr 2022 16:28:57 +0300
Subject: [PATCH 45/71] Add android-only hacked Dynamic makefile libs

---
 cinelerra-5.1/cinelerra/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index 1503b6d4..9962b681 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -441,6 +441,15 @@ LIBS += -lintl -liconv
 LIBS += -lexecinfo
 endif
 LIBS += `pkg-config --libs OpenEXR`
+LIBS += `pkg-config --libs flac`
+LIBS += `pkg-config --libs libjpeg`
+LIBS += `pkg-config --libs uuid`
+LIBS += `pkg-config --libs theora`
+LIBS += `pkg-config --libs vorbis`
+LIBS += `pkg-config --libs tiff`
+LIBS += `pkg-config --libs sndfile`
+LIBS += -lgif -l:libtheora.a -l:libvorbis.a -ltiff 
+LIBS += -landroid-shmem -liconv jpt.a
 LIBS += $(shared_libs)
 LIBS += $(system_libs)
 else
-- 
2.35.1

From 9eb856af1a0cb37179f5d5eda657e90b68b5bef4 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 2 Apr 2022 16:32:21 +0300
Subject: [PATCH 48/71] Dynamic termux configure

---
 cinelerra-5.1/termux_dyn.sh | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100755 cinelerra-5.1/termux_dyn.sh

diff --git a/cinelerra-5.1/termux_dyn.sh b/cinelerra-5.1/termux_dyn.sh
new file mode 100755
index 00000000..5e5d35b8
--- /dev/null
+++ b/cinelerra-5.1/termux_dyn.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+./configure --with-single-user --without-thirdparty \
+    --without-dvb --without-video4linux2 --without-dv \
+    --without-firewire --without-libzmpeg --without-vaapi \
+    --without-vdpau --without-lv2 --without-openexr --without-ogg \
+    --without-gl
-- 
2.35.1

From 9740011fd34713476cc0c708c639e97d10f9b701 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 22:19:13 +0300
Subject: [PATCH 39/71] pkg-config based dynamic openexr link fix for
 freebsdv13

---
 cinelerra-5.1/cinelerra/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index 1c10fc03..1d93305d 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -437,7 +437,7 @@ LIBS += -lavcodec -lavdevice -lavfilter -lavformat -lavutil
 LIBS += -lswresample -lswscale
 LIBS += -lintl -liconv
 LIBS += -lexecinfo
-
+LIBS += `pkg-config --libs OpenEXR`
 LIBS += $(shared_libs)
 LIBS += $(system_libs)
 else
-- 
2.35.1

From 8e54afcc4865e53c2ed270d33e9fc82da1177c60 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sun, 3 Apr 2022 01:17:11 +0300
Subject: [PATCH 51/71] Hopefully  fix dyn liba52  on termux

---
 cinelerra-5.1/configure.ac       | 2 +-
 cinelerra-5.1/libzmpeg3/Makefile | 5 ++++-
 cinelerra-5.1/mpeg2enc/Makefile  | 7 +++++++
 cinelerra-5.1/mplexlo/Makefile   | 7 +++++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index 7481d411..147a69de 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -28,7 +28,7 @@ CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS"
 CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS"
 CFG_CFLAGS+=" -DPNG_SKIP_SETJMP_CHECK=1"
 CFG_CFLAGS+=" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
-CFG_CFLAGS+=" -I/usr/include -I/usr/local/include"
+CFG_CFLAGS+=" -I/usr/include -I/usr/local/include -I/data/data/com.termux/files/usr/include/a52dec"
 CFG_CFLAGS+=" -I/usr/include/freetype2 -I/usr/local/include/freetype2"
 CFG_CFLAGS+=" -I/data/data/com.termux/files/usr/include/freetype2"
 CFG_CFLAGS+=" -I/usr/include/uuid -I/usr/local/include/uuid"
diff --git a/cinelerra-5.1/libzmpeg3/Makefile b/cinelerra-5.1/libzmpeg3/Makefile
index 1e59d36f..c5b8a083 100644
--- a/cinelerra-5.1/libzmpeg3/Makefile
+++ b/cinelerra-5.1/libzmpeg3/Makefile
@@ -79,9 +79,12 @@ UTILS += $(OBJDIR)/zmpeg3ifochk
 UTILS += $(OBJDIR)/zmpeg3cc2txt
 
 LIBS = -lm -lpthread
-ifeq ($(WITH_THIRDPARTY),no)
+ifeq ($(WANT_CIN_3RDPARTY),no)
 LIBS += -la52
 endif
+ifeq ($(shell uname -o), Android)
+LIBS += jpt.a
+endif
 
 LIBS += $(lib_a52dec) $(lib_djbfft) $(lib_libbthread)
 
diff --git a/cinelerra-5.1/mpeg2enc/Makefile b/cinelerra-5.1/mpeg2enc/Makefile
index 80e0f8f9..bab267cf 100644
--- a/cinelerra-5.1/mpeg2enc/Makefile
+++ b/cinelerra-5.1/mpeg2enc/Makefile
@@ -56,6 +56,13 @@ OBJ = \
 LIBS := $(LIBZMPEG3)/$(OBJDIR)/libzmpeg3.a
 LIBS += $(libraries)
 
+ifeq ($(WANT_CIN_3RDPARTY),no)
+LIBS += -la52
+endif
+ifeq ($(shell uname -o), Android)
+LIBS += jpt.a
+endif
+
 HVEG2LIB = $(OBJDIR)/hveg2enc.a
 HVEG2ENC = $(OBJDIR)/hveg2enc
 HVEG2ENC_G = $(OBJDIR)/hveg2enc_g
diff --git a/cinelerra-5.1/mplexlo/Makefile b/cinelerra-5.1/mplexlo/Makefile
index c1a8aae8..66126523 100644
--- a/cinelerra-5.1/mplexlo/Makefile
+++ b/cinelerra-5.1/mplexlo/Makefile
@@ -13,6 +13,13 @@ CFLAGS += $(static_incs)
 LIBS := $(LIBZMPEG3)/$(OBJDIR)/libzmpeg3.a
 LIBS += $(libraries)
 
+ifeq ($(WANT_CIN_3RDPARTY),no)
+LIBS += -la52
+endif
+ifeq ($(shell uname -o), Android)
+LIBS += jpt.a
+endif
+
 OUTPUT := $(OBJDIR)/mplexlo
 
 $(OUTPUT) all: $(OBJS)
-- 
2.35.1

From eca1b4912f190d28f6a5be7442a5e08dcfb78df5 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 2 Apr 2022 23:55:20 +0300
Subject: [PATCH 50/71] Cinelerra/Makefile dynamic section fix for non-android,
 i hope

---
 cinelerra-5.1/cinelerra/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index 9962b681..b559e4f5 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -446,10 +446,11 @@ LIBS += `pkg-config --libs libjpeg`
 LIBS += `pkg-config --libs uuid`
 LIBS += `pkg-config --libs theora`
 LIBS += `pkg-config --libs vorbis`
-LIBS += `pkg-config --libs tiff`
 LIBS += `pkg-config --libs sndfile`
 LIBS += -lgif -l:libtheora.a -l:libvorbis.a -ltiff 
+ifeq ($(shell uname -o), Android)
 LIBS += -landroid-shmem -liconv jpt.a
+endif
 LIBS += $(shared_libs)
 LIBS += $(system_libs)
 else
-- 
2.35.1

From 1bbb900418a2334a787e46992bf868a774a8c2c3 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 2 Apr 2022 16:29:57 +0300
Subject: [PATCH 46/71] Make cin compile with ffmpeg 5 (unconditionally)

---
 cinelerra-5.1/cinelerra/bdwrite.C |  4 ++--
 cinelerra-5.1/cinelerra/ffmpeg.C  | 39 ++++++++++++++++++-------------
 cinelerra-5.1/cinelerra/ffmpeg.h  |  7 +++---
 3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index 4dd5cc37..57966ead 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -2530,7 +2530,7 @@ static int field_probe(AVFormatContext *fmt_ctx, AVStream *st)
   AVDictionary *copts = 0;
   //av_dict_copy(&copts, opts, 0);
   AVCodecID codec_id = st->codecpar->codec_id;
-  AVCodec *decoder = avcodec_find_decoder(codec_id);
+  const AVCodec *decoder = avcodec_find_decoder(codec_id);
   AVCodecContext *ctx = avcodec_alloc_context3(decoder);
   if( !ctx ) {
     fprintf(stderr,"codec alloc failed\n");
@@ -2604,7 +2604,7 @@ int media_info::scan()
     stream *s = new stream(type, i);
     s->pid = st->id;
     AVCodecID codec_id = st->codecpar->codec_id;
-    AVCodec *decoder = avcodec_find_decoder(codec_id);
+    const AVCodec *decoder = avcodec_find_decoder(codec_id);
     s->ctx = avcodec_alloc_context3(decoder);
     if( !s->ctx ) {
       fprintf(stderr, "avcodec_alloc_context failed\n");
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 3655d643..294343fb 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -381,7 +381,7 @@ AVHWDeviceType FFStream::decode_hw_activate()
 	return AV_HWDEVICE_TYPE_NONE;
 }
 
-int FFStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type)
+int FFStream::decode_hw_format(const AVCodec *decoder, AVHWDeviceType type)
 {
 	return 0;
 }
@@ -406,7 +406,7 @@ int FFStream::decode_activate()
 		}
 		while( ret >= 0 && st != 0 && !reading ) {
 			AVCodecID codec_id = st->codecpar->codec_id;
-			AVCodec *decoder = 0;
+			const AVCodec *decoder = 0;
 			if( is_video() ) {
 				if( ffmpeg->opt_video_decoder )
 					decoder = avcodec_find_decoder_by_name(ffmpeg->opt_video_decoder);
@@ -722,10 +722,11 @@ int FFStream::seek(int64_t no, double rate)
 	double secs = pos < 0 ? 0. : pos / rate;
 	AVRational time_base = st->time_base;
 	int64_t tstmp = time_base.num > 0 ? secs * time_base.den/time_base.num : 0;
+	int nb_index_entries = avformat_index_get_entries_count(st);
 	if( !tstmp ) {
-		if( st->nb_index_entries > 0 ) tstmp = st->index_entries[0].timestamp;
+		if( nb_index_entries > 0 ) tstmp = (avformat_index_get_entry(st, 0))->timestamp;
 		else if( st->start_time != AV_NOPTS_VALUE ) tstmp = st->start_time;
-		else if( st->first_dts != AV_NOPTS_VALUE ) tstmp = st->first_dts;
+		/* else if( st->first_dts != AV_NOPTS_VALUE ) tstmp = st->first_dts; */
 		else tstmp = INT64_MIN+1;
 	}
 	else if( nudge != AV_NOPTS_VALUE ) tstmp += nudge;
@@ -1850,7 +1851,7 @@ FFMPEG::~FFMPEG()
 	delete [] opt_hw_dev;
 }
 
-int FFMPEG::check_sample_rate(AVCodec *codec, int sample_rate)
+int FFMPEG::check_sample_rate(const AVCodec *codec, int sample_rate)
 {
 	const int *p = codec->supported_samplerates;
 	if( !p ) return sample_rate;
@@ -2100,7 +2101,7 @@ void FFMPEG::scan_audio_options(Asset *asset, EDL *edl)
 		cin_fmt = (int)av_get_sample_fmt(cin_sample_fmt);
 	if( cin_fmt < 0 ) {
 		char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
-		AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", asset->acodec) ?
+		const AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", asset->acodec) ?
 			avcodec_find_encoder_by_name(audio_codec) : 0;
 		if( av_codec && av_codec->sample_fmts )
 			cin_fmt = find_best_sample_fmt_of_list(av_codec->sample_fmts, AV_SAMPLE_FMT_FLT);
@@ -2136,7 +2137,7 @@ void FFMPEG::scan_video_options(Asset *asset, EDL *edl)
 			cin_fmt = (int)av_get_pix_fmt(cin_pix_fmt);
 	if( cin_fmt < 0 ) {
 		char video_codec[BCSTRLEN];  video_codec[0] = 0;
-		AVCodec *av_codec = !get_codec(video_codec, "video", asset->vcodec) ?
+		const AVCodec *av_codec = !get_codec(video_codec, "video", asset->vcodec) ?
 			avcodec_find_encoder_by_name(video_codec) : 0;
 		if( av_codec && av_codec->pix_fmts ) {
 			if( 0 && edl ) { // frequently picks a bad answer
@@ -2331,9 +2332,9 @@ int FFCodecRemaps::add(const char *val)
 }
 
 
-int FFCodecRemaps::update(AVCodecID &codec_id, AVCodec *&decoder)
+int FFCodecRemaps::update(AVCodecID &codec_id, const AVCodec *&decoder)
 {
-	AVCodec *codec = avcodec_find_decoder(codec_id);
+	const AVCodec *codec = avcodec_find_decoder(codec_id);
 	if( !codec ) return -1;
 	const char *name = codec->name;
 	FFCodecRemaps &map = *this;
@@ -2553,7 +2554,7 @@ int FFMPEG::init_decoder(const char *filename)
 	char *sp = strrchr(bp, '.');
 	if( !sp ) sp = bp + strlen(bp);
 	FILE *fp = 0;
-	AVInputFormat *ifmt = 0;
+	const AVInputFormat *ifmt = 0;
 	if( sp ) {
 		strcpy(sp, ".opts");
 		fp = fopen(file_opts, "r");
@@ -2774,7 +2775,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 	AVCodecContext *ctx = 0;
 
 	const AVCodecDescriptor *codec_desc = 0;
-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
+	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
 	if( !codec ) {
 		eprintf(_("cant find codec %s:%s\n"), codec_name, filename);
 		ret = 1;
@@ -3027,7 +3028,12 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 		}
 		if( ret >= 0 ) {
 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-			ret = avcodec_copy_context(st->codec, ctx);
+			//ret = avcodec_copy_context(st->codec, ctx);
+			//AVCodecContext *codec_ctx = avcodec_alloc_context3(ctx);
+			ret = avcodec_parameters_to_context(ctx, st->codecpar);
+			// if (ret < 0)
+			//	fprintf(stderr, "could not copy codecpar to tmp codec_ctx\n");
+			//ret = avcodec_parameters_from_context(codec_ctx, 
 _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
 			if( ret < 0 )
 				fprintf(stderr, "Could not copy the stream context\n");
@@ -3672,7 +3678,7 @@ Preferences *FFMPEG::ff_prefs()
 
 double FFVideoStream::get_rotation_angle()
 {
-	int size = 0;
+	size_t size = 0;
 	int *matrix = (int*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, &size);
 	int len = size/sizeof(*matrix);
 	if( !matrix || len < 5 ) return 0;
@@ -3897,7 +3903,7 @@ AVCodecContext *FFMPEG::activate_decoder(AVStream *st)
 	AVDictionary *copts = 0;
 	av_dict_copy(&copts, opts, 0);
 	AVCodecID codec_id = st->codecpar->codec_id;
-	AVCodec *decoder = 0;
+	const AVCodec *decoder = 0;
 	switch( st->codecpar->codec_type ) {
 	case AVMEDIA_TYPE_VIDEO:
 		if( opt_video_decoder )
@@ -4089,10 +4095,11 @@ void FFStream::load_markers(IndexMarks &marks, double rate)
 	int in = 0;
 	int64_t sz = marks.size();
 	int max_entries = fmt_ctx->max_index_size / sizeof(AVIndexEntry) - 1;
-	int nb_ent = st->nb_index_entries;
+	int nb_ent = avformat_index_get_entries_count(st);
 // some formats already have an index
 	if( nb_ent > 0 ) {
-		AVIndexEntry *ep = &st->index_entries[nb_ent-1];
+		// AVIndexEntry *ep = &st->index_entries[nb_ent-1];
+		const AVIndexEntry *ep = avformat_index_get_entry(st, nb_ent-1);
 		int64_t tstmp = ep->timestamp;
 		if( nudge != AV_NOPTS_VALUE ) tstmp -= nudge;
 		double secs = ffmpeg->to_secs(tstmp, st->time_base);
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h
index 4f1624ce..6c7d68e0 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.h
+++ b/cinelerra-5.1/cinelerra/ffmpeg.h
@@ -25,6 +25,7 @@
 #include "vframe.inc"
 
 extern "C" {
+#include "libavcodec/bsf.h"
 #include "libavformat/avformat.h"
 #include "libavformat/avio.h"
 #include "libavcodec/avcodec.h"
@@ -86,7 +87,7 @@ public:
 	virtual int encode_activate();
 	virtual int decode_activate();
 	virtual AVHWDeviceType decode_hw_activate();
-	virtual int decode_hw_format(AVCodec *decoder, AVHWDeviceType type);
+	virtual int decode_hw_format(const AVCodec *decoder, AVHWDeviceType type);
 	virtual int write_packet(FFPacket &pkt);
 	int read_packet();
 	int seek(int64_t no, double rate);
@@ -290,7 +291,7 @@ class FFCodecRemaps : public ArrayList<FFCodecRemap>
 public:
 	FFCodecRemaps() {}
 	int add(const char *val);
-	int update(AVCodecID &codec_id, AVCodec *&decoder);
+	int update(AVCodecID &codec_id, const AVCodec *&decoder);
 };
 
 // for get_initial_timecode auto deletes
@@ -331,7 +332,7 @@ public:
 	static void ff_lock(const char *cp=0) { fflock.lock(cp); }
 	static void ff_unlock() { fflock.unlock(); }
 
-	int check_sample_rate(AVCodec *codec, int sample_rate);
+	int check_sample_rate(const AVCodec *codec, int sample_rate);
 	AVRational check_frame_rate(const AVRational *p, double frame_rate);
 	AVRational to_sample_aspect_ratio(Asset *asset);
 	AVRational to_time_base(int sample_rate);
-- 
2.35.1

From fbb73777afcfa098bda3a16d424ac89180c03488 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 2 Apr 2022 23:52:45 +0300
Subject: [PATCH 49/71] Hopefully fixed dynamic liba52

---
 cinelerra-5.1/configure.ac       | 2 +-
 cinelerra-5.1/libzmpeg3/Makefile | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index c7394b7b..7481d411 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -622,7 +622,7 @@ CHECK_HEADERS([dav1d], [libdav1d headers], [dav1d/dav1d.h])
 CHECK_LIB([libwebp], [webp], [WebPGetEncoderVersion])
 CHECK_HEADERS([libwebp], [libwebp headers], [webp/encode.h])
 CHECK_LIB([a52dec], [a52], [a52_init])
-CHECK_HEADERS([a52dec], [a52 headers], [stdint.h a52.h])
+CHECK_HEADERS([a52dec], [a52 headers], [stdint.h a52dec/a52.h])
 CHECK_LIB([encore], [encore], [encore])
 CHECK_HEADERS([encore], [encore headers], [encore.h])
 CHECK_LIB([giflib], [gif], [DGifOpen])
diff --git a/cinelerra-5.1/libzmpeg3/Makefile b/cinelerra-5.1/libzmpeg3/Makefile
index 47a0596f..1e59d36f 100644
--- a/cinelerra-5.1/libzmpeg3/Makefile
+++ b/cinelerra-5.1/libzmpeg3/Makefile
@@ -79,6 +79,9 @@ UTILS += $(OBJDIR)/zmpeg3ifochk
 UTILS += $(OBJDIR)/zmpeg3cc2txt
 
 LIBS = -lm -lpthread
+ifeq ($(WITH_THIRDPARTY),no)
+LIBS += -la52
+endif
 
 LIBS += $(lib_a52dec) $(lib_djbfft) $(lib_libbthread)
 
-- 
2.35.1

From 075571ecf6589bada072f60fc10ca18cca00df4f Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 02:07:50 +0300
Subject: [PATCH 63/71] Beginning of ffmpeg versioned compilation

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 17 +++++++++++++++--
 cinelerra-5.1/cinelerra/ffmpeg.h |  4 +++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 294343fb..ec776578 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -722,11 +722,15 @@ int FFStream::seek(int64_t no, double rate)
 	double secs = pos < 0 ? 0. : pos / rate;
 	AVRational time_base = st->time_base;
 	int64_t tstmp = time_base.num > 0 ? secs * time_base.den/time_base.num : 0;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	int nb_index_entries = avformat_index_get_entries_count(st);
+#endif
 	if( !tstmp ) {
 		if( nb_index_entries > 0 ) tstmp = (avformat_index_get_entry(st, 0))->timestamp;
 		else if( st->start_time != AV_NOPTS_VALUE ) tstmp = st->start_time;
-		/* else if( st->first_dts != AV_NOPTS_VALUE ) tstmp = st->first_dts; */
+#if LIBAVCODEC_VERSION_INT  <= AV_VERSION_INT(58,134,100)
+		else if( st->first_dts != AV_NOPTS_VALUE ) tstmp = st->first_dts;
+#endif
 		else tstmp = INT64_MIN+1;
 	}
 	else if( nudge != AV_NOPTS_VALUE ) tstmp += nudge;
@@ -4095,11 +4099,20 @@ void FFStream::load_markers(IndexMarks &marks, double rate)
 	int in = 0;
 	int64_t sz = marks.size();
 	int max_entries = fmt_ctx->max_index_size / sizeof(AVIndexEntry) - 1;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	int nb_ent = avformat_index_get_entries_count(st);
+#endif
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(58,134,100)
+	int nb_ent = st->nb_index_entries;
+#endif
 // some formats already have an index
 	if( nb_ent > 0 ) {
-		// AVIndexEntry *ep = &st->index_entries[nb_ent-1];
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(58,134,100)
+		AVIndexEntry *ep = &st->index_entries[nb_ent-1];
+#endif
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 		const AVIndexEntry *ep = avformat_index_get_entry(st, nb_ent-1);
+#endif
 		int64_t tstmp = ep->timestamp;
 		if( nudge != AV_NOPTS_VALUE ) tstmp -= nudge;
 		double secs = ffmpeg->to_secs(tstmp, st->time_base);
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h
index 6c7d68e0..d2b4ac7f 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.h
+++ b/cinelerra-5.1/cinelerra/ffmpeg.h
@@ -25,10 +25,12 @@
 #include "vframe.inc"
 
 extern "C" {
-#include "libavcodec/bsf.h"
 #include "libavformat/avformat.h"
 #include "libavformat/avio.h"
 #include "libavcodec/avcodec.h"
+#if LIBAVCODEC_VERSION_INT  >= AV_VERSION_INT(59,18,100)
+#include "libavcodec/bsf.h"
+#endif
 #include "libavfilter/avfilter.h"
 #include "libavutil/avutil.h"
 #include "libavfilter/buffersrc.h"
-- 
2.35.1

From cce1e2e18b8d3ec7fc70c1b5fff2517348069a84 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 02:17:41 +0300
Subject: [PATCH 64/71] Ffmpeg versioning in bdwrite.C

---
 cinelerra-5.1/cinelerra/bdwrite.C | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index 57966ead..178b5dcf 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -2530,7 +2530,12 @@ static int field_probe(AVFormatContext *fmt_ctx, AVStream *st)
   AVDictionary *copts = 0;
   //av_dict_copy(&copts, opts, 0);
   AVCodecID codec_id = st->codecpar->codec_id;
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(58,134,100)
+  AVCodec *decoder = avcodec_find_decoder(codec_id);
+#endif
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
   const AVCodec *decoder = avcodec_find_decoder(codec_id);
+#endif
   AVCodecContext *ctx = avcodec_alloc_context3(decoder);
   if( !ctx ) {
     fprintf(stderr,"codec alloc failed\n");
@@ -2604,7 +2609,13 @@ int media_info::scan()
     stream *s = new stream(type, i);
     s->pid = st->id;
     AVCodecID codec_id = st->codecpar->codec_id;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
     const AVCodec *decoder = avcodec_find_decoder(codec_id);
+#endif
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(58,134,100)
+    AVCodec *decoder = avcodec_find_decoder(codec_id);
+#endif
+
     s->ctx = avcodec_alloc_context3(decoder);
     if( !s->ctx ) {
       fprintf(stderr, "avcodec_alloc_context failed\n");
-- 
2.35.1

From dfd4df2dac651e12fab7873d27aa46113698021f Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 02:48:04 +0300
Subject: [PATCH 66/71] Even more ffmpeg versioning in ffmpeg.C

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index d4f63ebf..4ed25453 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -3032,12 +3032,11 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 		}
 		if( ret >= 0 ) {
 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-			//ret = avcodec_copy_context(st->codec, ctx);
-			//AVCodecContext *codec_ctx = avcodec_alloc_context3(ctx);
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(58,134,100)
+			ret = avcodec_copy_context(st->codec, ctx);
+#else
 			ret = avcodec_parameters_to_context(ctx, st->codecpar);
-			// if (ret < 0)
-			//	fprintf(stderr, "could not copy codecpar to tmp codec_ctx\n");
-			//ret = avcodec_parameters_from_context(codec_ctx, 
+#endif
 _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
 			if( ret < 0 )
 				fprintf(stderr, "Could not copy the stream context\n");
@@ -3682,7 +3681,11 @@ Preferences *FFMPEG::ff_prefs()
 
 double FFVideoStream::get_rotation_angle()
 {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	size_t size = 0;
+#else
+	int size = 0;
+#endif
 	int *matrix = (int*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, &size);
 	int len = size/sizeof(*matrix);
 	if( !matrix || len < 5 ) return 0;
-- 
2.35.1

From 337cd6223cb89fbc2fcdde70093e048107d6c473 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sun, 3 Apr 2022 02:49:58 +0300
Subject: [PATCH 52/71] Dynamic termux + libzmpeg

---
 cinelerra-5.1/cinelerra/Makefile | 3 +++
 cinelerra-5.1/termux_dyn.sh      | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index b559e4f5..76e0a9ba 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -447,6 +447,9 @@ LIBS += `pkg-config --libs uuid`
 LIBS += `pkg-config --libs theora`
 LIBS += `pkg-config --libs vorbis`
 LIBS += `pkg-config --libs sndfile`
+ifeq ($(WANT_LIBZMPEG),yes)
+LIBS += -la52 -ltwolame -lmp3lame
+endif
 LIBS += -lgif -l:libtheora.a -l:libvorbis.a -ltiff 
 ifeq ($(shell uname -o), Android)
 LIBS += -landroid-shmem -liconv jpt.a
diff --git a/cinelerra-5.1/termux_dyn.sh b/cinelerra-5.1/termux_dyn.sh
index 5e5d35b8..b557686c 100755
--- a/cinelerra-5.1/termux_dyn.sh
+++ b/cinelerra-5.1/termux_dyn.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 ./configure --with-single-user --without-thirdparty \
-    --without-dvb --without-video4linux2 --without-dv \
-    --without-firewire --without-libzmpeg --without-vaapi \
+    --without-dv \
+    --without-firewire  --without-vaapi \
     --without-vdpau --without-lv2 --without-openexr --without-ogg \
     --without-gl
-- 
2.35.1

From 4a8001ccac4bff3422b52d07f7a605ea58a17ade Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 02:33:54 +0300
Subject: [PATCH 65/71] More libavcodec versionkng in ffmpeg

---
 cinelerra-5.1/cinelerra/ffmpeg.C |  4 ++++
 cinelerra-5.1/cinelerra/ffmpeg.h | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index ec776578..d4f63ebf 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -3907,7 +3907,11 @@ AVCodecContext *FFMPEG::activate_decoder(AVStream *st)
 	AVDictionary *copts = 0;
 	av_dict_copy(&copts, opts, 0);
 	AVCodecID codec_id = st->codecpar->codec_id;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	const AVCodec *decoder = 0;
+#else
+	AVCodec *decoder = 0;
+#endif
 	switch( st->codecpar->codec_type ) {
 	case AVMEDIA_TYPE_VIDEO:
 		if( opt_video_decoder )
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h
index d2b4ac7f..1b46160a 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.h
+++ b/cinelerra-5.1/cinelerra/ffmpeg.h
@@ -89,7 +89,11 @@ public:
 	virtual int encode_activate();
 	virtual int decode_activate();
 	virtual AVHWDeviceType decode_hw_activate();
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	virtual int decode_hw_format(const AVCodec *decoder, AVHWDeviceType type);
+#else
+	virtual int decode_hw_format(AVCodec *decoder, AVHWDeviceType type);
+#endif
 	virtual int write_packet(FFPacket &pkt);
 	int read_packet();
 	int seek(int64_t no, double rate);
@@ -293,7 +297,11 @@ class FFCodecRemaps : public ArrayList<FFCodecRemap>
 public:
 	FFCodecRemaps() {}
 	int add(const char *val);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	int update(AVCodecID &codec_id, const AVCodec *&decoder);
+#else
+	int update(AVCodecID &codec_id, AVCodec *&decoder);
+#endif
 };
 
 // for get_initial_timecode auto deletes
@@ -334,7 +342,11 @@ public:
 	static void ff_lock(const char *cp=0) { fflock.lock(cp); }
 	static void ff_unlock() { fflock.unlock(); }
 
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	int check_sample_rate(const AVCodec *codec, int sample_rate);
+#else
+	int check_sample_rate(AVCodec *codec, int sample_rate);
+#endif
 	AVRational check_frame_rate(const AVRational *p, double frame_rate);
 	AVRational to_sample_aspect_ratio(Asset *asset);
 	AVRational to_time_base(int sample_rate);
-- 
2.35.1

From e5f1bf73d573f8d4689c13ee424bd6c132f1dd8b Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 04:36:39 +0300
Subject: [PATCH 69/71] Really fix ffmpeg.C for ffmpeg 4.4

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index ff03e85e..14c1171c 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -733,7 +733,11 @@ int FFStream::seek(int64_t no, double rate)
 	int nb_index_entries = avformat_index_get_entries_count(st);
 #endif
 	if( !tstmp ) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 		if( nb_index_entries > 0 ) tstmp = (avformat_index_get_entry(st, 0))->timestamp;
+#else
+		if( st->nb_index_entries > 0 ) tstmp = st->index_entries[0].timestamp;
+#endif
 		else if( st->start_time != AV_NOPTS_VALUE ) tstmp = st->start_time;
 #if LIBAVCODEC_VERSION_INT  <= AV_VERSION_INT(58,134,100)
 		else if( st->first_dts != AV_NOPTS_VALUE ) tstmp = st->first_dts;
-- 
2.35.1

From a55f598aaf9679b6fce27132221b29d67d4efeaf Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 03:21:33 +0300
Subject: [PATCH 67/71] Nearly all versioning in ffmpeg.C

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 4ed25453..5fd9cbe1 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -2105,7 +2105,11 @@ void FFMPEG::scan_audio_options(Asset *asset, EDL *edl)
 		cin_fmt = (int)av_get_sample_fmt(cin_sample_fmt);
 	if( cin_fmt < 0 ) {
 		char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,18,100)
 		const AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", asset->acodec) ?
+#else
+		AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", asset->acodec) ?
+#endif
 			avcodec_find_encoder_by_name(audio_codec) : 0;
 		if( av_codec && av_codec->sample_fmts )
 			cin_fmt = find_best_sample_fmt_of_list(av_codec->sample_fmts, AV_SAMPLE_FMT_FLT);
@@ -2141,7 +2145,11 @@ void FFMPEG::scan_video_options(Asset *asset, EDL *edl)
 			cin_fmt = (int)av_get_pix_fmt(cin_pix_fmt);
 	if( cin_fmt < 0 ) {
 		char video_codec[BCSTRLEN];  video_codec[0] = 0;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,18,100)
 		const AVCodec *av_codec = !get_codec(video_codec, "video", asset->vcodec) ?
+#else
+		AVCodec *av_codec = !get_codec(video_codec, "video", asset->vcodec) ?
+#endif
 			avcodec_find_encoder_by_name(video_codec) : 0;
 		if( av_codec && av_codec->pix_fmts ) {
 			if( 0 && edl ) { // frequently picks a bad answer
@@ -2335,10 +2343,15 @@ int FFCodecRemaps::add(const char *val)
 	return 0;
 }
 
-
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 int FFCodecRemaps::update(AVCodecID &codec_id, const AVCodec *&decoder)
 {
 	const AVCodec *codec = avcodec_find_decoder(codec_id);
+#else
+int FFCodecRemaps::update(AVCodecID &codec_id, AVCodec *&decoder)
+{
+	AVCodec *codec = avcodec_find_decoder(codec_id);
+#endif
 	if( !codec ) return -1;
 	const char *name = codec->name;
 	FFCodecRemaps &map = *this;
@@ -2558,7 +2571,11 @@ int FFMPEG::init_decoder(const char *filename)
 	char *sp = strrchr(bp, '.');
 	if( !sp ) sp = bp + strlen(bp);
 	FILE *fp = 0;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,18,100)
 	const AVInputFormat *ifmt = 0;
+#else
+	AVInputFormat *ifmt = 0;
+#endif
 	if( sp ) {
 		strcpy(sp, ".opts");
 		fp = fopen(file_opts, "r");
@@ -2779,7 +2796,11 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 	AVCodecContext *ctx = 0;
 
 	const AVCodecDescriptor *codec_desc = 0;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
+#else
+	AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
+#endif
 	if( !codec ) {
 		eprintf(_("cant find codec %s:%s\n"), codec_name, filename);
 		ret = 1;
-- 
2.35.1

From d94f673ac8876b02bd05808532985b4cc252bd39 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 4 Apr 2022 03:33:36 +0300
Subject: [PATCH 68/71] Finished versioning in ffmpeg.C

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 5fd9cbe1..ff03e85e 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -380,8 +380,11 @@ AVHWDeviceType FFStream::decode_hw_activate()
 {
 	return AV_HWDEVICE_TYPE_NONE;
 }
-
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 int FFStream::decode_hw_format(const AVCodec *decoder, AVHWDeviceType type)
+#else
+int FFStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type)
+#endif
 {
 	return 0;
 }
@@ -406,7 +409,11 @@ int FFStream::decode_activate()
 		}
 		while( ret >= 0 && st != 0 && !reading ) {
 			AVCodecID codec_id = st->codecpar->codec_id;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 			const AVCodec *decoder = 0;
+#else
+			AVCodec *decoder = 0;
+#endif
 			if( is_video() ) {
 				if( ffmpeg->opt_video_decoder )
 					decoder = avcodec_find_decoder_by_name(ffmpeg->opt_video_decoder);
@@ -1855,7 +1862,11 @@ FFMPEG::~FFMPEG()
 	delete [] opt_hw_dev;
 }
 
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
 int FFMPEG::check_sample_rate(const AVCodec *codec, int sample_rate)
+#else
+int FFMPEG::check_sample_rate(AVCodec *codec, int sample_rate)
+#endif
 {
 	const int *p = codec->supported_samplerates;
 	if( !p ) return sample_rate;
-- 
2.35.1

-- 
Cin mailing list
[email protected]
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to