diff options
author | Jun Zhao <mypopydev@gmail.com> | 2018-12-15 17:12:46 +0800 |
---|---|---|
committer | Jun Zhao <mypopydev@gmail.com> | 2018-12-20 18:40:41 +0800 |
commit | 59deae5d1c4d92a72f76301d45513cdc55f34971 (patch) | |
tree | 5b3e01525dcfa3306630ac399c4ddbfcb73cdf89 /libavcodec | |
parent | 90c45342066b43df03321846a1ae4f4ad3245acf (diff) | |
download | ffmpeg-59deae5d1c4d92a72f76301d45513cdc55f34971.tar.gz |
lavc/libkvazaar: Use avctx->frame_rate first for framerate setting
perfer avctx->frame_rate first than use avctx->time_base when setting
the frame rate to encoder.
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/libkvazaar.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index 8f50bef669..50910b7cda 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -79,13 +79,23 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx) cfg->width = avctx->width; cfg->height = avctx->height; - 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); + if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { + if (avctx->ticks_per_frame > INT_MAX / avctx->framerate.den) { + av_log(avctx, AV_LOG_ERROR, + "Could not set framerate for kvazaar: integer overflow\n"); + return AVERROR(EINVAL); + } + cfg->framerate_num = avctx->framerate.num; + cfg->framerate_denom = avctx->time_base.den * avctx->ticks_per_frame; + } else { + 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->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; |