FFmpeg
Loading...
Searching...
No Matches
bit_depth_template.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 "mathops.h"
20#include "rnd_avg.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 idctin
33# undef tpixel
34# undef no_rnd_avg_pixel4
35# undef rnd_avg_pixel4
36# undef AV_RN2P
37# undef AV_RN4P
38# undef AV_RN4PA
39# undef AV_WN2P
40# undef AV_WN4P
41# undef AV_WN4PA
42# undef CLIP
43# undef FUNC
44# undef FUNCC
45# undef av_clip_pixel
46# undef PIXEL_SPLAT_X4
47# undef PIXELSIZE
48#else
49# define AVCODEC_BIT_DEPTH_TEMPLATE_C
50#endif
51
52#if BIT_DEPTH > 8
53# define PIXELSIZE 16
54# define pixel uint16_t
55# define pixel2 uint32_t
56# define pixel4 uint64_t
57# define dctcoef int32_t
58#if BIT_DEPTH > 12
59# define tpixel int
60#else
61# define tpixel int16_t
62#endif
63
64#ifdef IN_IDCT_DEPTH
65#if IN_IDCT_DEPTH == 32
66# define idctin int32_t
67#else
68# define idctin int16_t
69#endif
70#else
71# define idctin int16_t
72#endif
73
74# define no_rnd_avg_pixel4 no_rnd_avg64
75# define rnd_avg_pixel4 rnd_avg64
76# define AV_RN2P AV_RN32
77# define AV_RN4P AV_RN64
78# define AV_RN4PA AV_RN64A
79# define AV_WN2P AV_WN32
80# define AV_WN4P AV_WN64
81# define AV_WN4PA AV_WN64A
82# define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
83
84# define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
85# define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
86#else
87# define PIXELSIZE 8
88# define pixel uint8_t
89# define pixel2 uint16_t
90# define pixel4 uint32_t
91# define dctcoef int16_t
92# define idctin int16_t
93# define tpixel int16_t
94
95# define no_rnd_avg_pixel4 no_rnd_avg32
96# define rnd_avg_pixel4 rnd_avg32
97# define AV_RN2P AV_RN16
98# define AV_RN4P AV_RN32
99# define AV_RN4PA AV_RN32A
100# define AV_WN2P AV_WN16
101# define AV_WN4P AV_WN32
102# define AV_WN4PA AV_WN32A
103# define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
104
105# define av_clip_pixel(a) av_clip_uint8(a)
106# define CLIP(a) av_clip_uint8(a)
107#endif
108
109#define FUNC3(a, b, c) a ## _ ## b ## c
110#define FUNC2(a, b, c) FUNC3(a, b, c)
111#define FUNC(a) FUNC2(a, BIT_DEPTH,)
112#define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)
113#define FUNCC2(a) FUNC2(a, PIXELSIZE, _c)
114#define FUNC4(a, b, c) a ## _int ## b ## _ ## c ## bit
115#define FUNC5(a, b, c) FUNC4(a, b, c)
116#define FUNC6(a) FUNC5(a, IN_IDCT_DEPTH, BIT_DEPTH)