• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2019 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  * Authors: Simon Ser <simon.ser@intel.com>
24  */
25 
26 #ifndef IGT_INFOFRAME_H
27 #define IGT_INFOFRAME_H
28 
29 #include "config.h"
30 
31 #include <stdbool.h>
32 #include <stddef.h>
33 #include <stdint.h>
34 
35 enum infoframe_avi_rgb_ycbcr {
36 	INFOFRAME_AVI_RGB = 0,
37 	INFOFRAME_AVI_YCBCR422 = 1,
38 	INFOFRAME_AVI_YCBCR444 = 2,
39 	INFOFRAME_AVI_YCBCR420 = 3,
40 	INFOFRAME_AVI_IDO_DEFINED = 7,
41 };
42 
43 enum infoframe_avi_scan {
44 	INFOFRAME_AVI_SCAN_UNSPECIFIED = 0,
45 	INFOFRAME_AVI_OVERSCAN = 1,
46 	INFOFRAME_AVI_UNDERSCAN = 2,
47 };
48 
49 enum infoframe_avi_colorimetry {
50 	INFOFRAME_AVI_COLORIMETRY_UNSPECIFIED = 0,
51 	INFOFRAME_AVI_SMPTE_170M = 1,
52 	INFOFRAME_AVI_ITUR_BT709 = 2,
53 	INFOFRAME_AVI_COLORIMETRY_EXTENDED = 3,
54 };
55 
56 enum infoframe_avi_picture_aspect_ratio {
57 	INFOFRAME_AVI_PIC_AR_UNSPECIFIED = 0,
58 	INFOFRAME_AVI_PIC_AR_4_3 = 1,
59 	INFOFRAME_AVI_PIC_AR_16_9 = 2,
60 };
61 
62 enum infoframe_avi_active_aspect_ratio {
63 	INFOFRAME_AVI_ACT_AR_PIC = 8, /* same as picture aspect ratio */
64 	INFOFRAME_AVI_ACT_AR_4_3 = 9,
65 	INFOFRAME_AVI_ACT_AR_16_9 = 10,
66 	INFOFRAME_AVI_ACT_AR_14_9 = 11,
67 };
68 
69 #define INFOFRAME_AVI_VIC_UNSPECIFIED 0
70 
71 struct infoframe_avi {
72 	enum infoframe_avi_rgb_ycbcr rgb_ycbcr;
73 	enum infoframe_avi_scan scan;
74 	enum infoframe_avi_colorimetry colorimetry;
75 	enum infoframe_avi_picture_aspect_ratio picture_aspect_ratio;
76 	enum infoframe_avi_active_aspect_ratio active_aspect_ratio;
77 	uint8_t vic; /* Video Identification Code */
78 	/* TODO: remaining fields */
79 };
80 
81 enum infoframe_audio_coding_type {
82 	INFOFRAME_AUDIO_CT_UNSPECIFIED = 0, /* refer to stream header */
83 	INFOFRAME_AUDIO_CT_PCM = 1, /* IEC 60958 PCM */
84 	INFOFRAME_AUDIO_CT_AC3 = 2,
85 	INFOFRAME_AUDIO_CT_MPEG1 = 3,
86 	INFOFRAME_AUDIO_CT_MP3 = 4,
87 	INFOFRAME_AUDIO_CT_MPEG2 = 5,
88 	INFOFRAME_AUDIO_CT_AAC = 6,
89 	INFOFRAME_AUDIO_CT_DTS = 7,
90 	INFOFRAME_AUDIO_CT_ATRAC = 8,
91 	INFOFRAME_AUDIO_CT_ONE_BIT = 9,
92 	INFOFRAME_AUDIO_CT_DOLBY = 10, /* Dolby Digital + */
93 	INFOFRAME_AUDIO_CT_DTS_HD = 11,
94 	INFOFRAME_AUDIO_CT_MAT = 12,
95 	INFOFRAME_AUDIO_CT_DST = 13,
96 	INFOFRAME_AUDIO_CT_WMA_PRO = 14,
97 };
98 
99 struct infoframe_audio {
100 	enum infoframe_audio_coding_type coding_type;
101 	int channel_count; /* -1 if unspecified */
102 	int sampling_freq; /* in Hz, -1 if unspecified */
103 	int sample_size; /* in bits, -1 if unspecified */
104 	/* TODO: speaker allocation */
105 };
106 
107 bool infoframe_avi_parse(struct infoframe_avi *infoframe, int version,
108 			 const uint8_t *buf, size_t buf_size);
109 bool infoframe_audio_parse(struct infoframe_audio *infoframe, int version,
110 			   const uint8_t *buf, size_t buf_size);
111 
112 #endif
113