Commit | Line | Data |
---|---|---|
2ba45a60 DM |
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 "mathops.h" | |
20 | #include "rnd_avg.h" | |
21 | #include "libavutil/intreadwrite.h" | |
22 | ||
23 | #ifndef BIT_DEPTH | |
24 | #define BIT_DEPTH 8 | |
25 | #endif | |
26 | ||
27 | #ifdef AVCODEC_BIT_DEPTH_TEMPLATE_C | |
28 | # undef pixel | |
29 | # undef pixel2 | |
30 | # undef pixel4 | |
31 | # undef dctcoef | |
32 | # undef INIT_CLIP | |
33 | # undef no_rnd_avg_pixel4 | |
34 | # undef rnd_avg_pixel4 | |
35 | # undef AV_RN2P | |
36 | # undef AV_RN4P | |
37 | # undef AV_RN4PA | |
38 | # undef AV_WN2P | |
39 | # undef AV_WN4P | |
40 | # undef AV_WN4PA | |
41 | # undef CLIP | |
42 | # undef FUNC | |
43 | # undef FUNCC | |
44 | # undef av_clip_pixel | |
45 | # undef PIXEL_SPLAT_X4 | |
46 | #else | |
47 | # define AVCODEC_BIT_DEPTH_TEMPLATE_C | |
48 | #endif | |
49 | ||
50 | #if BIT_DEPTH > 8 | |
51 | # define pixel uint16_t | |
52 | # define pixel2 uint32_t | |
53 | # define pixel4 uint64_t | |
54 | # define dctcoef int32_t | |
55 | ||
56 | # define INIT_CLIP | |
57 | # define no_rnd_avg_pixel4 no_rnd_avg64 | |
58 | # define rnd_avg_pixel4 rnd_avg64 | |
59 | # define AV_RN2P AV_RN32 | |
60 | # define AV_RN4P AV_RN64 | |
61 | # define AV_RN4PA AV_RN64A | |
62 | # define AV_WN2P AV_WN32 | |
63 | # define AV_WN4P AV_WN64 | |
64 | # define AV_WN4PA AV_WN64A | |
65 | # define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL) | |
66 | ||
67 | # define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH) | |
68 | # define CLIP(a) av_clip_uintp2(a, BIT_DEPTH) | |
69 | #else | |
70 | # define pixel uint8_t | |
71 | # define pixel2 uint16_t | |
72 | # define pixel4 uint32_t | |
73 | # define dctcoef int16_t | |
74 | ||
75 | # define INIT_CLIP | |
76 | # define no_rnd_avg_pixel4 no_rnd_avg32 | |
77 | # define rnd_avg_pixel4 rnd_avg32 | |
78 | # define AV_RN2P AV_RN16 | |
79 | # define AV_RN4P AV_RN32 | |
80 | # define AV_RN4PA AV_RN32A | |
81 | # define AV_WN2P AV_WN16 | |
82 | # define AV_WN4P AV_WN32 | |
83 | # define AV_WN4PA AV_WN32A | |
84 | # define PIXEL_SPLAT_X4(x) ((x)*0x01010101U) | |
85 | ||
86 | # define av_clip_pixel(a) av_clip_uint8(a) | |
87 | # define CLIP(a) av_clip_uint8(a) | |
88 | #endif | |
89 | ||
90 | #define FUNC3(a, b, c) a ## _ ## b ## c | |
91 | #define FUNC2(a, b, c) FUNC3(a, b, c) | |
92 | #define FUNC(a) FUNC2(a, BIT_DEPTH,) | |
93 | #define FUNCC(a) FUNC2(a, BIT_DEPTH, _c) |