FFmpeg
utvideodsp.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <stdint.h>
20 
21 #include "config.h"
22 #include "libavutil/attributes.h"
23 #include "utvideodsp.h"
24 
25 static void restore_rgb_planes_c(uint8_t *src_r,
26  uint8_t *src_g,
27  uint8_t *src_b,
28  ptrdiff_t linesize_r,
29  ptrdiff_t linesize_g,
30  ptrdiff_t linesize_b,
31  int width, int height)
32 {
33  uint8_t r, g, b;
34  int i, j;
35 
36  for (j = 0; j < height; j++) {
37  for (i = 0; i < width; i++) {
38  r = src_r[i];
39  g = src_g[i];
40  b = src_b[i];
41  src_r[i] = r + g - 0x80;
42  src_b[i] = b + g - 0x80;
43  }
44  src_r += linesize_r;
45  src_g += linesize_g;
46  src_b += linesize_b;
47  }
48 }
49 
50 static void restore_rgb_planes10_c(uint16_t *src_r,
51  uint16_t *src_g,
52  uint16_t *src_b,
53  ptrdiff_t linesize_r,
54  ptrdiff_t linesize_g,
55  ptrdiff_t linesize_b,
56  int width, int height)
57 {
58  int r, g, b;
59  int i, j;
60 
61  for (j = 0; j < height; j++) {
62  for (i = 0; i < width; i++) {
63  r = src_r[i];
64  g = src_g[i];
65  b = src_b[i];
66  src_r[i] = (r + g - 0x200) & 0x3FF;
67  src_b[i] = (b + g - 0x200) & 0x3FF;
68  }
69  src_r += linesize_r;
70  src_g += linesize_g;
71  src_b += linesize_b;
72  }
73 }
74 
76 {
77  c->restore_rgb_planes = restore_rgb_planes_c;
78  c->restore_rgb_planes10 = restore_rgb_planes10_c;
79 
80  if (ARCH_X86)
82 }
UTVideoDSPContext
Definition: utvideodsp.h:27
r
const char * r
Definition: vf_curves.c:116
b
#define b
Definition: input.c:41
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
g
const char * g
Definition: vf_curves.c:117
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
restore_rgb_planes_c
static void restore_rgb_planes_c(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b, ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b, int width, int height)
Definition: utvideodsp.c:25
height
#define height
ff_utvideodsp_init_x86
void ff_utvideodsp_init_x86(UTVideoDSPContext *c)
Definition: utvideodsp_init.c:42
attributes.h
i
int i
Definition: input.c:407
restore_rgb_planes10_c
static void restore_rgb_planes10_c(uint16_t *src_r, uint16_t *src_g, uint16_t *src_b, ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b, int width, int height)
Definition: utvideodsp.c:50
uint8_t
uint8_t
Definition: audio_convert.c:194
utvideodsp.h
ff_utvideodsp_init
av_cold void ff_utvideodsp_init(UTVideoDSPContext *c)
Definition: utvideodsp.c:75