[1/5] vaapi_encode: Decide on GOP setup before initialising sequence parameters

Message ID 2d2d1459-eefb-8c0b-640f-32a69259ca0a@jkqxz.net
State Committed
Headers show

Commit Message

Mark Thompson Sept. 30, 2016, 4:55 p.m.
This was always too late; several fields related to it have been incorrectly
zero since the encoder was added.
---
 libavcodec/vaapi_encode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Luca Barbato Sept. 30, 2016, 5:54 p.m. | #1
On 30/09/16 18:55, Mark Thompson wrote:
> This was always too late; several fields related to it have been incorrectly
> zero since the encoder was added.
> ---
>  libavcodec/vaapi_encode.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 

Sounds Ok.

Patch

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index dc6cdfe..b600a00 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1363,6 +1363,12 @@  av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
     ctx->decode_delay = 1;
     ctx->output_order = - ctx->output_delay - 1;

+    // Currently we never generate I frames, only IDR.
+    ctx->i_per_idr = 0;
+    ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
+                    (avctx->max_b_frames + 1));
+    ctx->b_per_p = avctx->max_b_frames;
+
     if (ctx->codec->sequence_params_size > 0) {
         ctx->codec_sequence_params =
             av_mallocz(ctx->codec->sequence_params_size);
@@ -1389,12 +1395,6 @@  av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
         }
     }

-    // All I are IDR for now.
-    ctx->i_per_idr = 0;
-    ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
-                    (avctx->max_b_frames + 1));
-    ctx->b_per_p = avctx->max_b_frames;
-
     // This should be configurable somehow.  (Needs testing on a machine
     // where it actually overlaps properly, though.)
     ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT;