Skip to content

Commit 97d5df5

Browse files
committed
Create 0001-avcodec-x86-mathops-clip-constants.patch (#33)
ADD: Create patch file `scripts/patch/ffmpeg/0001-avcodec-x86-mathops-clip-constants.patch` Created a temporary file based patch for FFmpeg This will be removed after version advancement/upgrade to more recent version of FFmpeg: ADD: Commands to `03_build_raisr_ffmpeg.sh` to reflect the added patch file. Co-authored by: @djie1 Signed-off-by: Miłosz Linkiewicz <[email protected]>
1 parent 381a2e4 commit 97d5df5

File tree

4 files changed

+138
-7
lines changed

4 files changed

+138
-7
lines changed

.github/workflows/build-baremetal-coverity.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ jobs:
8585
token: ${{ secrets.COVERITY_SCAN_TOKEN }}
8686
build_language: 'cxx'
8787
build_platform: 'linux64'
88-
command: ${{ github.workspace }}/./build.sh -DENABLE_RAISR_OPENCL=ON -DENABLE_AVX512FP16=ON -DENABLE_AVX512=ON
88+
command: |
89+
"${{ github.workspace }}/build.sh" -DENABLE_RAISR_OPENCL=ON \
90+
-DCMAKE_LIBRARY_PATH="/opt/intel/oneapi/ipp/latest/lib;${PREFIX}/lib;" \
91+
-DCMAKE_C_FLAGS="-I/opt/intel/oneapi/ipp/latest/include -I/opt/intel/oneapi/ipp/latest/include/ipp" \
92+
-DCMAKE_CXX_FLAGS="-I/opt/intel/oneapi/ipp/latest/include -I/opt/intel/oneapi/ipp/latest/include/ipp"
8993
9094
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
9195
with:

.github/workflows/build-baremetal-ubuntu.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,27 @@ jobs:
7474
sudo apt-get update --fix-missing && \
7575
sudo apt-get install --no-install-recommends -y intel-oneapi-ipp-devel-2022.0
7676
77-
- name: 'Download and patch ffmpeg repository'
77+
- name: 'preparation: download and patch ffmpeg repository'
7878
run: |
7979
set -eo pipefail && \
8080
curl -Lf https://github.com/ffmpeg/ffmpeg/archive/${FFMPEG_COMMIT_ID}.tar.gz | tar -zx --strip-components=1 -C "${BUILD_FFMPEG_DIR}"
8181
patch -d "${BUILD_FFMPEG_DIR}" -p1 -i <(cat "${{ github.workspace }}/ffmpeg/"*.patch)
8282
cp "${{ github.workspace }}/ffmpeg/vf_raisr"*.c "${BUILD_FFMPEG_DIR}/libavfilter"
8383
84-
- name: 'Build RAISR from source code'
84+
- name: 'build: building RAISR from source code'
8585
run: |
8686
./build.sh -DENABLE_RAISR_OPENCL=ON \
8787
-DCMAKE_LIBRARY_PATH="/opt/intel/oneapi/ipp/latest/lib;${PREFIX}/lib;" \
8888
-DCMAKE_C_FLAGS="-I/opt/intel/oneapi/ipp/latest/include -I/opt/intel/oneapi/ipp/latest/include/ipp" \
8989
-DCMAKE_CXX_FLAGS="-I/opt/intel/oneapi/ipp/latest/include -I/opt/intel/oneapi/ipp/latest/include/ipp"
9090
91-
- name: 'Configure ffmpeg repository'
91+
- name: 'post-build: upload build artifacts'
92+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
93+
with:
94+
name: raisr-library-binary
95+
path: '${{ github.workspace }}/build/Library'
96+
97+
- name: 'preparation: configure ffmpeg repository'
9298
continue-on-error: true
9399
run: |
94100
cd "${BUILD_FFMPEG_DIR}"
@@ -109,12 +115,54 @@ jobs:
109115
--prefix="${PREFIX}" || \
110116
{ tail -n 100 "${BUILD_DIR}/ffmpeg/ffbuild/config.log" && exit 1; }
111117
112-
- name: 'Build, install and check ffmpeg'
118+
- name: 'build: compilation and install of ffmpeg'
113119
continue-on-error: true
120+
working-directory: "${BUILD_FFMPEG_DIR}"
114121
run: |
115-
cd "${BUILD_FFMPEG_DIR}"
116122
make clean
117123
make -j"$(nproc)"
118124
sudo -E make install
125+
126+
- name: 'checks: check if ffmpeg was build properly'
127+
continue-on-error: true
128+
working-directory: "${BUILD_FFMPEG_DIR}"
129+
run: |
119130
sudo -E ldconfig
120-
ffmpeg -buildconf
131+
./ffmpeg -buildconf || \
132+
ffmpeg -buildconf || \
133+
/usr/local/bin/ffmpeg -buildconf
134+
135+
build-baremetal-using-scripts:
136+
runs-on: 'ubuntu-22.04'
137+
timeout-minutes: 70
138+
steps:
139+
- name: 'preparations: Harden Runner'
140+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
141+
with:
142+
egress-policy: audit
143+
144+
- name: 'preparations: Checkout repository'
145+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
146+
147+
- name: 'prerequisites: Download/Pull resources'
148+
shell: bash
149+
working-directory: scripts
150+
run: |
151+
git config --global user.email "[email protected]"
152+
git config --global user.name "Ubuntu Action Runnner"
153+
154+
- name: 'prerequisites: Download/Pull resources'
155+
shell: bash
156+
working-directory: scripts
157+
run: ./01_pull_resources.sh
158+
159+
- name: 'prerequisites: Install prerequisites'
160+
shell: bash
161+
working-directory: scripts
162+
run: ./02_install_prerequisites.sh ./raisr.tar.gz
163+
164+
- name: 'Build raisr and ffmpeg'
165+
shell: bash
166+
working-directory: scripts
167+
run: ./03_build_raisr_ffmpeg.sh ./raisr/Video-Super-Resolution-Library
168+

scripts/03_build_raisr_ffmpeg.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pushd "${raisr_path}"
3131
sudo -E ./build.sh
3232
popd
3333

34+
# TO-DO: Remove patch apply from bellow lines:
35+
# Apply a temporary patch - this will be removed after version of FFmpeg gets updated
36+
patch -d "${raisr_path}/../ffmpeg" -p1 -i <(cat "${raisr_path}/scripts/patch/ffmpeg/"*.patch)
37+
3438
# build ffmpeg
3539
pushd "${raisr_path}/../ffmpeg"
3640
cp "${raisr_path}/ffmpeg/vf_raisr.c" libavfilter/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
3+
Date: Sun, 16 Jul 2023 18:18:02 +0300
4+
Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
5+
instructions within inline assembly
6+
7+
Fixes assembling with binutil as >= 2.41
8+
9+
Signed-off-by: James Almer <[email protected]>
10+
---
11+
libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
12+
1 file changed, 23 insertions(+), 3 deletions(-)
13+
14+
diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
15+
index 6298f5ed19..ca7e2dffc1 100644
16+
--- a/libavcodec/x86/mathops.h
17+
+++ b/libavcodec/x86/mathops.h
18+
@@ -35,12 +35,20 @@
19+
static av_always_inline av_const int MULL(int a, int b, unsigned shift)
20+
{
21+
int rt, dummy;
22+
+ if (__builtin_constant_p(shift))
23+
__asm__ (
24+
"imull %3 \n\t"
25+
"shrdl %4, %%edx, %%eax \n\t"
26+
:"=a"(rt), "=d"(dummy)
27+
- :"a"(a), "rm"(b), "ci"((uint8_t)shift)
28+
+ :"a"(a), "rm"(b), "i"(shift & 0x1F)
29+
);
30+
+ else
31+
+ __asm__ (
32+
+ "imull %3 \n\t"
33+
+ "shrdl %4, %%edx, %%eax \n\t"
34+
+ :"=a"(rt), "=d"(dummy)
35+
+ :"a"(a), "rm"(b), "c"((uint8_t)shift)
36+
+ );
37+
return rt;
38+
}
39+
40+
@@ -113,19 +121,31 @@ __asm__ volatile(\
41+
// avoid +32 for shift optimization (gcc should do that ...)
42+
#define NEG_SSR32 NEG_SSR32
43+
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
44+
+ if (__builtin_constant_p(s))
45+
__asm__ ("sarl %1, %0\n\t"
46+
: "+r" (a)
47+
- : "ic" ((uint8_t)(-s))
48+
+ : "i" (-s & 0x1F)
49+
);
50+
+ else
51+
+ __asm__ ("sarl %1, %0\n\t"
52+
+ : "+r" (a)
53+
+ : "c" ((uint8_t)(-s))
54+
+ );
55+
return a;
56+
}
57+
58+
#define NEG_USR32 NEG_USR32
59+
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
60+
+ if (__builtin_constant_p(s))
61+
__asm__ ("shrl %1, %0\n\t"
62+
: "+r" (a)
63+
- : "ic" ((uint8_t)(-s))
64+
+ : "i" (-s & 0x1F)
65+
);
66+
+ else
67+
+ __asm__ ("shrl %1, %0\n\t"
68+
+ : "+r" (a)
69+
+ : "c" ((uint8_t)(-s))
70+
+ );
71+
return a;
72+
}
73+
74+
--
75+
2.34.1

0 commit comments

Comments
 (0)