FFmpeg
swscale_lsx.c
Go to the documentation of this file.
1 /*
2  * Loongson LSX optimized swscale
3  *
4  * Copyright (c) 2023 Loongson Technology Corporation Limited
5  * Contributed by Lu Wang <wanglu@loongson.cn>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "swscale_loongarch.h"
25 
26 void ff_hscale_16_to_15_lsx(SwsInternal *c, int16_t *_dst, int dstW,
27  const uint8_t *_src, const int16_t *filter,
28  const int32_t *filterPos, int filterSize)
29 {
30  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
31  int sh = desc->comp[0].depth - 1;
32 
33  if (sh < 15) {
34  sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 :
35  (desc->comp[0].depth - 1);
36  } else if (desc->flags && AV_PIX_FMT_FLAG_FLOAT) {
37  sh = 15;
38  }
39  ff_hscale_16_to_15_sub_lsx(c, _dst, dstW, _src, filter, filterPos, filterSize, sh);
40 }
41 
42 void ff_hscale_16_to_19_lsx(SwsInternal *c, int16_t *_dst, int dstW,
43  const uint8_t *_src, const int16_t *filter,
44  const int32_t *filterPos, int filterSize)
45 {
46  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
47  int bits = desc->comp[0].depth - 1;
48  int sh = bits - 4;
49 
50  if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
51 
52  sh = 9;
53  } else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
54  sh = 16 - 1 - 4;
55  }
56  ff_hscale_16_to_19_sub_lsx(c, _dst, dstW, _src, filter, filterPos, filterSize, sh);
57 }
_dst
uint8_t * _dst
Definition: dsp.h:52
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
ff_hscale_16_to_15_lsx
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
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
_src
uint8_t ptrdiff_t const uint8_t * _src
Definition: dsp.h:52
swscale_loongarch.h
ff_hscale_16_to_15_sub_lsx
void ff_hscale_16_to_15_sub_lsx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize, int sh)
bits
uint8_t bits
Definition: vp3data.h:128
ff_hscale_16_to_19_sub_lsx
void ff_hscale_16_to_19_sub_lsx(SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize, int sh)
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
isAnyRGB
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:858
ff_hscale_16_to_19_lsx
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
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
SwsInternal
Definition: swscale_internal.h:330
desc
const char * desc
Definition: libsvtav1.c:79
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
int32_t
int32_t
Definition: audioconvert.c:56