From 1f5ad9c7e51c27f7d3067ff7a9cd505b1ea5f55c Mon Sep 17 00:00:00 2001 From: Freyr Date: Thu, 6 Jun 2019 17:24:30 +0300 Subject: [PATCH] libs: encoder: vp8,vp9: reset frame_counter when input frame's format changes When input frame's formate changes, vp{8,9} encoders don't reset their frame counter, hence the newly created frame could become a P-frame, leading to some major troubles (sigabrt in libdrm in case of vp9). This patch adds some frame prediction-related reset logic to the `flush' methods of GstVaapiEncoderVP8 and GstVaapiEncoderVP9 implementations. --- gst-libs/gst/vaapi/gstvaapiencoder_vp8.c | 5 +++++ gst-libs/gst/vaapi/gstvaapiencoder_vp9.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c b/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c index 7ee0a2ef4d..0b8b379048 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp8.c @@ -445,6 +445,11 @@ error: static GstVaapiEncoderStatus gst_vaapi_encoder_vp8_flush (GstVaapiEncoder * base_encoder) { + GstVaapiEncoderVP8 *const encoder = GST_VAAPI_ENCODER_VP8 (base_encoder); + + encoder->frame_num = 0; + clear_references (encoder); + return GST_VAAPI_ENCODER_STATUS_SUCCESS; } diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c index 94c9a5a6ed..4464f41809 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c @@ -462,6 +462,10 @@ error: static GstVaapiEncoderStatus gst_vaapi_encoder_vp9_flush (GstVaapiEncoder * base_encoder) { + GstVaapiEncoderVP9 *const encoder = GST_VAAPI_ENCODER_VP9 (base_encoder); + + encoder->frame_num = 0; + return GST_VAAPI_ENCODER_STATUS_SUCCESS; }