diff options
author | Mans Rullgard <mans@mansr.com> | 2012-07-29 14:58:53 +0100 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-08-05 17:46:41 +0100 |
commit | 82494835c4ee2adf5afc51bfd19964b82eb80da9 (patch) | |
tree | cfeb1111d14bb5f6d1d40e605eaa356c4f76be72 /libavutil/rational.h | |
parent | 965efc1673074ac1e6c28177a4718ed84f89ac83 (diff) | |
download | ffmpeg-82494835c4ee2adf5afc51bfd19964b82eb80da9.tar.gz |
rational: add av_inv_q() returning the inverse of an AVRational
This allows simplifying a few expressions.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavutil/rational.h')
-rw-r--r-- | libavutil/rational.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavutil/rational.h b/libavutil/rational.h index 0ec18ec969..5d7dab7fd0 100644 --- a/libavutil/rational.h +++ b/libavutil/rational.h @@ -115,6 +115,17 @@ AVRational av_add_q(AVRational b, AVRational c) av_const; AVRational av_sub_q(AVRational b, AVRational c) av_const; /** + * Invert a rational. + * @param q value + * @return 1 / q + */ +static av_always_inline AVRational av_inv_q(AVRational q) +{ + AVRational r = { q.den, q.num }; + return r; +} + +/** * Convert a double precision floating point number to a rational. * inf is expressed as {1,0} or {-1,0} depending on the sign. * |