FFmpeg
mpegvideoencdsp_init.c
Go to the documentation of this file.
1 /*
2  * Copyright © 2024 Rémi Denis-Courmont.
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 <stdint.h>
22 
23 #include "libavutil/cpu.h"
25 
26 int ff_try_8x8basis_rvv(const int16_t rem[64], const int16_t weight[64],
27  const int16_t basis[16], int scale);
28 void ff_add_8x8basis_rvv(int16_t rem[64], const int16_t basis[16], int scale);
29 int ff_pix_sum_rvv(const uint8_t *pix, ptrdiff_t line_size);
30 int ff_pix_norm1_rvv(const uint8_t *pix, ptrdiff_t line_size);
31 
33  AVCodecContext *avctx)
34 {
35 #if HAVE_RVV
36  int flags = av_get_cpu_flags();
37 
38  if (flags & AV_CPU_FLAG_RVV_I32) {
39  if (flags & AV_CPU_FLAG_RVB) {
40  c->try_8x8basis = ff_try_8x8basis_rvv;
41  c->add_8x8basis = ff_add_8x8basis_rvv;
42  }
43 
44  if (flags & AV_CPU_FLAG_RVV_I64) {
45  if ((flags & AV_CPU_FLAG_RVB) && ff_rv_vlen_least(128))
46  c->pix_sum = ff_pix_sum_rvv;
47  c->pix_norm1 = ff_pix_norm1_rvv;
48  }
49  }
50 #endif
51 }
ff_try_8x8basis_rvv
int ff_try_8x8basis_rvv(const int16_t rem[64], const int16_t weight[64], const int16_t basis[16], int scale)
basis
static int16_t basis[64][64]
Definition: mpegvideo_enc.c:4210
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:109
AV_CPU_FLAG_RVB
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition: cpu.h:102
weight
const h264_weight_func weight
Definition: h264dsp_init.c:33
av_cold
#define av_cold
Definition: attributes.h:90
ff_add_8x8basis_rvv
void ff_add_8x8basis_rvv(int16_t rem[64], const int16_t basis[16], int scale)
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
cpu.h
ff_pix_sum_rvv
int ff_pix_sum_rvv(const uint8_t *pix, ptrdiff_t line_size)
MpegvideoEncDSPContext
Definition: mpegvideoencdsp.h:32
ff_mpegvideoencdsp_init_riscv
av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c, AVCodecContext *avctx)
Definition: mpegvideoencdsp_init.c:32
ff_pix_norm1_rvv
int ff_pix_norm1_rvv(const uint8_t *pix, ptrdiff_t line_size)
AV_CPU_FLAG_RVV_I32
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition: cpu.h:92
AVCodecContext
main external API structure.
Definition: avcodec.h:451
mpegvideoencdsp.h
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AV_CPU_FLAG_RVV_I64
#define AV_CPU_FLAG_RVV_I64
Vectors of 64-bit int's *‍/.
Definition: cpu.h:94