bit_depth_template.c
Go to the documentation of this file.
1 /*
2  * This file is part of Libav.
3  *
4  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "rnd_avg.h"
20 #include "libavutil/intreadwrite.h"
21 
22 #ifndef BIT_DEPTH
23 #define BIT_DEPTH 8
24 #endif
25 
26 #ifdef AVCODEC_H264_HIGH_DEPTH_H
27 # undef pixel
28 # undef pixel2
29 # undef pixel4
30 # undef dctcoef
31 # undef INIT_CLIP
32 # undef no_rnd_avg_pixel4
33 # undef rnd_avg_pixel4
34 # undef AV_RN2P
35 # undef AV_RN4P
36 # undef AV_RN4PA
37 # undef AV_WN2P
38 # undef AV_WN4P
39 # undef AV_WN4PA
40 # undef CLIP
41 # undef FUNC
42 # undef FUNCC
43 # undef av_clip_pixel
44 # undef PIXEL_SPLAT_X4
45 #else
46 # define AVCODEC_H264_HIGH_DEPTH_H
47 #endif
48 
49 #if BIT_DEPTH > 8
50 # define pixel uint16_t
51 # define pixel2 uint32_t
52 # define pixel4 uint64_t
53 # define dctcoef int32_t
54 
55 # define INIT_CLIP
56 # define no_rnd_avg_pixel4 no_rnd_avg64
57 # define rnd_avg_pixel4 rnd_avg64
58 # define AV_RN2P AV_RN32
59 # define AV_RN4P AV_RN64
60 # define AV_RN4PA AV_RN64A
61 # define AV_WN2P AV_WN32
62 # define AV_WN4P AV_WN64
63 # define AV_WN4PA AV_WN64A
64 # define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
65 
66 # define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
67 # define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
68 #else
69 # define pixel uint8_t
70 # define pixel2 uint16_t
71 # define pixel4 uint32_t
72 # define dctcoef int16_t
73 
74 # define INIT_CLIP
75 # define no_rnd_avg_pixel4 no_rnd_avg32
76 # define rnd_avg_pixel4 rnd_avg32
77 # define AV_RN2P AV_RN16
78 # define AV_RN4P AV_RN32
79 # define AV_RN4PA AV_RN32A
80 # define AV_WN2P AV_WN16
81 # define AV_WN4P AV_WN32
82 # define AV_WN4PA AV_WN32A
83 # define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
84 
85 # define av_clip_pixel(a) av_clip_uint8(a)
86 # define CLIP(a) av_clip_uint8(a)
87 #endif
88 
89 #define FUNC3(a, b, c) a ## _ ## b ## c
90 #define FUNC2(a, b, c) FUNC3(a, b, c)
91 #define FUNC(a) FUNC2(a, BIT_DEPTH,)
92 #define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)