61afe93878dabdac0ba1724fe06214fd235af34f
[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., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, 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
32 G_BEGIN_DECLS
33
34 typedef struct _H264Params H264Params;
35
36 #define GST_TYPE_H264_PARSE \
37   (gst_h264_parse_get_type())
38 #define GST_H264_PARSE(obj) \
39   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H264_PARSE,GstH264Parse))
40 #define GST_H264_PARSE_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H264_PARSE,GstH264ParseClass))
42 #define GST_IS_H264_PARSE(obj) \
43   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H264_PARSE))
44 #define GST_IS_H264_PARSE_CLASS(klass) \
45   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H264_PARSE))
46
47 GType gst_h264_parse_get_type (void);
48
49 typedef struct _GstH264Parse GstH264Parse;
50 typedef struct _GstH264ParseClass GstH264ParseClass;
51
52 struct _GstH264Parse
53 {
54   GstBaseParse baseparse;
55
56   GstPadChainFunction parse_chain;
57
58   /* stream */
59   gint width, height;
60   gint fps_num, fps_den;
61   gint aspect_ratio_idc;
62   gint sar_width, sar_height;
63   gint upstream_par_n, upstream_par_d;
64   GstBuffer *codec_data;
65   guint nal_length_size;
66   gboolean packetized;
67
68   /* state */
69   GstH264NalParser *nalparser;
70   guint align;
71   guint format;
72   gint current_off;
73   gboolean packetized_last;
74   gboolean packetized_chunked;
75
76   GstClockTime last_report;
77   gboolean push_codec;
78   gboolean have_sps;
79   gboolean have_pps;
80
81   /* collected SPS and PPS NALUs */
82   GstBuffer *sps_nals[GST_H264_MAX_SPS_COUNT];
83   GstBuffer *pps_nals[GST_H264_MAX_PPS_COUNT];
84
85   /* Infos we need to keep track of */
86   guint32 sei_cpb_removal_delay;
87   guint8 sei_pic_struct;
88   guint8 sei_pic_struct_pres_flag;
89   guint field_pic_flag;
90
91   /* cached timestamps */
92   /* (trying to) track upstream dts and interpolate */
93   GstClockTime dts;
94   /* dts at start of last buffering period */
95   GstClockTime ts_trn_nb;
96   gboolean do_ts;
97
98   /* frame parsing */
99   /*guint last_nal_pos;*/
100   /*guint next_sc_pos;*/
101   gint idr_pos, sei_pos;
102   gboolean update_caps;
103   GstAdapter *frame_out;
104   gboolean keyframe;
105   gboolean frame_start;
106   /* AU state */
107   gboolean picture_start;
108
109   /* props */
110   gboolean split_packetized;
111   guint interval;
112
113   GstClockTime pending_key_unit_ts;
114   GstEvent *force_key_unit_event;
115 };
116
117 struct _GstH264ParseClass
118 {
119   GstBaseParseClass parent_class;
120 };
121
122 G_END_DECLS
123 #endif