summaryrefslogtreecommitdiff
path: root/libavcodec/libopenh264enc.c
diff options
context:
space:
mode:
authorJun Zhao <barryjzhao@tencent.com>2020-07-26 19:16:43 +0800
committerJun Zhao <barryjzhao@tencent.com>2020-08-05 17:32:16 +0800
commitbecfdaaa0961fcdfea5e7be102d59e5861e5adea (patch)
tree743a934d1b2e9f7c086e033057164824c308260a /libavcodec/libopenh264enc.c
parentffa6072fc727a14680a85449259f6b49b47587e6 (diff)
downloadffmpeg-becfdaaa0961fcdfea5e7be102d59e5861e5adea.tar.gz
lavc/libopenh264enc: use framerate if available
Respecting the framerate in the libopenh264enc codec context. Both the libx264 and libx265 encoders already contain similar logic to first check the framerate before falling back to the timebase. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Diffstat (limited to 'libavcodec/libopenh264enc.c')
-rw-r--r--libavcodec/libopenh264enc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index f63aa52348..cf485663e1 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -156,7 +156,16 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
(*s->encoder)->GetDefaultParams(s->encoder, &param);
- param.fMaxFrameRate = 1/av_q2d(avctx->time_base);
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
+ param.fMaxFrameRate = av_q2d(avctx->framerate);
+ } else {
+ if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Could not set framerate for libopenh264enc: integer overflow\n");
+ return AVERROR(EINVAL);
+ }
+ param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1);
+ }
param.iPicWidth = avctx->width;
param.iPicHeight = avctx->height;
param.iTargetBitrate = avctx->bit_rate > 0 ? avctx->bit_rate : TARGET_BITRATE_DEFAULT;