1 /* GStreamer H.264 Parser
2 * Copyright (C) <2010> Collabora ltd
3 * Copyright (C) <2010> Nokia Corporation
4 * Copyright (C) <2011> Intel Corporation
6 * Copyright (C) <2010> Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
7 * Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #ifndef __GST_H264_PARSE_H__
26 #define __GST_H264_PARSE_H__
29 #include <gst/base/gstbaseparse.h>
30 #include <gst/codecparsers/gsth264parser.h>
31 #include <gst/video/video.h>
32 #include "gstvideoparseutils.h"
36 typedef struct _H264Params H264Params;
38 #define GST_TYPE_H264_PARSE \
39 (gst_h264_parse_get_type())
40 #define GST_H264_PARSE(obj) \
41 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H264_PARSE,GstH264Parse))
42 #define GST_H264_PARSE_CLASS(klass) \
43 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H264_PARSE,GstH264ParseClass))
44 #define GST_IS_H264_PARSE(obj) \
45 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H264_PARSE))
46 #define GST_IS_H264_PARSE_CLASS(klass) \
47 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H264_PARSE))
49 GType gst_h264_parse_get_type (void);
51 typedef struct _GstH264Parse GstH264Parse;
52 typedef struct _GstH264ParseClass GstH264ParseClass;
56 GstBaseParse baseparse;
60 gint fps_num, fps_den;
61 gint upstream_par_n, upstream_par_d;
62 gint parsed_par_n, parsed_par_d;
63 gint parsed_fps_n, parsed_fps_d;
64 GstVideoColorimetry parsed_colorimetry;
65 /* current codec_data in output caps, if any */
66 GstBuffer *codec_data;
67 /* input codec_data, if any */
68 GstBuffer *codec_data_in;
69 guint nal_length_size;
71 gboolean split_packetized;
75 GstH264NalParser *nalparser;
81 /* True if input format and alignment match negotiated output */
82 gboolean can_passthrough;
84 GstClockTime last_report;
86 /* The following variables have a meaning in context of "have
87 * SPS/PPS to push downstream", e.g. to update caps */
91 /* per frame sps/pps check for periodic push codec decision */
92 gboolean have_sps_in_frame;
93 gboolean have_pps_in_frame;
97 /* collected SPS and PPS NALUs */
98 GstBuffer *sps_nals[GST_H264_MAX_SPS_COUNT];
99 GstBuffer *pps_nals[GST_H264_MAX_PPS_COUNT];
101 /* collected SEI timestamps */
102 guint num_clock_timestamp;
103 GstH264PicTiming pic_timing_sei;
105 /* Infos we need to keep track of */
106 guint32 sei_cpb_removal_delay;
107 guint8 sei_pic_struct;
108 guint8 sei_pic_struct_pres_flag;
109 guint field_pic_flag;
111 /* cached timestamps */
112 /* (trying to) track upstream dts and interpolate */
114 /* dts at start of last buffering period */
115 GstClockTime ts_trn_nb;
121 /*guint last_nal_pos;*/
122 /*guint next_sc_pos;*/
123 gint idr_pos, sei_pos;
124 gint pic_timing_sei_pos;
125 gint pic_timing_sei_size;
126 gboolean update_caps;
127 GstAdapter *frame_out;
130 gboolean bidirectional;
132 gboolean frame_start;
134 gboolean picture_start;
138 gboolean update_timecode;
140 GstClockTime pending_key_unit_ts;
141 GstEvent *force_key_unit_event;
143 /* Stereo / multiview info */
144 GstVideoMultiviewMode multiview_mode;
145 GstVideoMultiviewFlags multiview_flags;
146 gboolean first_in_bundle;
148 /* For insertion of AU Delimiter */
152 GstVideoParseUserData user_data;
154 GstVideoMasteringDisplayInfo mastering_display_info;
155 guint mastering_display_info_state;
157 GstVideoContentLightLevel content_light_level;
158 guint content_light_level_state;
160 /* For forward predicted trickmode */
161 gboolean discard_bidirectional;
164 struct _GstH264ParseClass
166 GstBaseParseClass parent_class;