From aab5d994627c5401a048383064c736605bf18807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Linkiewicz?= Date: Mon, 3 Mar 2025 10:41:16 +0100 Subject: [PATCH 1/3] Create 0001-avcodec-x86-mathops-clip-constants.patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create temp. patch for FFmpeg, before it will get fully upgraded to more recent version: - 0001-avcodec-x86-mathops-clip-constants.patch Co-authored by: @djie1 Signed-off-by: Miłosz Linkiewicz --- ...1-avcodec-x86-mathops-clip-constants.patch | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 scripts/0001-avcodec-x86-mathops-clip-constants.patch diff --git a/scripts/0001-avcodec-x86-mathops-clip-constants.patch b/scripts/0001-avcodec-x86-mathops-clip-constants.patch new file mode 100644 index 0000000..4f3f6ec --- /dev/null +++ b/scripts/0001-avcodec-x86-mathops-clip-constants.patch @@ -0,0 +1,75 @@ +From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= +Date: Sun, 16 Jul 2023 18:18:02 +0300 +Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift + instructions within inline assembly + +Fixes assembling with binutil as >= 2.41 + +Signed-off-by: James Almer +--- + libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++--- + 1 file changed, 23 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h +index 6298f5ed19..ca7e2dffc1 100644 +--- a/libavcodec/x86/mathops.h ++++ b/libavcodec/x86/mathops.h +@@ -35,12 +35,20 @@ + static av_always_inline av_const int MULL(int a, int b, unsigned shift) + { + int rt, dummy; ++ if (__builtin_constant_p(shift)) + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) +- :"a"(a), "rm"(b), "ci"((uint8_t)shift) ++ :"a"(a), "rm"(b), "i"(shift & 0x1F) + ); ++ else ++ __asm__ ( ++ "imull %3 \n\t" ++ "shrdl %4, %%edx, %%eax \n\t" ++ :"=a"(rt), "=d"(dummy) ++ :"a"(a), "rm"(b), "c"((uint8_t)shift) ++ ); + return rt; + } + +@@ -113,19 +121,31 @@ __asm__ volatile(\ + // avoid +32 for shift optimization (gcc should do that ...) + #define NEG_SSR32 NEG_SSR32 + static inline int32_t NEG_SSR32( int32_t a, int8_t s){ ++ if (__builtin_constant_p(s)) + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) +- : "ic" ((uint8_t)(-s)) ++ : "i" (-s & 0x1F) + ); ++ else ++ __asm__ ("sarl %1, %0\n\t" ++ : "+r" (a) ++ : "c" ((uint8_t)(-s)) ++ ); + return a; + } + + #define NEG_USR32 NEG_USR32 + static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ ++ if (__builtin_constant_p(s)) + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) +- : "ic" ((uint8_t)(-s)) ++ : "i" (-s & 0x1F) + ); ++ else ++ __asm__ ("shrl %1, %0\n\t" ++ : "+r" (a) ++ : "c" ((uint8_t)(-s)) ++ ); + return a; + } + +-- +2.34.1 From 29aef0ea66b3d66973ec365f872f1e34496224f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Linkiewicz?= Date: Mon, 3 Mar 2025 10:44:51 +0100 Subject: [PATCH 2/3] FIX: Moved the patch to a subfolder patch/ffmpeg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIX: Moved the patch to a subfolder `patch/ffmpeg` to show clearly the purpose of it. Rename 'scripts/0001-avcodec-x86-mathops-clip-constants.patch to scripts/patch/ffmpeg/0001-avcodec-x86-mathops-clip-constants.patch' Signed-off-by: Miłosz Linkiewicz --- .../ffmpeg}/0001-avcodec-x86-mathops-clip-constants.patch | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{ => patch/ffmpeg}/0001-avcodec-x86-mathops-clip-constants.patch (100%) diff --git a/scripts/0001-avcodec-x86-mathops-clip-constants.patch b/scripts/patch/ffmpeg/0001-avcodec-x86-mathops-clip-constants.patch similarity index 100% rename from scripts/0001-avcodec-x86-mathops-clip-constants.patch rename to scripts/patch/ffmpeg/0001-avcodec-x86-mathops-clip-constants.patch From d94daed271312140a87a1cfaf4053d875eae00c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Linkiewicz?= Date: Mon, 3 Mar 2025 10:58:01 +0100 Subject: [PATCH 3/3] Update 03_build_raisr_ffmpeg.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add patch apply using `patch` command instead of trouble causing `git` Signed-off-by: Miłosz Linkiewicz --- scripts/03_build_raisr_ffmpeg.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/03_build_raisr_ffmpeg.sh b/scripts/03_build_raisr_ffmpeg.sh index e263a28..e24631a 100755 --- a/scripts/03_build_raisr_ffmpeg.sh +++ b/scripts/03_build_raisr_ffmpeg.sh @@ -31,6 +31,10 @@ pushd "${raisr_path}" sudo -E ./build.sh popd +# TO-DO: Remove patch apply from bellow lines: +# Apply a temporary patch - this will be removed after version of FFmpeg gets updated +patch -p1 -i "${REPOSITORY_DIR}/scripts/patch/ffmpeg/0001-avcodec-x86-mathops-clip-constants.patch" + # build ffmpeg pushd "${raisr_path}/../ffmpeg" cp "${raisr_path}/ffmpeg/vf_raisr.c" libavfilter/