From: HecaiYuan via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: HecaiYuan <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec: fix checkasm-hpeldsp failed on LA (PR #20951)
Date: Tue, 18 Nov 2025 07:28:52 -0000
Message-ID: <176345093291.25.12707410790096734733@2cb04c0e5124> (raw)
PR #20951 opened by HecaiYuan
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20951
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20951.patch
This wrapper performs runtime dispatch to SIMD-optimized functions and
falls back to a C implementation for unsupported block heights.
>From 3d5177ecfb1fe88ecfcb0dc66db68c1dd8d2977c Mon Sep 17 00:00:00 2001
From: yuanhecai <yuanhecai@loongson.cn>
Date: Mon, 17 Nov 2025 17:32:53 +0800
Subject: [PATCH] avcodec: fix checkasm-hpeldsp failed on LA
This wrapper performs runtime dispatch to SIMD-optimized functions and
falls back to a C implementation for unsupported block heights.
---
libavcodec/loongarch/hpeldsp_init_loongarch.c | 108 ++++++++++++++++--
1 file changed, 101 insertions(+), 7 deletions(-)
diff --git a/libavcodec/loongarch/hpeldsp_init_loongarch.c b/libavcodec/loongarch/hpeldsp_init_loongarch.c
index 1690be5438..681e11a70a 100644
--- a/libavcodec/loongarch/hpeldsp_init_loongarch.c
+++ b/libavcodec/loongarch/hpeldsp_init_loongarch.c
@@ -23,28 +23,122 @@
#include "libavcodec/hpeldsp.h"
#include "libavcodec/loongarch/hpeldsp_lasx.h"
+static op_pixels_func put_pixels16_xy2_8_c_fallback = NULL;
+static op_pixels_func put_no_rnd_pixels16_y2_8_c_fallback = NULL;
+static op_pixels_func put_no_rnd_pixels16_xy2_8_c_fallback = NULL;
+static op_pixels_func put_no_rnd_pixels8_y2_8_c_fallback = NULL;
+static op_pixels_func put_no_rnd_pixels8_xy2_8_c_fallback = NULL;
+static op_pixels_func put_no_rnd_pixels16_x2_8_c_fallback = NULL;
+static op_pixels_func put_no_rnd_pixels8_x2_8_c_fallback = NULL;
+
+static inline void put_no_rnd_pix16_y2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 16 || h == 8) {
+ ff_put_no_rnd_pixels16_y2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_no_rnd_pixels16_y2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
+static inline void put_no_rnd_pix16_xy2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 16 || h == 8) {
+ ff_put_no_rnd_pixels16_xy2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_no_rnd_pixels16_xy2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
+static inline void put_no_rnd_pix8_y2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 8 || h == 4) {
+ ff_put_no_rnd_pixels8_y2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_no_rnd_pixels8_y2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
+static inline void put_no_rnd_pix8_xy2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 8 || h == 4) {
+ ff_put_no_rnd_pixels8_xy2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_no_rnd_pixels8_xy2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
+static inline void put_pix16_xy2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 16) {
+ ff_put_pixels16_xy2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_pixels16_xy2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
+static inline void put_no_rnd_pix16_x2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 16 || h == 8) {
+ ff_put_no_rnd_pixels16_x2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_no_rnd_pixels16_x2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
+static inline void put_no_rnd_pix8_x2_8_lasx_wrap(uint8_t *block,
+ const uint8_t *pixels,
+ ptrdiff_t line_size, int h)
+{
+ if (h == 8 || h == 4) {
+ ff_put_no_rnd_pixels8_x2_8_lasx(block, pixels, line_size, h);
+ } else {
+ put_no_rnd_pixels8_x2_8_c_fallback(block, pixels, line_size, h);
+ }
+}
+
void ff_hpeldsp_init_loongarch(HpelDSPContext *c, int flags)
{
int cpu_flags = av_get_cpu_flags();
if (have_lasx(cpu_flags)) {
+
+ put_pixels16_xy2_8_c_fallback = c->put_pixels_tab[0][3];
+ put_no_rnd_pixels16_y2_8_c_fallback = c->put_no_rnd_pixels_tab[0][2];
+ put_no_rnd_pixels16_xy2_8_c_fallback = c->put_no_rnd_pixels_tab[0][3];
+ put_no_rnd_pixels8_y2_8_c_fallback = c->put_no_rnd_pixels_tab[1][2];
+ put_no_rnd_pixels8_xy2_8_c_fallback = c->put_no_rnd_pixels_tab[1][3];
+ put_no_rnd_pixels16_x2_8_c_fallback = c->put_no_rnd_pixels_tab[0][1];
+ put_no_rnd_pixels8_x2_8_c_fallback = c->put_no_rnd_pixels_tab[1][1];
+
c->put_pixels_tab[0][0] = ff_put_pixels16_8_lsx;
c->put_pixels_tab[0][1] = ff_put_pixels16_x2_8_lasx;
c->put_pixels_tab[0][2] = ff_put_pixels16_y2_8_lasx;
- c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_8_lasx;
+ c->put_pixels_tab[0][3] = put_pix16_xy2_8_lasx_wrap;
c->put_pixels_tab[1][0] = ff_put_pixels8_8_lasx;
c->put_pixels_tab[1][1] = ff_put_pixels8_x2_8_lasx;
c->put_pixels_tab[1][2] = ff_put_pixels8_y2_8_lasx;
c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_8_lasx;
c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_8_lsx;
- c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_8_lasx;
- c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_8_lasx;
- c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_8_lasx;
+ c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pix16_x2_8_lasx_wrap;
+ c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pix16_y2_8_lasx_wrap;
+ c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pix16_xy2_8_lasx_wrap;
c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_8_lasx;
- c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_8_lasx;
- c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_8_lasx;
- c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_8_lasx;
+ c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pix8_x2_8_lasx_wrap;
+ c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pix8_y2_8_lasx_wrap;
+ c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pix8_xy2_8_lasx_wrap;
}
}
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-11-18 7:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176345093291.25.12707410790096734733@2cb04c0e5124 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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