aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vaapi_encode.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2016-11-29 22:12:46 +0000
committerMark Thompson <sw@jkqxz.net>2017-01-30 22:52:54 +0000
commitff35aa8ca4069bf1543adeec4c28e51e4a012eee (patch)
tree1e6ba7b08f8c50e71983cce7fb0f0aef513203e0 /libavcodec/vaapi_encode.c
parenteddfb57210298a0a94472794485400a3a6c76196 (diff)
downloadffmpeg-ff35aa8ca4069bf1543adeec4c28e51e4a012eee.tar.gz
vaapi_encode: Pass framerate parameters to driver
Only do this when building for a recent VAAPI version - initial driver implementations were confused about the interpretation of the framerate field, but hopefully this will be consistent everywhere once 0.40.0 is released.
Diffstat (limited to 'libavcodec/vaapi_encode.c')
-rw-r--r--libavcodec/vaapi_encode.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index e9aa48606a..8238952543 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1116,6 +1116,7 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
int rc_window_size;
int hrd_buffer_size;
int hrd_initial_buffer_fullness;
+ int fr_num, fr_den;
if (avctx->rc_buffer_size)
hrd_buffer_size = avctx->rc_buffer_size;
@@ -1166,6 +1167,23 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
ctx->global_params_size[ctx->nb_global_params++] =
sizeof(ctx->hrd_params);
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
+ av_reduce(&fr_num, &fr_den,
+ avctx->framerate.num, avctx->framerate.den, 65535);
+ else
+ av_reduce(&fr_num, &fr_den,
+ avctx->time_base.den, avctx->time_base.num, 65535);
+
+ ctx->fr_params.misc.type = VAEncMiscParameterTypeFrameRate;
+ ctx->fr_params.fr.framerate = (unsigned int)fr_den << 16 | fr_num;
+
+#if VA_CHECK_VERSION(0, 40, 0)
+ ctx->global_params[ctx->nb_global_params] =
+ &ctx->fr_params.misc;
+ ctx->global_params_size[ctx->nb_global_params++] =
+ sizeof(ctx->fr_params);
+#endif
+
return 0;
}