This is required by both the VP8 and VP9 encoders and is harmless to
others, so add it to the common code.
---
The VP9 encoder just loses the appropriate fragment, with no other change (not 
resent here).


 libavcodec/vaapi_encode.c | 25 +++++++++++++++++++++++++
 libavcodec/vaapi_encode.h |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index bd8cdb5..592cd39 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1088,6 +1088,7 @@ static av_cold int 
vaapi_encode_init_rate_control(AVCodecContext *avctx)
     VAAPIEncodeContext *ctx = avctx->priv_data;
     int hrd_buffer_size;
     int hrd_initial_buffer_fullness;
+    unsigned int num, den;
 
     if (avctx->rc_buffer_size)
         hrd_buffer_size = avctx->rc_buffer_size;
@@ -1122,6 +1123,30 @@ static av_cold int 
vaapi_encode_init_rate_control(AVCodecContext *avctx)
     ctx->global_params_size[ctx->nb_global_params++] =
         sizeof(ctx->hrd_params);
 
+    // VAAPI specifies that this should be a 16.16 fraction, but the
+    // implementation in the i965 driver actually just assumes it is
+    // an integer.  Therefore, just give it the best integer we can
+    // make here.
+    if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
+        num = avctx->framerate.num;
+        den = avctx->framerate.den;
+    } else {
+        num = avctx->time_base.den;
+        den = avctx->time_base.num;
+    }
+    if (num < den) {
+        // Don't round down to zero.
+        num = den;
+    }
+
+    ctx->fr_params.misc.type = VAEncMiscParameterTypeFrameRate;
+    ctx->fr_params.fr.framerate = num / den;
+
+    ctx->global_params[ctx->nb_global_params] =
+        &ctx->fr_params.misc;
+    ctx->global_params_size[ctx->nb_global_params++] =
+        sizeof(ctx->fr_params);
+
     return 0;
 }
 
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index a9ab527..4e5b3b9 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -154,6 +154,10 @@ typedef struct VAAPIEncodeContext {
         VAEncMiscParameterBuffer misc;
         VAEncMiscParameterHRD hrd;
     } hrd_params;
+    struct {
+        VAEncMiscParameterBuffer misc;
+        VAEncMiscParameterFrameRate fr;
+    } fr_params;
 
     // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
     void           *codec_sequence_params;
-- 
2.10.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to