decoder: h264: retain SEI messages until the end of frame.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 25 Apr 2014 14:24:01 +0000 (16:24 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 25 Apr 2014 17:24:07 +0000 (19:24 +0200)
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

index f26c941..6dfcef5 100644 (file)
@@ -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;
 }