FFmpeg
swscale.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "config.h"
20 #include "libavutil/attributes.h"
21 #include "libavutil/riscv/cpu.h"
23 
24 void ff_range_lum_to_jpeg_16_rvv(int16_t *, int);
25 void ff_range_chr_to_jpeg_16_rvv(int16_t *, int16_t *, int);
26 void ff_range_lum_from_jpeg_16_rvv(int16_t *, int);
27 void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int);
28 
30 {
31 #if HAVE_RVV
32  static const struct {
33  void (*lum)(int16_t *, int);
34  void (*chr)(int16_t *, int16_t *, int);
35  } convs[2] = {
38  };
39 
40  if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat) &&
41  c->dstBpc <= 14 &&
43  bool from = c->srcRange != 0;
44 
45  c->lumConvertRange = convs[from].lum;
46  c->chrConvertRange = convs[from].chr;
47  }
48 #endif
49 }
50 
51 #define RVV_INPUT(name) \
52 void ff_##name##ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, \
53  const uint8_t *, int w, uint32_t *coeffs, void *); \
54 void ff_##name##ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, \
55  const uint8_t *, const uint8_t *, int w, \
56  uint32_t *coeffs, void *); \
57 void ff_##name##ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *, \
58  const uint8_t *, const uint8_t *, int w, \
59  uint32_t *coeffs, void *)
60 
61 RVV_INPUT(abgr32);
62 RVV_INPUT(argb32);
63 RVV_INPUT(bgr24);
64 RVV_INPUT(bgra32);
65 RVV_INPUT(rgb24);
66 RVV_INPUT(rgba32);
67 
69 {
70  int flags = av_get_cpu_flags();
71 
72 #if HAVE_RVV
74  switch (c->srcFormat) {
75  case AV_PIX_FMT_ABGR:
76  c->lumToYV12 = ff_abgr32ToY_rvv;
77  if (c->chrSrcHSubSample)
78  c->chrToYV12 = ff_abgr32ToUV_half_rvv;
79  else
80  c->chrToYV12 = ff_abgr32ToUV_rvv;
81  break;
82 
83  case AV_PIX_FMT_ARGB:
84  c->lumToYV12 = ff_argb32ToY_rvv;
85  if (c->chrSrcHSubSample)
86  c->chrToYV12 = ff_argb32ToUV_half_rvv;
87  else
88  c->chrToYV12 = ff_argb32ToUV_rvv;
89  break;
90 
91  case AV_PIX_FMT_BGR24:
92  c->lumToYV12 = ff_bgr24ToY_rvv;
93  if (c->chrSrcHSubSample)
94  c->chrToYV12 = ff_bgr24ToUV_half_rvv;
95  else
96  c->chrToYV12 = ff_bgr24ToUV_rvv;
97  break;
98 
99  case AV_PIX_FMT_BGRA:
100  c->lumToYV12 = ff_bgra32ToY_rvv;
101  if (c->chrSrcHSubSample)
102  c->chrToYV12 = ff_bgra32ToUV_half_rvv;
103  else
104  c->chrToYV12 = ff_bgra32ToUV_rvv;
105  break;
106 
107  case AV_PIX_FMT_RGB24:
108  c->lumToYV12 = ff_rgb24ToY_rvv;
109  if (c->chrSrcHSubSample)
110  c->chrToYV12 = ff_rgb24ToUV_half_rvv;
111  else
112  c->chrToYV12 = ff_rgb24ToUV_rvv;
113  break;
114 
115  case AV_PIX_FMT_RGBA:
116  c->lumToYV12 = ff_rgba32ToY_rvv;
117  if (c->chrSrcHSubSample)
118  c->chrToYV12 = ff_rgba32ToUV_half_rvv;
119  else
120  c->chrToYV12 = ff_rgba32ToUV_rvv;
121  break;
122  }
123  }
124 #endif
126 }
ff_range_chr_to_jpeg_16_rvv
void ff_range_chr_to_jpeg_16_rvv(int16_t *, int16_t *, int)
RVV_INPUT
#define RVV_INPUT(name)
Definition: swscale.c:51
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:103
ff_range_lum_to_jpeg_16_rvv
void ff_range_lum_to_jpeg_16_rvv(int16_t *, int)
av_cold
#define av_cold
Definition: attributes.h:90
cpu.h
from
const char * from
Definition: jacosubdec.c:66
AV_CPU_FLAG_RVB_ADDR
#define AV_CPU_FLAG_RVB_ADDR
Address bit-manipulations.
Definition: cpu.h:92
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
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
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
isAnyRGB
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:835
attributes.h
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
ff_sws_init_swscale_riscv
av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
Definition: swscale.c:68
AV_CPU_FLAG_RVV_I32
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition: cpu.h:87
swscale_internal.h
ff_range_chr_from_jpeg_16_rvv
void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int)
ff_range_lum_from_jpeg_16_rvv
void ff_range_lum_from_jpeg_16_rvv(int16_t *, int)
lum
static double lum(void *priv, double x, double y, int plane)
Definition: vf_fftfilt.c:107
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
ff_sws_init_range_convert_riscv
static av_cold void ff_sws_init_range_convert_riscv(SwsContext *c, int flags)
Definition: swscale.c:29
int
int
Definition: ffmpeg_filter.c:424
SwsContext
Definition: swscale_internal.h:299