From 64643fdfb4701d12c6ef24dbd21b442a35134f38 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 27 Sep 2018 15:33:32 +0200 Subject: [PATCH] h265parser: parse SEI recovery point Copied the implementation from h264parser and adapted it to the HEVC syntax. https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/790 --- gst-libs/gst/codecparsers/gsth265parser.c | 31 +++++++++++++++++++++++ gst-libs/gst/codecparsers/gsth265parser.h | 13 +++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c index a6baa495d3..d44a045f78 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.c +++ b/gst-libs/gst/codecparsers/gsth265parser.c @@ -1097,6 +1097,33 @@ error: return GST_H265_PARSER_ERROR; } +static GstH265ParserResult +gst_h265_parser_parse_recovery_point (GstH265Parser * parser, + GstH265RecoveryPoint * rp, NalReader * nr) +{ + GstH265SPS *const sps = parser->last_sps; + gint32 max_pic_order_cnt_lsb; + + GST_DEBUG ("parsing \"Recovery point\""); + if (!sps || !sps->valid) { + GST_WARNING ("didn't get the associated sequence paramater set for the " + "current access unit"); + goto error; + } + + max_pic_order_cnt_lsb = pow (2, (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)); + READ_SE_ALLOWED (nr, rp->recovery_poc_cnt, -max_pic_order_cnt_lsb / 2, + max_pic_order_cnt_lsb - 1); + READ_UINT8 (nr, rp->exact_match_flag, 1); + READ_UINT8 (nr, rp->broken_link_flag, 1); + + return GST_H265_PARSER_OK; + +error: + GST_WARNING ("error parsing \"Recovery point\""); + return GST_H265_PARSER_ERROR; +} + /******** API *************/ /** @@ -2281,6 +2308,10 @@ gst_h265_parser_parse_sei_message (GstH265Parser * parser, res = gst_h265_parser_parse_pic_timing (parser, &sei->payload.pic_timing, nr); break; + case GST_H265_SEI_RECOVERY_POINT: + res = gst_h265_parser_parse_recovery_point (parser, + &sei->payload.recovery_point, nr); + break; default: /* Just consume payloadSize bytes, which does not account for emulation prevention bytes */ diff --git a/gst-libs/gst/codecparsers/gsth265parser.h b/gst-libs/gst/codecparsers/gsth265parser.h index c8c0a98069..b4d1901c01 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.h +++ b/gst-libs/gst/codecparsers/gsth265parser.h @@ -220,6 +220,7 @@ typedef enum * GstH265SEIPayloadType: * @GST_H265_SEI_BUF_PERIOD: Buffering Period SEI Message * @GST_H265_SEI_PIC_TIMING: Picture Timing SEI Message + * @GST_H265_SEI_RECOVERY_POINT: Recovery Point SEI Message (D.3.8) * ... * * The type of SEI message. @@ -227,7 +228,8 @@ typedef enum typedef enum { GST_H265_SEI_BUF_PERIOD = 0, - GST_H265_SEI_PIC_TIMING = 1 + GST_H265_SEI_PIC_TIMING = 1, + GST_H265_SEI_RECOVERY_POINT = 6, /* and more... */ } GstH265SEIPayloadType; @@ -313,6 +315,7 @@ typedef struct _GstH265SliceHdr GstH265SliceHdr; typedef struct _GstH265PicTiming GstH265PicTiming; typedef struct _GstH265BufferingPeriod GstH265BufferingPeriod; +typedef struct _GstH265RecoveryPoint GstH265RecoveryPoint; typedef struct _GstH265SEIMessage GstH265SEIMessage; /** @@ -1063,6 +1066,13 @@ struct _GstH265BufferingPeriod guint8 vcl_initial_alt_cpb_removal_offset[32]; }; +struct _GstH265RecoveryPoint +{ + gint32 recovery_poc_cnt; + guint8 exact_match_flag; + guint8 broken_link_flag; +}; + struct _GstH265SEIMessage { GstH265SEIPayloadType payloadType; @@ -1070,6 +1080,7 @@ struct _GstH265SEIMessage union { GstH265BufferingPeriod buffering_period; GstH265PicTiming pic_timing; + GstH265RecoveryPoint recovery_point; /* ... could implement more */ } payload; };