libavutil/rational.c File Reference

Rational numbers. More...

#include <limits.h>
#include "common.h"
#include "mathematics.h"
#include "rational.h"

Go to the source code of this file.

Defines

#define LOG2   0.69314718055994530941723212145817656807550013436025

Functions

int av_reduce (int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
 Reduce a fraction.
AVRational av_mul_q (AVRational b, AVRational c)
 Multiplies two rationals.
AVRational av_div_q (AVRational b, AVRational c)
 Divides one rational by another.
AVRational av_add_q (AVRational b, AVRational c)
 Adds two rationals.
AVRational av_sub_q (AVRational b, AVRational c)
 Subtracts one rational from another.
AVRational av_d2q (double d, int max)
 Converts a double precision floating point number to a rational.


Detailed Description

Rational numbers.

Author:
Michael Niedermayer <michaelni@gmx.at>

Definition in file rational.c.


Define Documentation

#define LOG2   0.69314718055994530941723212145817656807550013436025

Referenced by av_d2q().


Function Documentation

AVRational av_add_q ( AVRational  b,
AVRational  c 
)

Adds two rationals.

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

Definition at line 86 of file rational.c.

Referenced by av_sub_q().

AVRational av_d2q ( double  d,
int  max 
)

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

Referenced by av_get_q(), av_opt_set_defaults2(), av_parse_video_frame_rate(), av_set_number(), mpeg_decode_postinit(), new_video_stream(), nuv_header(), and thp_read_header().

AVRational av_div_q ( AVRational  b,
AVRational  c 
)

Divides one rational by another.

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

Definition at line 82 of file rational.c.

Referenced by avi_read_header(), and mpeg_decode_postinit().

AVRational av_mul_q ( AVRational  b,
AVRational  c 
)

Multiplies two rationals.

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

Definition at line 77 of file rational.c.

Referenced by av_div_q(), and mkv_write_tracks().

int av_reduce ( int *  dst_nom,
int *  dst_den,
int64_t  nom,
int64_t  den,
int64_t  max 
)

Reduce a fraction.

This is useful for framerate calculations.

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

Definition at line 35 of file rational.c.

Referenced by asf_read_header(), av_add_q(), av_d2q(), av_find_stream_info(), av_mul_q(), avcodec_string(), decode_slice_header(), dxa_read_header(), matroska_read_header(), mpeg_decode_postinit(), smacker_read_header(), vmd_read_header(), yuv4_generate_header(), and yuv4_read_header().

AVRational av_sub_q ( AVRational  b,
AVRational  c 
)

Subtracts one rational from another.

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

Definition at line 91 of file rational.c.

Referenced by new_video_stream().


Generated on Thu Apr 2 07:15:44 2009 for ffmpeg by  doxygen 1.5.6