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(SwsContext *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(SwsContext *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 }
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
swscale_loongarch.h
bits
uint8_t bits
Definition: vp3data.h:128
ff_hscale_16_to_15_sub_lsx
void ff_hscale_16_to_15_sub_lsx(SwsContext *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:832
ff_hscale_16_to_15_lsx
void ff_hscale_16_to_15_lsx(SwsContext *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
ff_hscale_16_to_19_sub_lsx
void ff_hscale_16_to_19_sub_lsx(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize, int sh)
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
desc
const char * desc
Definition: libsvtav1.c:75
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
SwsContext
Definition: swscale_internal.h:299
ff_hscale_16_to_19_lsx
void ff_hscale_16_to_19_lsx(SwsContext *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