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  /* This code is currently disabled because of changes in the base
32  * implementation of these functions. This code should be enabled
33  * again once those changes are ported to this architecture. */
34 #if 0
35 #if HAVE_RVV
36  int flags = av_get_cpu_flags();
37 
38  static const struct {
39  void (*lum)(int16_t *, int);
40  void (*chr)(int16_t *, int16_t *, int);
41  } convs[2] = {
44  };
45 
46  if (c->dstBpc <= 14 &&
48  bool from = c->opts.src_range != 0;
49 
50  c->lumConvertRange = convs[from].lum;
51  c->chrConvertRange = convs[from].chr;
52  }
53 #endif
54 #endif
55 }
56 
57 #define RVV_INPUT(name) \
58 void ff_##name##ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, \
59  const uint8_t *, int w, uint32_t *coeffs, void *); \
60 void ff_##name##ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, \
61  const uint8_t *, const uint8_t *, int w, \
62  uint32_t *coeffs, void *); \
63 void ff_##name##ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *, \
64  const uint8_t *, const uint8_t *, int w, \
65  uint32_t *coeffs, void *)
66 
67 RVV_INPUT(abgr32);
68 RVV_INPUT(argb32);
69 RVV_INPUT(bgr24);
70 RVV_INPUT(bgra32);
71 RVV_INPUT(rgb24);
72 RVV_INPUT(rgba32);
73 
75 {
76 #if HAVE_RVV
77  int flags = av_get_cpu_flags();
78 
80  switch (c->opts.src_format) {
81  case AV_PIX_FMT_ABGR:
82  c->lumToYV12 = ff_abgr32ToY_rvv;
83  if (c->chrSrcHSubSample)
84  c->chrToYV12 = ff_abgr32ToUV_half_rvv;
85  else
86  c->chrToYV12 = ff_abgr32ToUV_rvv;
87  break;
88 
89  case AV_PIX_FMT_ARGB:
90  c->lumToYV12 = ff_argb32ToY_rvv;
91  if (c->chrSrcHSubSample)
92  c->chrToYV12 = ff_argb32ToUV_half_rvv;
93  else
94  c->chrToYV12 = ff_argb32ToUV_rvv;
95  break;
96 
97  case AV_PIX_FMT_BGR24:
98  c->lumToYV12 = ff_bgr24ToY_rvv;
99  if (c->chrSrcHSubSample)
100  c->chrToYV12 = ff_bgr24ToUV_half_rvv;
101  else
102  c->chrToYV12 = ff_bgr24ToUV_rvv;
103  break;
104 
105  case AV_PIX_FMT_BGRA:
106  c->lumToYV12 = ff_bgra32ToY_rvv;
107  if (c->chrSrcHSubSample)
108  c->chrToYV12 = ff_bgra32ToUV_half_rvv;
109  else
110  c->chrToYV12 = ff_bgra32ToUV_rvv;
111  break;
112 
113  case AV_PIX_FMT_RGB24:
114  c->lumToYV12 = ff_rgb24ToY_rvv;
115  if (c->chrSrcHSubSample)
116  c->chrToYV12 = ff_rgb24ToUV_half_rvv;
117  else
118  c->chrToYV12 = ff_rgb24ToUV_rvv;
119  break;
120 
121  case AV_PIX_FMT_RGBA:
122  c->lumToYV12 = ff_rgba32ToY_rvv;
123  if (c->chrSrcHSubSample)
124  c->chrToYV12 = ff_rgba32ToUV_half_rvv;
125  else
126  c->chrToYV12 = ff_rgba32ToUV_rvv;
127  break;
128  }
129  }
130 #endif
131 }
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:57
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
ff_sws_init_swscale_riscv
av_cold void ff_sws_init_swscale_riscv(SwsInternal *c)
Definition: swscale.c:74
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:109
ff_range_lum_to_jpeg_16_rvv
void ff_range_lum_to_jpeg_16_rvv(int16_t *, int)
AV_CPU_FLAG_RVB
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition: cpu.h:102
av_cold
#define av_cold
Definition: attributes.h:90
cpu.h
from
const char * from
Definition: jacosubdec.c:66
ff_sws_init_range_convert_riscv
av_cold void ff_sws_init_range_convert_riscv(SwsInternal *c)
Definition: swscale.c:29
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
attributes.h
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
AV_CPU_FLAG_RVV_I32
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition: cpu.h:92
swscale_internal.h
ff_range_chr_from_jpeg_16_rvv
void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int)
SwsInternal
Definition: swscale_internal.h:317
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:482