Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * base.h: misc common functions (bit depth independent) |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2003-2025 x264 project |
5 | | * |
6 | | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
7 | | * Loren Merritt <lorenm@u.washington.edu> |
8 | | * |
9 | | * This program is free software; you can redistribute it and/or modify |
10 | | * it under the terms of the GNU General Public License as published by |
11 | | * the Free Software Foundation; either version 2 of the License, or |
12 | | * (at your option) any later version. |
13 | | * |
14 | | * This program is distributed in the hope that it will be useful, |
15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | * GNU General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU General Public License |
20 | | * along with this program; if not, write to the Free Software |
21 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. |
22 | | * |
23 | | * This program is also available under a commercial proprietary license. |
24 | | * For more information, contact us at licensing@x264.com. |
25 | | *****************************************************************************/ |
26 | | |
27 | | #ifndef X264_BASE_H |
28 | | #define X264_BASE_H |
29 | | |
30 | | /**************************************************************************** |
31 | | * Macros (can be used in osdep.h) |
32 | | ****************************************************************************/ |
33 | 0 | #define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) ) |
34 | 0 | #define X264_MAX(a,b) ( (a)>(b) ? (a) : (b) ) |
35 | 0 | #define X264_MIN3(a,b,c) X264_MIN((a),X264_MIN((b),(c))) |
36 | 0 | #define X264_MAX3(a,b,c) X264_MAX((a),X264_MAX((b),(c))) |
37 | 0 | #define X264_MIN4(a,b,c,d) X264_MIN((a),X264_MIN3((b),(c),(d))) |
38 | | #define X264_MAX4(a,b,c,d) X264_MAX((a),X264_MAX3((b),(c),(d))) |
39 | | |
40 | | /**************************************************************************** |
41 | | * System includes |
42 | | ****************************************************************************/ |
43 | | #include "osdep.h" |
44 | | #include <stdarg.h> |
45 | | #include <stddef.h> |
46 | | #include <stdlib.h> |
47 | | #include <string.h> |
48 | | #include <assert.h> |
49 | | #include <limits.h> |
50 | | |
51 | | /**************************************************************************** |
52 | | * Macros |
53 | | ****************************************************************************/ |
54 | 0 | #define XCHG(type,a,b) do { type t = a; a = b; b = t; } while( 0 ) |
55 | 0 | #define FIX8(f) ((int)(f*(1<<8)+.5)) |
56 | 0 | #define ARRAY_ELEMS(a) ((int)((sizeof(a))/(sizeof(a[0])))) |
57 | 0 | #define ALIGN(x,a) (((x)+((a)-1))&~((a)-1)) |
58 | 0 | #define IS_DISPOSABLE(type) ( type == X264_TYPE_B ) |
59 | | |
60 | | /* Unions for type-punning. |
61 | | * Mn: load or store n bits, aligned, native-endian |
62 | | * CPn: copy n bits, aligned, native-endian |
63 | | * we don't use memcpy for CPn because memcpy's args aren't assumed to be aligned */ |
64 | | typedef union { uint16_t i; uint8_t b[2]; } MAY_ALIAS x264_union16_t; |
65 | | typedef union { uint32_t i; uint16_t w[2]; uint8_t b[4]; } MAY_ALIAS x264_union32_t; |
66 | | typedef union { uint64_t i; uint32_t d[2]; uint16_t w[4]; uint8_t b[8]; } MAY_ALIAS x264_union64_t; |
67 | | typedef struct { uint64_t i[2]; } x264_uint128_t; |
68 | | typedef union { x264_uint128_t i; uint64_t q[2]; uint32_t d[4]; uint16_t w[8]; uint8_t b[16]; } MAY_ALIAS x264_union128_t; |
69 | 0 | #define M16(src) (((x264_union16_t*)(src))->i) |
70 | 0 | #define M32(src) (((x264_union32_t*)(src))->i) |
71 | 0 | #define M64(src) (((x264_union64_t*)(src))->i) |
72 | 0 | #define M128(src) (((x264_union128_t*)(src))->i) |
73 | | #define M128_ZERO ((x264_uint128_t){{0,0}}) |
74 | 0 | #define CP16(dst,src) M16(dst) = M16(src) |
75 | 0 | #define CP32(dst,src) M32(dst) = M32(src) |
76 | 0 | #define CP64(dst,src) M64(dst) = M64(src) |
77 | 0 | #define CP128(dst,src) M128(dst) = M128(src) |
78 | | |
79 | | /* Macros for memory constraints of inline asm */ |
80 | | #if defined(__GNUC__) && __GNUC__ >= 8 && !defined(__clang__) && !defined(__INTEL_COMPILER) |
81 | | #define MEM_FIX(x, t, s) (*(t (*)[s])(x)) |
82 | | #define MEM_DYN(x, t) (*(t (*)[])(x)) |
83 | | #else |
84 | | //older versions of gcc prefer casting to structure instead of array |
85 | | #define MEM_FIX(x, t, s) (*(struct { t a[s]; } MAY_ALIAS (*))(x)) |
86 | | //let's set an arbitrary large constant size |
87 | | #define MEM_DYN(x, t) MEM_FIX(x, t, 4096) |
88 | | #endif |
89 | | |
90 | | /**************************************************************************** |
91 | | * Constants |
92 | | ****************************************************************************/ |
93 | | enum profile_e |
94 | | { |
95 | | PROFILE_BASELINE = 66, |
96 | | PROFILE_MAIN = 77, |
97 | | PROFILE_HIGH = 100, |
98 | | PROFILE_HIGH10 = 110, |
99 | | PROFILE_HIGH422 = 122, |
100 | | PROFILE_HIGH444_PREDICTIVE = 244, |
101 | | }; |
102 | | |
103 | | enum chroma_format_e |
104 | | { |
105 | | CHROMA_400 = 0, |
106 | | CHROMA_420 = 1, |
107 | | CHROMA_422 = 2, |
108 | | CHROMA_444 = 3, |
109 | | }; |
110 | | |
111 | | enum slice_type_e |
112 | | { |
113 | | SLICE_TYPE_P = 0, |
114 | | SLICE_TYPE_B = 1, |
115 | | SLICE_TYPE_I = 2, |
116 | | }; |
117 | | |
118 | | static const char slice_type_to_char[] = { 'P', 'B', 'I' }; |
119 | | |
120 | | enum sei_payload_type_e |
121 | | { |
122 | | SEI_BUFFERING_PERIOD = 0, |
123 | | SEI_PIC_TIMING = 1, |
124 | | SEI_PAN_SCAN_RECT = 2, |
125 | | SEI_FILLER = 3, |
126 | | SEI_USER_DATA_REGISTERED = 4, |
127 | | SEI_USER_DATA_UNREGISTERED = 5, |
128 | | SEI_RECOVERY_POINT = 6, |
129 | | SEI_DEC_REF_PIC_MARKING = 7, |
130 | | SEI_FRAME_PACKING = 45, |
131 | | SEI_MASTERING_DISPLAY = 137, |
132 | | SEI_CONTENT_LIGHT_LEVEL = 144, |
133 | | SEI_ALTERNATIVE_TRANSFER = 147, |
134 | | }; |
135 | | |
136 | 0 | #define X264_BFRAME_MAX 16 |
137 | 0 | #define X264_REF_MAX 16 |
138 | 0 | #define X264_THREAD_MAX 128 |
139 | | #define X264_LOOKAHEAD_THREAD_MAX 16 |
140 | 0 | #define X264_LOOKAHEAD_MAX 250 |
141 | | |
142 | | // number of pixels (per thread) in progress at any given time. |
143 | | // 16 for the macroblock in progress + 3 for deblocking + 3 for motion compensation filter + 2 for extra safety |
144 | 0 | #define X264_THREAD_HEIGHT 24 |
145 | | |
146 | | /* WEIGHTP_FAKE is set when mb_tree & psy are enabled, but normal weightp is disabled |
147 | | * (such as in baseline). It checks for fades in lookahead and adjusts qp accordingly |
148 | | * to increase quality. Defined as (-1) so that if(i_weighted_pred > 0) is true only when |
149 | | * real weights are being used. */ |
150 | | |
151 | 0 | #define X264_WEIGHTP_FAKE (-1) |
152 | | |
153 | | #define X264_SCAN8_LUMA_SIZE (5*8) |
154 | | #define X264_SCAN8_SIZE (X264_SCAN8_LUMA_SIZE*3) |
155 | 0 | #define X264_SCAN8_0 (4+1*8) |
156 | | |
157 | | /* Scan8 organization: |
158 | | * 0 1 2 3 4 5 6 7 |
159 | | * 0 DY y y y y y |
160 | | * 1 y Y Y Y Y |
161 | | * 2 y Y Y Y Y |
162 | | * 3 y Y Y Y Y |
163 | | * 4 y Y Y Y Y |
164 | | * 5 DU u u u u u |
165 | | * 6 u U U U U |
166 | | * 7 u U U U U |
167 | | * 8 u U U U U |
168 | | * 9 u U U U U |
169 | | * 10 DV v v v v v |
170 | | * 11 v V V V V |
171 | | * 12 v V V V V |
172 | | * 13 v V V V V |
173 | | * 14 v V V V V |
174 | | * DY/DU/DV are for luma/chroma DC. |
175 | | */ |
176 | | |
177 | 0 | #define LUMA_DC 48 |
178 | 0 | #define CHROMA_DC 49 |
179 | | |
180 | | static const uint8_t x264_scan8[16*3 + 3] = |
181 | | { |
182 | | 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8, |
183 | | 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8, |
184 | | 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8, |
185 | | 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8, |
186 | | 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8, |
187 | | 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8, |
188 | | 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8, |
189 | | 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8, |
190 | | 4+11*8, 5+11*8, 4+12*8, 5+12*8, |
191 | | 6+11*8, 7+11*8, 6+12*8, 7+12*8, |
192 | | 4+13*8, 5+13*8, 4+14*8, 5+14*8, |
193 | | 6+13*8, 7+13*8, 6+14*8, 7+14*8, |
194 | | 0+ 0*8, 0+ 5*8, 0+10*8 |
195 | | }; |
196 | | |
197 | | /**************************************************************************** |
198 | | * Includes |
199 | | ****************************************************************************/ |
200 | | #include "cpu.h" |
201 | | #include "tables.h" |
202 | | |
203 | | /**************************************************************************** |
204 | | * Inline functions |
205 | | ****************************************************************************/ |
206 | | static ALWAYS_INLINE int x264_clip3( int v, int i_min, int i_max ) |
207 | 0 | { |
208 | 0 | return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v ); |
209 | 0 | } Unexecuted instantiation: base.c:x264_clip3 Unexecuted instantiation: cpu.c:x264_clip3 Unexecuted instantiation: api.c:x264_clip3 Unexecuted instantiation: bitstream.c:x264_clip3 Unexecuted instantiation: encoder.c:x264_clip3 Unexecuted instantiation: lookahead.c:x264_clip3 Unexecuted instantiation: threadpool.c:x264_clip3 Unexecuted instantiation: tables.c:x264_clip3 Unexecuted instantiation: mc.c:x264_clip3 Unexecuted instantiation: predict.c:x264_clip3 Unexecuted instantiation: pixel.c:x264_clip3 Unexecuted instantiation: macroblock.c:x264_clip3 Unexecuted instantiation: frame.c:x264_clip3 Unexecuted instantiation: dct.c:x264_clip3 Unexecuted instantiation: cabac.c:x264_clip3 Unexecuted instantiation: common.c:x264_clip3 Unexecuted instantiation: set.c:x264_clip3 Unexecuted instantiation: quant.c:x264_clip3 Unexecuted instantiation: deblock.c:x264_clip3 Unexecuted instantiation: vlc.c:x264_clip3 Unexecuted instantiation: mvpred.c:x264_clip3 Unexecuted instantiation: analyse.c:x264_clip3 Unexecuted instantiation: me.c:x264_clip3 Unexecuted instantiation: ratecontrol.c:x264_clip3 Unexecuted instantiation: cavlc.c:x264_clip3 Unexecuted instantiation: rectangle.c:x264_clip3 |
210 | | |
211 | | static ALWAYS_INLINE double x264_clip3f( double v, double f_min, double f_max ) |
212 | 0 | { |
213 | 0 | return ( (v < f_min) ? f_min : (v > f_max) ? f_max : v ); |
214 | 0 | } Unexecuted instantiation: base.c:x264_clip3f Unexecuted instantiation: cpu.c:x264_clip3f Unexecuted instantiation: api.c:x264_clip3f Unexecuted instantiation: bitstream.c:x264_clip3f Unexecuted instantiation: encoder.c:x264_clip3f Unexecuted instantiation: lookahead.c:x264_clip3f Unexecuted instantiation: threadpool.c:x264_clip3f Unexecuted instantiation: tables.c:x264_clip3f Unexecuted instantiation: mc.c:x264_clip3f Unexecuted instantiation: predict.c:x264_clip3f Unexecuted instantiation: pixel.c:x264_clip3f Unexecuted instantiation: macroblock.c:x264_clip3f Unexecuted instantiation: frame.c:x264_clip3f Unexecuted instantiation: dct.c:x264_clip3f Unexecuted instantiation: cabac.c:x264_clip3f Unexecuted instantiation: common.c:x264_clip3f Unexecuted instantiation: set.c:x264_clip3f Unexecuted instantiation: quant.c:x264_clip3f Unexecuted instantiation: deblock.c:x264_clip3f Unexecuted instantiation: vlc.c:x264_clip3f Unexecuted instantiation: mvpred.c:x264_clip3f Unexecuted instantiation: analyse.c:x264_clip3f Unexecuted instantiation: me.c:x264_clip3f Unexecuted instantiation: ratecontrol.c:x264_clip3f Unexecuted instantiation: cavlc.c:x264_clip3f Unexecuted instantiation: rectangle.c:x264_clip3f |
215 | | |
216 | | /* Not a general-purpose function; multiplies input by -1/6 to convert |
217 | | * qp to qscale. */ |
218 | | static ALWAYS_INLINE int x264_exp2fix8( float x ) |
219 | 0 | { |
220 | 0 | int i = x*(-64.f/6.f) + 512.5f; |
221 | 0 | if( i < 0 ) return 0; |
222 | 0 | if( i > 1023 ) return 0xffff; |
223 | 0 | return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8; |
224 | 0 | } Unexecuted instantiation: base.c:x264_exp2fix8 Unexecuted instantiation: cpu.c:x264_exp2fix8 Unexecuted instantiation: api.c:x264_exp2fix8 Unexecuted instantiation: bitstream.c:x264_exp2fix8 Unexecuted instantiation: encoder.c:x264_exp2fix8 Unexecuted instantiation: lookahead.c:x264_exp2fix8 Unexecuted instantiation: threadpool.c:x264_exp2fix8 Unexecuted instantiation: tables.c:x264_exp2fix8 Unexecuted instantiation: mc.c:x264_exp2fix8 Unexecuted instantiation: predict.c:x264_exp2fix8 Unexecuted instantiation: pixel.c:x264_exp2fix8 Unexecuted instantiation: macroblock.c:x264_exp2fix8 Unexecuted instantiation: frame.c:x264_exp2fix8 Unexecuted instantiation: dct.c:x264_exp2fix8 Unexecuted instantiation: cabac.c:x264_exp2fix8 Unexecuted instantiation: common.c:x264_exp2fix8 Unexecuted instantiation: set.c:x264_exp2fix8 Unexecuted instantiation: quant.c:x264_exp2fix8 Unexecuted instantiation: deblock.c:x264_exp2fix8 Unexecuted instantiation: vlc.c:x264_exp2fix8 Unexecuted instantiation: mvpred.c:x264_exp2fix8 Unexecuted instantiation: analyse.c:x264_exp2fix8 Unexecuted instantiation: me.c:x264_exp2fix8 Unexecuted instantiation: ratecontrol.c:x264_exp2fix8 Unexecuted instantiation: cavlc.c:x264_exp2fix8 Unexecuted instantiation: rectangle.c:x264_exp2fix8 |
225 | | |
226 | | static ALWAYS_INLINE float x264_log2( uint32_t x ) |
227 | 0 | { |
228 | 0 | int lz = x264_clz( x ); |
229 | 0 | return x264_log2_lut[(x<<lz>>24)&0x7f] + x264_log2_lz_lut[lz]; |
230 | 0 | } Unexecuted instantiation: base.c:x264_log2 Unexecuted instantiation: cpu.c:x264_log2 Unexecuted instantiation: api.c:x264_log2 Unexecuted instantiation: bitstream.c:x264_log2 Unexecuted instantiation: encoder.c:x264_log2 Unexecuted instantiation: lookahead.c:x264_log2 Unexecuted instantiation: threadpool.c:x264_log2 Unexecuted instantiation: tables.c:x264_log2 Unexecuted instantiation: mc.c:x264_log2 Unexecuted instantiation: predict.c:x264_log2 Unexecuted instantiation: pixel.c:x264_log2 Unexecuted instantiation: macroblock.c:x264_log2 Unexecuted instantiation: frame.c:x264_log2 Unexecuted instantiation: dct.c:x264_log2 Unexecuted instantiation: cabac.c:x264_log2 Unexecuted instantiation: common.c:x264_log2 Unexecuted instantiation: set.c:x264_log2 Unexecuted instantiation: quant.c:x264_log2 Unexecuted instantiation: deblock.c:x264_log2 Unexecuted instantiation: vlc.c:x264_log2 Unexecuted instantiation: mvpred.c:x264_log2 Unexecuted instantiation: analyse.c:x264_log2 Unexecuted instantiation: me.c:x264_log2 Unexecuted instantiation: ratecontrol.c:x264_log2 Unexecuted instantiation: cavlc.c:x264_log2 Unexecuted instantiation: rectangle.c:x264_log2 |
231 | | |
232 | | static ALWAYS_INLINE int x264_median( int a, int b, int c ) |
233 | 0 | { |
234 | 0 | int t = (a-b)&((a-b)>>31); |
235 | 0 | a -= t; |
236 | 0 | b += t; |
237 | 0 | b -= (b-c)&((b-c)>>31); |
238 | 0 | b += (a-b)&((a-b)>>31); |
239 | 0 | return b; |
240 | 0 | } Unexecuted instantiation: base.c:x264_median Unexecuted instantiation: cpu.c:x264_median Unexecuted instantiation: api.c:x264_median Unexecuted instantiation: bitstream.c:x264_median Unexecuted instantiation: encoder.c:x264_median Unexecuted instantiation: lookahead.c:x264_median Unexecuted instantiation: threadpool.c:x264_median Unexecuted instantiation: tables.c:x264_median Unexecuted instantiation: mc.c:x264_median Unexecuted instantiation: predict.c:x264_median Unexecuted instantiation: pixel.c:x264_median Unexecuted instantiation: macroblock.c:x264_median Unexecuted instantiation: frame.c:x264_median Unexecuted instantiation: dct.c:x264_median Unexecuted instantiation: cabac.c:x264_median Unexecuted instantiation: common.c:x264_median Unexecuted instantiation: set.c:x264_median Unexecuted instantiation: quant.c:x264_median Unexecuted instantiation: deblock.c:x264_median Unexecuted instantiation: vlc.c:x264_median Unexecuted instantiation: mvpred.c:x264_median Unexecuted instantiation: analyse.c:x264_median Unexecuted instantiation: me.c:x264_median Unexecuted instantiation: ratecontrol.c:x264_median Unexecuted instantiation: cavlc.c:x264_median Unexecuted instantiation: rectangle.c:x264_median |
241 | | |
242 | | static ALWAYS_INLINE void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b, int16_t *c ) |
243 | 0 | { |
244 | 0 | dst[0] = x264_median( a[0], b[0], c[0] ); |
245 | 0 | dst[1] = x264_median( a[1], b[1], c[1] ); |
246 | 0 | } Unexecuted instantiation: base.c:x264_median_mv Unexecuted instantiation: cpu.c:x264_median_mv Unexecuted instantiation: api.c:x264_median_mv Unexecuted instantiation: bitstream.c:x264_median_mv Unexecuted instantiation: encoder.c:x264_median_mv Unexecuted instantiation: lookahead.c:x264_median_mv Unexecuted instantiation: threadpool.c:x264_median_mv Unexecuted instantiation: tables.c:x264_median_mv Unexecuted instantiation: mc.c:x264_median_mv Unexecuted instantiation: predict.c:x264_median_mv Unexecuted instantiation: pixel.c:x264_median_mv Unexecuted instantiation: macroblock.c:x264_median_mv Unexecuted instantiation: frame.c:x264_median_mv Unexecuted instantiation: dct.c:x264_median_mv Unexecuted instantiation: cabac.c:x264_median_mv Unexecuted instantiation: common.c:x264_median_mv Unexecuted instantiation: set.c:x264_median_mv Unexecuted instantiation: quant.c:x264_median_mv Unexecuted instantiation: deblock.c:x264_median_mv Unexecuted instantiation: vlc.c:x264_median_mv Unexecuted instantiation: mvpred.c:x264_median_mv Unexecuted instantiation: analyse.c:x264_median_mv Unexecuted instantiation: me.c:x264_median_mv Unexecuted instantiation: ratecontrol.c:x264_median_mv Unexecuted instantiation: cavlc.c:x264_median_mv Unexecuted instantiation: rectangle.c:x264_median_mv |
247 | | |
248 | | static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc ) |
249 | 0 | { |
250 | 0 | int sum = 0; |
251 | 0 | for( int i = 0; i < i_mvc-1; i++ ) |
252 | 0 | { |
253 | 0 | sum += abs( mvc[i][0] - mvc[i+1][0] ) |
254 | 0 | + abs( mvc[i][1] - mvc[i+1][1] ); |
255 | 0 | } |
256 | 0 | return sum; |
257 | 0 | } Unexecuted instantiation: base.c:x264_predictor_difference Unexecuted instantiation: cpu.c:x264_predictor_difference Unexecuted instantiation: api.c:x264_predictor_difference Unexecuted instantiation: bitstream.c:x264_predictor_difference Unexecuted instantiation: encoder.c:x264_predictor_difference Unexecuted instantiation: lookahead.c:x264_predictor_difference Unexecuted instantiation: threadpool.c:x264_predictor_difference Unexecuted instantiation: tables.c:x264_predictor_difference Unexecuted instantiation: mc.c:x264_predictor_difference Unexecuted instantiation: predict.c:x264_predictor_difference Unexecuted instantiation: pixel.c:x264_predictor_difference Unexecuted instantiation: macroblock.c:x264_predictor_difference Unexecuted instantiation: frame.c:x264_predictor_difference Unexecuted instantiation: dct.c:x264_predictor_difference Unexecuted instantiation: cabac.c:x264_predictor_difference Unexecuted instantiation: common.c:x264_predictor_difference Unexecuted instantiation: set.c:x264_predictor_difference Unexecuted instantiation: quant.c:x264_predictor_difference Unexecuted instantiation: deblock.c:x264_predictor_difference Unexecuted instantiation: vlc.c:x264_predictor_difference Unexecuted instantiation: mvpred.c:x264_predictor_difference Unexecuted instantiation: analyse.c:x264_predictor_difference Unexecuted instantiation: me.c:x264_predictor_difference Unexecuted instantiation: ratecontrol.c:x264_predictor_difference Unexecuted instantiation: cavlc.c:x264_predictor_difference Unexecuted instantiation: rectangle.c:x264_predictor_difference |
258 | | |
259 | | static ALWAYS_INLINE uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvdtop ) |
260 | 0 | { |
261 | 0 | int amvd0 = mvdleft[0] + mvdtop[0]; |
262 | 0 | int amvd1 = mvdleft[1] + mvdtop[1]; |
263 | 0 | amvd0 = (amvd0 > 2) + (amvd0 > 32); |
264 | 0 | amvd1 = (amvd1 > 2) + (amvd1 > 32); |
265 | 0 | return amvd0 + (amvd1<<8); |
266 | 0 | } Unexecuted instantiation: base.c:x264_cabac_mvd_sum Unexecuted instantiation: cpu.c:x264_cabac_mvd_sum Unexecuted instantiation: api.c:x264_cabac_mvd_sum Unexecuted instantiation: bitstream.c:x264_cabac_mvd_sum Unexecuted instantiation: encoder.c:x264_cabac_mvd_sum Unexecuted instantiation: lookahead.c:x264_cabac_mvd_sum Unexecuted instantiation: threadpool.c:x264_cabac_mvd_sum Unexecuted instantiation: tables.c:x264_cabac_mvd_sum Unexecuted instantiation: mc.c:x264_cabac_mvd_sum Unexecuted instantiation: predict.c:x264_cabac_mvd_sum Unexecuted instantiation: pixel.c:x264_cabac_mvd_sum Unexecuted instantiation: macroblock.c:x264_cabac_mvd_sum Unexecuted instantiation: frame.c:x264_cabac_mvd_sum Unexecuted instantiation: dct.c:x264_cabac_mvd_sum Unexecuted instantiation: cabac.c:x264_cabac_mvd_sum Unexecuted instantiation: common.c:x264_cabac_mvd_sum Unexecuted instantiation: set.c:x264_cabac_mvd_sum Unexecuted instantiation: quant.c:x264_cabac_mvd_sum Unexecuted instantiation: deblock.c:x264_cabac_mvd_sum Unexecuted instantiation: vlc.c:x264_cabac_mvd_sum Unexecuted instantiation: mvpred.c:x264_cabac_mvd_sum Unexecuted instantiation: analyse.c:x264_cabac_mvd_sum Unexecuted instantiation: me.c:x264_cabac_mvd_sum Unexecuted instantiation: ratecontrol.c:x264_cabac_mvd_sum Unexecuted instantiation: cavlc.c:x264_cabac_mvd_sum Unexecuted instantiation: rectangle.c:x264_cabac_mvd_sum |
267 | | |
268 | | /**************************************************************************** |
269 | | * General functions |
270 | | ****************************************************************************/ |
271 | | X264_API void x264_reduce_fraction( uint32_t *n, uint32_t *d ); |
272 | | X264_API void x264_reduce_fraction64( uint64_t *n, uint64_t *d ); |
273 | | |
274 | | X264_API void x264_log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg ); |
275 | | X264_API void x264_log_internal( int i_level, const char *psz_fmt, ... ); |
276 | | |
277 | | /* x264_malloc: will do or emulate a memalign |
278 | | * you have to use x264_free for buffers allocated with x264_malloc */ |
279 | | X264_API void *x264_malloc( int64_t ); |
280 | | X264_API void x264_free( void * ); |
281 | | |
282 | | /* x264_slurp_file: malloc space for the whole file and read it */ |
283 | | X264_API char *x264_slurp_file( const char *filename ); |
284 | | |
285 | | /* x264_param_strdup: will do strdup and save returned pointer inside |
286 | | * x264_param_t for later freeing during x264_param_cleanup */ |
287 | | char *x264_param_strdup( x264_param_t *param, const char *src ); |
288 | | |
289 | | /* x264_param2string: return a (malloced) string containing most of |
290 | | * the encoding options */ |
291 | | X264_API char *x264_param2string( x264_param_t *p, int b_res ); |
292 | | |
293 | | /**************************************************************************** |
294 | | * Macros |
295 | | ****************************************************************************/ |
296 | 0 | #define CHECKED_MALLOC( var, size )\ |
297 | 0 | do {\ |
298 | 0 | var = x264_malloc( size );\ |
299 | 0 | if( !var )\ |
300 | 0 | goto fail;\ |
301 | 0 | } while( 0 ) |
302 | 0 | #define CHECKED_MALLOCZERO( var, size )\ |
303 | 0 | do {\ |
304 | 0 | CHECKED_MALLOC( var, size );\ |
305 | 0 | memset( var, 0, size );\ |
306 | 0 | } while( 0 ) |
307 | 0 | #define CHECKED_PARAM_STRDUP( var, param, src )\ |
308 | 0 | do {\ |
309 | 0 | var = x264_param_strdup( param, src );\ |
310 | 0 | if( !var )\ |
311 | 0 | goto fail;\ |
312 | 0 | } while( 0 ) |
313 | | |
314 | | /* Macros for merging multiple allocations into a single large malloc, for improved |
315 | | * use with huge pages. */ |
316 | | |
317 | | /* Needs to be enough to contain any set of buffers that use combined allocations */ |
318 | | #define PREALLOC_BUF_SIZE 1024 |
319 | | |
320 | | #define PREALLOC_INIT\ |
321 | 0 | int prealloc_idx = 0;\ |
322 | 0 | int64_t prealloc_size = 0;\ |
323 | 0 | uint8_t **preallocs[PREALLOC_BUF_SIZE]; |
324 | | |
325 | 0 | #define PREALLOC( var, size )\ |
326 | 0 | do {\ |
327 | 0 | var = (void*)(intptr_t)prealloc_size;\ |
328 | 0 | preallocs[prealloc_idx++] = (uint8_t**)&var;\ |
329 | 0 | prealloc_size += ALIGN((int64_t)(size), NATIVE_ALIGN);\ |
330 | 0 | } while( 0 ) |
331 | | |
332 | 0 | #define PREALLOC_END( ptr )\ |
333 | 0 | do {\ |
334 | 0 | CHECKED_MALLOC( ptr, prealloc_size );\ |
335 | 0 | while( prealloc_idx-- )\ |
336 | 0 | *preallocs[prealloc_idx] = (uint8_t*)((intptr_t)(*preallocs[prealloc_idx]) + (intptr_t)ptr);\ |
337 | 0 | } while( 0 ) |
338 | | |
339 | | #endif |