From 3a4fc0d9ea25818f9de852a0a7e3eab22ceaaebd Mon Sep 17 00:00:00 2001
From: Good Guy <good1.2guy@gmail.com>
Date: Thu, 6 Apr 2023 19:39:09 -0600
Subject: [PATCH] Credit Andrew for termux patches and Andrew for prores_ks
 format

---
 cinelerra-5.1/ffmpeg/video/prores_ks.pro      |  3 ++
 cinelerra-5.1/mpeg2enc/mpeg2enc.c             |  1 +
 cinelerra-5.1/thirdparty/Makefile             |  4 +-
 .../thirdparty/src/libuuid-1.0.3.patch        | 48 +++++++++++++++++++
 4 files changed, 54 insertions(+), 2 deletions(-)
 create mode 100644 cinelerra-5.1/thirdparty/src/libuuid-1.0.3.patch

diff --git a/cinelerra-5.1/ffmpeg/video/prores_ks.pro b/cinelerra-5.1/ffmpeg/video/prores_ks.pro
index e1f6968e..116e3cfe 100644
--- a/cinelerra-5.1/ffmpeg/video/prores_ks.pro
+++ b/cinelerra-5.1/ffmpeg/video/prores_ks.pro
@@ -3,6 +3,9 @@ mov prores_ks
 # Do not render audio as it will fail with current opts
 profile=3
 quant_mat=auto
+# Option to make players believe that
+# the original Apple engine was used
+vendor=apl0
 # cin_pix_fmt=yuv422p10le; yuva444p10le; gbrp10le
 # The possible video profile values for the ProRes codec are:
 # 5 = 4444xq
diff --git a/cinelerra-5.1/mpeg2enc/mpeg2enc.c b/cinelerra-5.1/mpeg2enc/mpeg2enc.c
index af76232d..04f237be 100644
--- a/cinelerra-5.1/mpeg2enc/mpeg2enc.c
+++ b/cinelerra-5.1/mpeg2enc/mpeg2enc.c
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 
 #define GLOBAL_ /* used by global.h */
 #include "config.h"
diff --git a/cinelerra-5.1/thirdparty/Makefile b/cinelerra-5.1/thirdparty/Makefile
index 1568b615..8a5e5131 100644
--- a/cinelerra-5.1/thirdparty/Makefile
+++ b/cinelerra-5.1/thirdparty/Makefile
@@ -190,7 +190,7 @@ a52dec.ldflags?= "$(call ld_path,djbfft)"
 a52dec.cfg_vars?= CFLAGS+=" -U__FreeBSD__ $(call inc_path,djbfft)" LIBS+=" $(call ld_path,djbfft)"; autoreconf -ifv && automake -caf;
 a52dec.cfg_params?=--enable-djbfft --disable-oss
 djbfft.cfg_vars?=echo "$(call bld_path,djbfft)" > conf-home; \
- (CFLAGS="$(CFLAGS)"; $(CFG_VARS)$(if $(CFG_VARS),; )echo "$(CC) $$$$CFLAGS") > conf-cc; \
+ (CFLAGS="$(CFLAGS) -std=gnu89"; $(CFG_VARS)$(if $(CFG_VARS),; )echo "$(CC) $$$$CFLAGS") > conf-cc; \
  echo "exec true" > ./configure; chmod +x ./configure;
 djbfft.mak_params?=; cd $(call bld_path,djbfft); ln -sf djbfft.a libdjbfft.a
 audiofile.cfg_params?=--enable-shared=no --disable-doxygen-docs --enable-debug=no --enable-examples=no
@@ -212,7 +212,7 @@ dav1d.mak_params?=; $(MAKE) -C dav1d* install DESTDIR="$(call bld_path,dav1d)"
 libwebp.cfg_vars?= mkdir build && cd build && $(call cmake_config,..)
 libwebp.mak_params?= -C build all install DESTDIR=$(call bld_path,libwebp)
 mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,build)"
-mjpegtools.cfg_vars?= ./autogen.sh; 
+mjpegtools.cfg_vars?= ./autogen.sh; export CXXFLAGS+="-std=c++11";
 mjpegtools.cfg_params?= --enable-shared=no --without-libquicktime --without-libdv \
  --without-libpng --without-dga --without-gtk --without-libsdl --without-sdlgfx
 mjpegtools.mak_params?= all
diff --git a/cinelerra-5.1/thirdparty/src/libuuid-1.0.3.patch b/cinelerra-5.1/thirdparty/src/libuuid-1.0.3.patch
new file mode 100644
index 00000000..80292b4a
--- /dev/null
+++ b/cinelerra-5.1/thirdparty/src/libuuid-1.0.3.patch
@@ -0,0 +1,48 @@
+--- ./gen_uuid_c	2023-04-06 18:59:49.376261216 -0600
++++ ./gen_uuid.c	2023-04-06 17:57:00.987526837 -0600
+@@ -216,7 +216,7 @@
+ 	for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
+ 		ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
+ 		strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
+-#ifdef SIOCGIFHWADDR
++#if defined(SIOCGIFHWADDR) && !defined(__sun)
+ 		if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
+ 			continue;
+ 		a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
+@@ -271,11 +271,16 @@
+ 	THREAD_LOCAL int		state_fd = -2;
+ 	THREAD_LOCAL FILE		*state_f;
+ 	THREAD_LOCAL uint16_t		clock_seq;
++	struct flock			lock;
+ 	struct timeval			tv;
+ 	uint64_t			clock_reg;
+ 	mode_t				save_umask;
+ 	int				len;
+ 	int				ret = 0;
++	
++lock.l_whence = SEEK_SET;
++lock.l_start = 0;
++lock.l_len = 0;
+ 
+ 	if (state_fd == -2) {
+ 		save_umask = umask(0);
+@@ -294,7 +299,8 @@
+ 	}
+ 	if (state_fd >= 0) {
+ 		rewind(state_f);
+-		while (flock(state_fd, LOCK_EX) < 0) {
++		lock.l_type = F_WRLCK;
++		while (fcntl(state_fd, F_SETLKW, &lock) < 0) {
+ 			if ((errno == EAGAIN) || (errno == EINTR))
+ 				continue;
+ 			fclose(state_f);
+@@ -366,7 +372,8 @@
+ 			fflush(state_f);
+ 		}
+ 		rewind(state_f);
+-		flock(state_fd, LOCK_UN);
++		lock.l_type = F_UNLCK;
++		fcntl(state_fd, F_SETLK, &lock);
+ 	}
+ 
+ 	*clock_high = clock_reg >> 32;
-- 
2.26.2