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{
29 /* This code is currently disabled because of changes in the base
30 * implementation of these functions. This code should be enabled
31 * again once those changes are ported to this architecture. */
32#if 0
34
35 if (have_lsx(cpu_flags)) {
36 if (c->dstBpc <= 14) {
37 if (c->opts.src_range) {
38 c->lumConvertRange = lumRangeFromJpeg_lsx;
39 c->chrConvertRange = chrRangeFromJpeg_lsx;
40 } else {
41 c->lumConvertRange = lumRangeToJpeg_lsx;
42 c->chrConvertRange = chrRangeToJpeg_lsx;
43 }
44 }
45 }
46#if HAVE_LASX
47 if (have_lasx(cpu_flags)) {
48 if (c->dstBpc <= 14) {
49 if (c->opts.src_range) {
50 c->lumConvertRange = lumRangeFromJpeg_lasx;
51 c->chrConvertRange = chrRangeFromJpeg_lasx;
52 } else {
53 c->lumConvertRange = lumRangeToJpeg_lasx;
54 c->chrConvertRange = chrRangeToJpeg_lasx;
55 }
56 }
57 }
58#endif // #if HAVE_LASX
59#endif
60}
61
63{
65 if (have_lsx(cpu_flags)) {
66 ff_sws_init_output_lsx(c, &c->yuv2plane1, &c->yuv2planeX,
67 &c->yuv2nv12cX, &c->yuv2packed1,
68 &c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);
70 if (c->srcBpc == 8) {
71 if (c->dstBpc <= 14) {
72 c->hyScale = c->hcScale = ff_hscale_8_to_15_lsx;
73 } else {
74 c->hyScale = c->hcScale = ff_hscale_8_to_19_lsx;
75 }
76 } else {
77 c->hyScale = c->hcScale = c->dstBpc > 14 ? ff_hscale_16_to_19_lsx
79 }
80 }
81#if HAVE_LASX
82 if (have_lasx(cpu_flags)) {
83 ff_sws_init_output_lasx(c, &c->yuv2plane1, &c->yuv2planeX,
84 &c->yuv2nv12cX, &c->yuv2packed1,
85 &c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);
87 if (c->srcBpc == 8) {
88 if (c->dstBpc <= 14) {
89 c->hyScale = c->hcScale = ff_hscale_8_to_15_lasx;
90 } else {
91 c->hyScale = c->hcScale = ff_hscale_8_to_19_lasx;
92 }
93 } else {
94 c->hyScale = c->hcScale = c->dstBpc > 14 ? ff_hscale_16_to_19_lasx
96 }
97 }
98#endif // #if HAVE_LASX
99}
100
102{
103#if HAVE_LASX
105 if (have_lasx(cpu_flags))
107#endif // #if HAVE_LASX
108}
109
111{
113#if HAVE_LASX
114 if (have_lasx(cpu_flags)) {
115 if (c->opts.src_format == AV_PIX_FMT_YUV420P) {
116 switch (c->opts.dst_format) {
117 case AV_PIX_FMT_RGB24:
118 return yuv420_rgb24_lasx;
119 case AV_PIX_FMT_BGR24:
120 return yuv420_bgr24_lasx;
121 case AV_PIX_FMT_RGBA:
122 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
123 break;
124 } else
125 return yuv420_rgba32_lasx;
126 case AV_PIX_FMT_ARGB:
127 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
128 break;
129 } else
130 return yuv420_argb32_lasx;
131 case AV_PIX_FMT_BGRA:
132 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
133 break;
134 } else
135 return yuv420_bgra32_lasx;
136 case AV_PIX_FMT_ABGR:
137 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
138 break;
139 } else
140 return yuv420_abgr32_lasx;
141 }
142 }
143 }
144#endif // #if HAVE_LASX
145 if (have_lsx(cpu_flags)) {
146 if (c->opts.src_format == AV_PIX_FMT_YUV420P) {
147 switch (c->opts.dst_format) {
148 case AV_PIX_FMT_RGB24:
149 return yuv420_rgb24_lsx;
150 case AV_PIX_FMT_BGR24:
151 return yuv420_bgr24_lsx;
152 case AV_PIX_FMT_RGBA:
153 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
154 break;
155 } else
156 return yuv420_rgba32_lsx;
157 case AV_PIX_FMT_ARGB:
158 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
159 break;
160 } else
161 return yuv420_argb32_lsx;
162 case AV_PIX_FMT_BGRA:
163 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
164 break;
165 } else
166 return yuv420_bgra32_lsx;
167 case AV_PIX_FMT_ABGR:
168 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) {
169 break;
170 } else
171 return yuv420_abgr32_lsx;
172 }
173 }
174 }
175 return NULL;
176}
#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 lumRangeToJpeg_lsx(int16_t *dst, int width)
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[])
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 chrRangeFromJpeg_lsx(int16_t *dstU, int16_t *dstV, int width)
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 chrRangeToJpeg_lsx(int16_t *dstU, int16_t *dstV, int width)
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)
static double c[64]