@@ -87,7 +87,9 @@ av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt
c->add_hfyu_median_pred_int16 = add_hfyu_median_pred_int16_c;
c->add_hfyu_left_pred_bgr32 = add_hfyu_left_pred_bgr32_c;
-#if ARCH_X86
+#if ARCH_RISCV
+ ff_huffyuvdsp_init_riscv(c, pix_fmt);
+#elif ARCH_X86
ff_huffyuvdsp_init_x86(c, pix_fmt);
#endif
}
@@ -34,6 +34,8 @@ typedef struct HuffYUVDSPContext {
} HuffYUVDSPContext;
void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt);
+void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c,
+ enum AVPixelFormat pix_fmt);
void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt);
#endif /* AVCODEC_HUFFYUVDSP_H */
@@ -18,6 +18,8 @@ OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o
RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o
OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o
RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o
+OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o
+RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o
OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o
RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o
OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_init.o
new file mode 100644
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2023 Rémi Denis-Courmont.
+ *
+ * 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
+ */
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavcodec/huffyuvdsp.h"
+
+void ff_add_int16_rvv(uint16_t *dst, const uint16_t *src, unsigned m, int w);
+
+av_cold void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c,
+ enum AVPixelFormat pix_fmt)
+{
+#if HAVE_RVV
+ int flags = av_get_cpu_flags();
+
+ if (flags & AV_CPU_FLAG_RVV_I32)
+ c->add_int16 = ff_add_int16_rvv;
+#endif
+}
new file mode 100644
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2023 Rémi Denis-Courmont.
+ *
+ * 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
+ */
+
+#include "libavutil/riscv/asm.S"
+
+func ff_add_int16_rvv, zve32x
+1:
+ vsetvli t0, a3, e16, m8, ta, ma
+ vle16.v v16, (a0)
+ sub a3, a3, t0
+ vle16.v v24, (a1)
+ sh1add a1, t0, a1
+ vadd.vv v16, v16, v24
+ vand.vx v16, v16, a2
+ vse16.v v16, (a0)
+ sh1add a0, t0, a0
+ bnez a3, 1b
+
+ ret
+endfunc