1 /* GStreamer H.265 Parser 2 * Copyright (C) 2013 Intel Corporation 3 * Contact: Sreerenj Balachandran <sreerenj.balachandran@intel.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_H265_PARSE_H__ 22 #define __GST_H265_PARSE_H__ 23 24 #include <gst/gst.h> 25 #include <gst/base/gstbaseparse.h> 26 #include <gst/codecparsers/gsth265parser.h> 27 #include <gst/video/video.h> 28 #include "gstvideoparseutils.h" 29 30 G_BEGIN_DECLS 31 32 #define GST_TYPE_H265_PARSE \ 33 (gst_h265_parse_get_type()) 34 #define GST_H265_PARSE(obj) \ 35 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H265_PARSE,GstH265Parse)) 36 #define GST_H265_PARSE_CLASS(klass) \ 37 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H265_PARSE,GstH265ParseClass)) 38 #define GST_IS_H265_PARSE(obj) \ 39 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H265_PARSE)) 40 #define GST_IS_H265_PARSE_CLASS(klass) \ 41 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H265_PARSE)) 42 43 GType gst_h265_parse_get_type (void); 44 45 typedef struct _GstH265Parse GstH265Parse; 46 typedef struct _GstH265ParseClass GstH265ParseClass; 47 48 struct _GstH265Parse 49 { 50 GstBaseParse baseparse; 51 52 /* stream */ 53 gint width, height; 54 gint fps_num, fps_den; 55 gint upstream_par_n, upstream_par_d; 56 gint parsed_par_n, parsed_par_d; 57 gint parsed_fps_n, parsed_fps_d; 58 GstVideoColorimetry parsed_colorimetry; 59 /* current codec_data in output caps, if any */ 60 GstBuffer *codec_data; 61 /* input codec_data, if any */ 62 GstBuffer *codec_data_in; 63 guint nal_length_size; 64 gboolean packetized; 65 gboolean split_packetized; 66 gboolean transform; 67 68 /* state */ 69 GstH265Parser *nalparser; 70 guint in_align; 71 guint state; 72 guint align; 73 guint format; 74 gint current_off; 75 76 GstClockTime last_report; 77 gboolean push_codec; 78 /* The following variables have a meaning in context of "have 79 * VPS/SPS/PPS to push downstream", e.g. to update caps */ 80 gboolean have_vps; 81 gboolean have_sps; 82 gboolean have_pps; 83 84 /* per frame vps/sps/pps check for periodic push codec decision */ 85 gboolean have_vps_in_frame; 86 gboolean have_sps_in_frame; 87 gboolean have_pps_in_frame; 88 89 gboolean first_frame; 90 91 /* collected SPS and PPS NALUs */ 92 GstBuffer *vps_nals[GST_H265_MAX_VPS_COUNT]; 93 GstBuffer *sps_nals[GST_H265_MAX_SPS_COUNT]; 94 GstBuffer *pps_nals[GST_H265_MAX_PPS_COUNT]; 95 96 /* Infos we need to keep track of */ 97 guint8 sei_pic_struct; 98 99 /* Collected TimeCode SEI */ 100 GstH265TimeCode time_code; 101 102 gboolean discont; 103 gboolean marker; 104 105 /* frame parsing */ 106 gint idr_pos, sei_pos; 107 gboolean update_caps; 108 GstAdapter *frame_out; 109 gboolean keyframe; 110 gboolean predicted; 111 gboolean bidirectional; 112 gboolean header; 113 gboolean parsed_framerate; 114 /* AU state */ 115 gboolean picture_start; 116 117 GstVideoParseUserData user_data; 118 119 /* props */ 120 gint interval; 121 122 GstClockTime pending_key_unit_ts; 123 GstEvent *force_key_unit_event; 124 125 GstVideoMasteringDisplayInfo mastering_display_info; 126 guint mastering_display_info_state; 127 128 GstVideoContentLightLevel content_light_level; 129 guint content_light_level_state; 130 131 /* For forward predicted trickmode */ 132 gboolean discard_bidirectional; 133 }; 134 135 struct _GstH265ParseClass 136 { 137 GstBaseParseClass parent_class; 138 }; 139 140 G_END_DECLS 141 #endif 142