From 56c3b40c30e218518f0cd1c724968336b3078f90 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 14 Feb 2020 21:50:15 -0500 Subject: [PATCH] h264picture: Add system_frame_num This allow cross-referencing GstH264Picture and GstVideoCodecFrame. --- gst-libs/gst/codecs/gsth264decoder.c | 2 ++ gst-libs/gst/codecs/gsth264picture.h | 2 ++ gst-libs/gst/codecs/gsth265decoder.c | 2 ++ gst-libs/gst/codecs/gsth265picture.h | 2 ++ gst-libs/gst/codecs/gstvp9decoder.c | 15 +++++++++------ gst-libs/gst/codecs/gstvp9picture.h | 2 ++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/codecs/gsth264decoder.c b/gst-libs/gst/codecs/gsth264decoder.c index 81db6ff..55d9fab 100644 --- a/gst-libs/gst/codecs/gsth264decoder.c +++ b/gst-libs/gst/codecs/gsth264decoder.c @@ -661,6 +661,8 @@ gst_h264_decoder_parse_slice (GstH264Decoder * self, GstH264NalUnit * nalu, return FALSE; } + /* This allows accessing the frame from the picture. */ + picture->system_frame_number = priv->current_frame->system_frame_number; priv->current_picture = picture; gst_video_codec_frame_set_user_data (priv->current_frame, gst_h264_picture_ref (priv->current_picture), diff --git a/gst-libs/gst/codecs/gsth264picture.h b/gst-libs/gst/codecs/gsth264picture.h index 8d3a449..73cad13 100644 --- a/gst-libs/gst/codecs/gsth264picture.h +++ b/gst-libs/gst/codecs/gsth264picture.h @@ -58,6 +58,8 @@ struct _GstH264Picture GstH264SliceType type; GstClockTime pts; + /* From GstVideoCodecFrame */ + guint32 system_frame_number; guint8 pic_order_cnt_type; /* SPS */ gint32 top_field_order_cnt; diff --git a/gst-libs/gst/codecs/gsth265decoder.c b/gst-libs/gst/codecs/gsth265decoder.c index 9ce7d46..09ca56a 100644 --- a/gst-libs/gst/codecs/gsth265decoder.c +++ b/gst-libs/gst/codecs/gsth265decoder.c @@ -392,6 +392,8 @@ gst_h265_decoder_parse_slice (GstH265Decoder * self, GstH265NalUnit * nalu, return FALSE; } + /* This allows accessing the frame from the picture. */ + picture->system_frame_number = priv->current_frame->system_frame_number; priv->current_picture = picture; gst_video_codec_frame_set_user_data (priv->current_frame, gst_h265_picture_ref (priv->current_picture), diff --git a/gst-libs/gst/codecs/gsth265picture.h b/gst-libs/gst/codecs/gsth265picture.h index 2c40bad..38dd5b3 100644 --- a/gst-libs/gst/codecs/gsth265picture.h +++ b/gst-libs/gst/codecs/gsth265picture.h @@ -64,6 +64,8 @@ struct _GstH265Picture GstH265SliceType type; GstClockTime pts; + /* From GstVideoCodecFrame */ + guint32 system_frame_number; gint pic_order_cnt; gint pic_order_cnt_msb; diff --git a/gst-libs/gst/codecs/gstvp9decoder.c b/gst-libs/gst/codecs/gstvp9decoder.c index 3b11c62..7ddf808 100644 --- a/gst-libs/gst/codecs/gstvp9decoder.c +++ b/gst-libs/gst/codecs/gstvp9decoder.c @@ -396,6 +396,15 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder, picture->subsampling_y = priv->parser->subsampling_y; picture->bit_depth = priv->parser->bit_depth; + if (i == frame_idx_to_consume) { + /* This allows accessing the frame from the picture. */ + picture->system_frame_number = frame->system_frame_number; + gst_video_codec_frame_set_user_data (frame, + gst_vp9_picture_ref (picture), + (GDestroyNotify) gst_vp9_picture_unref); + } + + if (klass->new_picture) { if (!klass->new_picture (self, picture)) { GST_ERROR_OBJECT (self, "new picture error"); @@ -424,12 +433,6 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder, } } - if (i == frame_idx_to_consume) { - gst_video_codec_frame_set_user_data (frame, - gst_vp9_picture_ref (picture), - (GDestroyNotify) gst_vp9_picture_unref); - } - if (klass->output_picture) ret = klass->output_picture (self, picture); diff --git a/gst-libs/gst/codecs/gstvp9picture.h b/gst-libs/gst/codecs/gstvp9picture.h index 1380145..25a82df 100644 --- a/gst-libs/gst/codecs/gstvp9picture.h +++ b/gst-libs/gst/codecs/gstvp9picture.h @@ -37,6 +37,8 @@ struct _GstVp9Picture GstMiniObject parent; GstClockTime pts; + /* From GstVideoCodecFrame */ + guint32 system_frame_number; GstVp9FrameHdr frame_hdr; -- 2.7.4