2011-01-28 11:38:19 +00:00
|
|
|
/* GStreamer H.264 Parser
|
2011-08-02 10:37:02 +00:00
|
|
|
* Copyright (C) <2010> Collabora ltd
|
2011-01-28 11:38:19 +00:00
|
|
|
* Copyright (C) <2010> Nokia Corporation
|
2011-08-02 10:37:02 +00:00
|
|
|
* Copyright (C) <2011> Intel Corporation
|
|
|
|
*
|
|
|
|
* Copyright (C) <2010> Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
|
|
|
|
* Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
|
2011-01-28 11:38:19 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-01-28 11:38:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_H264_PARSE_H__
|
|
|
|
#define __GST_H264_PARSE_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2011-04-02 17:30:22 +00:00
|
|
|
#include <gst/base/gstbaseparse.h>
|
2011-08-02 10:37:02 +00:00
|
|
|
#include <gst/codecparsers/gsth264parser.h>
|
2015-05-29 15:38:16 +00:00
|
|
|
#include <gst/video/video.h>
|
2019-05-08 15:05:40 +00:00
|
|
|
#include "gstvideoparseutils.h"
|
2011-01-28 11:38:19 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
typedef struct _H264Params H264Params;
|
|
|
|
|
|
|
|
#define GST_TYPE_H264_PARSE \
|
|
|
|
(gst_h264_parse_get_type())
|
|
|
|
#define GST_H264_PARSE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H264_PARSE,GstH264Parse))
|
|
|
|
#define GST_H264_PARSE_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H264_PARSE,GstH264ParseClass))
|
|
|
|
#define GST_IS_H264_PARSE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H264_PARSE))
|
|
|
|
#define GST_IS_H264_PARSE_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H264_PARSE))
|
|
|
|
|
|
|
|
GType gst_h264_parse_get_type (void);
|
|
|
|
|
|
|
|
typedef struct _GstH264Parse GstH264Parse;
|
|
|
|
typedef struct _GstH264ParseClass GstH264ParseClass;
|
|
|
|
|
|
|
|
struct _GstH264Parse
|
|
|
|
{
|
|
|
|
GstBaseParse baseparse;
|
|
|
|
|
|
|
|
/* stream */
|
|
|
|
gint width, height;
|
|
|
|
gint fps_num, fps_den;
|
2011-12-01 08:02:46 +00:00
|
|
|
gint upstream_par_n, upstream_par_d;
|
2013-10-28 13:04:16 +00:00
|
|
|
gint parsed_par_n, parsed_par_d;
|
2019-03-28 21:02:02 +00:00
|
|
|
gint parsed_fps_n, parsed_fps_d;
|
2019-07-16 00:40:01 +00:00
|
|
|
GstVideoColorimetry parsed_colorimetry;
|
2013-02-02 17:44:11 +00:00
|
|
|
/* current codec_data in output caps, if any */
|
2011-01-28 11:38:19 +00:00
|
|
|
GstBuffer *codec_data;
|
2013-02-02 17:44:11 +00:00
|
|
|
/* input codec_data, if any */
|
|
|
|
GstBuffer *codec_data_in;
|
2011-01-28 11:38:19 +00:00
|
|
|
guint nal_length_size;
|
|
|
|
gboolean packetized;
|
2012-02-15 15:38:32 +00:00
|
|
|
gboolean split_packetized;
|
|
|
|
gboolean transform;
|
2011-01-28 11:38:19 +00:00
|
|
|
|
|
|
|
/* state */
|
2011-08-02 10:37:02 +00:00
|
|
|
GstH264NalParser *nalparser;
|
2014-06-25 09:06:41 +00:00
|
|
|
guint state;
|
2016-05-09 17:32:59 +00:00
|
|
|
guint in_align;
|
2011-01-28 11:38:19 +00:00
|
|
|
guint align;
|
|
|
|
guint format;
|
2012-02-10 13:46:00 +00:00
|
|
|
gint current_off;
|
2015-06-10 15:57:08 +00:00
|
|
|
/* True if input format and alignment match negotiated output */
|
|
|
|
gboolean can_passthrough;
|
2011-01-28 11:38:19 +00:00
|
|
|
|
|
|
|
GstClockTime last_report;
|
|
|
|
gboolean push_codec;
|
2014-06-25 09:06:41 +00:00
|
|
|
/* The following variables have a meaning in context of "have
|
|
|
|
* SPS/PPS to push downstream", e.g. to update caps */
|
2011-12-19 11:32:26 +00:00
|
|
|
gboolean have_sps;
|
|
|
|
gboolean have_pps;
|
2011-01-28 11:38:19 +00:00
|
|
|
|
2018-11-23 02:28:44 +00:00
|
|
|
/* per frame sps/pps check for periodic push codec decision */
|
|
|
|
gboolean have_sps_in_frame;
|
|
|
|
gboolean have_pps_in_frame;
|
|
|
|
|
2021-11-03 08:09:52 +00:00
|
|
|
/* per frame AU Delimiter check used when in_format == avc or avc3 */
|
|
|
|
gboolean have_aud_in_frame;
|
|
|
|
|
|
|
|
/* tracing state whether h264parse needs to insert AUD or not.
|
|
|
|
* Used when in_format == byte-stream */
|
|
|
|
gboolean aud_needed;
|
|
|
|
|
|
|
|
/* For insertion of AU Delimiter */
|
|
|
|
gboolean aud_insert;
|
|
|
|
|
2020-03-10 04:20:17 +00:00
|
|
|
gboolean first_frame;
|
2013-12-16 09:18:23 +00:00
|
|
|
|
2011-08-02 10:37:02 +00:00
|
|
|
/* collected SPS and PPS NALUs */
|
|
|
|
GstBuffer *sps_nals[GST_H264_MAX_SPS_COUNT];
|
|
|
|
GstBuffer *pps_nals[GST_H264_MAX_PPS_COUNT];
|
|
|
|
|
2019-03-28 21:02:02 +00:00
|
|
|
/* collected SEI timestamps */
|
|
|
|
guint num_clock_timestamp;
|
2020-04-08 06:37:03 +00:00
|
|
|
GstH264PicTiming pic_timing_sei;
|
2019-03-28 21:02:02 +00:00
|
|
|
|
2011-08-02 10:37:02 +00:00
|
|
|
/* Infos we need to keep track of */
|
|
|
|
guint32 sei_cpb_removal_delay;
|
|
|
|
guint8 sei_pic_struct;
|
|
|
|
guint8 sei_pic_struct_pres_flag;
|
|
|
|
guint field_pic_flag;
|
2023-03-07 14:46:50 +00:00
|
|
|
gboolean ignore_vui_fps;
|
2011-08-02 10:37:02 +00:00
|
|
|
|
|
|
|
/* cached timestamps */
|
|
|
|
/* (trying to) track upstream dts and interpolate */
|
|
|
|
GstClockTime dts;
|
|
|
|
/* dts at start of last buffering period */
|
|
|
|
GstClockTime ts_trn_nb;
|
2012-01-04 09:56:51 +00:00
|
|
|
gboolean do_ts;
|
2011-08-02 10:37:02 +00:00
|
|
|
|
2014-03-28 17:27:16 +00:00
|
|
|
gboolean discont;
|
2018-09-28 20:49:52 +00:00
|
|
|
gboolean marker;
|
2014-03-28 17:27:16 +00:00
|
|
|
|
2011-01-28 11:38:19 +00:00
|
|
|
/* frame parsing */
|
2011-08-02 10:37:02 +00:00
|
|
|
/*guint last_nal_pos;*/
|
|
|
|
/*guint next_sc_pos;*/
|
2012-02-01 11:23:23 +00:00
|
|
|
gint idr_pos, sei_pos;
|
2020-04-08 06:37:03 +00:00
|
|
|
gint pic_timing_sei_pos;
|
2024-08-06 16:09:58 +00:00
|
|
|
gint pic_timing_sei_end;
|
2011-01-28 11:38:19 +00:00
|
|
|
gboolean update_caps;
|
|
|
|
GstAdapter *frame_out;
|
|
|
|
gboolean keyframe;
|
2019-07-10 21:40:36 +00:00
|
|
|
gboolean predicted;
|
|
|
|
gboolean bidirectional;
|
2014-11-07 14:50:51 +00:00
|
|
|
gboolean header;
|
2011-01-28 11:38:19 +00:00
|
|
|
gboolean frame_start;
|
|
|
|
/* AU state */
|
|
|
|
gboolean picture_start;
|
|
|
|
|
|
|
|
/* props */
|
2016-05-25 09:54:55 +00:00
|
|
|
gint interval;
|
2020-04-08 06:37:03 +00:00
|
|
|
gboolean update_timecode;
|
2011-12-06 12:06:06 +00:00
|
|
|
|
|
|
|
GstClockTime pending_key_unit_ts;
|
|
|
|
GstEvent *force_key_unit_event;
|
2015-05-29 15:38:16 +00:00
|
|
|
|
|
|
|
/* Stereo / multiview info */
|
|
|
|
GstVideoMultiviewMode multiview_mode;
|
|
|
|
GstVideoMultiviewFlags multiview_flags;
|
|
|
|
gboolean first_in_bundle;
|
2017-03-07 09:33:12 +00:00
|
|
|
|
2019-05-08 15:05:40 +00:00
|
|
|
GstVideoParseUserData user_data;
|
2021-12-19 18:14:05 +00:00
|
|
|
GstVideoParseUserDataUnregistered user_data_unregistered;
|
2019-05-08 15:05:40 +00:00
|
|
|
|
2019-11-28 11:59:46 +00:00
|
|
|
GstVideoMasteringDisplayInfo mastering_display_info;
|
|
|
|
guint mastering_display_info_state;
|
|
|
|
|
|
|
|
GstVideoContentLightLevel content_light_level;
|
|
|
|
guint content_light_level_state;
|
2019-07-10 21:40:36 +00:00
|
|
|
|
|
|
|
/* For forward predicted trickmode */
|
|
|
|
gboolean discard_bidirectional;
|
2011-01-28 11:38:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstH264ParseClass
|
|
|
|
{
|
|
|
|
GstBaseParseClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
#endif
|