1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #ifndef MMAL_IL_H |
29 | #define MMAL_IL_H |
30 | |
31 | /** \defgroup MmalILUtility MMAL to OMX IL conversion utilities |
32 | * \ingroup MmalUtilities |
33 | * |
34 | * @{ |
35 | */ |
36 | |
37 | #ifdef __cplusplus |
38 | extern "C" { |
39 | #endif |
40 | |
41 | #include "interface/vmcs_host/khronos/IL/OMX_Core.h" |
42 | #include "interface/vmcs_host/khronos/IL/OMX_Component.h" |
43 | #include "interface/vmcs_host/khronos/IL/OMX_Video.h" |
44 | #include "interface/vmcs_host/khronos/IL/OMX_Audio.h" |
45 | #include "interface/vmcs_host/khronos/IL/OMX_Broadcom.h" |
46 | |
47 | /** Convert MMAL status codes into OMX error codes. |
48 | * |
49 | * @param status MMAL status code. |
50 | * @return OMX error code. |
51 | */ |
52 | OMX_ERRORTYPE mmalil_error_to_omx(MMAL_STATUS_T status); |
53 | |
54 | /** Convert OMX error codes into MMAL status codes. |
55 | * |
56 | * @param error OMX error code. |
57 | * @return MMAL status code. |
58 | */ |
59 | MMAL_STATUS_T mmalil_error_to_mmal(OMX_ERRORTYPE error); |
60 | |
61 | /** Convert MMAL buffer header flags into OMX buffer header flags. |
62 | * |
63 | * @param flags OMX buffer header flags. |
64 | * @return MMAL buffer header flags. |
65 | */ |
66 | uint32_t mmalil_buffer_flags_to_mmal(OMX_U32 flags); |
67 | |
68 | /** Convert OMX buffer header flags into MMAL buffer header flags. |
69 | * |
70 | * @param flags MMAL buffer header flags. |
71 | * @return OMX buffer header flags. |
72 | */ |
73 | OMX_U32 mmalil_buffer_flags_to_omx(uint32_t flags); |
74 | |
75 | /** Convert MMAL buffer header type video specific flags into OMX buffer header |
76 | * flags. |
77 | * |
78 | * @param flags OMX buffer header flags. |
79 | * @return MMAL buffer header video specific flags. |
80 | */ |
81 | uint32_t mmalil_video_buffer_flags_to_mmal(OMX_U32 flags); |
82 | |
83 | /** Convert OMX buffer header flags into MMAL buffer header type video specific |
84 | * flags. |
85 | * |
86 | * @param flags MMAL buffer header video specific flags. |
87 | * @return OMX buffer header flags. |
88 | */ |
89 | OMX_U32 mmalil_video_buffer_flags_to_omx(uint32_t flags); |
90 | |
91 | /** Convert a MMAL buffer header into an OMX buffer header. |
92 | * Note that only the fields which have a direct mapping between OMX and MMAL are converted. |
93 | * |
94 | * @param omx Pointer to the destination OMX buffer header. |
95 | * @param mmal Pointer to the source MMAL buffer header. |
96 | */ |
97 | void (OMX_BUFFERHEADERTYPE *omx, MMAL_BUFFER_HEADER_T *mmal); |
98 | |
99 | /** Convert an OMX buffer header into a MMAL buffer header. |
100 | * |
101 | * @param mmal Pointer to the destination MMAL buffer header. |
102 | * @param omx Pointer to the source OMX buffer header. |
103 | */ |
104 | void (MMAL_BUFFER_HEADER_T *mmal, OMX_BUFFERHEADERTYPE *omx); |
105 | |
106 | OMX_PORTDOMAINTYPE mmalil_es_type_to_omx_domain(MMAL_ES_TYPE_T type); |
107 | MMAL_ES_TYPE_T mmalil_omx_domain_to_es_type(OMX_PORTDOMAINTYPE domain); |
108 | uint32_t mmalil_omx_audio_coding_to_encoding(OMX_AUDIO_CODINGTYPE coding); |
109 | OMX_AUDIO_CODINGTYPE mmalil_encoding_to_omx_audio_coding(uint32_t encoding); |
110 | uint32_t mmalil_omx_video_coding_to_encoding(OMX_VIDEO_CODINGTYPE coding); |
111 | OMX_VIDEO_CODINGTYPE mmalil_encoding_to_omx_video_coding(uint32_t encoding); |
112 | uint32_t mmalil_omx_image_coding_to_encoding(OMX_IMAGE_CODINGTYPE coding); |
113 | OMX_IMAGE_CODINGTYPE mmalil_encoding_to_omx_image_coding(uint32_t encoding); |
114 | uint32_t mmalil_omx_coding_to_encoding(uint32_t encoding, OMX_PORTDOMAINTYPE domain); |
115 | uint32_t mmalil_omx_color_format_to_encoding(OMX_COLOR_FORMATTYPE coding); |
116 | OMX_COLOR_FORMATTYPE mmalil_encoding_to_omx_color_format(uint32_t encoding); |
117 | uint32_t mmalil_omx_bayer_format_order_to_encoding(OMX_BAYERORDERTYPE bayer_order, OMX_COLOR_FORMATTYPE color_format); |
118 | OMX_BAYERORDERTYPE mmalil_encoding_to_omx_bayer_order(uint32_t encoding); |
119 | uint32_t mmalil_omx_color_space_to_mmal(OMX_COLORSPACETYPE coding); |
120 | OMX_COLORSPACETYPE mmalil_color_space_to_omx(uint32_t coding); |
121 | uint32_t mmalil_omx_video_profile_to_mmal(OMX_U32 level, OMX_VIDEO_CODINGTYPE coding); |
122 | OMX_U32 mmalil_video_profile_to_omx(uint32_t profile); |
123 | uint32_t mmalil_omx_video_level_to_mmal(OMX_U32 level, OMX_VIDEO_CODINGTYPE coding); |
124 | OMX_U32 mmalil_video_level_to_omx(uint32_t level); |
125 | MMAL_VIDEO_RATECONTROL_T mmalil_omx_video_ratecontrol_to_mmal(OMX_VIDEO_CONTROLRATETYPE omx); |
126 | OMX_VIDEO_CONTROLRATETYPE mmalil_video_ratecontrol_to_omx(MMAL_VIDEO_RATECONTROL_T mmal); |
127 | MMAL_VIDEO_INTRA_REFRESH_T mmalil_omx_video_intrarefresh_to_mmal(OMX_VIDEO_INTRAREFRESHTYPE omx); |
128 | |
129 | /** Union of all the OMX_VIDEO/AUDIO_PARAM types */ |
130 | typedef union OMX_FORMAT_PARAM_TYPE { |
131 | OMX_PARAM_U32TYPE common; |
132 | |
133 | /* Video */ |
134 | OMX_VIDEO_PARAM_AVCTYPE avc; |
135 | OMX_VIDEO_PARAM_H263TYPE h263; |
136 | OMX_VIDEO_PARAM_MPEG2TYPE mpeg2; |
137 | OMX_VIDEO_PARAM_MPEG4TYPE mpeg4; |
138 | OMX_VIDEO_PARAM_WMVTYPE wmv; |
139 | OMX_VIDEO_PARAM_RVTYPE rv; |
140 | |
141 | /* Audio */ |
142 | OMX_AUDIO_PARAM_PCMMODETYPE pcm; |
143 | OMX_AUDIO_PARAM_MP3TYPE mp3; |
144 | OMX_AUDIO_PARAM_AACPROFILETYPE aac; |
145 | OMX_AUDIO_PARAM_VORBISTYPE vorbis; |
146 | OMX_AUDIO_PARAM_WMATYPE wma; |
147 | OMX_AUDIO_PARAM_RATYPE ra; |
148 | OMX_AUDIO_PARAM_SBCTYPE sbc; |
149 | OMX_AUDIO_PARAM_ADPCMTYPE adpcm; |
150 | OMX_AUDIO_PARAM_G723TYPE g723; |
151 | OMX_AUDIO_PARAM_G726TYPE g726; |
152 | OMX_AUDIO_PARAM_G729TYPE g729; |
153 | OMX_AUDIO_PARAM_AMRTYPE amr; |
154 | OMX_AUDIO_PARAM_GSMFRTYPE gsmfr; |
155 | OMX_AUDIO_PARAM_GSMHRTYPE gsmhr; |
156 | OMX_AUDIO_PARAM_GSMEFRTYPE gsmefr; |
157 | OMX_AUDIO_PARAM_TDMAFRTYPE tdmafr; |
158 | OMX_AUDIO_PARAM_TDMAEFRTYPE tdmaefr; |
159 | OMX_AUDIO_PARAM_PDCFRTYPE pdcfr; |
160 | OMX_AUDIO_PARAM_PDCEFRTYPE pdcefr; |
161 | OMX_AUDIO_PARAM_PDCHRTYPE pdchr; |
162 | OMX_AUDIO_PARAM_QCELP8TYPE qcelp8; |
163 | OMX_AUDIO_PARAM_QCELP13TYPE qcelp13; |
164 | OMX_AUDIO_PARAM_EVRCTYPE evrc; |
165 | OMX_AUDIO_PARAM_SMVTYPE smv; |
166 | OMX_AUDIO_PARAM_MIDITYPE midi; |
167 | #ifdef OMX_AUDIO_CodingDDP_Supported |
168 | OMX_AUDIO_PARAM_DDPTYPE ddp; |
169 | #endif |
170 | #ifdef OMX_AUDIO_CodingDTS_Supported |
171 | OMX_AUDIO_PARAM_DTSTYPE dts; |
172 | #endif |
173 | |
174 | } OMX_FORMAT_PARAM_TYPE; |
175 | |
176 | /** Get the OMX_IndexParamAudio index corresponding to a specified audio coding type. |
177 | * |
178 | * @param coding Audio coding type. |
179 | * @param size Pointer used to return the size of the parameter. |
180 | * |
181 | * @return OMX index or 0 if no match was found. |
182 | */ |
183 | OMX_INDEXTYPE mmalil_omx_audio_param_index(OMX_AUDIO_CODINGTYPE coding, OMX_U32 *size); |
184 | |
185 | /** Get the audio coding corresponding to a specified OMX_IndexParamAudio index. |
186 | * |
187 | * @param index Audio coding type. |
188 | * |
189 | * @return Audio coding type. |
190 | */ |
191 | OMX_AUDIO_CODINGTYPE mmalil_omx_audio_param_index_to_coding(OMX_INDEXTYPE index); |
192 | |
193 | /** Setup a default channel mapping based on the number of channels |
194 | * @param channel_mapping The output channel mapping |
195 | * @param nchannels Number of channels |
196 | * |
197 | * @return MMAL_SUCCESS if we managed to produce a channel mapping |
198 | */ |
199 | MMAL_STATUS_T mmalil_omx_default_channel_mapping(OMX_AUDIO_CHANNELTYPE *channel_mapping, unsigned int nchannels); |
200 | |
201 | /** Convert an OMX_IndexParamAudio into a MMAL elementary stream format. |
202 | * |
203 | * @param format Format structure to update. |
204 | * @param coding Audio coding type. |
205 | * @param param Source OMX_IndexParamAudio structure. |
206 | * |
207 | * @return The MMAL encoding if a match was found or MMAL_ENCODING_UNKNOWN otherwise. |
208 | */ |
209 | MMAL_FOURCC_T mmalil_omx_audio_param_to_format(MMAL_ES_FORMAT_T *format, |
210 | OMX_AUDIO_CODINGTYPE coding, OMX_FORMAT_PARAM_TYPE *param); |
211 | |
212 | /** Convert a MMAL elementary stream format into a OMX_IndexParamAudio structure. |
213 | * |
214 | * @param param OMX_IndexParamAudio structure to update. |
215 | * @param param_index returns the OMX_IndexParamAudio index corresponding to the format. |
216 | * @param format Source format structure. |
217 | * |
218 | * @return The OMX aduio coding type if a match was found or OMX_AUDIO_CodingUnused otherwise. |
219 | */ |
220 | OMX_AUDIO_CODINGTYPE mmalil_format_to_omx_audio_param(OMX_FORMAT_PARAM_TYPE *param, |
221 | OMX_INDEXTYPE *param_index, MMAL_ES_FORMAT_T *format); |
222 | |
223 | #ifdef __cplusplus |
224 | } |
225 | #endif |
226 | |
227 | /** @} */ |
228 | |
229 | #endif /* MMAL_IL_H */ |
230 | |