Libav
Data Structures | Macros | Enumerations | Functions

Data Structures

struct  AVRational
 rational number numerator/denominator More...
 

Macros

#define ff_ctz   ff_ctz_c
 

Enumerations

enum  AVRounding {
  AV_ROUND_ZERO = 0, AV_ROUND_INF = 1, AV_ROUND_DOWN = 2, AV_ROUND_UP = 3,
  AV_ROUND_NEAR_INF = 5
}
 

Functions

static av_always_inline av_const int ff_ctz_c (int v)
 
int av_ctz (int v)
 Trailing zero bit count. More...
 
int64_t av_const av_gcd (int64_t a, int64_t b)
 Return the greatest common divisor of a and b. More...
 
int64_t av_rescale (int64_t a, int64_t b, int64_t c) av_const
 Rescale a 64-bit integer with rounding to nearest. More...
 
int64_t av_rescale_rnd (int64_t a, int64_t b, int64_t c, enum AVRounding) av_const
 Rescale a 64-bit integer with specified rounding. More...
 
int64_t av_rescale_q (int64_t a, AVRational bq, AVRational cq) av_const
 Rescale a 64-bit integer by 2 rational numbers. More...
 
int64_t av_rescale_q_rnd (int64_t a, AVRational bq, AVRational cq, enum AVRounding) av_const
 Rescale a 64-bit integer by 2 rational numbers with specified rounding. More...
 
int av_compare_ts (int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
 Compare 2 timestamps each in its own timebases. More...
 
int64_t av_compare_mod (uint64_t a, uint64_t b, uint64_t mod)
 Compare 2 integers modulo mod. More...
 
static int av_cmp_q (AVRational a, AVRational b)
 Compare two rationals. More...
 
static double av_q2d (AVRational a)
 Convert rational to double. More...
 
int av_reduce (int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
 Reduce a fraction. More...
 
AVRational av_mul_q (AVRational b, AVRational c) av_const
 Multiply two rationals. More...
 
AVRational av_div_q (AVRational b, AVRational c) av_const
 Divide one rational by another. More...
 
AVRational av_add_q (AVRational b, AVRational c) av_const
 Add two rationals. More...
 
AVRational av_sub_q (AVRational b, AVRational c) av_const
 Subtract one rational from another. More...
 
static av_always_inline AVRational av_inv_q (AVRational q)
 Invert a rational. More...
 
AVRational av_d2q (double d, int max) av_const
 Convert a double precision floating point number to a rational. More...
 
int av_nearer_q (AVRational q, AVRational q1, AVRational q2)
 
int av_find_nearest_q_idx (AVRational q, const AVRational *q_list)
 Find the nearest value in q_list to q. More...
 

Detailed Description

Macro Definition Documentation

§ ff_ctz

#define ff_ctz   ff_ctz_c

Definition at line 104 of file intmath.h.

Referenced by av_ctz().

Enumeration Type Documentation

§ AVRounding

enum AVRounding
Enumerator
AV_ROUND_ZERO 

Round toward zero.

AV_ROUND_INF 

Round away from zero.

AV_ROUND_DOWN 

Round toward -infinity.

AV_ROUND_UP 

Round toward +infinity.

AV_ROUND_NEAR_INF 

Round to nearest and halfway cases away from zero.

Definition at line 49 of file mathematics.h.

Function Documentation

§ ff_ctz_c()

static av_always_inline av_const int ff_ctz_c ( int  v)
static

Definition at line 105 of file intmath.h.

§ av_ctz()

int av_ctz ( int  v)

Trailing zero bit count.

Parameters
vinput value. If v is 0, the result is undefined.
Returns
the number of trailing 0-bits

Definition at line 36 of file intmath.c.

Referenced by ff_ctz_c(), and remove_wasted_bits().

§ av_gcd()

int64_t av_const av_gcd ( int64_t  a,
int64_t  b 
)

Return the greatest common divisor of a and b.

If both a and b are 0 or either or both are <0 then behavior is undefined.

Definition at line 53 of file mathematics.c.

Referenced by av_gcd(), av_reduce(), avcodec_string(), decode_main_header(), ff_h263_decode_picture_header(), ff_mpv_encode_init(), ff_parse_specific_params(), ff_put_wav_header(), rtp_send_samples(), and xvid_correct_framerate().

§ av_rescale()

int64_t av_rescale ( int64_t  a,
int64_t  b,
int64_t  c 
) const

§ av_rescale_rnd()

int64_t av_rescale_rnd ( int64_t  a,
int64_t  b,
int64_t  c,
enum  AVRounding 
) const

§ av_rescale_q()

int64_t av_rescale_q ( int64_t  a,
AVRational  bq,
AVRational  cq 
) const

Rescale a 64-bit integer by 2 rational numbers.

Definition at line 129 of file mathematics.c.

Referenced by asf_write_markers(), av_buffersink_get_samples(), av_packet_rescale_ts(), avformat_find_stream_info(), avi_read_packet(), avi_read_seek(), avisynth_read_packet_audio(), avisynth_read_seek(), buffer_offset(), check_stream_max_drift(), compand_delay(), compand_drain(), compute_chapters_end(), copy_chapters(), decode_audio(), decode_frame(), decode_syncpoint(), do_streamcopy(), do_subtitle_out(), do_video_out(), dv_extract_video_info(), dv_read_header(), ff_af_queue_add(), ff_dv_offset_reset(), ff_interleave_packet_per_dts(), ff_rtsp_open_transport_ctx(), ff_samples_to_time_base(), ff_write_chained(), fill_all_stream_timings(), filter_frame(), get_subtitle_pkt(), hls_read_packet(), init_common(), interleave_new_audio_packet(), main(), matroska_parse_tracks(), mkv_write_chapters(), mkv_write_track(), mov_create_chapter_track(), mov_read_seek(), mov_write_chpl_tag(), mov_write_packet(), mp3_parse_info_tag(), mp3_parse_vbr_tags(), mxf_parse_structural_metadata(), mxf_read_seek(), nut_write_packet(), ogg_buffer_data(), ogg_compare_granule(), ogg_write_packet_internal(), parse_forced_key_frames(), poll_filter(), poll_filters(), process_input(), process_input_packet(), r3d_read_rdvo(), r3d_seek(), read_from_fifo(), read_header(), read_seek2(), request_frame(), rl2_read_seek(), rtcp_send_sr(), rtp_parse_one_packet(), rtp_write_header(), rtsp_read_play(), rtsp_read_seek(), seek_chapter(), seek_subtitle(), source_request_frame(), update_stream_timings(), v4l2_set_parameters(), video_thread(), and write_packet().

§ av_rescale_q_rnd()

int64_t av_rescale_q_rnd ( int64_t  a,
AVRational  bq,
AVRational  cq,
enum  AVRounding 
) const

Rescale a 64-bit integer by 2 rational numbers with specified rounding.

Definition at line 121 of file mathematics.c.

Referenced by av_rescale_q(), parse_packet(), and rtp_write_header().

§ av_compare_ts()

int av_compare_ts ( int64_t  ts_a,
AVRational  tb_a,
int64_t  ts_b,
AVRational  tb_b 
)

Compare 2 timestamps each in its own timebases.

The result of the function is undefined if one of the timestamps is outside the int64_t range when represented in the others timebase.

Returns
-1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position

Definition at line 134 of file mathematics.c.

Referenced by check_recording_time(), ff_gen_syncpoint_search(), get_audio_frame(), get_video_frame(), hds_write_packet(), hls_read_packet(), hls_write_packet(), interleave_compare_dts(), ism_write_packet(), main(), request_frame(), search_hi_lo_keyframes(), seek_chapter(), and seg_write_packet().

§ av_compare_mod()

int64_t av_compare_mod ( uint64_t  a,
uint64_t  b,
uint64_t  mod 
)

Compare 2 integers modulo mod.

That is we compare integers a and b for which only the least significant log2(mod) bits are known.

Parameters
modmust be a power of 2
Returns
a negative value if a is smaller than b a positive value if a is greater than b 0 if a equals b

Definition at line 145 of file mathematics.c.

Referenced by av_read_frame().

§ av_cmp_q()

static int av_cmp_q ( AVRational  a,
AVRational  b 
)
inlinestatic

Compare two rationals.

Parameters
afirst rational
bsecond rational
Returns
0 if a==b, 1 if a>b, -1 if a<b, and INT_MIN if one of the values is of the form 0/0

Definition at line 55 of file rational.h.

Referenced by av_nearer_q(), config_output(), dump_stream_format(), ff_h263_aspect_to_info(), ff_mxf_get_samples_per_frame(), filter_frame(), init_muxer(), mpeg_decode_postinit(), and video_thread().

§ av_q2d()

static double av_q2d ( AVRational  a)
inlinestatic

§ av_reduce()

int av_reduce ( int *  dst_num,
int *  dst_den,
int64_t  num,
int64_t  den,
int64_t  max 
)

§ av_mul_q()

AVRational av_mul_q ( AVRational  b,
AVRational  c 
) const

Multiply two rationals.

Parameters
bfirst rational
csecond rational
Returns
b*c

Definition at line 79 of file rational.c.

Referenced by av_div_q(), avi_write_header(), config_props(), mpeg_decode_postinit(), and mxf_compute_sample_count().

§ av_div_q()

AVRational av_div_q ( AVRational  b,
AVRational  c 
) const

Divide one rational by another.

Parameters
bfirst rational
csecond rational
Returns
b/c

Definition at line 87 of file rational.c.

Referenced by avi_read_header(), config_props_output(), and mpeg_decode_postinit().

§ av_add_q()

AVRational av_add_q ( AVRational  b,
AVRational  c 
) const

Add two rationals.

Parameters
bfirst rational
csecond rational
Returns
b+c

Definition at line 92 of file rational.c.

Referenced by av_sub_q().

§ av_sub_q()

AVRational av_sub_q ( AVRational  b,
AVRational  c 
) const

Subtract one rational from another.

Parameters
bfirst rational
csecond rational
Returns
b-c

Definition at line 100 of file rational.c.

Referenced by ff_mxf_get_samples_per_frame().

§ av_inv_q()

static av_always_inline AVRational av_inv_q ( AVRational  q)
static

§ av_d2q()

AVRational av_d2q ( double  d,
int  max 
) const

Convert a double precision floating point number to a rational.

inf is expressed as {1,0} or {-1,0} depending on the sign.

Parameters
ddouble to convert
maxthe maximum allowed numerator and denominator
Returns
(AVRational) d

Definition at line 105 of file rational.c.

Referenced by av_inv_q(), av_opt_get_q(), av_opt_set_defaults(), av_parse_video_rate(), config_output_props(), config_props(), decode_header(), get_aspect_ratio(), init(), mov_read_tkhd(), mov_read_trak(), mpeg_decode_postinit(), nuv_header(), thp_read_header(), transcode_init(), var_read_float(), and write_number().

§ av_nearer_q()

int av_nearer_q ( AVRational  q,
AVRational  q1,
AVRational  q2 
)
Returns
1 if q1 is nearer to q than q2, -1 if q2 is nearer than q1, 0 if they have the same distance.

Definition at line 122 of file rational.c.

Referenced by av_find_nearest_q_idx(), and av_inv_q().

§ av_find_nearest_q_idx()

int av_find_nearest_q_idx ( AVRational  q,
const AVRational q_list 
)

Find the nearest value in q_list to q.

Parameters
q_listan array of rationals terminated by {0, 0}
Returns
the index of the nearest value found in the array

Definition at line 137 of file rational.c.

Referenced by av_inv_q(), ff_mxf_get_samples_per_frame(), and transcode_init().