Commit 59deae5d authored by Jun Zhao's avatar Jun Zhao

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: 's avatarJun Zhao <mypopydev@gmail.com>
parent 90c45342
......@@ -79,6 +79,15 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
cfg->width = avctx->width;
cfg->height = avctx->height;
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");
......@@ -86,6 +95,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
}
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment