From 73355a680f87d9cc56e7c165fb4e1904c5feb166 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 7 May 2014 00:09:19 +0300 Subject: [PATCH] encoder: h264: store subset sps to generate the codec-data Store the SubsetSPS nal unit which we need for MVC specific codec_data generation. --- gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c index 6930ec3fa4..9140c7513c 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c @@ -713,6 +713,7 @@ struct _GstVaapiEncoderH264 guint32 idr_num; GstBuffer *sps_data; + GstBuffer *subset_sps_data; GstBuffer *pps_data; guint bitrate_bits; // bitrate (bits) @@ -733,10 +734,12 @@ _check_sps_pps_status (GstVaapiEncoderH264 * encoder, { guint8 nal_type; gsize ret; + gboolean has_subset_sps; g_assert (size); - if (encoder->sps_data && encoder->pps_data) + has_subset_sps = !encoder->is_mvc || (encoder->subset_sps_data != NULL); + if (encoder->sps_data && encoder->pps_data && has_subset_sps) return; nal_type = nal[0] & 0x1F; @@ -746,6 +749,11 @@ _check_sps_pps_status (GstVaapiEncoderH264 * encoder, ret = gst_buffer_fill (encoder->sps_data, 0, nal, size); g_assert (ret == size); break; + case GST_VAAPI_ENCODER_H264_NAL_SUBSET_SPS: + encoder->subset_sps_data = gst_buffer_new_allocate (NULL, size, NULL); + ret = gst_buffer_fill (encoder->subset_sps_data, 0, nal, size); + g_assert (ret == size); + break; case GST_VAAPI_ENCODER_H264_NAL_PPS: encoder->pps_data = gst_buffer_new_allocate (NULL, size, NULL); ret = gst_buffer_fill (encoder->pps_data, 0, nal, size); @@ -1164,6 +1172,9 @@ add_packed_sequence_header_mvc (GstVaapiEncoderH264 * encoder, gst_vaapi_enc_picture_add_packed_header (picture, packed_seq); gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) & packed_seq, NULL); + + /* store subset sps data */ + _check_sps_pps_status (encoder, data + 4, data_bit_size / 8 - 4); gst_bit_writer_clear (&bs, TRUE); return TRUE; @@ -2409,6 +2420,7 @@ gst_vaapi_encoder_h264_finalize (GstVaapiEncoder * base_encoder) guint32 i; gst_buffer_replace (&encoder->sps_data, NULL); + gst_buffer_replace (&encoder->subset_sps_data, NULL); gst_buffer_replace (&encoder->pps_data, NULL); /* reference list info de-init */