diff options
author | Moonchild <moonchild@palemoon.org> | 2021-03-03 18:48:48 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-03-04 00:03:46 +0000 |
commit | d192e6808fab971ffbe8c15ff3695c7d08b280c6 (patch) | |
tree | 9d9cc4d21c93ae3e1a88ab5c160c3be5f6af0ca9 /media/libaom/src/common/webmdec.cc | |
parent | c81c0395a36b0a6b21a6a0ae7b31953fe4a460d9 (diff) | |
download | uxp-d192e6808fab971ffbe8c15ff3695c7d08b280c6.tar.gz |
Issue #1737 - Import libaom 2.0.2 source
Diffstat (limited to 'media/libaom/src/common/webmdec.cc')
-rw-r--r-- | media/libaom/src/common/webmdec.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/media/libaom/src/common/webmdec.cc b/media/libaom/src/common/webmdec.cc index 17ac53c930..33bda59021 100644 --- a/media/libaom/src/common/webmdec.cc +++ b/media/libaom/src/common/webmdec.cc @@ -197,6 +197,17 @@ int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer, return frame.Read(reader, *buffer) ? -1 : 0; } +// Calculate the greatest common divisor between two numbers. +static int gcd(int a, int b) { + int remainder; + while (b > 0) { + remainder = a % b; + a = b; + b = remainder; + } + return a; +} + int webm_guess_framerate(struct WebmInputContext *webm_ctx, struct AvxInputContext *aom_ctx) { uint32_t i = 0; @@ -213,6 +224,14 @@ int webm_guess_framerate(struct WebmInputContext *webm_ctx, aom_ctx->framerate.numerator = (i - 1) * 1000000; aom_ctx->framerate.denominator = static_cast<int>(webm_ctx->timestamp_ns / 1000); + // Fraction might be represented in large numbers, like 49000000/980000 + // for 50fps. Simplify as much as possible. + int g = gcd(aom_ctx->framerate.numerator, aom_ctx->framerate.denominator); + if (g != 0) { + aom_ctx->framerate.numerator /= g; + aom_ctx->framerate.denominator /= g; + } + delete[] buffer; webm_ctx->buffer = NULL; |