From 615494715d6d6902536d3d0f3675850953524056 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Sat, 5 Sep 2026 04:35:46 +0300
Subject: [PATCH 1/4] Add x264 patch from Arch Power/PPCports so it compiles
 with vsx on powerpc G5

---
 .../thirdparty/src/x264-stableR3191.patch3    | 83 +++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 cinelerra-5.1/thirdparty/src/x264-stableR3191.patch3

diff --git a/cinelerra-5.1/thirdparty/src/x264-stableR3191.patch3 b/cinelerra-5.1/thirdparty/src/x264-stableR3191.patch3
new file mode 100644
index 00000000..402a00f8
--- /dev/null
+++ b/cinelerra-5.1/thirdparty/src/x264-stableR3191.patch3
@@ -0,0 +1,83 @@
+--- ./common/ppc/ppccommon.h	2021-01-10 14:00:05.489543000 -0500
++++ ./common/ppc/ppccommon.h	2021-01-10 14:03:38.828554000 -0500
+@@ -90,6 +90,37 @@
+   vec_s8_t v;
+ } vec_s8_u;
+ 
++// vec_xxpermdi is quite useful but some version of clang do not expose it
++#if !HAVE_VSX || (defined(__clang__) && __clang_major__ < 6)
++static const vec_u8_t xxpermdi0_perm = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
++                                         0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
++                                         0x14, 0x15, 0x16, 0x17 };
++static const vec_u8_t xxpermdi1_perm = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
++                                         0x06, 0x07, 0x18, 0x19, 0x1A, 0x1B,
++                                         0x1C, 0x1D, 0x1E, 0x1F };
++static const vec_u8_t xxpermdi2_perm = { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
++                                         0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
++                                         0x14, 0x15, 0x16, 0x17 };
++static const vec_u8_t xxpermdi3_perm = { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
++                                         0x0E, 0x0F, 0x18, 0x19, 0x1A, 0x1B,
++                                         0x1C, 0x1D, 0x1E, 0x1F };
++#define xxpermdi(a, b, c) vec_perm(a, b, xxpermdi##c##_perm)
++#elif (defined(__GNUC__) && (__GNUC__ > 6 || (__GNUC__ == 6 && __GNUC_MINOR__ >= 3))) || \
++      (defined(__clang__) && __clang_major__ >= 7) && __POWER7_VECTOR__ 
++#define xxpermdi(a, b, c) vec_xxpermdi(a, b, c)
++#endif
++
++// vec_xxpermdi has its endianness bias exposed in early gcc and clang
++#ifdef WORDS_BIGENDIAN
++#ifndef xxpermdi
++#define xxpermdi(a, b, c) vec_xxpermdi(a, b, c)
++#endif
++#else
++#ifndef xxpermdi
++#define xxpermdi(a, b, c) vec_xxpermdi(b, a, ((c >> 1) | (c & 1) << 1) ^ 3)
++#endif
++#endif
++
+ /***********************************************************************
+  * Null vector
+  **********************************************************************/
+@@ -150,7 +181,7 @@
+  **********************************************************************/
+ #ifndef __POWER9_VECTOR__
+ #define VEC_STORE8( v, p ) \
+-    vec_vsx_st( vec_xxpermdi( v, vec_vsx_ld( 0, p ), 1 ), 0, p )
++    vec_vsx_st( xxpermdi( v, vec_vsx_ld( 0, p ), 1 ), 0, p )
+ #else
+ #define VEC_STORE8( v, p ) vec_xst_len( v, p, 8 )
+ #endif
+@@ -304,33 +335,3 @@
+ #define vec_absd( a, b ) vec_sub( vec_max( a, b ), vec_min( a, b ) )
+ #endif
+ 
+-// vec_xxpermdi is quite useful but some version of clang do not expose it
+-#if !HAVE_VSX || (defined(__clang__) && __clang_major__ < 6)
+-static const vec_u8_t xxpermdi0_perm = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
+-                                         0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
+-                                         0x14, 0x15, 0x16, 0x17 };
+-static const vec_u8_t xxpermdi1_perm = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
+-                                         0x06, 0x07, 0x18, 0x19, 0x1A, 0x1B,
+-                                         0x1C, 0x1D, 0x1E, 0x1F };
+-static const vec_u8_t xxpermdi2_perm = { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
+-                                         0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
+-                                         0x14, 0x15, 0x16, 0x17 };
+-static const vec_u8_t xxpermdi3_perm = { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
+-                                         0x0E, 0x0F, 0x18, 0x19, 0x1A, 0x1B,
+-                                         0x1C, 0x1D, 0x1E, 0x1F };
+-#define xxpermdi(a, b, c) vec_perm(a, b, xxpermdi##c##_perm)
+-#elif (defined(__GNUC__) && (__GNUC__ > 6 || (__GNUC__ == 6 && __GNUC_MINOR__ >= 3))) || \
+-      (defined(__clang__) && __clang_major__ >= 7)
+-#define xxpermdi(a, b, c) vec_xxpermdi(a, b, c)
+-#endif
+-
+-// vec_xxpermdi has its endianness bias exposed in early gcc and clang
+-#ifdef WORDS_BIGENDIAN
+-#ifndef xxpermdi
+-#define xxpermdi(a, b, c) vec_xxpermdi(a, b, c)
+-#endif
+-#else
+-#ifndef xxpermdi
+-#define xxpermdi(a, b, c) vec_xxpermdi(b, a, ((c >> 1) | (c & 1) << 1) ^ 3)
+-#endif
+-#endif
-- 
2.51.2

