/src/ffmpeg/libavutil/internal.h
Line | Count | Source |
1 | | /* |
2 | | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> |
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 | | /** |
22 | | * @file |
23 | | * common internal API header |
24 | | */ |
25 | | |
26 | | #ifndef AVUTIL_INTERNAL_H |
27 | | #define AVUTIL_INTERNAL_H |
28 | | |
29 | | #if !defined(DEBUG) && !defined(NDEBUG) |
30 | | # define NDEBUG |
31 | | #endif |
32 | | |
33 | | // This can be enabled to allow detection of additional integer overflows with ubsan |
34 | | //#define CHECKED |
35 | | |
36 | | #include <limits.h> |
37 | | #include <stdint.h> |
38 | | #include <stddef.h> |
39 | | #include <assert.h> |
40 | | #include <stdio.h> |
41 | | #include "config.h" |
42 | | #include "attributes.h" |
43 | | #include "libm.h" |
44 | | #include "macros.h" |
45 | | |
46 | | #ifndef attribute_align_arg |
47 | | #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2) |
48 | | # define attribute_align_arg __attribute__((force_align_arg_pointer)) |
49 | | #else |
50 | | # define attribute_align_arg |
51 | | #endif |
52 | | #endif |
53 | | |
54 | | #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avutil) |
55 | | # define av_export_avutil __declspec(dllimport) |
56 | | #else |
57 | | # define av_export_avutil |
58 | | #endif |
59 | | |
60 | | #if HAVE_PRAGMA_DEPRECATED |
61 | | # if defined(__ICL) || defined (__INTEL_COMPILER) |
62 | | # define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478)) |
63 | | # define FF_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop)) |
64 | | # elif defined(_MSC_VER) |
65 | | # define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996)) |
66 | | # define FF_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop)) |
67 | | # else |
68 | | # define FF_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
69 | | # define FF_ENABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic pop") |
70 | | # endif |
71 | | #else |
72 | | # define FF_DISABLE_DEPRECATION_WARNINGS |
73 | | # define FF_ENABLE_DEPRECATION_WARNINGS |
74 | | #endif |
75 | | |
76 | | |
77 | 0 | #define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p))) |
78 | 0 | #define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p))) |
79 | | |
80 | 0 | #define FF_PTR_ADD(ptr, off) ((off) ? (ptr) + (off) : (ptr)) |
81 | | |
82 | | /** |
83 | | * Access a field in a structure by its offset. |
84 | | */ |
85 | 0 | #define FF_FIELD_AT(type, off, obj) (*(type *)((char *)&(obj) + (off))) |
86 | | |
87 | | /** |
88 | | * Return NULL if CONFIG_SMALL is true, otherwise the argument |
89 | | * without modification. Used to disable the definition of strings. |
90 | | */ |
91 | | #if CONFIG_SMALL |
92 | | # define NULL_IF_CONFIG_SMALL(x) NULL |
93 | | #else |
94 | | # define NULL_IF_CONFIG_SMALL(x) x |
95 | | #endif |
96 | | |
97 | | /** |
98 | | * Log a generic warning message about a missing feature. |
99 | | * |
100 | | * @param[in] avc a pointer to an arbitrary struct of which the first |
101 | | * field is a pointer to an AVClass struct |
102 | | * @param[in] msg string containing the name of the missing feature |
103 | | */ |
104 | | void avpriv_report_missing_feature(void *avc, |
105 | | const char *msg, ...) av_printf_format(2, 3); |
106 | | |
107 | | /** |
108 | | * Log a generic warning message about a missing feature. |
109 | | * Additionally request that a sample showcasing the feature be uploaded. |
110 | | * |
111 | | * @param[in] avc a pointer to an arbitrary struct of which the first field is |
112 | | * a pointer to an AVClass struct |
113 | | * @param[in] msg string containing the name of the missing feature |
114 | | */ |
115 | | void avpriv_request_sample(void *avc, |
116 | | const char *msg, ...) av_printf_format(2, 3); |
117 | | |
118 | | #ifdef DEBUG |
119 | | # define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__) |
120 | | #else |
121 | 0 | # define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0) |
122 | | #endif |
123 | | |
124 | | #ifdef TRACE |
125 | | # define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__) |
126 | | #else |
127 | 0 | # define ff_tlog(ctx, ...) do { } while(0) |
128 | | #endif |
129 | | |
130 | | // For debugging we use signed operations so overflows can be detected (by ubsan) |
131 | | // For production we use unsigned so there are no undefined operations |
132 | | #ifdef CHECKED |
133 | | #define SUINT int |
134 | | #define SUINT32 int32_t |
135 | | #else |
136 | 0 | #define SUINT unsigned |
137 | | #define SUINT32 uint32_t |
138 | | #endif |
139 | | |
140 | | static av_always_inline av_const int avpriv_mirror(int x, int w) |
141 | 0 | { |
142 | 0 | if (!w) |
143 | 0 | return 0; |
144 | 0 |
|
145 | 0 | while ((unsigned)x > (unsigned)w) { |
146 | 0 | x = -x; |
147 | 0 | if (x < 0) |
148 | 0 | x += 2 * w; |
149 | 0 | } |
150 | 0 | return x; |
151 | 0 | } Unexecuted instantiation: avfiltergraph.c:avpriv_mirror Unexecuted instantiation: buffersink.c:avpriv_mirror Unexecuted instantiation: buffersrc.c:avpriv_mirror Unexecuted instantiation: formats.c:avpriv_mirror Unexecuted instantiation: framequeue.c:avpriv_mirror Unexecuted instantiation: graphparser.c:avpriv_mirror Unexecuted instantiation: pthread.c:avpriv_mirror Unexecuted instantiation: video.c:avpriv_mirror Unexecuted instantiation: allfilters.c:avpriv_mirror Unexecuted instantiation: avfilter.c:avpriv_mirror Unexecuted instantiation: framepool.c:avpriv_mirror Unexecuted instantiation: audio.c:avpriv_mirror Unexecuted instantiation: swscale.c:avpriv_mirror Unexecuted instantiation: utils.c:avpriv_mirror Unexecuted instantiation: vscale.c:avpriv_mirror Unexecuted instantiation: hscale_fast_bilinear_simd.c:avpriv_mirror Unexecuted instantiation: yuv2rgb.c:avpriv_mirror Unexecuted instantiation: alphablend.c:avpriv_mirror Unexecuted instantiation: format.c:avpriv_mirror Unexecuted instantiation: graph.c:avpriv_mirror Unexecuted instantiation: hscale_fast_bilinear.c:avpriv_mirror Unexecuted instantiation: input.c:avpriv_mirror Unexecuted instantiation: lut3d.c:avpriv_mirror Unexecuted instantiation: ops.c:avpriv_mirror Unexecuted instantiation: ops_backend.c:avpriv_mirror Unexecuted instantiation: ops_chain.c:avpriv_mirror Unexecuted instantiation: ops_memcpy.c:avpriv_mirror Unexecuted instantiation: ops_optimizer.c:avpriv_mirror Unexecuted instantiation: options.c:avpriv_mirror Unexecuted instantiation: output.c:avpriv_mirror Unexecuted instantiation: rgb2rgb.c:avpriv_mirror Unexecuted instantiation: slice.c:avpriv_mirror Unexecuted instantiation: swscale_unscaled.c:avpriv_mirror Unexecuted instantiation: cms.c:avpriv_mirror Unexecuted instantiation: csputils.c:avpriv_mirror Unexecuted instantiation: gamma.c:avpriv_mirror Unexecuted instantiation: hscale.c:avpriv_mirror Unexecuted instantiation: avformat.c:avpriv_mirror Unexecuted instantiation: demux.c:avpriv_mirror Unexecuted instantiation: demux_utils.c:avpriv_mirror Unexecuted instantiation: id3v2.c:avpriv_mirror Unexecuted instantiation: metadata.c:avpriv_mirror Unexecuted instantiation: seek.c:avpriv_mirror Unexecuted instantiation: allformats.c:avpriv_mirror Unexecuted instantiation: avio.c:avpriv_mirror Unexecuted instantiation: aviobuf.c:avpriv_mirror Unexecuted instantiation: id3v1.c:avpriv_mirror Unexecuted instantiation: network.c:avpriv_mirror Unexecuted instantiation: os_support.c:avpriv_mirror Unexecuted instantiation: allcodecs.c:avpriv_mirror Unexecuted instantiation: avcodec.c:avpriv_mirror Unexecuted instantiation: bitstream_filters.c:avpriv_mirror Unexecuted instantiation: bsf.c:avpriv_mirror Unexecuted instantiation: codec_desc.c:avpriv_mirror Unexecuted instantiation: codec_par.c:avpriv_mirror Unexecuted instantiation: decode.c:avpriv_mirror Unexecuted instantiation: encode.c:avpriv_mirror Unexecuted instantiation: exif.c:avpriv_mirror Unexecuted instantiation: get_buffer.c:avpriv_mirror Unexecuted instantiation: packet.c:avpriv_mirror Unexecuted instantiation: parser.c:avpriv_mirror Unexecuted instantiation: parsers.c:avpriv_mirror Unexecuted instantiation: profiles.c:avpriv_mirror Unexecuted instantiation: pthread_frame.c:avpriv_mirror Unexecuted instantiation: pthread_slice.c:avpriv_mirror Unexecuted instantiation: raw.c:avpriv_mirror Unexecuted instantiation: threadprogress.c:avpriv_mirror Unexecuted instantiation: tiff_common.c:avpriv_mirror Unexecuted instantiation: to_upper4.c:avpriv_mirror Unexecuted instantiation: buffer.c:avpriv_mirror Unexecuted instantiation: channel_layout.c:avpriv_mirror Unexecuted instantiation: container_fifo.c:avpriv_mirror Unexecuted instantiation: cpu.c:avpriv_mirror Unexecuted instantiation: eval.c:avpriv_mirror Unexecuted instantiation: frame.c:avpriv_mirror Unexecuted instantiation: hwcontext.c:avpriv_mirror Unexecuted instantiation: iamf.c:avpriv_mirror Unexecuted instantiation: imgutils.c:avpriv_mirror Unexecuted instantiation: log.c:avpriv_mirror Unexecuted instantiation: mastering_display_metadata.c:avpriv_mirror Unexecuted instantiation: mathematics.c:avpriv_mirror Unexecuted instantiation: mem.c:avpriv_mirror Unexecuted instantiation: opt.c:avpriv_mirror Unexecuted instantiation: parseutils.c:avpriv_mirror Unexecuted instantiation: pixdesc.c:avpriv_mirror Unexecuted instantiation: random_seed.c:avpriv_mirror Unexecuted instantiation: rational.c:avpriv_mirror Unexecuted instantiation: side_data.c:avpriv_mirror Unexecuted instantiation: slicethread.c:avpriv_mirror Unexecuted instantiation: timestamp.c:avpriv_mirror Unexecuted instantiation: file_open.c:avpriv_mirror |
152 | | |
153 | | #endif /* AVUTIL_INTERNAL_H */ |