lavc/vp8dsp: save one R-V GPR
[FFMpeg-mirror.git] / libavcodec / riscv / pixblockdsp_init.c
blob27357761052f3a3b0ec3a5a34aa6e36d1543c212
1 /*
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
21 #include <stdint.h>
23 #include "config.h"
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,
31 ptrdiff_t stride);
32 void ff_get_pixels_16_rvi(int16_t *block, const uint8_t *pixels,
33 ptrdiff_t stride);
35 void ff_get_pixels_8_rvv(int16_t *block, const uint8_t *pixels,
36 ptrdiff_t stride);
37 void ff_get_pixels_unaligned_8_rvv(int16_t *block, const uint8_t *pixels,
38 ptrdiff_t stride);
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)
48 #if HAVE_RV
49 int cpu_flags = av_get_cpu_flags();
51 if (cpu_flags & AV_CPU_FLAG_RVI) {
52 if (high_bit_depth)
53 c->get_pixels = ff_get_pixels_16_rvi;
54 else
55 c->get_pixels = ff_get_pixels_8_rvi;
58 if (cpu_flags & AV_CPU_FLAG_RV_MISALIGNED) {
59 if (high_bit_depth)
60 c->get_pixels_unaligned = ff_get_pixels_16_rvi;
61 else
62 c->get_pixels_unaligned = ff_get_pixels_8_rvi;
65 #if HAVE_RVV
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;
79 #endif
80 #endif