Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2015-2016 Kieran Kunhya <kieran@kunhya.com> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #include "libavutil/attributes.h" | ||
22 | #include "libavutil/common.h" | ||
23 | |||
24 | #include "cfhddsp.h" | ||
25 | |||
26 | 158158 | static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, | |
27 | const int16_t *low, ptrdiff_t low_stride, | ||
28 | const int16_t *high, ptrdiff_t high_stride, | ||
29 | int len, int clip) | ||
30 | { | ||
31 | int16_t tmp; | ||
32 | int i; | ||
33 | |||
34 | 158158 | tmp = (11*low[0*low_stride] - 4*low[1*low_stride] + low[2*low_stride] + 4) >> 3; | |
35 | 158158 | output[(2*0+0)*out_stride] = (tmp + high[0*high_stride]) >> 1; | |
36 |
2/2✓ Branch 0 taken 39864 times.
✓ Branch 1 taken 118294 times.
|
158158 | if (clip) |
37 | 39864 | output[(2*0+0)*out_stride] = av_clip_uintp2_c(output[(2*0+0)*out_stride], clip); | |
38 | |||
39 | 158158 | tmp = ( 5*low[0*low_stride] + 4*low[1*low_stride] - low[2*low_stride] + 4) >> 3; | |
40 | 158158 | output[(2*0+1)*out_stride] = (tmp - high[0*high_stride]) >> 1; | |
41 |
2/2✓ Branch 0 taken 39864 times.
✓ Branch 1 taken 118294 times.
|
158158 | if (clip) |
42 | 39864 | output[(2*0+1)*out_stride] = av_clip_uintp2_c(output[(2*0+1)*out_stride], clip); | |
43 | |||
44 |
2/2✓ Branch 0 taken 28183540 times.
✓ Branch 1 taken 158158 times.
|
28341698 | for (i = 1; i < len - 1; i++) { |
45 | 28183540 | tmp = (low[(i-1)*low_stride] - low[(i+1)*low_stride] + 4) >> 3; | |
46 | 28183540 | output[(2*i+0)*out_stride] = (tmp + low[i*low_stride] + high[i*high_stride]) >> 1; | |
47 |
2/2✓ Branch 0 taken 10777360 times.
✓ Branch 1 taken 17406180 times.
|
28183540 | if (clip) |
48 | 10777360 | output[(2*i+0)*out_stride] = av_clip_uintp2_c(output[(2*i+0)*out_stride], clip); | |
49 | |||
50 | 28183540 | tmp = (low[(i+1)*low_stride] - low[(i-1)*low_stride] + 4) >> 3; | |
51 | 28183540 | output[(2*i+1)*out_stride] = (tmp + low[i*low_stride] - high[i*high_stride]) >> 1; | |
52 |
2/2✓ Branch 0 taken 10777360 times.
✓ Branch 1 taken 17406180 times.
|
28183540 | if (clip) |
53 | 10777360 | output[(2*i+1)*out_stride] = av_clip_uintp2_c(output[(2*i+1)*out_stride], clip); | |
54 | } | ||
55 | |||
56 | 158158 | tmp = ( 5*low[i*low_stride] + 4*low[(i-1)*low_stride] - low[(i-2)*low_stride] + 4) >> 3; | |
57 | 158158 | output[(2*i+0)*out_stride] = (tmp + high[i*high_stride]) >> 1; | |
58 |
2/2✓ Branch 0 taken 39864 times.
✓ Branch 1 taken 118294 times.
|
158158 | if (clip) |
59 | 39864 | output[(2*i+0)*out_stride] = av_clip_uintp2_c(output[(2*i+0)*out_stride], clip); | |
60 | |||
61 | 158158 | tmp = (11*low[i*low_stride] - 4*low[(i-1)*low_stride] + low[(i-2)*low_stride] + 4) >> 3; | |
62 | 158158 | output[(2*i+1)*out_stride] = (tmp - high[i*high_stride]) >> 1; | |
63 |
2/2✓ Branch 0 taken 39864 times.
✓ Branch 1 taken 118294 times.
|
158158 | if (clip) |
64 | 39864 | output[(2*i+1)*out_stride] = av_clip_uintp2_c(output[(2*i+1)*out_stride], clip); | |
65 | 158158 | } | |
66 | |||
67 | 594 | static void vert_filter(int16_t *output, ptrdiff_t out_stride, | |
68 | const int16_t *low, ptrdiff_t low_stride, | ||
69 | const int16_t *high, ptrdiff_t high_stride, | ||
70 | int width, int height) | ||
71 | { | ||
72 |
2/2✓ Branch 0 taken 88396 times.
✓ Branch 1 taken 594 times.
|
88990 | for (int i = 0; i < width; i++) { |
73 | 88396 | filter(output, out_stride, low, low_stride, high, high_stride, height, 0); | |
74 | 88396 | low++; | |
75 | 88396 | high++; | |
76 | 88396 | output++; | |
77 | } | ||
78 | 594 | } | |
79 | |||
80 | 198 | static void horiz_filter(int16_t *output, ptrdiff_t ostride, | |
81 | const int16_t *low, ptrdiff_t lstride, | ||
82 | const int16_t *high, ptrdiff_t hstride, | ||
83 | int width, int height) | ||
84 | { | ||
85 |
2/2✓ Branch 0 taken 29898 times.
✓ Branch 1 taken 198 times.
|
30096 | for (int i = 0; i < height; i++) { |
86 | 29898 | filter(output, 1, low, 1, high, 1, width, 0); | |
87 | 29898 | low += lstride; | |
88 | 29898 | high += hstride; | |
89 | 29898 | output += ostride * 2; | |
90 | } | ||
91 | 198 | } | |
92 | |||
93 | 39864 | static void horiz_filter_clip(int16_t *output, const int16_t *low, const int16_t *high, | |
94 | int width, int clip) | ||
95 | { | ||
96 | 39864 | filter(output, 1, low, 1, high, 1, width, clip); | |
97 | 39864 | } | |
98 | |||
99 | ✗ | static void horiz_filter_clip_bayer(int16_t *output, const int16_t *low, const int16_t *high, | |
100 | int width, int clip) | ||
101 | { | ||
102 | ✗ | filter(output, 2, low, 1, high, 1, width, clip); | |
103 | ✗ | } | |
104 | |||
105 | 6 | av_cold void ff_cfhddsp_init(CFHDDSPContext *c, int depth, int bayer) | |
106 | { | ||
107 | 6 | c->horiz_filter = horiz_filter; | |
108 | 6 | c->vert_filter = vert_filter; | |
109 | |||
110 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (bayer) |
111 | ✗ | c->horiz_filter_clip = horiz_filter_clip_bayer; | |
112 | else | ||
113 | 6 | c->horiz_filter_clip = horiz_filter_clip; | |
114 | |||
115 | #if ARCH_X86 | ||
116 | 6 | ff_cfhddsp_init_x86(c, depth, bayer); | |
117 | #endif | ||
118 | 6 | } | |
119 |