| 1 | /* GStreamer |
| 2 | * Copyright (C) <2018> Edward Hervey <edward@centricular.com> |
| 3 | * |
| 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. |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __GST_VIDEO_ANC_H__ |
| 21 | #define __GST_VIDEO_ANC_H__ |
| 22 | |
| 23 | #include <gst/gst.h> |
| 24 | #include <gst/video/video-format.h> |
| 25 | #include <gst/video/video-info.h> |
| 26 | |
| 27 | G_BEGIN_DECLS |
| 28 | |
| 29 | typedef struct _GstVideoAncillary GstVideoAncillary; |
| 30 | |
| 31 | /** |
| 32 | * 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. |
| 39 | * |
| 40 | * Video Ancillary data, according to SMPTE-291M specification. |
| 41 | * |
| 42 | * Note that the contents of the data are always stored as 8bit data (i.e. do not contain |
| 43 | * the parity check bits). |
| 44 | * |
| 45 | * Since: 1.16 |
| 46 | */ |
| 47 | struct _GstVideoAncillary { |
| 48 | guint8 DID; |
| 49 | guint8 SDID_block_number; |
| 50 | guint8 data_count; |
| 51 | guint8 data[256]; |
| 52 | |
| 53 | /*< private >*/ |
| 54 | /* Padding for future extension */ |
| 55 | gpointer _gst_reserved[GST_PADDING]; |
| 56 | }; |
| 57 | |
| 58 | /** |
| 59 | * GstVideoAncillaryDID: |
| 60 | * |
| 61 | * Since: 1.16 |
| 62 | */ |
| 63 | typedef enum { |
| 64 | GST_VIDEO_ANCILLARY_DID_UNDEFINED = 0x00, |
| 65 | GST_VIDEO_ANCILLARY_DID_DELETION = 0x80, |
| 66 | GST_VIDEO_ANCILLARY_DID_HANC_3G_AUDIO_DATA_FIRST = 0xa0, |
| 67 | GST_VIDEO_ANCILLARY_DID_HANC_3G_AUDIO_DATA_LAST = 0xa7, |
| 68 | GST_VIDEO_ANCILLARY_DID_HANC_HDTV_AUDIO_DATA_FIRST = 0xe0, |
| 69 | GST_VIDEO_ANCILLARY_DID_HANC_HDTV_AUDIO_DATA_LAST = 0xe7, |
| 70 | GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_1_FIRST = 0xec, |
| 71 | GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_1_LAST = 0xef, |
| 72 | GST_VIDEO_ANCILLARY_DID_CAMERA_POSITION = 0xf0, |
| 73 | GST_VIDEO_ANCILLARY_DID_HANC_ERROR_DETECTION = 0xf4, |
| 74 | GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_2_FIRST = 0xf8, |
| 75 | GST_VIDEO_ANCILLARY_DID_HANC_SDTV_AUDIO_DATA_2_LAST = 0xff, |
| 76 | } GstVideoAncillaryDID; |
| 77 | |
| 78 | /** |
| 79 | * GST_VIDEO_ANCILLARY_DID16: |
| 80 | * @anc: a #GstVideoAncillary |
| 81 | * |
| 82 | * Returns the #GstVideoAncillaryDID16 of the ancillary data. |
| 83 | * |
| 84 | * Since: 1.16 |
| 85 | * |
| 86 | * Returns: a #GstVideoAncillaryDID16 identifier |
| 87 | */ |
| 88 | #define GST_VIDEO_ANCILLARY_DID16(anc) ((guint16)((anc)->DID) << 8 | (guint16)((anc)->SDID_block_number)) |
| 89 | |
| 90 | /** |
| 91 | * GstVideoAncillaryDID16: |
| 92 | * @GST_VIDEO_ANCILLARY_DID16_S334_EIA_708: CEA 708 Ancillary data according to SMPTE 334 |
| 93 | * @GST_VIDEO_ANCILLARY_DID16_S334_EIA_608: CEA 608 Ancillary data according to SMPTE 334 |
| 94 | * @GST_VIDEO_ANCILLARY_DID16_S2016_3_AFD_BAR: AFD/Bar Ancillary data according to SMPTE 2016-3 (Since: 1.18) |
| 95 | * |
| 96 | * Some know types of Ancillary Data identifiers. |
| 97 | * |
| 98 | * Since: 1.16 |
| 99 | */ |
| 100 | typedef enum { |
| 101 | GST_VIDEO_ANCILLARY_DID16_S334_EIA_708 = 0x6101, |
| 102 | GST_VIDEO_ANCILLARY_DID16_S334_EIA_608 = 0x6102, |
| 103 | GST_VIDEO_ANCILLARY_DID16_S2016_3_AFD_BAR = 0x4105, |
| 104 | } GstVideoAncillaryDID16; |
| 105 | |
| 106 | /** |
| 107 | * GstAncillaryMetaField: |
| 108 | * @GST_ANCILLARY_META_FIELD_PROGRESSIVE: Progressive or no field specified (default) |
| 109 | * @GST_ANCILLARY_META_FIELD_INTERLACED_FIRST: Interlaced first field |
| 110 | * @GST_ANCILLARY_META_FIELD_INTERLACED_SECOND: Interlaced second field |
| 111 | * |
| 112 | * Location of a @GstAncillaryMeta. |
| 113 | * |
| 114 | * Since: 1.24 |
| 115 | */ |
| 116 | |
| 117 | typedef enum { |
| 118 | GST_ANCILLARY_META_FIELD_PROGRESSIVE = 0x00, |
| 119 | GST_ANCILLARY_META_FIELD_INTERLACED_FIRST = 0x10, |
| 120 | GST_ANCILLARY_META_FIELD_INTERLACED_SECOND = 0x11, |
| 121 | } GstAncillaryMetaField; |
| 122 | |
| 123 | /** |
| 124 | * GstAncillaryMeta: |
| 125 | * @meta: Parent #GstMeta |
| 126 | * @field: The field where the ancillary data is located |
| 127 | * @c_not_y_channel: Which channel (luminance or chrominance) the ancillary |
| 128 | * data is located. 0 if content is SD or stored in the luminance channel |
| 129 | * (default). 1 if HD and stored in the chrominance channel. |
| 130 | * @line: The line on which the ancillary data is located (max 11bit). There |
| 131 | * are two special values: 0x7ff if no line is specified (default), 0x7fe |
| 132 | * to specify the ancillary data is on any valid line before active video |
| 133 | * @offset: The location of the ancillary data packet in a SDI raster relative |
| 134 | * to the start of active video (max 12bits). A value of 0 means the ADF of |
| 135 | * the ancillary packet starts immediately following SAV. There are 3 |
| 136 | * special values: 0xfff: No specified location (default), 0xffe: within |
| 137 | * HANC data space, 0xffd: within the ancillary data space located between |
| 138 | * SAV and EAV |
| 139 | * @DID: Data Identified |
| 140 | * @SDID_block_number: Secondary Data identification (if type 2) or Data block |
| 141 | * number (if type 1) |
| 142 | * @data_count: The amount of user data |
| 143 | * @data: The User data |
| 144 | * @checksum: The checksum of the ADF |
| 145 | * |
| 146 | * #GstMeta for carrying SMPTE-291M Ancillary data. Note that all the ADF fields |
| 147 | * (@DID to @checksum) are 10bit values with parity/non-parity high-bits set. |
| 148 | * |
| 149 | * Since: 1.24 |
| 150 | */ |
| 151 | |
| 152 | typedef struct { |
| 153 | GstMeta meta; |
| 154 | |
| 155 | GstAncillaryMetaField field; /* Field location */ |
| 156 | |
| 157 | gboolean c_not_y_channel; /* 1 if content is HD and the ANC data is stored |
| 158 | in the chrominance channel. 0 if content is |
| 159 | SD or the ANC data is stored in the luminance |
| 160 | channel (default) */ |
| 161 | |
| 162 | guint16 line; /* The line on which this ANC data is located. |
| 163 | * |
| 164 | * 11bit value |
| 165 | * |
| 166 | * Special values: |
| 167 | * * 0x7ff : No line specified (default) |
| 168 | * * 0x7fe : Any valid line before active video */ |
| 169 | |
| 170 | guint16 offset; /* Location of the ANC data packet in a SDI |
| 171 | * raster relative to SAV. A value of 0 means |
| 172 | * the ADF of the ANC data packet beings |
| 173 | * immediately following SAV. |
| 174 | * |
| 175 | * 12bits value |
| 176 | * |
| 177 | * The unit is 10-bit words of the indicated |
| 178 | * data stream and data channel |
| 179 | * |
| 180 | * Special values: |
| 181 | * * 0xfff: No specified horizontal location (default) |
| 182 | * * 0xffe: Within HANC data space |
| 183 | * * 0xffd: Within the ancillary data space located |
| 184 | * between SAV and EAV |
| 185 | */ |
| 186 | |
| 187 | /* EXCLUDED from ANC RTP are the multi-stream properties (ex: stereoscopic |
| 188 | * video). That information should be conveyed by having separate VANC |
| 189 | * streams */ |
| 190 | |
| 191 | /* What follows are all the fields making up a ST 291 ADF packet. All of the |
| 192 | * fields are stored as 10bit, including the parity/non-parity high-bits set. |
| 193 | * |
| 194 | * To access the 8bit content, just cast the value */ |
| 195 | guint16 DID; /* Data Identifier (10 bit) */ |
| 196 | guint16 SDID_block_number; /* Secondary data identification (If type 2) or |
| 197 | * Data Block number (if type 1). Value is |
| 198 | * 10bit */ |
| 199 | guint16 data_count; /* The amount of User Data. Only the low 8 bits are to be used */ |
| 200 | guint16 *data; /* The User Data (10bit) */ |
| 201 | guint16 checksum; /* The checksum (10bit) */ |
| 202 | |
| 203 | } GstAncillaryMeta; |
| 204 | |
| 205 | GST_VIDEO_API GType gst_ancillary_meta_api_get_type(void); |
| 206 | #define GST_ANCILLARY_META_API_TYPE (gst_ancillary_meta_api_get_type()) |
| 207 | |
| 208 | GST_VIDEO_API const GstMetaInfo *gst_ancillary_meta_get_info(void); |
| 209 | #define GST_ANCILLARY_META_INFO (gst_ancillary_meta_get_info()) |
| 210 | |
| 211 | GST_VIDEO_API GstAncillaryMeta * |
| 212 | gst_buffer_add_ancillary_meta(GstBuffer *buffer); |
| 213 | |
| 214 | /** |
| 215 | * gst_buffer_get_ancillary_meta: |
| 216 | * @b: A #GstBuffer |
| 217 | * |
| 218 | * Gets the #GstAncillaryMeta that might be present on @b. |
| 219 | * |
| 220 | * Note: It is quite likely that there might be more than one ancillary meta on |
| 221 | * a given buffer. This function will only return the first one. See gst_buffer_iterate_ancillary_meta() for a way to iterate over all ancillary metas of the buffer. |
| 222 | * |
| 223 | * Since: 1.24 |
| 224 | * |
| 225 | * Returns: The first #GstAncillaryMeta present on @b, or %NULL if none are |
| 226 | * present. |
| 227 | */ |
| 228 | #define gst_buffer_get_ancillary_meta(b) \ |
| 229 | ((GstAncillaryMeta*)gst_buffer_get_meta((b), GST_ANCILLARY_META_API_TYPE) |
| 230 | |
| 231 | |
| 232 | /** |
| 233 | * gst_buffer_iterate_ancillary_meta: |
| 234 | * @b: A #GstBuffer |
| 235 | * @s: (out caller-allocates): An opaque state pointer |
| 236 | * |
| 237 | * Retrieves the next #GstAncillaryMeta after the current one according to |
| 238 | * @s. If @s points to %NULL, the first #GstAncillaryMeta will be returned (if |
| 239 | * any). |
| 240 | * |
| 241 | * @s will be updated with an opaque state pointer. |
| 242 | * |
| 243 | * Since: 1.24 |
| 244 | * |
| 245 | * Returns: (transfer none) (nullable): The next #GstAncillaryMeta present on @b |
| 246 | * or %NULL when there are no more items. |
| 247 | */ |
| 248 | #define gst_buffer_iterate_ancillary_meta(b, s) \ |
| 249 | ((GstAncillaryMeta*)gst_buffer_iterate_meta_filtered((b), (s), GST_ANCILLARY_META_API_TYPE)) |
| 250 | |
| 251 | /** |
| 252 | * GstVideoAFDValue: |
| 253 | * @GST_VIDEO_AFD_UNAVAILABLE: Unavailable (see note 0 below). |
| 254 | * @GST_VIDEO_AFD_16_9_TOP_ALIGNED: For 4:3 coded frame, letterbox 16:9 image, |
| 255 | * at top of the coded frame. For 16:9 coded frame, full frame 16:9 image, |
| 256 | * the same as the coded frame. |
| 257 | * @GST_VIDEO_AFD_14_9_TOP_ALIGNED: For 4:3 coded frame, letterbox 14:9 image, |
| 258 | * at top of the coded frame. For 16:9 coded frame, pillarbox 14:9 image, |
| 259 | * horizontally centered in the coded frame. |
| 260 | * @GST_VIDEO_AFD_GREATER_THAN_16_9: For 4:3 coded frame, letterbox image with an aspect ratio |
| 261 | * greater than 16:9, vertically centered in the coded frame. For 16:9 coded frame, |
| 262 | * letterbox image with an aspect ratio greater than 16:9. |
| 263 | * @GST_VIDEO_AFD_4_3_FULL_16_9_FULL: For 4:3 coded frame, full frame 4:3 image, |
| 264 | * the same as the coded frame. For 16:9 coded frame, full frame 16:9 image, the same as |
| 265 | * the coded frame. |
| 266 | * @GST_VIDEO_AFD_4_3_FULL_4_3_PILLAR: For 4:3 coded frame, full frame 4:3 image, the same as |
| 267 | * the coded frame. For 16:9 coded frame, pillarbox 4:3 image, horizontally centered in the |
| 268 | * coded frame. |
| 269 | * @GST_VIDEO_AFD_16_9_LETTER_16_9_FULL: For 4:3 coded frame, letterbox 16:9 image, vertically centered in |
| 270 | * the coded frame with all image areas protected. For 16:9 coded frame, full frame 16:9 image, |
| 271 | * with all image areas protected. |
| 272 | * @GST_VIDEO_AFD_14_9_LETTER_14_9_PILLAR: For 4:3 coded frame, letterbox 14:9 image, vertically centered in |
| 273 | * the coded frame. For 16:9 coded frame, pillarbox 14:9 image, horizontally centered in the |
| 274 | * coded frame. |
| 275 | * @GST_VIDEO_AFD_4_3_FULL_14_9_CENTER: For 4:3 coded frame, full frame 4:3 image, with alternative 14:9 |
| 276 | * center. For 16:9 coded frame, pillarbox 4:3 image, with alternative 14:9 center. |
| 277 | * @GST_VIDEO_AFD_16_9_LETTER_14_9_CENTER: For 4:3 coded frame, letterbox 16:9 image, with alternative 14:9 |
| 278 | * center. For 16:9 coded frame, full frame 16:9 image, with alternative 14:9 center. |
| 279 | * @GST_VIDEO_AFD_16_9_LETTER_4_3_CENTER: For 4:3 coded frame, letterbox 16:9 image, with alternative 4:3 |
| 280 | * center. For 16:9 coded frame, full frame 16:9 image, with alternative 4:3 center. |
| 281 | * |
| 282 | * Enumeration of the various values for Active Format Description (AFD) |
| 283 | * |
| 284 | * AFD should be included in video user data whenever the rectangular |
| 285 | * picture area containing useful information does not extend to the full height or width of the coded |
| 286 | * frame. AFD data may also be included in user data when the rectangular picture area containing |
| 287 | * useful information extends to the full height and width of the coded frame. |
| 288 | * |
| 289 | * For details, see Table 6.14 Active Format in: |
| 290 | * |
| 291 | * ATSC Digital Television Standard: |
| 292 | * Part 4 – MPEG-2 Video System Characteristics |
| 293 | * |
| 294 | * https://www.atsc.org/wp-content/uploads/2015/03/a_53-Part-4-2009.pdf |
| 295 | * |
| 296 | * and Active Format Description in Complete list of AFD codes |
| 297 | * |
| 298 | * https://en.wikipedia.org/wiki/Active_Format_Description#Complete_list_of_AFD_codes |
| 299 | * |
| 300 | * and SMPTE ST2016-1 |
| 301 | * |
| 302 | * Notes: |
| 303 | * |
| 304 | * 1) AFD 0 is undefined for ATSC and SMPTE ST2016-1, indicating that AFD data is not available: |
| 305 | * If Bar Data is not present, AFD '0000' indicates that exact information |
| 306 | * is not available and the active image should be assumed to be the same as the coded frame. AFD '0000'. |
| 307 | * AFD '0000' accompanied by Bar Data signals that the active image’s aspect ratio is narrower than 16:9, |
| 308 | * but is not 4:3 or 14:9. As the exact aspect ratio cannot be conveyed by AFD alone, wherever possible, |
| 309 | * AFD ‘0000’ should be accompanied by Bar Data to define the exact vertical or horizontal extent |
| 310 | * of the active image. |
| 311 | * 2) AFD 0 is reserved for DVB/ETSI |
| 312 | * 3) values 1, 5, 6, 7, and 12 are reserved for both ATSC and DVB/ETSI |
| 313 | * 4) values 2 and 3 are not recommended for ATSC, but are valid for DVB/ETSI |
| 314 | * |
| 315 | * Since: 1.18 |
| 316 | */ |
| 317 | typedef enum { |
| 318 | GST_VIDEO_AFD_UNAVAILABLE = 0, |
| 319 | GST_VIDEO_AFD_16_9_TOP_ALIGNED = 2, |
| 320 | GST_VIDEO_AFD_14_9_TOP_ALIGNED = 3, |
| 321 | GST_VIDEO_AFD_GREATER_THAN_16_9 = 4, |
| 322 | GST_VIDEO_AFD_4_3_FULL_16_9_FULL = 8, |
| 323 | GST_VIDEO_AFD_4_3_FULL_4_3_PILLAR = 9, |
| 324 | GST_VIDEO_AFD_16_9_LETTER_16_9_FULL = 10, |
| 325 | GST_VIDEO_AFD_14_9_LETTER_14_9_PILLAR = 11, |
| 326 | GST_VIDEO_AFD_4_3_FULL_14_9_CENTER = 13, |
| 327 | GST_VIDEO_AFD_16_9_LETTER_14_9_CENTER = 14, |
| 328 | GST_VIDEO_AFD_16_9_LETTER_4_3_CENTER = 15 |
| 329 | } GstVideoAFDValue; |
| 330 | |
| 331 | /** |
| 332 | * GstVideoAFDSpec: |
| 333 | * @GST_VIDEO_AFD_SPEC_DVB_ETSI: AFD value is from DVB/ETSI standard |
| 334 | * @GST_VIDEO_AFD_SPEC_ATSC_A53: AFD value is from ATSC A/53 standard |
| 335 | * @GST_VIDEO_AFD_SPEC_SMPT_ST2016_1 : AFD value is from SMPTE ST2016-1 standard |
| 336 | * |
| 337 | * Enumeration of the different standards that may apply to AFD data: |
| 338 | * |
| 339 | * 0) ETSI/DVB: |
| 340 | * https://www.etsi.org/deliver/etsi_ts/101100_101199/101154/02.01.01_60/ts_101154v020101p.pdf |
| 341 | * |
| 342 | * 1) ATSC A/53: |
| 343 | * https://www.atsc.org/wp-content/uploads/2015/03/a_53-Part-4-2009.pdf |
| 344 | * |
| 345 | * 2) SMPTE ST2016-1: |
| 346 | * |
| 347 | * Since: 1.18 |
| 348 | */ |
| 349 | typedef enum { |
| 350 | GST_VIDEO_AFD_SPEC_DVB_ETSI, |
| 351 | GST_VIDEO_AFD_SPEC_ATSC_A53, |
| 352 | GST_VIDEO_AFD_SPEC_SMPTE_ST2016_1 |
| 353 | } GstVideoAFDSpec; |
| 354 | |
| 355 | /** |
| 356 | * GstVideoAFDMeta: |
| 357 | * @meta: parent #GstMeta |
| 358 | * @field: 0 for progressive or field 1 and 1 for field 2 |
| 359 | * @spec: #GstVideoAFDSpec that applies to @afd |
| 360 | * @afd: #GstVideoAFDValue AFD value |
| 361 | * |
| 362 | * Active Format Description (AFD) |
| 363 | * |
| 364 | * For details, see Table 6.14 Active Format in: |
| 365 | * |
| 366 | * ATSC Digital Television Standard: |
| 367 | * Part 4 – MPEG-2 Video System Characteristics |
| 368 | * |
| 369 | * https://www.atsc.org/wp-content/uploads/2015/03/a_53-Part-4-2009.pdf |
| 370 | * |
| 371 | * and Active Format Description in Complete list of AFD codes |
| 372 | * |
| 373 | * https://en.wikipedia.org/wiki/Active_Format_Description#Complete_list_of_AFD_codes |
| 374 | * |
| 375 | * and SMPTE ST2016-1 |
| 376 | * |
| 377 | * Since: 1.18 |
| 378 | */ |
| 379 | typedef struct { |
| 380 | GstMeta meta; |
| 381 | |
| 382 | guint8 field; |
| 383 | GstVideoAFDSpec spec; |
| 384 | GstVideoAFDValue afd; |
| 385 | } GstVideoAFDMeta; |
| 386 | |
| 387 | GST_VIDEO_API GType gst_video_afd_meta_api_get_type (void); |
| 388 | #define GST_VIDEO_AFD_META_API_TYPE (gst_video_afd_meta_api_get_type()) |
| 389 | |
| 390 | GST_VIDEO_API const GstMetaInfo *gst_video_afd_meta_get_info (void); |
| 391 | #define GST_VIDEO_AFD_META_INFO (gst_video_afd_meta_get_info()) |
| 392 | |
| 393 | /** |
| 394 | * gst_buffer_get_video_afd_meta: |
| 395 | * @b: A #GstBuffer |
| 396 | * |
| 397 | * Gets the #GstVideoAFDMeta that might be present on @b. |
| 398 | * |
| 399 | * Note: there may be two #GstVideoAFDMeta structs for interlaced video. |
| 400 | * |
| 401 | * Since: 1.18 |
| 402 | * |
| 403 | * Returns: (nullable): The first #GstVideoAFDMeta present on @b, or %NULL if |
| 404 | * no #GstVideoAFDMeta are present |
| 405 | */ |
| 406 | #define gst_buffer_get_video_afd_meta(b) \ |
| 407 | ((GstVideoAFDMeta*)gst_buffer_get_meta((b),GST_VIDEO_AFD_META_API_TYPE)) |
| 408 | |
| 409 | GST_VIDEO_API |
| 410 | GstVideoAFDMeta *gst_buffer_add_video_afd_meta (GstBuffer * buffer, guint8 field, |
| 411 | GstVideoAFDSpec spec, |
| 412 | GstVideoAFDValue afd); |
| 413 | /** |
| 414 | * GstVideoBarMeta: |
| 415 | * @meta: parent #GstMeta |
| 416 | * @field: 0 for progressive or field 1 and 1 for field 2 |
| 417 | * @is_letterbox: if true then bar data specifies letterbox, otherwise pillarbox |
| 418 | * @bar_data1: If @is_letterbox is true, then the value specifies the |
| 419 | * last line of a horizontal letterbox bar area at top of reconstructed frame. |
| 420 | * Otherwise, it specifies the last horizontal luminance sample of a vertical pillarbox |
| 421 | * bar area at the left side of the reconstructed frame |
| 422 | * @bar_data2: If @is_letterbox is true, then the value specifies the |
| 423 | * first line of a horizontal letterbox bar area at bottom of reconstructed frame. |
| 424 | * Otherwise, it specifies the first horizontal |
| 425 | * luminance sample of a vertical pillarbox bar area at the right side of the reconstructed frame. |
| 426 | * |
| 427 | * Bar data should be included in video user data |
| 428 | * whenever the rectangular picture area containing useful information |
| 429 | * does not extend to the full height or width of the coded frame |
| 430 | * and AFD alone is insufficient to describe the extent of the image. |
| 431 | * |
| 432 | * Note: either vertical or horizontal bars are specified, but not both. |
| 433 | * |
| 434 | * For more details, see: |
| 435 | * |
| 436 | * https://www.atsc.org/wp-content/uploads/2015/03/a_53-Part-4-2009.pdf |
| 437 | * |
| 438 | * and SMPTE ST2016-1 |
| 439 | * |
| 440 | * Since: 1.18 |
| 441 | */ |
| 442 | typedef struct { |
| 443 | GstMeta meta; |
| 444 | |
| 445 | guint8 field; |
| 446 | gboolean is_letterbox; |
| 447 | guint bar_data1; |
| 448 | guint bar_data2; |
| 449 | } GstVideoBarMeta; |
| 450 | |
| 451 | GST_VIDEO_API GType gst_video_bar_meta_api_get_type (void); |
| 452 | #define GST_VIDEO_BAR_META_API_TYPE (gst_video_bar_meta_api_get_type()) |
| 453 | |
| 454 | GST_VIDEO_API const GstMetaInfo *gst_video_bar_meta_get_info (void); |
| 455 | #define GST_VIDEO_BAR_META_INFO (gst_video_bar_meta_get_info()) |
| 456 | /** |
| 457 | * gst_buffer_get_video_bar_meta: |
| 458 | * @b: A #GstBuffer |
| 459 | * |
| 460 | * Gets the #GstVideoBarMeta that might be present on @b. |
| 461 | * |
| 462 | * Since: 1.18 |
| 463 | * |
| 464 | * Returns: (nullable): The first #GstVideoBarMeta present on @b, or %NULL if |
| 465 | * no #GstVideoBarMeta are present |
| 466 | */ |
| 467 | #define gst_buffer_get_video_bar_meta(b) \ |
| 468 | ((GstVideoBarMeta*)gst_buffer_get_meta((b),GST_VIDEO_BAR_META_API_TYPE)) |
| 469 | |
| 470 | GST_VIDEO_API |
| 471 | GstVideoBarMeta *gst_buffer_add_video_bar_meta (GstBuffer * buffer, guint8 field, |
| 472 | gboolean is_letterbox, guint bar_data1, guint bar_data2); |
| 473 | |
| 474 | /* Closed Caption support */ |
| 475 | /** |
| 476 | * GstVideoCaptionType: |
| 477 | * @GST_VIDEO_CAPTION_TYPE_UNKNOWN: Unknown type of CC |
| 478 | * @GST_VIDEO_CAPTION_TYPE_CEA608_RAW: CEA-608 as byte pairs. Note that |
| 479 | * this format is not recommended since is does not specify to |
| 480 | * which field the caption comes from and therefore assumes |
| 481 | * it comes from the first field (and that there is no information |
| 482 | * on the second field). Use @GST_VIDEO_CAPTION_TYPE_CEA708_RAW |
| 483 | * if you wish to store CEA-608 from two fields and prefix each byte pair |
| 484 | * with 0xFC for the first field and 0xFD for the second field. |
| 485 | * @GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A: CEA-608 as byte triplets as defined |
| 486 | * in SMPTE S334-1 Annex A. The second and third byte of the byte triplet |
| 487 | * is the raw CEA608 data, the first byte is a bitfield: The top/7th bit is |
| 488 | * 0 for the second field, 1 for the first field, bit 6 and 5 are 0 and |
| 489 | * bits 4 to 0 are a 5 bit unsigned integer that represents the line |
| 490 | * offset relative to the base-line of the original image format (line 9 |
| 491 | * for 525-line field 1, line 272 for 525-line field 2, line 5 for |
| 492 | * 625-line field 1 and line 318 for 625-line field 2). |
| 493 | * @GST_VIDEO_CAPTION_TYPE_CEA708_RAW: CEA-708 as cc_data byte triplets. They |
| 494 | * can also contain 608-in-708 and the first byte of each triplet has to |
| 495 | * be inspected for detecting the type. |
| 496 | * @GST_VIDEO_CAPTION_TYPE_CEA708_CDP: CEA-708 (and optionally CEA-608) in |
| 497 | * a CDP (Caption Distribution Packet) defined by SMPTE S-334-2. |
| 498 | * Contains the whole CDP (starting with 0x9669). |
| 499 | * |
| 500 | * The various known types of Closed Caption (CC). |
| 501 | * |
| 502 | * Since: 1.16 |
| 503 | */ |
| 504 | typedef enum { |
| 505 | GST_VIDEO_CAPTION_TYPE_UNKNOWN = 0, |
| 506 | GST_VIDEO_CAPTION_TYPE_CEA608_RAW = 1, |
| 507 | GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A = 2, |
| 508 | GST_VIDEO_CAPTION_TYPE_CEA708_RAW = 3, |
| 509 | GST_VIDEO_CAPTION_TYPE_CEA708_CDP = 4 |
| 510 | } GstVideoCaptionType; |
| 511 | |
| 512 | GST_VIDEO_API |
| 513 | GstVideoCaptionType |
| 514 | gst_video_caption_type_from_caps (const GstCaps *caps); |
| 515 | |
| 516 | GST_VIDEO_API |
| 517 | GstCaps * |
| 518 | gst_video_caption_type_to_caps (GstVideoCaptionType type); |
| 519 | |
| 520 | /** |
| 521 | * GstVideoCaptionMeta: |
| 522 | * @meta: parent #GstMeta |
| 523 | * @caption_type: The type of Closed Caption contained in the meta. |
| 524 | * @data: (array length=size): The Closed Caption data. |
| 525 | * @size: The size in bytes of @data |
| 526 | * |
| 527 | * Extra buffer metadata providing Closed Caption. |
| 528 | * |
| 529 | * Since: 1.16 |
| 530 | */ |
| 531 | typedef struct { |
| 532 | GstMeta meta; |
| 533 | |
| 534 | GstVideoCaptionType caption_type; |
| 535 | guint8 *data; |
| 536 | gsize size; |
| 537 | } GstVideoCaptionMeta; |
| 538 | |
| 539 | GST_VIDEO_API |
| 540 | GType gst_video_caption_meta_api_get_type (void); |
| 541 | #define GST_VIDEO_CAPTION_META_API_TYPE (gst_video_caption_meta_api_get_type()) |
| 542 | |
| 543 | GST_VIDEO_API |
| 544 | const GstMetaInfo *gst_video_caption_meta_get_info (void); |
| 545 | #define GST_VIDEO_CAPTION_META_INFO (gst_video_caption_meta_get_info()) |
| 546 | |
| 547 | /** |
| 548 | * gst_buffer_get_video_caption_meta: |
| 549 | * @b: A #GstBuffer |
| 550 | * |
| 551 | * Gets the #GstVideoCaptionMeta that might be present on @b. |
| 552 | * |
| 553 | * Since: 1.16 |
| 554 | * |
| 555 | * Returns: (nullable): The first #GstVideoCaptionMeta present on @b, or %NULL if |
| 556 | * no #GstVideoCaptionMeta are present |
| 557 | */ |
| 558 | #define gst_buffer_get_video_caption_meta(b) \ |
| 559 | ((GstVideoCaptionMeta*)gst_buffer_get_meta((b),GST_VIDEO_CAPTION_META_API_TYPE)) |
| 560 | |
| 561 | GST_VIDEO_API |
| 562 | GstVideoCaptionMeta *gst_buffer_add_video_caption_meta (GstBuffer * buffer, |
| 563 | GstVideoCaptionType caption_type, |
| 564 | const guint8 *data, |
| 565 | gsize size); |
| 566 | |
| 567 | /** |
| 568 | * GstVideoVBIParser: |
| 569 | * |
| 570 | * A parser for detecting and extracting @GstVideoAncillary data from |
| 571 | * Vertical Blanking Interval lines of component signals. |
| 572 | * |
| 573 | * Since: 1.16 |
| 574 | */ |
| 575 | |
| 576 | typedef struct _GstVideoVBIParser GstVideoVBIParser; |
| 577 | |
| 578 | GST_VIDEO_API |
| 579 | GType gst_video_vbi_parser_get_type (void); |
| 580 | |
| 581 | /** |
| 582 | * GstVideoVBIParserResult: |
| 583 | * @GST_VIDEO_VBI_PARSER_RESULT_DONE: No line were provided, or no more Ancillary data was found. |
| 584 | * @GST_VIDEO_VBI_PARSER_RESULT_OK: A #GstVideoAncillary was found. |
| 585 | * @GST_VIDEO_VBI_PARSER_RESULT_ERROR: An error occurred |
| 586 | * |
| 587 | * Return values for #GstVideoVBIParser |
| 588 | * |
| 589 | * Since: 1.16 |
| 590 | */ |
| 591 | typedef enum { |
| 592 | GST_VIDEO_VBI_PARSER_RESULT_DONE = 0, |
| 593 | GST_VIDEO_VBI_PARSER_RESULT_OK = 1, |
| 594 | GST_VIDEO_VBI_PARSER_RESULT_ERROR = 2 |
| 595 | } GstVideoVBIParserResult; |
| 596 | |
| 597 | GST_VIDEO_API |
| 598 | GstVideoVBIParserResult gst_video_vbi_parser_get_ancillary(GstVideoVBIParser *parser, |
| 599 | GstVideoAncillary *anc); |
| 600 | |
| 601 | GST_VIDEO_API |
| 602 | GstVideoVBIParser *gst_video_vbi_parser_new (GstVideoFormat format, guint32 pixel_width); |
| 603 | |
| 604 | GST_VIDEO_API |
| 605 | GstVideoVBIParser *gst_video_vbi_parser_copy (const GstVideoVBIParser *parser); |
| 606 | |
| 607 | GST_VIDEO_API |
| 608 | void gst_video_vbi_parser_free (GstVideoVBIParser *parser); |
| 609 | |
| 610 | GST_VIDEO_API |
| 611 | void gst_video_vbi_parser_add_line (GstVideoVBIParser *parser, const guint8 *data); |
| 612 | |
| 613 | /** |
| 614 | * GstVideoVBIEncoder: |
| 615 | * |
| 616 | * An encoder for writing ancillary data to the |
| 617 | * Vertical Blanking Interval lines of component signals. |
| 618 | * |
| 619 | * Since: 1.16 |
| 620 | */ |
| 621 | |
| 622 | typedef struct _GstVideoVBIEncoder GstVideoVBIEncoder; |
| 623 | |
| 624 | GST_VIDEO_API |
| 625 | GType gst_video_vbi_encoder_get_type (void); |
| 626 | |
| 627 | GST_VIDEO_API |
| 628 | GstVideoVBIEncoder *gst_video_vbi_encoder_new (GstVideoFormat format, guint32 pixel_width); |
| 629 | |
| 630 | GST_VIDEO_API |
| 631 | GstVideoVBIEncoder *gst_video_vbi_encoder_copy (const GstVideoVBIEncoder *encoder); |
| 632 | |
| 633 | GST_VIDEO_API |
| 634 | void gst_video_vbi_encoder_free (GstVideoVBIEncoder *encoder); |
| 635 | |
| 636 | GST_VIDEO_API |
| 637 | gboolean gst_video_vbi_encoder_add_ancillary (GstVideoVBIEncoder *encoder, |
| 638 | gboolean composite, |
| 639 | guint8 DID, |
| 640 | guint8 SDID_block_number, |
| 641 | const guint8 *data, |
| 642 | guint data_count); |
| 643 | |
| 644 | GST_VIDEO_API |
| 645 | void gst_video_vbi_encoder_write_line (GstVideoVBIEncoder *encoder, guint8 *data); |
| 646 | |
| 647 | G_END_DECLS |
| 648 | |
| 649 | #endif /* __GST_VIDEO_ANC_H__ */ |
| 650 | |