h264parse: Add support for inband timecode update
[platform/upstream/gstreamer.git] / gst / videoparsers / gsth264parse.h
1 /* GStreamer H.264 Parser
2  * Copyright (C) <2010> Collabora ltd
3  * Copyright (C) <2010> Nokia Corporation
4  * Copyright (C) <2011> Intel Corporation
5  *
6  * Copyright (C) <2010> Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
7  * Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
8  *
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.
13  *
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.
18  *
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.
23  */
24
25 #ifndef __GST_H264_PARSE_H__
26 #define __GST_H264_PARSE_H__
27
28 #include <gst/gst.h>
29 #include <gst/base/gstbaseparse.h>
30 #include <gst/codecparsers/gsth264parser.h>
31 #include <gst/video/video.h>
32 #include "gstvideoparseutils.h"
33
34 G_BEGIN_DECLS
35
36 typedef struct _H264Params H264Params;
37
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))
48
49 GType gst_h264_parse_get_type (void);
50
51 typedef struct _GstH264Parse GstH264Parse;
52 typedef struct _GstH264ParseClass GstH264ParseClass;
53
54 struct _GstH264Parse
55 {
56   GstBaseParse baseparse;
57
58   /* stream */
59   gint width, height;
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;
70   gboolean packetized;
71   gboolean split_packetized;
72   gboolean transform;
73
74   /* state */
75   GstH264NalParser *nalparser;
76   guint state;
77   guint in_align;
78   guint align;
79   guint format;
80   gint current_off;
81   /* True if input format and alignment match negotiated output */
82   gboolean can_passthrough;
83
84   GstClockTime last_report;
85   gboolean push_codec;
86   /* The following variables have a meaning in context of "have
87    * SPS/PPS to push downstream", e.g. to update caps */
88   gboolean have_sps;
89   gboolean have_pps;
90
91   /* per frame sps/pps check for periodic push codec decision */
92   gboolean have_sps_in_frame;
93   gboolean have_pps_in_frame;
94
95   gboolean first_frame;
96
97   /* collected SPS and PPS NALUs */
98   GstBuffer *sps_nals[GST_H264_MAX_SPS_COUNT];
99   GstBuffer *pps_nals[GST_H264_MAX_PPS_COUNT];
100
101   /* collected SEI timestamps */
102   guint num_clock_timestamp;
103   GstH264PicTiming pic_timing_sei;
104
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;
110
111   /* cached timestamps */
112   /* (trying to) track upstream dts and interpolate */
113   GstClockTime dts;
114   /* dts at start of last buffering period */
115   GstClockTime ts_trn_nb;
116   gboolean do_ts;
117
118   gboolean discont;
119
120   /* frame parsing */
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;
128   gboolean keyframe;
129   gboolean predicted;
130   gboolean bidirectional;
131   gboolean header;
132   gboolean frame_start;
133   /* AU state */
134   gboolean picture_start;
135
136   /* props */
137   gint interval;
138   gboolean update_timecode;
139
140   GstClockTime pending_key_unit_ts;
141   GstEvent *force_key_unit_event;
142
143   /* Stereo / multiview info */
144   GstVideoMultiviewMode multiview_mode;
145   GstVideoMultiviewFlags multiview_flags;
146   gboolean first_in_bundle;
147
148   /* For insertion of AU Delimiter */
149   gboolean aud_needed;
150   gboolean aud_insert;
151
152   GstVideoParseUserData user_data;
153
154   GstVideoMasteringDisplayInfo mastering_display_info;
155   guint mastering_display_info_state;
156
157   GstVideoContentLightLevel content_light_level;
158   guint content_light_level_state;
159
160   /* For forward predicted trickmode */
161   gboolean discard_bidirectional;
162 };
163
164 struct _GstH264ParseClass
165 {
166   GstBaseParseClass parent_class;
167 };
168
169 G_END_DECLS
170 #endif