Browse Source

lavu: add av_gcd_q().

tags/n4.3
Nicolas George 5 years ago
parent
commit
6b65c4ec54
4 changed files with 20 additions and 2 deletions
  1. +3
    -0
      doc/APIchanges
  2. +9
    -0
      libavutil/rational.c
  3. +6
    -0
      libavutil/rational.h
  4. +2
    -2
      libavutil/version.h

+ 3
- 0
doc/APIchanges View File

@@ -15,6 +15,9 @@ libavutil: 2017-10-21

API changes, most recent first:

2020-05-23 - xxxxxxxxxx - lavu 56.47.100 - rational.h
Add av_gcd_q().

2020-05-22 - xxxxxxxxxx - lavu 56.46.101 - opt.h
Add AV_OPT_FLAG_CHILD_CONSTS.



+ 9
- 0
libavutil/rational.c View File

@@ -182,3 +182,12 @@ uint32_t av_q2intfloat(AVRational q) {

return sign<<31 | (150-shift)<<23 | (n - (1<<23));
}

AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def)
{
int64_t gcd, lcm;

gcd = av_gcd(a.den, b.den);
lcm = (a.den / gcd) * b.den;
return lcm < max_den ? av_make_q(av_gcd(a.num, b.num), lcm) : def;
}

+ 6
- 0
libavutil/rational.h View File

@@ -207,6 +207,12 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list);
*/
uint32_t av_q2intfloat(AVRational q);

/**
* Return the best rational so that a and b are multiple of it.
* If the resulting denominator is larger than max_den, return def.
*/
AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def);

/**
* @}
*/


+ 2
- 2
libavutil/version.h View File

@@ -79,8 +79,8 @@
*/

#define LIBAVUTIL_VERSION_MAJOR 56
#define LIBAVUTIL_VERSION_MINOR 46
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_MINOR 47
#define LIBAVUTIL_VERSION_MICRO 100

#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \


Loading…
Cancel
Save