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
This commit is contained in:
Gwenole Beauchesne 2014-01-21 18:01:20 +01:00
parent 71113e4999
commit 1e502d63d5

View file

@ -1356,26 +1356,35 @@ ensure_sequence (GstVaapiEncoderH264 * encoder, GstVaapiEncPicture * picture)
{ {
GstVaapiEncSequence *sequence; GstVaapiEncSequence *sequence;
g_assert (picture); // Submit an SPS header before every new I-frame
if (picture->type != GST_VAAPI_PICTURE_TYPE_I)
return TRUE;
sequence = GST_VAAPI_ENC_SEQUENCE_NEW (H264, encoder); sequence = GST_VAAPI_ENC_SEQUENCE_NEW (H264, encoder);
g_assert (sequence); if (!sequence || !fill_sequence (encoder, sequence))
if (!sequence) goto error_create_seq_param;
goto error;
if (!fill_sequence (encoder, sequence)) if ((GST_VAAPI_ENCODER_PACKED_HEADERS (encoder) & VAEncPackedHeaderH264_SPS)
goto error;
if (picture->type == GST_VAAPI_PICTURE_TYPE_I &&
(GST_VAAPI_ENCODER_PACKED_HEADERS (encoder) & VAEncPackedHeaderH264_SPS)
&& !add_packed_sequence_header (encoder, picture, sequence)) && !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_enc_picture_set_sequence (picture, sequence);
gst_vaapi_codec_object_replace (&sequence, NULL); gst_vaapi_codec_object_replace (&sequence, NULL);
return TRUE; return TRUE;
error: /* ERRORS */
gst_vaapi_codec_object_replace (&sequence, NULL); error_create_seq_param:
return FALSE; {
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 */ /* Generates additional control parameters */