FFmpeg
input_lsx.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Loongson Technology Corporation Limited
3  * Contributed by Shiyou Yin<yinshiyou-hf@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"
23 
25 {
26  enum AVPixelFormat srcFormat = c->opts.src_format;
27 
28  switch (srcFormat) {
29  case AV_PIX_FMT_YUYV422:
30  c->chrToYV12 = yuy2ToUV_lsx;
31  break;
32  case AV_PIX_FMT_YVYU422:
33  c->chrToYV12 = yvy2ToUV_lsx;
34  break;
35  case AV_PIX_FMT_UYVY422:
36  c->chrToYV12 = uyvyToUV_lsx;
37  break;
38  case AV_PIX_FMT_NV12:
39  case AV_PIX_FMT_NV16:
40  case AV_PIX_FMT_NV24:
41  c->chrToYV12 = nv12ToUV_lsx;
42  break;
43  case AV_PIX_FMT_NV21:
44  case AV_PIX_FMT_NV42:
45  c->chrToYV12 = nv21ToUV_lsx;
46  break;
47  case AV_PIX_FMT_GBRAP:
48  case AV_PIX_FMT_GBRP:
49  c->readChrPlanar = planar_rgb_to_uv_lsx;
50  break;
51  }
52 
53  if (c->needAlpha) {
54  switch (srcFormat) {
55  case AV_PIX_FMT_BGRA:
56  case AV_PIX_FMT_RGBA:
57  c->alpToYV12 = rgbaToA_lsx;
58  break;
59  case AV_PIX_FMT_ABGR:
60  case AV_PIX_FMT_ARGB:
61  c->alpToYV12 = abgrToA_lsx;
62  break;
63  }
64  }
65 }
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
planar_rgb_to_uv_lsx
void planar_rgb_to_uv_lsx(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv, void *opq)
nv12ToUV_lsx
void nv12ToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused, void *opq)
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
swscale_loongarch.h
av_cold
#define av_cold
Definition: attributes.h:90
ff_sws_init_input_lsx
av_cold void ff_sws_init_input_lsx(SwsInternal *c)
Definition: input_lsx.c:24
uyvyToUV_lsx
void uyvyToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused, void *opq)
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
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
yvy2ToUV_lsx
void yvy2ToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused, void *opq)
AV_PIX_FMT_NV16
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:198
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
AV_PIX_FMT_NV24
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:371
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:97
AV_PIX_FMT_NV42
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
Definition: pixfmt.h:372
AV_PIX_FMT_YVYU422
@ AV_PIX_FMT_YVYU422
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:207
SwsInternal
Definition: swscale_internal.h:317
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
rgbaToA_lsx
void rgbaToA_lsx(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused, void *opq)
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
abgrToA_lsx
void abgrToA_lsx(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused, void *opq)
nv21ToUV_lsx
void nv21ToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused, void *opq)
yuy2ToUV_lsx
void yuy2ToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused, void *opq)