From 1e502d63d5a5634e2de986a6d749c8e659d0e959 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 21 Jan 2014 18:01:20 +0100 Subject: [PATCH] encoder: h264: submit sequence parameter only once. Submit sequence parameter buffers only once, or when the bitstream was reconfigured in a way that requires such. Always submit packed sequence parameter buffers at I-frame period, if the VA driver needs those. https://bugzilla.gnome.org/show_bug.cgi?id=722737 --- gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c index 8b7f283..d4b2253 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c @@ -1356,26 +1356,35 @@ ensure_sequence (GstVaapiEncoderH264 * encoder, GstVaapiEncPicture * picture) { GstVaapiEncSequence *sequence; - g_assert (picture); - sequence = GST_VAAPI_ENC_SEQUENCE_NEW (H264, encoder); - g_assert (sequence); - if (!sequence) - goto error; + // Submit an SPS header before every new I-frame + if (picture->type != GST_VAAPI_PICTURE_TYPE_I) + return TRUE; - if (!fill_sequence (encoder, sequence)) - goto error; + sequence = GST_VAAPI_ENC_SEQUENCE_NEW (H264, encoder); + if (!sequence || !fill_sequence (encoder, sequence)) + goto error_create_seq_param; - if (picture->type == GST_VAAPI_PICTURE_TYPE_I && - (GST_VAAPI_ENCODER_PACKED_HEADERS (encoder) & VAEncPackedHeaderH264_SPS) + if ((GST_VAAPI_ENCODER_PACKED_HEADERS (encoder) & VAEncPackedHeaderH264_SPS) && !add_packed_sequence_header (encoder, picture, sequence)) - goto error; + goto error_create_packed_seq_hdr; + gst_vaapi_enc_picture_set_sequence (picture, sequence); gst_vaapi_codec_object_replace (&sequence, NULL); return TRUE; -error: - gst_vaapi_codec_object_replace (&sequence, NULL); - return FALSE; + /* ERRORS */ +error_create_seq_param: + { + GST_ERROR ("failed to create sequence parameter buffer (SPS)"); + gst_vaapi_codec_object_replace (&sequence, NULL); + return FALSE; + } +error_create_packed_seq_hdr: + { + GST_ERROR ("failed to create packed sequence header buffer"); + gst_vaapi_codec_object_replace (&sequence, NULL); + return FALSE; + } } /* Generates additional control parameters */ -- 2.7.4