2 * Copyright (C) <2018> Edward Hervey <edward@centricular.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef __GST_VIDEO_ANC_H__
21 #define __GST_VIDEO_ANC_H__
24 #include <gst/video/video-format.h>
25 #include <gst/video/video-info.h>
29 typedef struct _GstVideoAncillary GstVideoAncillary;
33 * @DID: The Data Identifier
34 * @SDID_block_number: The Secondary Data Identifier (if type 2) or the Data
35 * Block Number (if type 1)
36 * @data_count: The amount of data (in bytes) in @data (max 255 bytes)
37 * @data: (array length=data_count): The user data content of the Ancillary packet.
38 * Does not contain the ADF, DID, SDID nor CS.
40 * Video Ancillary data, according to SMPTE-291M specification.
42 * Note that the contents of the data are always stored as 8bit data (i.e. do not contain
43 * the parity check bits).
47 struct _GstVideoAncillary {
49 guint8 SDID_block_number;
54 /* Padding for future extension */
55 gpointer _gst_reserved[GST_PADDING];
59 GST_VIDEO_ANCILLARY_DID_UNDEFINED = 0x00,
60 GST_VIDEO_ANCILLARY_DID_DELETION = 0x80,
61 GST_VIDEO_ANCILLARY_DID_HANC_3G_AUDIO_DATA_FIRST = 0xa0,
62 GST_VIDEO_ANCILLARY_DID_HANC_3G_AUDIO_DATA_LAST = 0xa7,
63 GST_VIDEO_ANCILLARY_DID_HANC_HDTV_AUDIO_DATA_FIRST = 0xe0,
64 GST_VIDEO_ANCILLARY_DID_HANC_HDTV_AUDIO_DATA_LAST = 0xe7,
65 GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_1_FIRST = 0xec,
66 GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_1_LAST = 0xef,
67 GST_VIDEO_ANCILLARY_DID_CAMERA_POSITION = 0xf0,
68 GST_VIDEO_ANCILLARY_DID_HANC_ERROR_DETECTION = 0xf4,
69 GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_2_FIRST = 0xf8,
70 GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_2_LAST = 0xff,
71 } GstVideoAncillaryDID;
74 * GST_VIDEO_ANCILLARY_DID16:
75 * @anc: a #GstVideoAncillary
77 * Returns the #GstVideoAncillaryDID16 of the ancillary data.
81 * Returns: a #GstVideoAncillaryDID16 identifier
83 #define GST_VIDEO_ANCILLARY_DID16(anc) ((guint16)((anc)->DID) << 8 | (guint16)((anc)->SDID_block_number))
86 * GstVideoAncillaryDID16:
87 * @GST_VIDEO_ANCILLARY_DID16_S334_EIA_708: CEA 708 Ancillary data according to SMPTE 334
88 * @GST_VIDEO_ANCILLARY_DID16_S334_EIA_608: CEA 608 Ancillary data according to SMPTE 334
89 * @GST_VIDEO_ANCILLARY_DID16_S2016_3_AFD_BAR: AFD/Bar Ancillary data according to SMPTE 2016-3 (Since: 1.18)
91 * Some know types of Ancillary Data identifiers.
96 GST_VIDEO_ANCILLARY_DID16_S334_EIA_708 = 0x6101,
97 GST_VIDEO_ANCILLARY_DID16_S334_EIA_608 = 0x6102,
98 GST_VIDEO_ANCILLARY_DID16_S2016_3_AFD_BAR = 0x4105,
99 } GstVideoAncillaryDID16;
101 /* Closed Caption support */
103 * GstVideoCaptionType:
104 * @GST_VIDEO_CAPTION_TYPE_UNKNOWN: Unknown type of CC
105 * @GST_VIDEO_CAPTION_TYPE_CEA608_RAW: CEA-608 as byte pairs. Note that
106 * this format is not recommended since is does not specify to
107 * which field the caption comes from and therefore assumes
108 * it comes from the first field (and that there is no information
109 * on the second field). Use @GST_VIDEO_CAPTION_TYPE_CEA708_RAW
110 * if you wish to store CEA-608 from two fields and prefix each byte pair
111 * with 0xFC for the first field and 0xFD for the second field.
112 * @GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A: CEA-608 as byte triplets as defined
113 * in SMPTE S334-1 Annex A. The second and third byte of the byte triplet
114 * is the raw CEA608 data, the first byte is a bitfield: The top/7th bit is
115 * 0 for the second field, 1 for the first field, bit 6 and 5 are 0 and
116 * bits 4 to 0 are a 5 bit unsigned integer that represents the line
117 * offset relative to the base-line of the original image format (line 9
118 * for 525-line field 1, line 272 for 525-line field 2, line 5 for
119 * 625-line field 1 and line 318 for 625-line field 2).
120 * @GST_VIDEO_CAPTION_TYPE_CEA708_RAW: CEA-708 as cc_data byte triplets. They
121 * can also contain 608-in-708 and the first byte of each triplet has to
122 * be inspected for detecting the type.
123 * @GST_VIDEO_CAPTION_TYPE_CEA708_CDP: CEA-708 (and optionally CEA-608) in
124 * a CDP (Caption Distribution Packet) defined by SMPTE S-334-2.
125 * Contains the whole CDP (starting with 0x9669).
127 * The various known types of Closed Caption (CC).
132 GST_VIDEO_CAPTION_TYPE_UNKNOWN = 0,
133 GST_VIDEO_CAPTION_TYPE_CEA608_RAW = 1,
134 GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A = 2,
135 GST_VIDEO_CAPTION_TYPE_CEA708_RAW = 3,
136 GST_VIDEO_CAPTION_TYPE_CEA708_CDP = 4
137 } GstVideoCaptionType;
141 gst_video_caption_type_from_caps (const GstCaps *caps);
145 gst_video_caption_type_to_caps (GstVideoCaptionType type);
148 * GstVideoCaptionMeta:
149 * @meta: parent #GstMeta
150 * @caption_type: The type of Closed Caption contained in the meta.
151 * @data: (array length=size): The Closed Caption data.
152 * @size: The size in bytes of @data
154 * Extra buffer metadata providing Closed Caption.
161 GstVideoCaptionType caption_type;
164 } GstVideoCaptionMeta;
167 GType gst_video_caption_meta_api_get_type (void);
168 #define GST_VIDEO_CAPTION_META_API_TYPE (gst_video_caption_meta_api_get_type())
171 const GstMetaInfo *gst_video_caption_meta_get_info (void);
172 #define GST_VIDEO_CAPTION_META_INFO (gst_video_caption_meta_get_info())
175 * gst_buffer_get_video_caption_meta:
178 * Gets the #GstVideoCaptionMeta that might be present on @b.
182 * Returns: The first #GstVideoCaptionMeta present on @b, or %NULL if
183 * no #GstVideoCaptionMeta are present
185 #define gst_buffer_get_video_caption_meta(b) \
186 ((GstVideoCaptionMeta*)gst_buffer_get_meta((b),GST_VIDEO_CAPTION_META_API_TYPE))
189 GstVideoCaptionMeta *gst_buffer_add_video_caption_meta (GstBuffer * buffer,
190 GstVideoCaptionType caption_type,
197 * A parser for detecting and extracting @GstVideoAncillary data from
198 * Vertical Blanking Interval lines of component signals.
203 typedef struct _GstVideoVBIParser GstVideoVBIParser;
206 GType gst_video_vbi_parser_get_type (void);
209 * GstVideoVBIParserResult:
210 * @GST_VIDEO_VBI_PARSER_RESULT_DONE: No line were provided, or no more Ancillary data was found.
211 * @GST_VIDEO_VBI_PARSER_RESULT_OK: A #GstVideoAncillary was found.
212 * @GST_VIDEO_VBI_PARSER_RESULT_ERROR: An error occured
214 * Return values for #GstVideoVBIParser
219 GST_VIDEO_VBI_PARSER_RESULT_DONE = 0,
220 GST_VIDEO_VBI_PARSER_RESULT_OK = 1,
221 GST_VIDEO_VBI_PARSER_RESULT_ERROR = 2
222 } GstVideoVBIParserResult;
225 GstVideoVBIParserResult gst_video_vbi_parser_get_ancillary(GstVideoVBIParser *parser,
226 GstVideoAncillary *anc);
229 GstVideoVBIParser *gst_video_vbi_parser_new (GstVideoFormat format, guint32 pixel_width);
232 GstVideoVBIParser *gst_video_vbi_parser_copy (const GstVideoVBIParser *parser);
235 void gst_video_vbi_parser_free (GstVideoVBIParser *parser);
238 void gst_video_vbi_parser_add_line (GstVideoVBIParser *parser, const guint8 *data);
241 * GstVideoVBIEncoder:
243 * An encoder for writing ancillary data to the
244 * Vertical Blanking Interval lines of component signals.
249 typedef struct _GstVideoVBIEncoder GstVideoVBIEncoder;
252 GType gst_video_vbi_encoder_get_type (void);
255 GstVideoVBIEncoder *gst_video_vbi_encoder_new (GstVideoFormat format, guint32 pixel_width);
258 GstVideoVBIEncoder *gst_video_vbi_encoder_copy (const GstVideoVBIEncoder *encoder);
261 void gst_video_vbi_encoder_free (GstVideoVBIEncoder *encoder);
264 gboolean gst_video_vbi_encoder_add_ancillary (GstVideoVBIEncoder *encoder,
267 guint8 SDID_block_number,
272 void gst_video_vbi_encoder_write_line (GstVideoVBIEncoder *encoder, guint8 *data);
276 #endif /* __GST_VIDEO_ANC_H__ */