2 * Copyright © 2022 Rémi Denis-Courmont.
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavutil/attributes.h"
25 #include "libavutil/cpu.h"
26 #include "libavutil/riscv/cpu.h"
27 #include "libavcodec/avcodec.h"
28 #include "libavcodec/pixblockdsp.h"
30 void ff_get_pixels_8_rvi(int16_t *block
, const uint8_t *pixels
,
32 void ff_get_pixels_16_rvi(int16_t *block
, const uint8_t *pixels
,
35 void ff_get_pixels_8_rvv(int16_t *block
, const uint8_t *pixels
,
37 void ff_get_pixels_unaligned_8_rvv(int16_t *block
, const uint8_t *pixels
,
39 void ff_diff_pixels_rvv(int16_t *block
, const uint8_t *s1
,
40 const uint8_t *s2
, ptrdiff_t stride
);
41 void ff_diff_pixels_unaligned_rvv(int16_t *block
, const uint8_t *s1
,
42 const uint8_t *s2
, ptrdiff_t stride
);
44 av_cold
void ff_pixblockdsp_init_riscv(PixblockDSPContext
*c
,
45 AVCodecContext
*avctx
,
46 unsigned high_bit_depth
)
49 int cpu_flags
= av_get_cpu_flags();
51 if (cpu_flags
& AV_CPU_FLAG_RVI
) {
53 c
->get_pixels
= ff_get_pixels_16_rvi
;
55 c
->get_pixels
= ff_get_pixels_8_rvi
;
58 if (cpu_flags
& AV_CPU_FLAG_RV_MISALIGNED
) {
60 c
->get_pixels_unaligned
= ff_get_pixels_16_rvi
;
62 c
->get_pixels_unaligned
= ff_get_pixels_8_rvi
;
66 if ((cpu_flags
& AV_CPU_FLAG_RVV_I32
) && ff_rv_vlen_least(128)) {
67 c
->diff_pixels
= ff_diff_pixels_unaligned_rvv
;
68 c
->diff_pixels_unaligned
= ff_diff_pixels_unaligned_rvv
;
71 if ((cpu_flags
& AV_CPU_FLAG_RVV_I64
) && ff_get_rv_vlenb() >= 16) {
72 if (!high_bit_depth
) {
73 c
->get_pixels
= ff_get_pixels_8_rvv
;
74 c
->get_pixels_unaligned
= ff_get_pixels_unaligned_8_rvv
;
77 c
->diff_pixels
= ff_diff_pixels_rvv
;