This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 952e588600b487deb9657c3b138101953da023ea
Author:     Shreesh Adiga <[email protected]>
AuthorDate: Thu Feb 5 18:23:18 2026 +0530
Commit:     Martin Storsjö <[email protected]>
CommitDate: Wed Mar 11 14:03:36 2026 +0000

    avutil/crc: refactor helper functions to separate header file
    
    Move the reverse and xnmodp functions to a separate header
    so that it can be reused for aarch64 implementation of av_crc.
---
 libavutil/crc_internal.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/x86/crc.h      | 44 ++------------------------------
 2 files changed, 68 insertions(+), 42 deletions(-)

diff --git a/libavutil/crc_internal.h b/libavutil/crc_internal.h
new file mode 100644
index 0000000000..8a856990a9
--- /dev/null
+++ b/libavutil/crc_internal.h
@@ -0,0 +1,66 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_CRC_INTERNAL_H
+#define AVUTIL_CRC_INTERNAL_H
+
+#include <stdint.h>
+#include "libavutil/reverse.h"
+
+static uint64_t reverse(uint64_t p, unsigned int deg)
+{
+    uint64_t ret = 0;
+    int i;
+    for (i = 0; i < (deg / 8); i += 1) {
+        ret = (ret << 8) | (ff_reverse[p & 0xff]);
+        p >>= 8;
+    }
+    int rem = (deg + 1) - 8 * i;
+    ret = (ret << rem) | (ff_reverse[p & 0xff] >> (8 - rem));
+    return ret;
+}
+
+static uint64_t xnmodp(unsigned n, uint64_t poly, unsigned deg, uint64_t *div, 
int bitreverse)
+{
+    uint64_t mod, mask, high;
+
+    if (n < deg) {
+        *div = 0;
+        return poly;
+    }
+    mask = ((uint64_t)1 << deg) - 1;
+    poly &= mask;
+    mod = poly;
+    *div = 1;
+    deg--;
+    while (--n > deg) {
+        high = (mod >> deg) & 1;
+        *div = (*div << 1) | high;
+        mod <<= 1;
+        if (high)
+            mod ^= poly;
+    }
+    uint64_t ret = mod & mask;
+    if (bitreverse) {
+        *div = reverse(*div, deg) << 1;
+        return reverse(ret, deg) << 1;
+    }
+    return ret;
+}
+
+#endif /* AVUTIL_CRC_INTERNAL_H */
diff --git a/libavutil/x86/crc.h b/libavutil/x86/crc.h
index c836c090c6..ef98ed318d 100644
--- a/libavutil/x86/crc.h
+++ b/libavutil/x86/crc.h
@@ -28,10 +28,11 @@
 #include "libavutil/cpu.h"
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/reverse.h"
 #include "libavutil/x86/cpu.h"
 
 #if HAVE_CLMUL_EXTERNAL
+#include "libavutil/crc_internal.h"
+
 FF_VISIBILITY_PUSH_HIDDEN
 uint32_t ff_crc_clmul(const AVCRC *ctx, uint32_t crc,
                       const uint8_t *buffer, size_t length);
@@ -104,47 +105,6 @@ static const AVCRC crc_table_clmul[AV_CRC_MAX][17] = {
     },
 };
 
-static uint64_t reverse(uint64_t p, unsigned int deg)
-{
-    uint64_t ret = 0;
-    int i;
-    for (i = 0; i < (deg / 8); i += 1) {
-        ret = (ret << 8) | (ff_reverse[p & 0xff]);
-        p >>= 8;
-    }
-    int rem = (deg + 1) - 8 * i;
-    ret = (ret << rem) | (ff_reverse[p & 0xff] >> (8 - rem));
-    return ret;
-}
-
-static uint64_t xnmodp(unsigned n, uint64_t poly, unsigned deg, uint64_t *div, 
int bitreverse)
-{
-    uint64_t mod, mask, high;
-
-    if (n < deg) {
-        *div = 0;
-        return poly;
-    }
-    mask = ((uint64_t)1 << deg) - 1;
-    poly &= mask;
-    mod = poly;
-    *div = 1;
-    deg--;
-    while (--n > deg) {
-        high = (mod >> deg) & 1;
-        *div = (*div << 1) | high;
-        mod <<= 1;
-        if (high)
-            mod ^= poly;
-    }
-    uint64_t ret = mod & mask;
-    if (bitreverse) {
-        *div = reverse(*div, deg) << 1;
-        return reverse(ret, deg) << 1;
-    }
-    return ret;
-}
-
 static inline void crc_init_x86(AVCRC *ctx, int le, int bits, uint32_t poly, 
int ctx_size)
 {
     uint64_t poly_;

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

Reply via email to