summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-09-25 17:04:12 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-09-26 11:44:51 +0200
commite5ef90f98d9e6a82b1d287018017608bd9cea8d8 (patch)
treebca1d2517098c2b379b372a5f3f7e3a8017ca705
parent6b98d6a0763e366e3d663c7ba91c5d5cf9c17bbd (diff)
vaapiencode: flush pending frames before set format
Flush pending frames, if any, in the internal encorder, before setting the new negotiated format. https://bugzilla.gnome.org/show_bug.cgi?id=786173
-rw-r--r--gst/vaapi/gstvaapiencode.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c
index 5712a7d8..fc50f71b 100644
--- a/gst/vaapi/gstvaapiencode.c
+++ b/gst/vaapi/gstvaapiencode.c
@@ -553,6 +553,22 @@ set_codec_state (GstVaapiEncode * encode, GstVideoCodecState * state)
}
static gboolean
+gst_vaapiencode_drain (GstVaapiEncode * encode)
+{
+ GstVaapiEncoderStatus status;
+
+ if (!encode->encoder)
+ return TRUE;
+
+ status = gst_vaapi_encoder_flush (encode->encoder);
+ if (status != GST_VAAPI_ENCODER_STATUS_SUCCESS)
+ return FALSE;
+ gst_vaapiencode_purge (encode);
+
+ return TRUE;
+}
+
+static gboolean
gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
{
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
@@ -567,6 +583,9 @@ gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
state->caps, NULL))
return FALSE;
+ if (!gst_vaapiencode_drain (encode))
+ return FALSE;
+
if (encode->input_state)
gst_video_codec_state_unref (encode->input_state);
encode->input_state = gst_video_codec_state_ref (state);
@@ -763,17 +782,14 @@ static gboolean
gst_vaapiencode_flush (GstVideoEncoder * venc)
{
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
- GstVaapiEncoderStatus status;
if (!encode->encoder)
return FALSE;
GST_LOG_OBJECT (encode, "flushing");
- status = gst_vaapi_encoder_flush (encode->encoder);
- if (status != GST_VAAPI_ENCODER_STATUS_SUCCESS)
+ if (!gst_vaapiencode_drain (encode))
return FALSE;
- gst_vaapiencode_purge (encode);
gst_vaapi_encoder_replace (&encode->encoder, NULL);
if (!ensure_encoder (encode))