FFmpeg
swscale_init_loongarch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Loongson Technology Corporation Limited
3  * Contributed by Hao Chen(chenhao@loongson.cn)
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 "swscale_loongarch.h"
24 #include "libswscale/rgb2rgb.h"
26 
28 {
30  if (have_lasx(cpu_flags)) {
32  if (c->srcBpc == 8) {
33  if (c->dstBpc <= 14) {
34  c->hyScale = c->hcScale = ff_hscale_8_to_15_lasx;
35  } else {
36  c->hyScale = c->hcScale = ff_hscale_8_to_19_lasx;
37  }
38  } else {
39  c->hyScale = c->hcScale = c->dstBpc > 14 ? ff_hscale_16_to_19_lasx
41  }
42  switch (c->srcFormat) {
43  case AV_PIX_FMT_GBRAP:
44  case AV_PIX_FMT_GBRP:
45  {
46  c->readChrPlanar = planar_rgb_to_uv_lasx;
47  c->readLumPlanar = planar_rgb_to_y_lasx;
48  }
49  break;
50  }
51  if (c->dstBpc == 8)
52  c->yuv2planeX = ff_yuv2planeX_8_lasx;
53  }
54 }
55 
57 {
59  if (have_lasx(cpu_flags))
61 }
62 
64 {
66  if (have_lasx(cpu_flags)) {
67  switch (c->dstFormat) {
68  case AV_PIX_FMT_RGB24:
69  return yuv420_rgb24_lasx;
70  case AV_PIX_FMT_BGR24:
71  return yuv420_bgr24_lasx;
72  case AV_PIX_FMT_RGBA:
73  if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) {
74  break;
75  } else
76  return yuv420_rgba32_lasx;
77  case AV_PIX_FMT_ARGB:
78  if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) {
79  break;
80  } else
81  return yuv420_argb32_lasx;
82  case AV_PIX_FMT_BGRA:
83  if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) {
84  break;
85  } else
86  return yuv420_bgra32_lasx;
87  case AV_PIX_FMT_ABGR:
88  if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) {
89  break;
90  } else
91  return yuv420_abgr32_lasx;
92  }
93  }
94  return NULL;
95 }
yuv420_bgr24_lasx
int yuv420_bgr24_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
ff_yuv2planeX_8_lasx
void ff_yuv2planeX_8_lasx(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
Definition: output_lasx.c:25
have_lasx
#define have_lasx(flags)
Definition: cpu.h:29
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:103
cpu_flags
static atomic_int cpu_flags
Definition: cpu.c:52
SwsFunc
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
Definition: swscale_internal.h:99
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
swscale_loongarch.h
ff_yuv2rgb_init_loongarch
av_cold SwsFunc ff_yuv2rgb_init_loongarch(SwsContext *c)
Definition: swscale_init_loongarch.c:63
av_cold
#define av_cold
Definition: attributes.h:90
ff_sws_init_swscale_loongarch
av_cold void ff_sws_init_swscale_loongarch(SwsContext *c)
Definition: swscale_init_loongarch.c:27
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
interleaveBytes
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
Definition: rgb2rgb.c:88
NULL
#define NULL
Definition: coverity.c:32
ff_sws_init_output_loongarch
av_cold void ff_sws_init_output_loongarch(SwsContext *c)
Definition: output_lasx.c:1780
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
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:68
yuv420_bgra32_lasx
int yuv420_bgra32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
ff_interleave_bytes_lasx
void ff_interleave_bytes_lasx(const uint8_t *src1, const uint8_t *src2, uint8_t *dest, int width, int height, int src1Stride, int src2Stride, int dstStride)
Definition: rgb2rgb_lasx.c:25
isALPHA
#define isALPHA(x)
Definition: swscale.c:51
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
swscale_internal.h
planar_rgb_to_uv_lasx
void planar_rgb_to_uv_lasx(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv, void *opq)
Definition: input_lasx.c:25
ff_hscale_8_to_15_lasx
void ff_hscale_8_to_15_lasx(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Definition: swscale_lasx.c:314
ff_hscale_16_to_19_lasx
void ff_hscale_16_to_19_lasx(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Definition: swscale_lasx.c:823
yuv420_rgb24_lasx
int yuv420_rgb24_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
yuv420_abgr32_lasx
int yuv420_abgr32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
yuv420_argb32_lasx
int yuv420_argb32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
ff_hscale_16_to_15_lasx
void ff_hscale_16_to_15_lasx(SwsContext *c, int16_t *dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Definition: swscale_lasx.c:676
rgb2rgb_init_loongarch
av_cold void rgb2rgb_init_loongarch(void)
Definition: swscale_init_loongarch.c:56
planar_rgb_to_y_lasx
void planar_rgb_to_y_lasx(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv, void *opq)
Definition: input_lasx.c:127
ff_hscale_8_to_19_lasx
void ff_hscale_8_to_19_lasx(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Definition: swscale_lasx.c:474
SwsContext
Definition: swscale_internal.h:299
cpu.h
rgb2rgb.h
yuv420_rgba32_lasx
int yuv420_rgba32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])