From 65fc58da4d6e8abc69142fc1d19b446bc2cc7f77 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 22 May 2014 13:13:14 +0200 Subject: [PATCH] codecparsers: h264: recognize SVC NAL units. Identify SVC NAL units and tag them as such. This is necessary for gst_h264_parser_parse_slice_hdr() to fail gracefully, if the user did not perform the check himself. Signed-off-by: Gwenole Beauchesne --- gst-libs/gst/codecparsers/gsth264parser.c | 12 +++++++++++- gst-libs/gst/codecparsers/gsth264parser.h | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c index 9ea9ce1fa9..6b1f35a452 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.c +++ b/gst-libs/gst/codecparsers/gsth264parser.c @@ -226,7 +226,11 @@ gst_h264_parse_nalu_header (GstH264NalUnit * nalu) nalu->size - nalu->header_bytes); svc_extension_flag = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); - if (!svc_extension_flag) { /* MVC */ + if (svc_extension_flag) { /* SVC */ + + nalu->extension_type = GST_H264_NAL_EXTENSION_SVC; + + } else { /* MVC */ GstH264NalUnitExtensionMVC *const mvc = &nalu->extension.mvc; nalu->extension_type = GST_H264_NAL_EXTENSION_MVC; @@ -2139,6 +2143,12 @@ gst_h264_parser_parse_slice_hdr (GstH264NalParser * nalparser, return GST_H264_PARSER_BROKEN_LINK; } + /* Check we can actually parse this slice (AVC, MVC headers only) */ + if (sps->extension_type && sps->extension_type != GST_H264_NAL_EXTENSION_MVC) { + GST_WARNING ("failed to parse unsupported slice header"); + return GST_H264_PARSER_BROKEN_DATA; + } + /* set default values for fields that might not be present in the bitstream and have valid defaults */ slice->field_pic_flag = 0; diff --git a/gst-libs/gst/codecparsers/gsth264parser.h b/gst-libs/gst/codecparsers/gsth264parser.h index a6aaa223b3..c024b763e8 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.h +++ b/gst-libs/gst/codecparsers/gsth264parser.h @@ -50,6 +50,17 @@ G_BEGIN_DECLS #define GST_H264_IS_SP_SLICE(slice) (((slice)->type % 5) == GST_H264_SP_SLICE) #define GST_H264_IS_SI_SLICE(slice) (((slice)->type % 5) == GST_H264_SI_SLICE) +/** + * GST_H264_IS_SVC_NALU: + * @nalu: a #GstH264NalUnit + * + * Check if @nalu is a scalable extension NAL unit. + * + * Since: 1.6 + */ +#define GST_H264_IS_SVC_NALU(nalu) \ + ((nalu)->extension_type == GST_H264_NAL_EXTENSION_SVC) + /** * GST_H264_IS_MVC_NALU: * @nalu: a #GstH264NalUnit @@ -147,6 +158,7 @@ typedef enum /** * GstH264NalUnitExtensionType: * @GST_H264_NAL_EXTENSION_NONE: No NAL unit header extension is available + * @GST_H264_NAL_EXTENSION_SVC: NAL unit header extension for SVC (Annex G) * @GST_H264_NAL_EXTENSION_MVC: NAL unit header extension for MVC (Annex H) * * Indicates the type of H.264 NAL unit extension. @@ -156,6 +168,7 @@ typedef enum typedef enum { GST_H264_NAL_EXTENSION_NONE = 0, + GST_H264_NAL_EXTENSION_SVC, GST_H264_NAL_EXTENSION_MVC, } GstH264NalUnitExtensionType;