FFmpeg
Loading...
Searching...
No Matches
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
31 if (c->dstBpc > 14)
32 return;
33
34 if (have_lsx(cpu_flags)) {
35 if (c->opts.src_range) {
36 c->lumConvertRange = lumRangeFromJpeg_lsx;
37 c->chrConvertRange = chrRangeFromJpeg_lsx;
38 } else {
39 c->lumConvertRange = lumRangeToJpeg_lsx;
40 c->chrConvertRange = chrRangeToJpeg_lsx;
41 }
42 }
43#if HAVE_LASX
44 if (have_lasx(cpu_flags)) {
45 if (c->opts.src_range) {
46 c->lumConvertRange = lumRangeFromJpeg_lasx;
47 c->chrConvertRange = chrRangeFromJpeg_lasx;
48 } else {
49 c->lumConvertRange = lumRangeToJpeg_lasx;
50 c->chrConvertRange = chrRangeToJpeg_lasx;
51 }
52 }
53#endif // #if HAVE_LASX
54}
55
57{
59 if (have_lsx(cpu_flags)) {
60 ff_sws_init_output_lsx(c, &c->yuv2plane1, &c->yuv2planeX,
61 &c->yuv2nv12cX, &c->yuv2packed1,
62 &c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);
64 if (c->srcBpc == 8) {
65 if (c->dstBpc <= 14) {
66 c->hyScale = c->hcScale = ff_hscale_8_to_15_lsx;
67 } else {
68 c->hyScale = c->hcScale = ff_hscale_8_to_19_lsx;
69 }
70 } else {
71 c->hyScale = c->hcScale = c->dstBpc > 14 ? ff_hscale_16_to_19_lsx
73 }
74 }
75#if HAVE_LASX
76 if (have_lasx(cpu_flags)) {
77 ff_sws_init_output_lasx(c, &c->yuv2plane1, &c->yuv2planeX,
78 &c->yuv2nv12cX, &c->yuv2packed1,
79 &c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);
81 if (c->srcBpc == 8) {
82 if (c->dstBpc <= 14) {
83 c->hyScale = c->hcScale = ff_hscale_8_to_15_lasx;
84 } else {
85 c->hyScale = c->hcScale = ff_hscale_8_to_19_lasx;
86 }
87 } else {
88 c->hyScale = c->hcScale = c->dstBpc > 14 ? ff_hscale_16_to_19_lasx
90 }
91 }
92#endif // #if HAVE_LASX
93}
94
96{
97#if HAVE_LASX
101#endif // #if HAVE_LASX
102}
103
105{
107#if HAVE_LASX
108 if (have_lasx(cpu_flags)) {
109 if (c->opts.src_format == AV_PIX_FMT_YUV420P) {
110 switch (c->opts.dst_format) {
111 case AV_PIX_FMT_RGB24:
112 return yuv420_rgb24_lasx;
113 case AV_PIX_FMT_BGR24:
114 return yuv420_bgr24_lasx;
115 case AV_PIX_FMT_RGBA:
116 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
117 break;
118 } else
119 return yuv420_rgba32_lasx;
120 case AV_PIX_FMT_ARGB:
121 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
122 break;
123 } else
124 return yuv420_argb32_lasx;
125 case AV_PIX_FMT_BGRA:
126 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
127 break;
128 } else
129 return yuv420_bgra32_lasx;
130 case AV_PIX_FMT_ABGR:
131 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
132 break;
133 } else
134 return yuv420_abgr32_lasx;
135 }
136 }
137 }
138#endif // #if HAVE_LASX
139 if (have_lsx(cpu_flags)) {
140 if (c->opts.src_format == AV_PIX_FMT_YUV420P) {
141 switch (c->opts.dst_format) {
142 case AV_PIX_FMT_RGB24:
143 return yuv420_rgb24_lsx;
144 case AV_PIX_FMT_BGR24:
145 return yuv420_bgr24_lsx;
146 case AV_PIX_FMT_RGBA:
147 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
148 break;
149 } else
150 return yuv420_rgba32_lsx;
151 case AV_PIX_FMT_ARGB:
152 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
153 break;
154 } else
155 return yuv420_argb32_lsx;
156 case AV_PIX_FMT_BGRA:
157 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
158 break;
159 } else
160 return yuv420_bgra32_lsx;
161 case AV_PIX_FMT_ABGR:
162 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
163 break;
164 } else
165 return yuv420_abgr32_lsx;
166 }
167 }
168 }
169 return NULL;
170}
#define NULL
Definition coverity.c:32
av_cold void ff_sws_init_input_lasx(SwsInternal *c)
Definition input_lasx.c:204
av_cold void ff_sws_init_input_lsx(SwsInternal *c)
Definition input_lsx.c:24
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define have_lsx(flags)
Definition cpu.h:28
#define have_lasx(flags)
Definition cpu.h:29
av_cold void ff_sws_init_output_lasx(SwsInternal *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, yuv2interleavedX_fn *yuv2nv12cX, yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, yuv2packedX_fn *yuv2packedX, yuv2anyX_fn *yuv2anyX)
av_cold void ff_sws_init_output_lsx(SwsInternal *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, yuv2interleavedX_fn *yuv2nv12cX, yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, yuv2packedX_fn *yuv2packedX, yuv2anyX_fn *yuv2anyX)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
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
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)
av_cold void rgb2rgb_init_loongarch(void)
av_cold SwsFunc ff_yuv2rgb_init_loongarch(SwsInternal *c)
av_cold void ff_sws_init_swscale_loongarch(SwsInternal *c)
av_cold void ff_sws_init_range_convert_loongarch(SwsInternal *c)
int(* SwsFunc)(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
void ff_hscale_16_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
void ff_hscale_8_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
void ff_hscale_16_to_15_lasx(SwsInternal *c, int16_t *dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
void ff_hscale_8_to_19_lasx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
void ff_hscale_8_to_15_lsx(SwsInternal *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
void ff_hscale_8_to_19_lsx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
int yuv420_argb32_lsx(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
void chrRangeToJpeg_lsx(int16_t *dstU, int16_t *dstV, int width, uint32_t coeff, int64_t offset)
int yuv420_rgba32_lsx(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
void lumRangeToJpeg_lsx(int16_t *dst, int width, uint32_t coeff, int64_t offset)
int yuv420_bgra32_lsx(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
int yuv420_rgb24_lsx(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
void ff_hscale_16_to_15_lsx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Definition swscale_lsx.c:26
void ff_hscale_16_to_19_lsx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Definition swscale_lsx.c:42
void chrRangeFromJpeg_lsx(int16_t *dstU, int16_t *dstV, int width, uint32_t coeff, int64_t offset)
int yuv420_bgr24_lsx(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
int yuv420_abgr32_lsx(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
void lumRangeFromJpeg_lsx(int16_t *dst, int width, uint32_t coeff, int64_t offset)
static double c[64]