common internal and external API header More...
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "attributes.h"
#include "libavutil/avconfig.h"
#include "config.h"
#include "intmath.h"
#include "common.h"
#include "mem.h"
#include "internal.h"
#include "intmath.h"
Go to the source code of this file.
Defines | |
#define | AV_NE(be, le) (le) |
#define | RSHIFT(a, b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) |
#define | ROUNDED_DIV(a, b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) |
#define | FFUDIV(a, b) (((a)>0 ?(a):(a)-(b)+1) / (b)) |
#define | FFUMOD(a, b) ((a)-(b)*FFUDIV(a,b)) |
#define | FFABS(a) ((a) >= 0 ? (a) : (-(a))) |
#define | FFSIGN(a) ((a) > 0 ? 1 : -1) |
#define | FFMAX(a, b) ((a) > (b) ? (a) : (b)) |
#define | FFMAX3(a, b, c) FFMAX(FFMAX(a,b),c) |
#define | FFMIN(a, b) ((a) > (b) ? (b) : (a)) |
#define | FFMIN3(a, b, c) FFMIN(FFMIN(a,b),c) |
#define | FFSWAP(type, a, b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) |
#define | FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) |
#define | FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) |
#define | MKTAG(a, b, c, d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) |
#define | MKBETAG(a, b, c, d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) |
#define | GET_UTF8(val, GET_BYTE, ERROR) |
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. | |
#define | GET_UTF16(val, GET_16BIT, ERROR) |
Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. | |
#define | PUT_UTF8(val, tmp, PUT_BYTE) |
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). | |
#define | PUT_UTF16(val, tmp, PUT_16BIT) |
Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). | |
#define | av_log2 av_log2_c |
#define | av_log2_16bit av_log2_16bit_c |
#define | av_ceil_log2 av_ceil_log2_c |
#define | av_clip av_clip_c |
#define | av_clip_uint8 av_clip_uint8_c |
#define | av_clip_int8 av_clip_int8_c |
#define | av_clip_uint16 av_clip_uint16_c |
#define | av_clip_int16 av_clip_int16_c |
#define | av_clipl_int32 av_clipl_int32_c |
#define | av_clip_uintp2 av_clip_uintp2_c |
#define | av_clipf av_clipf_c |
#define | av_popcount av_popcount_c |
#define | av_popcount64 av_popcount64_c |
Functions | |
static av_always_inline av_const int | av_log2_c (unsigned int v) |
static av_always_inline av_const int | av_log2_16bit_c (unsigned int v) |
static av_always_inline av_const int | av_clip_c (int a, int amin, int amax) |
Clip a signed integer value into the amin-amax range. | |
static av_always_inline av_const uint8_t | av_clip_uint8_c (int a) |
Clip a signed integer value into the 0-255 range. | |
static av_always_inline av_const int8_t | av_clip_int8_c (int a) |
Clip a signed integer value into the -128,127 range. | |
static av_always_inline av_const uint16_t | av_clip_uint16_c (int a) |
Clip a signed integer value into the 0-65535 range. | |
static av_always_inline av_const int16_t | av_clip_int16_c (int a) |
Clip a signed integer value into the -32768,32767 range. | |
static av_always_inline av_const int32_t | av_clipl_int32_c (int64_t a) |
Clip a signed 64-bit integer value into the -2147483648,2147483647 range. | |
static av_always_inline av_const unsigned | av_clip_uintp2_c (int a, int p) |
Clip a signed integer to an unsigned power of two range. | |
static av_always_inline av_const float | av_clipf_c (float a, float amin, float amax) |
Clip a float value into the amin-amax range. | |
static av_always_inline av_const int | av_ceil_log2_c (int x) |
Compute ceil(log2(x)). | |
static av_always_inline av_const int | av_popcount_c (uint32_t x) |
Count number of bits set to one in x. | |
static av_always_inline av_const int | av_popcount64_c (uint64_t x) |
Count number of bits set to one in x. | |
Variables | |
const uint8_t | ff_log2_tab [256] |
const uint8_t | av_reverse [256] |
common internal and external API header
Definition in file common.h.
#define av_ceil_log2 av_ceil_log2_c |
Definition at line 369 of file common.h.
Referenced by decode_channel_residues(), read_channel_data(), read_specific_config(), read_var_block_data(), and wmavoice_decode_init().
#define av_clip av_clip_c |
Definition at line 372 of file common.h.
Referenced by ac3_bit_alloc_calc_bap_c(), adpcm_compress_trellis(), adpcm_ct_expand_nibble(), adpcm_decode_frame(), adpcm_ima_compress_sample(), adpcm_ima_qt_compress_sample(), adpcm_ima_qt_expand_nibble(), adpcm_ms_compress_sample(), adpcm_sbpro_expand_nibble(), adpcm_yamaha_compress_sample(), adpcm_yamaha_expand_nibble(), adx_encode(), alac_encode_init(), apply_channel_coupling(), av_log_default_callback(), bgmc_lut_getp(), blend_subrect(), build_filter(), build_qp_table(), bytestream2_seek(), bytestream2_seek_p(), calc_bit_demand(), calc_input_response(), categorize(), choose_vlc_set(), chroma_4mv_motion(), clamp_mv(), clip(), config_input(), config_props(), dec_delay3_2nd(), decode(), decode_frame(), decode_gain_and_index(), decode_init(), decode_pitch_lag_1_6(), decode_pitch_lag_high(), decode_pitch_lag_low(), decode_scalefactors(), decode_slice(), decode_slice_thread(), decode_subband_slice_buffered(), decode_tile(), delta_decode(), dequantize(), dequantize_slice_buffered(), direct_search(), do_adaptive_prediction(), do_audio_out(), draw_arrow(), draw_line(), encode_block(), encode_frame(), encode_init(), encode_mb_internal(), escape130_decode_frame(), eval_expr(), execute_code(), ff_decode_pitch_lag(), ff_er_add_slice(), ff_g722_update_high_predictor(), ff_g722_update_low_predictor(), ff_gmc_c(), ff_h263_encode_picture_header(), ff_h264_init_cabac_states(), ff_init_qscale_tab(), ff_ivi_decode_blocks(), ff_jpegls_decode_picture(), ff_mspel_motion(), ff_nelly_get_sample_bits(), ff_vbv_update(), fill_gv_table(), fill_table(), g722_decode_frame(), g722_encode_init(), g722_encode_trellis(), g726_decode(), g726_encode_init(), get_dc(), get_qminmax(), get_scale(), get_scale_factor(), gmc1_motion(), gmc_c(), gsm_decode_block(), h263_h_loop_filter_c(), h263_v_loop_filter_c(), h264_loop_filter_chroma(), h264_loop_filter_luma(), horizontal_compose_fidelityi(), hpel_motion(), idct(), implicit_weight_table(), init(), init_dequantizer(), init_pass2(), initFilter(), lms_update(), loop_filter_c1(), loop_filter_l1(), ls_decode_line(), ls_encode_line(), modplug_read_packet(), mp_decode_frame_helper(), mp_decode_layer3(), mp_decode_line(), mpc7_decode_frame(), MPV_motion_internal(), parse(), png_enc_init(), quantize(), quantize_and_encode_band_cost_template(), quantize_lpc_coefs(), ratecontrol_1pass(), read_channel_data(), read_var_block_data(), rv30_weak_loop_filter(), rv40_strong_loop_filter(), scaleforopp_x(), scaleforopp_y(), scaleforsame_x(), scaleforsame_y(), search_for_quantizers_anmr(), search_for_quantizers_faac(), search_for_quantizers_fast(), search_for_quantizers_twoloop(), set_bandwidth(), skip_bits_long(), spatial_compose_dd137i_dy(), spatial_compose_dd137i_init(), spatial_compose_dd97i_dy(), spatial_compose_dd97i_init(), spatial_compose_fidelity(), sum_bits(), svq3_mc_dir(), svq3_mc_dir_part(), synth_block_fcb_acb(), synth_frame(), tm2_motion_block(), truespeech_apply_twopoint_filter(), truespeech_synth(), update_qscale(), value_string(), vc1_draw_sprites(), vc1_interp_mc(), vc1_mc_1mv(), vc1_mc_4mv_chroma(), vc1_mc_4mv_chroma4(), vc1_mc_4mv_luma(), vc1_pred_b_mv(), vector_clip_int32_c(), vp5_parse_coeff_models(), vp6_parse_coeff_models(), and wv_get_value_integer().
#define av_clip_int16 av_clip_int16_c |
Definition at line 384 of file common.h.
Referenced by adpcm_ct_expand_nibble(), adpcm_decode_frame(), adpcm_ima_compress_sample(), adpcm_ima_expand_nibble(), adpcm_ima_qt_compress_sample(), adpcm_ima_qt_expand_nibble(), adpcm_ms_compress_sample(), adpcm_ms_expand_nibble(), adpcm_yamaha_compress_sample(), adpcm_yamaha_expand_nibble(), adx_decode(), apply_tilt_comp(), av_audio_convert(), av_resample(), bmv_aud_decode_frame(), cinaudio_decode_frame(), comp_ppf_gains(), decode_audio_s16(), do_adaptive_prediction(), do_apply_filter(), dpcm_decode_frame(), encode_high(), encode_low(), ff_acelp_high_pass_filter(), ff_acelp_interpolate(), ff_acelp_weighted_vector_sum(), ff_g729_adaptive_gain_control(), filter_samples(), float_to_int16_one(), g722_decode_frame(), g723_1_decode_frame(), g723_1_encode_frame(), gain_scale(), interleave_buffer(), postprocess(), ra144_decode_frame(), round_sample(), smka_decode_frame(), sonic_decode_frame(), surround_to_stereo(), swri_resample(), transcode_audio(), xa_decode(), and yuv2gray16_X_c_template().
#define av_clip_uint16 av_clip_uint16_c |
Definition at line 381 of file common.h.
Referenced by end_frame(), and vorbis_floor1_decode().
#define av_clip_uint8 av_clip_uint8_c |
Definition at line 375 of file common.h.
Referenced by add_pixels_clamped2_c(), add_pixels_clamped4_c(), add_rect_clamped_c(), ana_convert(), apply_unsharp(), av_audio_convert(), coef2maxsf(), coef2minsf(), comp(), dirac_hpel_filter(), dpcm_decode_frame(), encode_picture(), ff_add_pixels_clamped_c(), ff_gradfun_filter_line_c(), ff_ivi_output_plane(), ff_ivi_recompose53(), ff_ivi_recompose_haar(), ff_jref_idct1_add(), ff_jref_idct1_put(), ff_put_pixels_clamped_c(), ff_svq3_add_idct_c(), ff_vp3_h_loop_filter_c(), ff_vp3_idct_dc_add_c(), ff_vp3_v_loop_filter_c(), ff_vp6_filter_diag4_c(), ff_yuv2rgb_c_init_tables(), filter_samples(), idct(), idct4col_add(), idct4col_put(), ir2_decode_plane(), ir2_decode_plane_inter(), loop_filter_c1(), loop_filter_l1(), p8idct(), put_pixels_clamped2_c(), put_pixels_clamped4_c(), put_signed_rect_clamped_c(), render_line(), render_line_unrolled(), rv34_idct_add_c(), rv34_idct_dc_add_c(), search_for_quantizers_anmr(), search_for_quantizers_faac(), smka_decode_frame(), sws_scale(), tgq_dconly(), tm2_apply_deltas(), tm2_decode_blocks(), transcode_audio(), vc1_filter_line(), vc1_h_overlap_c(), vc1_inv_trans_4x4_c(), vc1_inv_trans_4x4_dc_c(), vc1_inv_trans_4x8_c(), vc1_inv_trans_4x8_dc_c(), vc1_inv_trans_8x4_c(), vc1_inv_trans_8x4_dc_c(), vc1_inv_trans_8x8_dc_c(), vc1_parse_frame_header(), vc1_v_overlap_c(), vp6_filter_hv4(), vp8_idct_add_c(), vp8_idct_dc_add_c(), ws_snd_decode_frame(), x8_decode_intra_mb(), yuv2422_X_c_template(), yuv2mono_X_c_template(), yuv2NBPS(), yuv2nv12cX_c(), yuv2plane1_8_c(), yuv2rgb_full_X_c_template(), and yuv2rgb_X_c_template().
#define av_clip_uintp2 av_clip_uintp2_c |
Definition at line 390 of file common.h.
Referenced by filter_level_for_mb(), get_quants(), get_scale_idx(), yuv2rgb48_1_c_template(), yuv2rgb48_2_c_template(), yuv2rgb48_X_c_template(), and yuv2rgb_full_X_c_template().
#define av_clipf av_clipf_c |
Definition at line 393 of file common.h.
Referenced by avfilter_transform(), bit_allocation(), calc_bit_demand(), config_props(), decode(), decode_audio_block(), encode_init(), find_hb_gain(), find_motion(), fixed_gain_smooth(), init(), mulawinv(), pitch_sharpening(), psy_3gpp_init(), saturate_output_float(), synth_block_fcb_acb(), and vector_clipf_c().
#define av_log2 av_log2_c |
Definition at line 363 of file common.h.
Referenced by ac3_extract_exponents_c(), alac_entropy_coder(), av_ceil_log2_c(), av_mod_i(), av_normalize_sf(), av_read_packet(), bastardized_rice_decompress(), compute_scale_factors(), decode_ac_coeffs(), decode_block(), decode_cdlms(), decode_channel_residues(), decode_frame(), decode_init(), decode_lowdelay_slice(), decode_mclms(), decode_packet(), decode_q_branch(), decode_slice(), decode_spectrum_and_dequant(), decode_subframe(), decode_subframe_length(), decode_vlc_codeword(), decode_vol_header(), ebml_id_size(), encode_block(), encode_cblk(), encode_codeword(), encode_packet(), encode_q_branch(), encode_q_branch2(), encode_subband_c0run(), escape124_decode_frame(), ff_eac3_parse_header(), ff_g729_adaptive_gain_control(), ff_log2(), ff_mpeg1_encode_init(), ff_mpeg4_encode_video_packet_header(), ff_wma_init(), find_optimal_param(), fps_umf2avr(), get_block_bits(), get_level_prefix(), get_max_p_order(), get_rac_count(), get_se_golomb(), get_tail(), get_tilt_comp(), get_ue_golomb(), get_ue_golomb_long(), get_ur_golomb(), get_ur_golomb_jpegls(), headroom(), imdct_and_window(), init_cavlc_level_tab(), init_cook_mlt(), init_lengths(), init_mdct_win(), init_mv_penalty_and_fcode(), init_quantization(), klv_ber_length(), klv_encode_ber_length(), lag_get_rac(), lag_read_prob_header(), long_term_filter(), mp_decode_init(), mpeg4_decode_video_packet_header(), mpeg4_is_resync(), MPV_encode_init(), normalize_bits(), normalize_samples(), parse_source_parameters(), prores_encode_picture(), put_symbol(), put_symbol_inline(), qdm2_decode_init(), quantize_and_encode_band_cost_template(), read_header(), set_ue_golomb(), shorten_decode_frame(), softfloat_mul(), softfloat_reciprocal(), svq3_decode_slice_header(), theora_decode_tables(), unpack_coeffs(), very_broken_op(), vp8_init(), wma_decode_block(), wmapro_window(), wp_log2(), and wv_get_value_float().
#define av_log2_16bit av_log2_16bit_c |
Definition at line 366 of file common.h.
Referenced by av_log2_i(), aw_pulse_set2(), dnxhd_calc_bits_thread(), dnxhd_encode_dc(), encode_dc(), ff_mjpeg_encode_dc(), ff_sqrt(), i2f(), quant(), and renorm().
#define av_popcount av_popcount_c |
Definition at line 396 of file common.h.
Referenced by av_popcount64_c(), dca_exss_mask2count(), dca_exss_parse_asset_header(), dca_exss_skip_mix_coeffs(), get_packet_header(), and vmdaudio_decode_frame().
#define av_popcount64 av_popcount64_c |
Definition at line 399 of file common.h.
Referenced by get_logical_cpus().
#define FFSWAP | ( | type, | ||
a, | ||||
b | ||||
) | do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) |
#define GET_UTF16 | ( | val, | ||
GET_16BIT, | ||||
ERROR | ||||
) |
val = GET_16BIT;\ {\ unsigned int hi = val - 0xD800;\ if (hi < 0x800) {\ val = GET_16BIT - 0xDC00;\ if (val > 0x3FFU || hi > 0x3FFU)\ ERROR\ val += (hi<<10) + 0x10000;\ }\ }\
Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
val | Output value, must be an lvalue of type uint32_t. | |
GET_16BIT | Expression returning two bytes of UTF-16 data converted to native byte order. Evaluated one or two times. | |
ERROR | Expression to be evaluated on invalid input, typically a goto statement. |
#define GET_UTF8 | ( | val, | ||
GET_BYTE, | ||||
ERROR | ||||
) |
val= GET_BYTE;\ {\ int ones= 7 - av_log2(val ^ 255);\ if(ones==1)\ ERROR\ val&= 127>>ones;\ while(--ones > 0){\ int tmp= GET_BYTE - 128;\ if(tmp>>6)\ ERROR\ val= (val<<6) + tmp;\ }\ }
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
val | Output value, must be an lvalue of type uint32_t. | |
GET_BYTE | Expression reading one byte from the input. Evaluated up to 7 times (4 for the currently assigned Unicode range). With a memory buffer input, this could be *ptr++. | |
ERROR | Expression to be evaluated on invalid input, typically a goto statement. |
#define PUT_UTF16 | ( | val, | ||
tmp, | ||||
PUT_16BIT | ||||
) |
{\ uint32_t in = val;\ if (in < 0x10000) {\ tmp = in;\ PUT_16BIT\ } else {\ tmp = 0xD800 | ((in - 0x10000) >> 10);\ PUT_16BIT\ tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ PUT_16BIT\ }\ }\
Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
val | is an input-only argument and should be of type uint32_t. It holds a UCS-4 encoded Unicode character that is to be converted to UTF-16. If val is given as a function it is executed only once. | |
tmp | is a temporary variable and should be of type uint16_t. It represents an intermediate value during conversion that is to be output by PUT_16BIT. | |
PUT_16BIT | writes the converted UTF-16 data to any proper destination in desired endianness. It could be a function or a statement, and uses tmp as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be executed 1 or 2 times depending on input character. |
#define PUT_UTF8 | ( | val, | ||
tmp, | ||||
PUT_BYTE | ||||
) |
{\ int bytes, shift;\ uint32_t in = val;\ if (in < 0x80) {\ tmp = in;\ PUT_BYTE\ } else {\ bytes = (av_log2(in) + 4) / 5;\ shift = (bytes - 1) * 6;\ tmp = (256 - (256 >> bytes)) | (in >> shift);\ PUT_BYTE\ while (shift >= 6) {\ shift -= 6;\ tmp = 0x80 | ((in >> shift) & 0x3f);\ PUT_BYTE\ }\ }\ }
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
val | is an input-only argument and should be of type uint32_t. It holds a UCS-4 encoded Unicode character that is to be converted to UTF-8. If val is given as a function it is executed only once. | |
tmp | is a temporary variable and should be of type uint8_t. It represents an intermediate value during conversion that is to be output by PUT_BYTE. | |
PUT_BYTE | writes the converted UTF-8 bytes to any proper destination. It could be a function or a statement, and uses tmp as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be executed up to 4 times for values in the valid UTF-8 range and up to 7 times in the general case, depending on the length of the converted Unicode character. |
#define ROUNDED_DIV | ( | a, | ||
b | ||||
) | (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) |
#define RSHIFT | ( | a, | ||
b | ||||
) | ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) |
static av_always_inline av_const int av_ceil_log2_c | ( | int | x | ) | [static] |
static av_always_inline av_const int av_clip_c | ( | int | a, | |
int | amin, | |||
int | amax | |||
) | [static] |
static av_always_inline av_const int16_t av_clip_int16_c | ( | int | a | ) | [static] |
static av_always_inline av_const int8_t av_clip_int8_c | ( | int | a | ) | [static] |
static av_always_inline av_const uint16_t av_clip_uint16_c | ( | int | a | ) | [static] |
static av_always_inline av_const uint8_t av_clip_uint8_c | ( | int | a | ) | [static] |
static av_always_inline av_const unsigned av_clip_uintp2_c | ( | int | a, | |
int | p | |||
) | [static] |
static av_always_inline av_const float av_clipf_c | ( | float | a, | |
float | amin, | |||
float | amax | |||
) | [static] |
static av_always_inline av_const int32_t av_clipl_int32_c | ( | int64_t | a | ) | [static] |
static av_always_inline av_const int av_log2_16bit_c | ( | unsigned int | v | ) | [static] |
static av_always_inline av_const int av_log2_c | ( | unsigned int | v | ) | [static] |
static av_always_inline av_const int av_popcount64_c | ( | uint64_t | x | ) | [static] |
static av_always_inline av_const int av_popcount_c | ( | uint32_t | x | ) | [static] |
const uint8_t av_reverse[256] |
Definition at line 54 of file mathematics.c.
const uint8_t ff_log2_tab[256] |
Definition at line 43 of file mathematics.c.