rational numbers More...
#include <stdint.h>#include <limits.h>#include "attributes.h"Go to the source code of this file.
Data Structures | |
| struct | AVRational |
| rational number numerator/denominator More... | |
Typedefs | |
| typedef struct AVRational | AVRational |
| rational number numerator/denominator | |
Functions | |
| static int | av_cmp_q (AVRational a, AVRational b) |
| Compare two rationals. | |
| static double | av_q2d (AVRational a) |
| Convert rational to double. | |
| int | av_reduce (int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max) |
| Reduce a fraction. | |
| AVRational | av_mul_q (AVRational b, AVRational c) av_const |
| Multiply two rationals. | |
| AVRational | av_div_q (AVRational b, AVRational c) av_const |
| Divide one rational by another. | |
| AVRational | av_add_q (AVRational b, AVRational c) av_const |
| Add two rationals. | |
| AVRational | av_sub_q (AVRational b, AVRational c) av_const |
| Subtract one rational from another. | |
| AVRational | av_d2q (double d, int max) av_const |
| Convert 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) |
| Find the nearest value in q_list to q. | |
rational numbers
Definition in file rational.h.
| typedef struct AVRational AVRational |
rational number numerator/denominator
| AVRational av_add_q | ( | AVRational | b, | |
| AVRational | c | |||
| ) | const |
Add two rationals.
| b | first rational | |
| c | second rational |
Definition at line 87 of file rational.c.
| static int av_cmp_q | ( | AVRational | a, | |
| AVRational | b | |||
| ) | [inline, static] |
Compare two rationals.
| a | first rational | |
| b | second rational |
Definition at line 50 of file rational.h.
| 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.
| d | double to convert | |
| max | the maximum allowed numerator and denominator |
Definition at line 96 of file rational.c.
| AVRational av_div_q | ( | AVRational | b, | |
| AVRational | c | |||
| ) | const |
Divide one rational by another.
| b | first rational | |
| c | second rational |
Definition at line 83 of file rational.c.
| int av_find_nearest_q_idx | ( | AVRational | q, | |
| const AVRational * | q_list | |||
| ) |
Find the nearest value in q_list to q.
| q_list | an array of rationals terminated by {0, 0} |
Definition at line 127 of file rational.c.
| AVRational av_mul_q | ( | AVRational | b, | |
| AVRational | c | |||
| ) | const |
Multiply two rationals.
| b | first rational | |
| c | second rational |
Definition at line 78 of file rational.c.
| int av_nearer_q | ( | AVRational | q, | |
| AVRational | q1, | |||
| AVRational | q2 | |||
| ) |
Definition at line 112 of file rational.c.
| static double av_q2d | ( | AVRational | a | ) | [inline, static] |
Convert rational to double.
| a | rational to convert |
Definition at line 64 of file rational.h.
| int av_reduce | ( | int * | dst_num, | |
| int * | dst_den, | |||
| int64_t | num, | |||
| int64_t | den, | |||
| int64_t | max | |||
| ) |
Reduce a fraction.
This is useful for framerate calculations.
| dst_num | destination numerator | |
| dst_den | destination denominator | |
| num | source numerator | |
| den | source denominator | |
| max | the maximum allowed for dst_num & dst_den |
Definition at line 36 of file rational.c.
| AVRational av_sub_q | ( | AVRational | b, | |
| AVRational | c | |||
| ) | const |
Subtract one rational from another.
| b | first rational | |
| c | second rational |
Definition at line 92 of file rational.c.
1.7.1