From a365dfd269ed79504a5c8b24a6807a793cd3944e Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 25 Apr 2014 16:24:01 +0200 Subject: [PATCH] decoder: h264: retain SEI messages until the end of frame. Retain the SEI messages that were parsed from the access unit until we have completely decoded the current frame. This is done so that we can peek at that data whenever necessary during decoding. e.g. for exposing 3D stereoscopic information at a later stage. --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index f26c941..6dfcef5 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -66,17 +66,31 @@ struct _GstVaapiParserInfoH264 { union { GstH264SPS sps; GstH264PPS pps; + GArray *sei; GstH264SliceHdr slice_hdr; } data; guint state; }; +static void +gst_vaapi_parser_info_h264_finalize(GstVaapiParserInfoH264 *pi) +{ + switch (pi->nalu.type) { + case GST_H264_NAL_SEI: + if (pi->data.sei) { + g_array_unref(pi->data.sei); + pi->data.sei = NULL; + } + break; + } +} + static inline const GstVaapiMiniObjectClass * gst_vaapi_parser_info_h264_class(void) { static const GstVaapiMiniObjectClass GstVaapiParserInfoH264Class = { - sizeof(GstVaapiParserInfoH264), - NULL + .size = sizeof(GstVaapiParserInfoH264), + .finalize = (GDestroyNotify)gst_vaapi_parser_info_h264_finalize }; return &GstVaapiParserInfoH264Class; } @@ -1057,19 +1071,16 @@ parse_sei(GstVaapiDecoderH264 *decoder, GstVaapiDecoderUnit *unit) { GstVaapiDecoderH264Private * const priv = &decoder->priv; GstVaapiParserInfoH264 * const pi = unit->parsed_info; - GArray *sei_messages = NULL; + GArray ** const sei_ptr = &pi->data.sei; GstH264ParserResult result; GST_DEBUG("parse SEI"); - result = gst_h264_parser_parse_sei(priv->parser, &pi->nalu, &sei_messages); + result = gst_h264_parser_parse_sei(priv->parser, &pi->nalu, sei_ptr); if (result != GST_H264_PARSER_OK) { GST_WARNING("failed to parse SEI messages"); - g_array_unref(sei_messages); return get_status(result); } - - g_array_unref(sei_messages); return GST_VAAPI_DECODER_STATUS_SUCCESS; } -- 2.7.4