Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2007 Benoit Fouet | ||
3 | * Copyright (c) 2010 Stefano Sabatini | ||
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 | #ifndef AVFILTER_HFLIP_INIT_H | ||
23 | #define AVFILTER_HFLIP_INIT_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | |||
27 | #include "config.h" | ||
28 | #include "libavutil/attributes.h" | ||
29 | #include "libavutil/error.h" | ||
30 | #include "libavutil/intreadwrite.h" | ||
31 | #include "hflip.h" | ||
32 | |||
33 | 33309 | static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w) | |
34 | { | ||
35 |
2/2✓ Branch 0 taken 9956736 times.
✓ Branch 1 taken 33309 times.
|
9990045 | for (int j = 0; j < w; j++) |
36 | 9956736 | dst[j] = src[-j]; | |
37 | 33309 | } | |
38 | |||
39 | 174909 | static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w) | |
40 | { | ||
41 | 174909 | const uint16_t *src = (const uint16_t *)ssrc; | |
42 | 174909 | uint16_t *dst = (uint16_t *)ddst; | |
43 | |||
44 |
2/2✓ Branch 0 taken 55983936 times.
✓ Branch 1 taken 174909 times.
|
56158845 | for (int j = 0; j < w; j++) |
45 | 55983936 | dst[j] = src[-j]; | |
46 | 174909 | } | |
47 | |||
48 | 29376 | static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w) | |
49 | { | ||
50 | 29376 | const uint32_t *src = (const uint32_t *)ssrc; | |
51 | 29376 | uint32_t *dst = (uint32_t *)ddst; | |
52 | |||
53 |
2/2✓ Branch 0 taken 9225216 times.
✓ Branch 1 taken 29376 times.
|
9254592 | for (int j = 0; j < w; j++) |
54 | 9225216 | dst[j] = src[-j]; | |
55 | 29376 | } | |
56 | |||
57 | 1728 | static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w) | |
58 | { | ||
59 | 1728 | const uint8_t *in = src; | |
60 | 1728 | uint8_t *out = dst; | |
61 | |||
62 |
2/2✓ Branch 0 taken 608256 times.
✓ Branch 1 taken 1728 times.
|
609984 | for (int j = 0; j < w; j++, out += 3, in -= 3) { |
63 | 608256 | int32_t v = AV_RB24(in); | |
64 | |||
65 | 608256 | AV_WB24(out, v); | |
66 | } | ||
67 | 1728 | } | |
68 | |||
69 | 3456 | static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w) | |
70 | { | ||
71 | 3456 | const uint8_t *in = src; | |
72 | 3456 | uint8_t *out = dst; | |
73 | |||
74 |
2/2✓ Branch 0 taken 1216512 times.
✓ Branch 1 taken 3456 times.
|
1219968 | for (int j = 0; j < w; j++, out += 6, in -= 6) { |
75 | 1216512 | int64_t v = AV_RB48(in); | |
76 | |||
77 | 1216512 | AV_WB48(out, v); | |
78 | } | ||
79 | 3456 | } | |
80 | |||
81 | 5760 | static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w) | |
82 | { | ||
83 | 5760 | const uint64_t *src = (const uint64_t *)ssrc; | |
84 | 5760 | uint64_t *dst = (uint64_t *)ddst; | |
85 | |||
86 |
2/2✓ Branch 0 taken 2027520 times.
✓ Branch 1 taken 5760 times.
|
2033280 | for (int j = 0; j < w; j++) |
87 | 2027520 | dst[j] = src[-j]; | |
88 | 5760 | } | |
89 | |||
90 | 221 | static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes) | |
91 | { | ||
92 |
2/2✓ Branch 0 taken 564 times.
✓ Branch 1 taken 221 times.
|
785 | for (int i = 0; i < nb_planes; i++) { |
93 | 564 | step[i] *= s->bayer_plus1; | |
94 |
6/7✓ Branch 0 taken 115 times.
✓ Branch 1 taken 376 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
|
564 | switch (step[i]) { |
95 | 115 | case 1: s->flip_line[i] = hflip_byte_c; break; | |
96 | 376 | case 2: s->flip_line[i] = hflip_short_c; break; | |
97 | 3 | case 3: s->flip_line[i] = hflip_b24_c; break; | |
98 | 54 | case 4: s->flip_line[i] = hflip_dword_c; break; | |
99 | 6 | case 6: s->flip_line[i] = hflip_b48_c; break; | |
100 | 10 | case 8: s->flip_line[i] = hflip_qword_c; break; | |
101 | ✗ | default: | |
102 | ✗ | return AVERROR_BUG; | |
103 | } | ||
104 | } | ||
105 | #if ARCH_X86 | ||
106 | 221 | ff_hflip_init_x86(s, step, nb_planes); | |
107 | #endif | ||
108 | |||
109 | 221 | return 0; | |
110 | } | ||
111 | |||
112 | #endif /* AVFILTER_HFLIP_INIT_H */ | ||
113 |