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.
This commit is contained in:
Freyr 2019-06-06 17:24:30 +03:00
parent ed7277a1b7
commit 1f5ad9c7e5
2 changed files with 9 additions and 0 deletions

View file

@ -445,6 +445,11 @@ error:
static GstVaapiEncoderStatus static GstVaapiEncoderStatus
gst_vaapi_encoder_vp8_flush (GstVaapiEncoder * base_encoder) 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; return GST_VAAPI_ENCODER_STATUS_SUCCESS;
} }

View file

@ -462,6 +462,10 @@ error:
static GstVaapiEncoderStatus static GstVaapiEncoderStatus
gst_vaapi_encoder_vp9_flush (GstVaapiEncoder * base_encoder) 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; return GST_VAAPI_ENCODER_STATUS_SUCCESS;
} }