libavutil/rational.h File Reference

#include <stdint.h>
#include "attributes.h"

Go to the source code of this file.

Data Structures

struct  AVRational
 rational number numerator/denominator More...

Functions

static int av_cmp_q (AVRational a, AVRational b)
 Compares two rationals.
static double av_q2d (AVRational a)
 Converts rational to double.
int av_reduce (int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
 Reduces a fraction.
AVRational av_mul_q (AVRational b, AVRational c) av_const
 Multiplies two rationals.
AVRational av_div_q (AVRational b, AVRational c) av_const
 Divides one rational by another.
AVRational av_add_q (AVRational b, AVRational c) av_const
 Adds two rationals.
AVRational av_sub_q (AVRational b, AVRational c) av_const
 Subtracts one rational from another.
AVRational av_d2q (double d, int max) av_const
 Converts a double precision floating point number to a rational.
int av_nearer_q (AVRational q, AVRational q1, AVRational q2)
int av_find_nearest_q_idx (AVRational q, const AVRational *q_list)
 Finds the nearest value in q_list to q.


Function Documentation

AVRational av_add_q ( AVRational  b,
AVRational  c 
) const

Adds two rationals.

Parameters:
b first rational
c second rational
Returns:
b+c

Definition at line 87 of file rational.c.

static int av_cmp_q ( AVRational  a,
AVRational  b 
) [inline, static]

Compares two rationals.

Parameters:
a first rational
b second rational
Returns:
0 if a==b, 1 if a>b and -1 if a<b

Definition at line 48 of file rational.h.

AVRational av_d2q ( double  d,
int  max 
) const

Converts a double precision floating point number to a rational.

Parameters:
d double to convert
max the maximum allowed numerator and denominator
Returns:
(AVRational) d

Definition at line 96 of file rational.c.

AVRational av_div_q ( AVRational  b,
AVRational  c 
) const

Divides one rational by another.

Parameters:
b first rational
c second rational
Returns:
b/c

Definition at line 83 of file rational.c.

int av_find_nearest_q_idx ( AVRational  q,
const AVRational q_list 
)

Finds the nearest value in q_list to q.

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

Definition at line 121 of file rational.c.

AVRational av_mul_q ( AVRational  b,
AVRational  c 
) const

Multiplies two rationals.

Parameters:
b first rational
c second rational
Returns:
b*c

Definition at line 78 of file rational.c.

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 106 of file rational.c.

static double av_q2d ( AVRational  a  )  [inline, static]

Converts rational to double.

Parameters:
a rational to convert
Returns:
(double) a

Definition at line 60 of file rational.h.

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

Reduces a fraction.

This is useful for framerate calculations.

Parameters:
dst_num destination numerator
dst_den destination denominator
num source numerator
den source denominator
max the maximum allowed for dst_num & dst_den
Returns:
1 if exact, 0 otherwise

Definition at line 36 of file rational.c.

AVRational av_sub_q ( AVRational  b,
AVRational  c 
) const

Subtracts one rational from another.

Parameters:
b first rational
c second rational
Returns:
b-c

Definition at line 92 of file rational.c.


Generated on Tue Apr 20 17:39:22 2010 for FFmpeg by  doxygen 1.5.6