* [FFmpeg-devel] [PR] avcodec/mlp: Don't use internals of CRC API (PR #21507)
@ 2026-01-18 23:30 mkver via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: mkver via ffmpeg-devel @ 2026-01-18 23:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: mkver
PR #21507 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21507
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21507.patch
ff_mlp_restart_checksum() used the (undocumented) layout
of the CRC tables and therefore broke on x86 when the
clmul implementation added in dc03cffe9c9577127ef82b6f56118115f900e5f2
is used. This commit fixes this.
>From f330d178adf5508607f2c1f3d0cc0201b6fd4d18 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Mon, 19 Jan 2026 00:26:34 +0100
Subject: [PATCH] avcodec/mlp: Don't use internals of CRC API
ff_mlp_restart_checksum() used the (undocumented) layout
of the CRC tables and therefore broke on x86 when the
clmul implementation added in dc03cffe9c9577127ef82b6f56118115f900e5f2
is used. This commit fixes this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mlp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c
index 33045c08c7..8ea6e6d72e 100644
--- a/libavcodec/mlp.c
+++ b/libavcodec/mlp.c
@@ -107,8 +107,11 @@ uint8_t ff_mlp_restart_checksum(const uint8_t *buf, unsigned int bit_size)
int i;
int num_bytes = (bit_size + 2) / 8;
- int crc = crc_1D[buf[0] & 0x3f];
- crc = av_crc(crc_1D, crc, buf + 1, num_bytes - 2);
+ // The two most significant bits of buf[0] are not supposed
+ // to be contained in the checksum; using buf[0] & 0xC0 as start value
+ // achieves this.
+ int crc = av_crc(crc_1D, buf[0] & 0xC0, buf, num_bytes - 1);
+
crc ^= buf[num_bytes - 1];
for (i = 0; i < ((bit_size + 2) & 7); i++) {
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-18 23:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-18 23:30 [FFmpeg-devel] [PR] avcodec/mlp: Don't use internals of CRC API (PR #21507) mkver via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git