summaryrefslogtreecommitdiff
path: root/libavcodec/libkvazaar.c
diff options
context:
space:
mode:
authorArttu Ylä-Outinen <arttu.yla-outinen@tut.fi>2016-01-15 13:47:10 +0200
committerArttu Ylä-Outinen <arttu.yla-outinen@tut.fi>2016-01-20 17:29:13 +0200
commit7d1e985528886139ea00387ad34c75cfab018d48 (patch)
treea46662d8dc56efcb8dcf6b48b0ebc5275a704f13 /libavcodec/libkvazaar.c
parent158f0545d81b2aca1c936490f80d13988616910e (diff)
libkvazaar: Set frame rate as a rational number
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 <arttu.yla-outinen@tut.fi>
Diffstat (limited to 'libavcodec/libkvazaar.c')
-rw-r--r--libavcodec/libkvazaar.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index e58405d27e..79fde41bfb 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -75,8 +75,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;