PR #25010 opened by kierank
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25010
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25010.patch

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 4a185039141dfe17d3ae959457f322622e79f7fc Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 23 Jan 2025 01:31:22 +0100
Subject: [PATCH 1/8] Add test action

---
 .forgejo/workflows/test.yml | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 .forgejo/workflows/test.yml

diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
new file mode 100644
index 0000000000..83ef87f5a9
--- /dev/null
+++ b/.forgejo/workflows/test.yml
@@ -0,0 +1,13 @@
+on:
+  push:
+    branches:
+      - master
+  pull_requests:
+
+jobs:
+  run_fate:
+    runs-on: linux-amd64
+    steps:
+      - uses: actions/checkout@v4
+      - name: Build
+        run: ./configure && make -j$(nproc)
-- 
2.52.0


>From 2f09c4d4c5bf56525e850122c0f774de7c60704c Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 23 Jan 2025 01:48:28 +0100
Subject: [PATCH 2/8] Use better image

---
 .forgejo/workflows/test.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index 83ef87f5a9..af204e9082 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -7,6 +7,8 @@ on:
 jobs:
   run_fate:
     runs-on: linux-amd64
+    container:
+      image: ghcr.io/btbn/ffmpeg-builds/linux64-gpl:latest
     steps:
       - uses: actions/checkout@v4
       - name: Build
-- 
2.52.0


>From f1ea3f15a39167cfe542406e947e614e47e5e51b Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 23 Jan 2025 21:53:44 +0100
Subject: [PATCH 3/8] More complete workflow

---
 .forgejo/workflows/image/Dockerfile |  4 ++++
 .forgejo/workflows/test.yml         | 32 +++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)
 create mode 100644 .forgejo/workflows/image/Dockerfile

diff --git a/.forgejo/workflows/image/Dockerfile 
b/.forgejo/workflows/image/Dockerfile
new file mode 100644
index 0000000000..ad88e85b82
--- /dev/null
+++ b/.forgejo/workflows/image/Dockerfile
@@ -0,0 +1,4 @@
+FROM ghcr.io/btbn/ffmpeg-build/linux64-gpl:latest
+RUN useradd -md /work -s /bin/bash -U runner
+WORKDIR /work
+USER runner
diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index af204e9082..af6d236a87 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -4,12 +4,36 @@ on:
       - master
   pull_requests:
 
+runs:
+  using: 'docker'
+  image: 'image/Dockerfile'
+
 jobs:
   run_fate:
     runs-on: linux-amd64
-    container:
-      image: ghcr.io/btbn/ffmpeg-builds/linux64-gpl:latest
     steps:
-      - uses: actions/checkout@v4
+      - name: Get Date
+        id: get-date
+        run: echo "date=$(date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
+      - name: Checkout
+        uses: actions/checkout@v4
+      - name: Configure
+        run: ./configure
       - name: Build
-        run: ./configure && make -j$(nproc)
+        run: make -j$(nproc)
+      - name: Restore Cached Fate-Suite
+        uses: actions/cache/restore@v4
+        with:
+          path: fate-suite
+          key: fate-suite
+          restore-keys: |
+            fate-suite-
+      - name: Sync Fate-Suite
+        run: make fate-rsync SAMPLES=$PWD/fate-suite
+      - name: Cache Fate-Suite
+        uses: actions/cache/save@v4
+        with:
+          path: fate-suite
+          key: fate-suite-${{ hashFiles('fate-suite/**') }}
+      - name: Run Fate
+        run: make fate SAMPLES=$PWD/fate-suite -j$(nproc)
-- 
2.52.0


>From afcf07a1644f82b752f65c1772d044721a083a5f Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 23 Jan 2025 22:47:22 +0100
Subject: [PATCH 4/8] Hash file-names, not contents

---
 .forgejo/workflows/test.yml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index af6d236a87..e6e64ea4a5 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -12,9 +12,6 @@ jobs:
   run_fate:
     runs-on: linux-amd64
     steps:
-      - name: Get Date
-        id: get-date
-        run: echo "date=$(date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
       - name: Checkout
         uses: actions/checkout@v4
       - name: Configure
@@ -29,11 +26,14 @@ jobs:
           restore-keys: |
             fate-suite-
       - name: Sync Fate-Suite
-        run: make fate-rsync SAMPLES=$PWD/fate-suite
+        id: fate
+        run: |
+          make fate-rsync SAMPLES=$PWD/fate-suite
+          echo "hash=$(find fate-suite -type f | sha256sum | cut -d' ' -f1)" 
>> $GITHUB_OUTPUT
       - name: Cache Fate-Suite
         uses: actions/cache/save@v4
         with:
           path: fate-suite
-          key: fate-suite-${{ hashFiles('fate-suite/**') }}
+          key: fate-suite-${{ steps.fate.outputs.hash }}
       - name: Run Fate
         run: make fate SAMPLES=$PWD/fate-suite -j$(nproc)
-- 
2.52.0


>From 34068885a22fba227e63ec7011d67dcd4db2d30d Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 23 Jan 2025 22:56:18 +0100
Subject: [PATCH 5/8] test building image

---
 .forgejo/workflows/test.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index e6e64ea4a5..74b63d96bb 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -4,13 +4,11 @@ on:
       - master
   pull_requests:
 
-runs:
-  using: 'docker'
-  image: 'image/Dockerfile'
-
 jobs:
   run_fate:
     runs-on: linux-amd64
+    container:
+      image: 'image/Dockerfile'
     steps:
       - name: Checkout
         uses: actions/checkout@v4
-- 
2.52.0


>From 6788af9fb9f71142b6ac4a96306497292baee808 Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 23 Jan 2025 22:57:26 +0100
Subject: [PATCH 6/8] Can only use pre-built images

---
 .forgejo/workflows/image/Dockerfile | 4 ----
 .forgejo/workflows/test.yml         | 2 --
 2 files changed, 6 deletions(-)
 delete mode 100644 .forgejo/workflows/image/Dockerfile

diff --git a/.forgejo/workflows/image/Dockerfile 
b/.forgejo/workflows/image/Dockerfile
deleted file mode 100644
index ad88e85b82..0000000000
--- a/.forgejo/workflows/image/Dockerfile
+++ /dev/null
@@ -1,4 +0,0 @@
-FROM ghcr.io/btbn/ffmpeg-build/linux64-gpl:latest
-RUN useradd -md /work -s /bin/bash -U runner
-WORKDIR /work
-USER runner
diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index 74b63d96bb..bce6465d53 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -7,8 +7,6 @@ on:
 jobs:
   run_fate:
     runs-on: linux-amd64
-    container:
-      image: 'image/Dockerfile'
     steps:
       - name: Checkout
         uses: actions/checkout@v4
-- 
2.52.0


>From 66f2a34c1fcbbca677e5e1f03ca08889a026a87c Mon Sep 17 00:00:00 2001
From: BtbN <[email protected]>
Date: Thu, 13 Feb 2025 19:30:20 +0100
Subject: [PATCH 7/8] Fix typo in workflow file

---
 .forgejo/workflows/test.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index bce6465d53..f20c6c9f62 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -2,7 +2,7 @@ on:
   push:
     branches:
       - master
-  pull_requests:
+  pull_request:
 
 jobs:
   run_fate:
-- 
2.52.0


>From 08882da35ec1ceb3307c68f0bf14a59bf4c942bb Mon Sep 17 00:00:00 2001
From: Kieran Kunhya <[email protected]>
Date: Sun, 11 Oct 2026 14:51:24 +0100
Subject: [PATCH 8/8] avcodec/x86/h264_qpel_8bit: saturate the SSSE3 hv2
 intermediate

The second pass of the centre (hv) 6-tap filter computes
((a-b)/4-b+c)/4+c from the first pass's 16-bit sums a, b, c, each in
[-5100, 21420] for 8-bit input (plus a bias that cancels here). The
partial sum (a-b)/4-b+c spans [-33150, 33150], so it can wrap in a 16-bit
lane. The MMX qpel4 and SSE2 hv2 functions already add c with paddsw; the
SSSE3 qpel8/qpel16 hv2 used paddw, and they are the versions every CPU
with SSSE3 runs. With alternating 0/255 stripes of period 3 in both
directions, mc21/mc12/mc22/mc23/mc32 return wrong pixels: a decoder
running this asm reconstructs a different picture from the spec and from
--disable-asm.

Saturating is exact. Saturation happens only when c >= 21038, where the
exact result is at least (8192+21038)/64 = 457 and clips to 255, as does
the saturated path; or when c <= -4719, where both results are negative
and clip to 0. The following add stays inside 16 bits. The assembled
objects differ only in the six opcode bytes (three sites, put and avg).

checkasm now also runs every qpel function on that stripe pattern, in
all six column phases and both polarities.
---
 libavcodec/x86/h264_qpel_8bit.asm |  6 +++---
 tests/checkasm/h264qpel.c         | 27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/libavcodec/x86/h264_qpel_8bit.asm 
b/libavcodec/x86/h264_qpel_8bit.asm
index 4e64329991..374b5c4d4b 100644
--- a/libavcodec/x86/h264_qpel_8bit.asm
+++ b/libavcodec/x86/h264_qpel_8bit.asm
@@ -650,7 +650,7 @@ cglobal %1_h264_qpel8or16_hv2_lowpass, 5,5,8 ; dst, tmp, 
dstStride, tmpStride, s
     psubw         m0, m1
     psraw         m0, 2
     psubw         m0, m1
-    paddw         m0, m2
+    paddsw        m0, m2
     psraw         m0, 2
     paddw         m0, m2
     psraw         m0, 6
@@ -695,8 +695,8 @@ cglobal %1_h264_qpel8or16_hv2_lowpass, 5,5,8 ; dst, tmp, 
dstStride, tmpStride, s
     psraw         m3, 2
     psubw         m0, m1
     psubw         m3, m4
-    paddw         m0, m2
-    paddw         m3, m5
+    paddsw        m0, m2
+    paddsw        m3, m5
     psraw         m0, 2
     psraw         m3, 2
     paddw         m0, m2
diff --git a/tests/checkasm/h264qpel.c b/tests/checkasm/h264qpel.c
index e47d659929..1adaefff3f 100644
--- a/tests/checkasm/h264qpel.c
+++ b/tests/checkasm/h264qpel.c
@@ -45,6 +45,24 @@ static const uint32_t pixel_mask[3] = { 0xffffffff, 
0x01ff01ff, 0x03ff03ff };
         }                                          \
     } while (0)
 
+/* 0/max stripes with period 3 in both directions take the centre filter's
+ * intermediate sums to their extremes; phase covers every column offset
+ * and both polarities */
+static void fill_stripes(uint8_t *buf0, uint8_t *buf1, int width, int 
bit_depth, int phase)
+{
+    int max = (1 << bit_depth) - 1;
+    for (int k = 0; k < BUF_SIZE / SIZEOF_PIXEL; k++) {
+        int x = k % width, y = k / width;
+        int v = ((y % 3 == 1) ^ ("010010"[(x + phase) % 6] - '0') ^ (phase >= 
6)) ? max : 0;
+        if (bit_depth == 8) {
+            buf0[k] = buf1[k] = v;
+        } else {
+            AV_WN16A(buf0 + 2 * k, v);
+            AV_WN16A(buf1 + 2 * k, v);
+        }
+    }
+}
+
 #define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative 
src pointer offsets */
 #define src1 (buf1 + 3 * 2 * 16)
 
@@ -73,6 +91,15 @@ void checkasm_check_h264qpel(void)
                         call_new(dst1, src1, size * SIZEOF_PIXEL);
                         if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, 
BUF_SIZE))
                             fail();
+                        for (int phase = 0; phase < 12; phase++) {
+                            fill_stripes(buf0, buf1, size, bit_depth, phase);
+                            call_ref(dst0, src0, size * SIZEOF_PIXEL);
+                            call_new(dst1, src1, size * SIZEOF_PIXEL);
+                            if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, 
dst1, BUF_SIZE)) {
+                                fail();
+                                break;
+                            }
+                        }
                         bench_new(dst1, src1, size * SIZEOF_PIXEL);
                     }
             }
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to