On 2016-01-18 15:22, Luca Barbato wrote:
On 18/01/16 08:23, Arttu Ylä-Outinen wrote:
I sent this to FFmpeg as well and they noticed that the multiplication
might overflow. I'll send an updated patch soon.
Ticks per frame is 1 or 2, any other value is highly unlikely if I
understand what's the problem at hand.
Here's the updated version anyway (attached).
- Arttu
>From 81b3f152f9b9b22be6479a677ba32c9e176108ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= <[email protected]>
Date: Fri, 15 Jan 2016 13:47:10 +0200
Subject: [PATCH v2] libkvazaar: Set frame rate as a rational number
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Updates libkvazaar to pass the exact frame rate to Kvazaar by setting
the numerator and denominator separately instead of a single floating
point number. The exact frame rate is needed for writing timing info to
the bitstream.
Requires Kvazaar version 0.8.1.
Signed-off-by: Arttu Ylä-Outinen <[email protected]>
---
configure | 2 +-
libavcodec/libkvazaar.c | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 8518e69..1067e00 100755
--- a/configure
+++ b/configure
@@ -4472,7 +4472,7 @@ enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
check_lib "${gsm_hdr}" gsm_create -lgsm && break;
done || die "ERROR: libgsm not found"; }
enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
-enabled libkvazaar && require_pkg_config "kvazaar >= 0.7.1" kvazaar.h kvz_api_get
+enabled libkvazaar && require_pkg_config "kvazaar >= 0.8.1" kvazaar.h kvz_api_get
enabled libmfx && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 89b024a..748b352 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -80,8 +80,13 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
cfg->width = avctx->width;
cfg->height = avctx->height;
- cfg->framerate =
- avctx->time_base.den / (double)(avctx->time_base.num * avctx->ticks_per_frame);
+ if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Could not set framerate for kvazaar: integer overflow\n");
+ return AVERROR(EINVAL);
+ }
+ cfg->framerate_num = avctx->time_base.den;
+ cfg->framerate_denom = avctx->time_base.num * avctx->ticks_per_frame;
cfg->target_bitrate = avctx->bit_rate;
cfg->vui.sar_width = avctx->sample_aspect_ratio.num;
cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
--
2.7.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel