FFmpeg
Loading...
Searching...
No Matches
h264dsp_init.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 J. Dekker <jdek@itanimul.li>
3 * Copyright © 2024 Rémi Denis-Courmont.
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "config.h"
23
24#include <stdint.h>
25#include <string.h>
26
28#include "libavutil/cpu.h"
29#include "libavutil/riscv/cpu.h"
30#include "libavcodec/h264dsp.h"
31
32extern const struct {
36
38 int alpha, int beta, int8_t *tc0);
40 int alpha, int beta, int8_t *tc0);
42 int alpha, int beta, int8_t *tc0);
44 int alpha, int beta);
46 int alpha, int beta);
48 int a, int b);
50 int alpha, int beta, int8_t *tc0);
52 int alpha, int beta, int8_t *tc0);
54 int alpha, int beta,
55 int8_t *tc0);
57 int alpha, int beta);
59 int alpha, int beta);
61 ptrdiff_t stride,
62 int alpha, int beta);
63
64#define IDCT_DEPTH(depth) \
65void ff_h264_idct_add_##depth##_rvv(uint8_t *d, int16_t *s, ptrdiff_t stride); \
66void ff_h264_idct8_add_##depth##_rvv(uint8_t *d, int16_t *s, ptrdiff_t stride); \
67void ff_h264_idct4_dc_add_##depth##_rvv(uint8_t *, int16_t *, ptrdiff_t); \
68void ff_h264_idct8_dc_add_##depth##_rvv(uint8_t *, int16_t *, ptrdiff_t); \
69void ff_h264_idct_add16_##depth##_rvv(uint8_t *d, const int *soffset, \
70 int16_t *s, ptrdiff_t stride, \
71 const uint8_t nnzc[5 * 8]); \
72void ff_h264_idct_add16intra_##depth##_rvv(uint8_t *d, const int *soffset, \
73 int16_t *s, ptrdiff_t stride, \
74 const uint8_t nnzc[5 * 8]); \
75void ff_h264_idct8_add4_##depth##_rvv(uint8_t *d, const int *soffset, \
76 int16_t *s, ptrdiff_t stride, \
77 const uint8_t nnzc[5 * 8]); \
78void ff_h264_idct4_add8_##depth##_rvv(uint8_t **d, const int *soffset, \
79 int16_t *s, ptrdiff_t stride, \
80 const uint8_t nnzc[5 * 8]); \
81void ff_h264_idct4_add8_422_##depth##_rvv(uint8_t **d, const int *soffset, \
82 int16_t *s, ptrdiff_t stride, \
83 const uint8_t nnzc[5 * 8]); \
84void ff_h264_luma_dc_dequant_idct_##depth##_rvv(int16_t *d, int16_t *s, int q);
85
88IDCT_DEPTH(10)
89IDCT_DEPTH(12)
90IDCT_DEPTH(14)
91#undef IDCT_DEPTH
92
93void ff_h264_add_pixels8_8_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride);
94void ff_h264_add_pixels4_8_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride);
95void ff_h264_add_pixels8_16_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride);
96void ff_h264_add_pixels4_16_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride);
97
98extern int ff_startcode_find_candidate_rvb(const uint8_t *, int);
99extern int ff_startcode_find_candidate_rvv(const uint8_t *, int);
100
102 const int chroma_format_idc)
103{
104#if HAVE_RV
105 int flags = av_get_cpu_flags();
106
109# if HAVE_RVV
111 const bool zvl128b = ff_rv_vlen_least(128);
112
113 if (bit_depth == 8) {
114 if (zvl128b) {
116 dsp->weight_pixels_tab[0] =
118 dsp->biweight_pixels_tab[0] =
119 ff_h264_weight_funcs_8_rvv[0].biweight;
120 }
122 dsp->weight_pixels_tab[1] =
124 dsp->biweight_pixels_tab[1] =
125 ff_h264_weight_funcs_8_rvv[1].biweight;
126 }
127 dsp->weight_pixels_tab[2] =
129 dsp->biweight_pixels_tab[2] =
130 ff_h264_weight_funcs_8_rvv[2].biweight;
131 dsp->weight_pixels_tab[3] =
133 dsp->biweight_pixels_tab[3] =
134 ff_h264_weight_funcs_8_rvv[3].biweight;
135 }
136
137 if (bit_depth == 8 && zvl128b) {
152
153 if (chroma_format_idc <= 1) {
162 }
163
164 dsp->idct_add = ff_h264_idct_add_8_rvv;
165 dsp->idct8_add = ff_h264_idct8_add_8_rvv;
166 if (flags & AV_CPU_FLAG_RVB) {
167 dsp->idct_dc_add = ff_h264_idct4_dc_add_8_rvv;
168 dsp->idct_add16 = ff_h264_idct_add16_8_rvv;
169 dsp->idct_add16intra = ff_h264_idct_add16intra_8_rvv;
170# if __riscv_xlen == 64
171 dsp->idct8_add4 = ff_h264_idct8_add4_8_rvv;
172 if (chroma_format_idc <= 1)
173 dsp->idct_add8 = ff_h264_idct4_add8_8_rvv;
174 else
175 dsp->idct_add8 = ff_h264_idct4_add8_422_8_rvv;
176# endif
177 }
178
180 ff_h264_luma_dc_dequant_idct_8_rvv;
181
185 dsp->idct8_dc_add = ff_h264_idct8_dc_add_8_rvv;
186 }
188 }
189
190#define IDCT_DEPTH(depth) \
191 if (bit_depth == depth) { \
192 if (zvl128b) { \
193 dsp->idct_add = ff_h264_idct_add_##depth##_rvv; \
194 dsp->luma_dc_dequant_idct = \
195 ff_h264_luma_dc_dequant_idct_9_rvv; \
196 } \
197 if (flags & AV_CPU_FLAG_RVB) \
198 dsp->idct8_add = ff_h264_idct8_add_##depth##_rvv; \
199 if (zvl128b && (flags & AV_CPU_FLAG_RVB)) { \
200 dsp->idct_dc_add = ff_h264_idct4_dc_add_##depth##_rvv; \
201 dsp->idct8_dc_add = ff_h264_idct8_dc_add_##depth##_rvv; \
202 dsp->idct_add16 = ff_h264_idct_add16_##depth##_rvv; \
203 dsp->idct_add16intra = \
204 ff_h264_idct_add16intra_##depth##_rvv; \
205 if (__riscv_xlen == 64) { \
206 if (chroma_format_idc <= 1) \
207 dsp->idct_add8 = \
208 ff_h264_idct4_add8_##depth##_rvv; \
209 else \
210 dsp->idct_add8 = \
211 ff_h264_idct4_add8_422_##depth##_rvv; \
212 } \
213 } \
214 if (__riscv_xlen == 64 && (flags & AV_CPU_FLAG_RVB)) \
215 dsp->idct8_add4 = ff_h264_idct8_add4_##depth##_rvv; \
216 }
217
218 IDCT_DEPTH(9)
219 IDCT_DEPTH(10)
220 IDCT_DEPTH(12)
221 IDCT_DEPTH(14)
222
223 if (bit_depth > 8 && zvl128b) {
227 }
228
230 }
231# endif
232#endif
233}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define s(width, name)
Definition cbs_vp9.c:198
static int16_t block[64]
Definition dct.c:125
H.264 DSP functions.
void(* h264_weight_func)(uint8_t *block, ptrdiff_t stride, int height, int log2_denom, int weight, int offset)
Definition h264dsp.h:33
void(* h264_biweight_func)(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int height, int log2_denom, int weightd, int weights, int offset)
Definition h264dsp.h:35
int a
static const int16_t alpha[]
Definition ilbcdata.h:55
#define b
Definition input.c:43
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define AV_CPU_FLAG_RVV_I64
Vectors of 64-bit int's *‍/.
Definition cpu.h:99
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition cpu.h:104
#define AV_CPU_FLAG_RVB_BASIC
Basic bit-manipulations.
Definition cpu.h:101
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition cpu.h:97
enum AVPixelFormat pix
Definition ohcodec.c:55
void ff_h264_add_pixels4_16_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride)
void ff_h264_h_loop_filter_chroma_mbaff_intra_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
void ff_h264_h_loop_filter_luma_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
int ff_startcode_find_candidate_rvv(const uint8_t *, int)
void ff_h264_h_loop_filter_chroma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
const struct @072147237165205171276005137247123301230277000354 ff_h264_weight_funcs_8_rvv[]
void ff_h264_h_loop_filter_chroma_mbaff_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
int ff_startcode_find_candidate_rvb(const uint8_t *, int)
void ff_h264_v_loop_filter_luma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
void ff_h264_v_loop_filter_chroma_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
void ff_h264_h_loop_filter_luma_mbaff_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, const int bit_depth, const int chroma_format_idc)
void ff_h264_add_pixels8_8_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride)
void ff_h264_v_loop_filter_luma_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
void ff_h264_h_loop_filter_luma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
void ff_h264_add_pixels4_8_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride)
void ff_h264_add_pixels8_16_rvv(uint8_t *dst, int16_t *block, ptrdiff_t stride)
void ff_h264_h_loop_filter_chroma_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
void ff_h264_h_loop_filter_luma_mbaff_intra_8_rvv(uint8_t *pix, ptrdiff_t s, int a, int b)
const h264_biweight_func biweight
const h264_weight_func weight
void ff_h264_v_loop_filter_chroma_intra_8_rvv(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
#define IDCT_DEPTH(depth)
Context for storing H.264 DSP functions.
Definition h264dsp.h:42
void(* luma_dc_dequant_idct)(int16_t *output, int16_t *input, int qmul)
Definition h264dsp.h:102
void(* v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
Definition h264dsp.h:61
void(* idct_add16intra)(uint8_t *dst, const int *blockoffset, int16_t *block, ptrdiff_t stride, const uint8_t nnzc[5 *8])
Definition h264dsp.h:99
void(* idct_dc_add)(uint8_t *dst, int16_t *block, ptrdiff_t stride)
Definition h264dsp.h:85
void(* h_loop_filter_luma_mbaff_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
Definition h264dsp.h:59
void(* h_loop_filter_chroma_mbaff_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
Definition h264dsp.h:72
h264_weight_func weight_pixels_tab[4]
Definition h264dsp.h:44
void(* v_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
Definition h264dsp.h:55
void(* h_loop_filter_luma_mbaff)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
Definition h264dsp.h:52
h264_biweight_func biweight_pixels_tab[4]
Definition h264dsp.h:45
void(* h_loop_filter_chroma_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
Definition h264dsp.h:70
void(* add_pixels4_clear)(uint8_t *dst, int16_t *block, ptrdiff_t stride)
Definition h264dsp.h:108
void(* h_loop_filter_chroma_mbaff)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
Definition h264dsp.h:65
void(* idct8_add4)(uint8_t *dst, const int *blockoffset, int16_t *block, ptrdiff_t stride, const uint8_t nnzc[5 *8])
Definition h264dsp.h:93
void(* v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
Definition h264dsp.h:48
int(* startcode_find_candidate)(const uint8_t *buf, int size)
Search buf from the start for up to size bytes.
Definition h264dsp.h:117
void(* idct_add16)(uint8_t *dst, const int *blockoffset, int16_t *block, ptrdiff_t stride, const uint8_t nnzc[5 *8])
Definition h264dsp.h:90
void(* idct_add)(uint8_t *dst, int16_t *block, ptrdiff_t stride)
Definition h264dsp.h:81
void(* idct8_add)(uint8_t *dst, int16_t *block, ptrdiff_t stride)
Definition h264dsp.h:83
void(* h_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
Definition h264dsp.h:57
void(* v_loop_filter_chroma_intra)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
Definition h264dsp.h:68
void(* h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
Definition h264dsp.h:63
void(* add_pixels8_clear)(uint8_t *dst, int16_t *block, ptrdiff_t stride)
Definition h264dsp.h:107
void(* idct_add8)(uint8_t **dst, const int *blockoffset, int16_t *block, ptrdiff_t stride, const uint8_t nnzc[15 *8])
Definition h264dsp.h:96
void(* h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
Definition h264dsp.h:50
void(* idct8_dc_add)(uint8_t *dst, int16_t *block, ptrdiff_t stride)
Definition h264dsp.h:87
#define stride