FFmpeg
Loading...
Searching...
No Matches
dsp_init.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Institute of Software Chinese Academy of Sciences (ISCAS).
3 *
4 * This file is part of FFmpeg.
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "config.h"
22
24#include "libavutil/cpu.h"
25#include "libavutil/riscv/cpu.h"
26#include "libavcodec/vvc/dsp.h"
27#include "libavcodec/vvc/dec.h"
29
30#define bf(fn, bd, opt) fn##_##bd##_##opt
31
32#define AVG_PROTOTYPES(bd, opt) \
33void bf(ff_vvc_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \
34 const int16_t *src0, const int16_t *src1, int width, int height); \
35void bf(ff_vvc_w_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \
36 const int16_t *src0, const int16_t *src1, int width, int height, \
37 int denom, int w0, int w1, int o);
38
39AVG_PROTOTYPES(8, rvv_128)
40AVG_PROTOTYPES(8, rvv_256)
41
42#define DMVR_PROTOTYPES(bd, opt) \
43void ff_vvc_dmvr_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
44 int height, intptr_t mx, intptr_t my, int width); \
45void ff_vvc_dmvr_h_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
46 int height, intptr_t mx, intptr_t my, int width); \
47void ff_vvc_dmvr_v_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
48 int height, intptr_t mx, intptr_t my, int width); \
49void ff_vvc_dmvr_hv_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \
50 int height, intptr_t mx, intptr_t my, int width); \
51
52DMVR_PROTOTYPES(8, rvv_128)
53DMVR_PROTOTYPES(8, rvv_256)
54
55#define DMVR_INIT(bd, opt) do { \
56 c->inter.dmvr[0][0] = ff_vvc_dmvr_##bd##_##opt; \
57 c->inter.dmvr[0][1] = ff_vvc_dmvr_h_##bd##_##opt; \
58 c->inter.dmvr[1][0] = ff_vvc_dmvr_v_##bd##_##opt; \
59 c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_##bd##_##opt; \
60} while (0)
61
62int ff_vvc_sad_rvv_128(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h);
63int ff_vvc_sad_rvv_256(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h);
64
65#define PUT_PIXELS_PROTOTYPES2(bd, opt) \
66void bf(ff_vvc_put_pixels, bd, opt)(int16_t *dst, \
67 const uint8_t *_src, const ptrdiff_t _src_stride, \
68 const int height, const int8_t *hf, const int8_t *vf, const int width);
69
70PUT_PIXELS_PROTOTYPES2(8, rvv_128)
71PUT_PIXELS_PROTOTYPES2(8, rvv_256)
72
73#define PEL_FUNC(dst, C, idx1, idx2, a) \
74 do { \
75 for (int w = 1; w < 7; w++) \
76 c->inter.dst[C][w][idx1][idx2] = a; \
77 } while (0) \
78
79#define FUNCS(C, opt) \
80 PEL_FUNC(put, C, 0, 0, ff_vvc_put_pixels_8_##opt); \
81
82void ff_vvc_dsp_init_riscv(VVCDSPContext *const c, const int bd)
83{
84#if HAVE_RVV
85 const int flags = av_get_cpu_flags();
86 int vlenb;
87
89 return;
90
91 vlenb = ff_get_rv_vlenb();
92 if (vlenb >= 32) {
93 switch (bd) {
94 case 8:
95 c->inter.avg = ff_vvc_avg_8_rvv_256;
96# if (__riscv_xlen == 64)
97 c->inter.w_avg = ff_vvc_w_avg_8_rvv_256;
98# endif
99 DMVR_INIT(8, rvv_256);
100 FUNCS(LUMA, rvv_256);
101 FUNCS(CHROMA, rvv_256);
102 break;
103 case 10:
104 c->inter.sad = ff_vvc_sad_rvv_256;
105 break;
106 }
107 } else if (vlenb >= 16) {
108 switch (bd) {
109 case 8:
110 c->inter.avg = ff_vvc_avg_8_rvv_128;
111# if (__riscv_xlen == 64)
112 c->inter.w_avg = ff_vvc_w_avg_8_rvv_128;
113# endif
114 DMVR_INIT(8, rvv_128);
115 FUNCS(LUMA, rvv_128);
116 FUNCS(CHROMA, rvv_128);
117 break;
118 case 10:
119 c->inter.sad = ff_vvc_sad_rvv_128;
120 break;
121 }
122 }
123#endif
124}
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define CHROMA(h)
Definition h264dec.h:88
#define LUMA
Definition filter.c:31
Macro definitions for various function/variable attributes.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition cpu.h:104
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition cpu.h:97
#define DMVR_PROTOTYPES(bd, opt)
Definition dsp_init.c:42
#define AVG_PROTOTYPES(bd, opt)
Definition dsp_init.c:32
int ff_vvc_sad_rvv_128(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h)
void ff_vvc_dsp_init_riscv(VVCDSPContext *const c, const int bd)
Definition dsp_init.c:82
int ff_vvc_sad_rvv_256(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h)
#define FUNCS(C, opt)
Definition dsp_init.c:79
#define PUT_PIXELS_PROTOTYPES2(bd, opt)
Definition dsp_init.c:65
#define DMVR_INIT(bd, opt)
Definition dsp_init.c:55
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
static double c[64]