1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27#ifndef VC_CONTAINERS_CODECS_H
28#define VC_CONTAINERS_CODECS_H
29
30/** \file containers_codecs.h
31 * Codec helpers
32 */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include "containers/containers_types.h"
39
40/* Video */
41#define VC_CONTAINER_CODEC_MP1V VC_FOURCC('m','p','1','v')
42#define VC_CONTAINER_CODEC_MP2V VC_FOURCC('m','p','2','v')
43#define VC_CONTAINER_CODEC_MP4V VC_FOURCC('m','p','4','v')
44#define VC_CONTAINER_CODEC_DIV3 VC_FOURCC('d','i','v','3')
45#define VC_CONTAINER_CODEC_DIV4 VC_FOURCC('d','i','v','4')
46#define VC_CONTAINER_CODEC_H263 VC_FOURCC('h','2','6','3')
47#define VC_CONTAINER_CODEC_H264 VC_FOURCC('h','2','6','4')
48#define VC_CONTAINER_CODEC_MVC VC_FOURCC('m','v','c',' ')
49#define VC_CONTAINER_CODEC_WMV1 VC_FOURCC('w','m','v','1')
50#define VC_CONTAINER_CODEC_WMV2 VC_FOURCC('w','m','v','2')
51#define VC_CONTAINER_CODEC_WMV3 VC_FOURCC('w','m','v','3')
52#define VC_CONTAINER_CODEC_WVC1 VC_FOURCC('w','v','c','1')
53#define VC_CONTAINER_CODEC_WMVA VC_FOURCC('w','m','v','a')
54#define VC_CONTAINER_CODEC_MJPEG VC_FOURCC('m','j','p','g')
55#define VC_CONTAINER_CODEC_MJPEGA VC_FOURCC('m','j','p','a')
56#define VC_CONTAINER_CODEC_MJPEGB VC_FOURCC('m','j','p','b')
57#define VC_CONTAINER_CODEC_THEORA VC_FOURCC('t','h','e','o')
58#define VC_CONTAINER_CODEC_VP3 VC_FOURCC('v','p','3',' ')
59#define VC_CONTAINER_CODEC_VP6 VC_FOURCC('v','p','6',' ')
60#define VC_CONTAINER_CODEC_VP7 VC_FOURCC('v','p','7',' ')
61#define VC_CONTAINER_CODEC_VP8 VC_FOURCC('v','p','8',' ')
62#define VC_CONTAINER_CODEC_RV10 VC_FOURCC('r','v','1','0')
63#define VC_CONTAINER_CODEC_RV20 VC_FOURCC('r','v','2','0')
64#define VC_CONTAINER_CODEC_RV30 VC_FOURCC('r','v','3','0')
65#define VC_CONTAINER_CODEC_RV40 VC_FOURCC('r','v','4','0')
66#define VC_CONTAINER_CODEC_AVS VC_FOURCC('a','v','s',' ')
67#define VC_CONTAINER_CODEC_SPARK VC_FOURCC('s','p','r','k')
68#define VC_CONTAINER_CODEC_DIRAC VC_FOURCC('d','r','a','c')
69
70#define VC_CONTAINER_CODEC_YUV VC_FOURCC('y','u','v',' ')
71#define VC_CONTAINER_CODEC_I420 VC_FOURCC('I','4','2','0')
72#define VC_CONTAINER_CODEC_YV12 VC_FOURCC('Y','V','1','2')
73#define VC_CONTAINER_CODEC_I422 VC_FOURCC('I','4','2','2')
74#define VC_CONTAINER_CODEC_YUYV VC_FOURCC('Y','U','Y','V')
75#define VC_CONTAINER_CODEC_YVYU VC_FOURCC('Y','V','Y','U')
76#define VC_CONTAINER_CODEC_UYVY VC_FOURCC('U','Y','V','Y')
77#define VC_CONTAINER_CODEC_VYUY VC_FOURCC('V','Y','U','Y')
78#define VC_CONTAINER_CODEC_NV12 VC_FOURCC('N','V','1','2')
79#define VC_CONTAINER_CODEC_NV21 VC_FOURCC('N','V','2','1')
80#define VC_CONTAINER_CODEC_ARGB VC_FOURCC('A','R','G','B')
81#define VC_CONTAINER_CODEC_RGBA VC_FOURCC('R','G','B','A')
82#define VC_CONTAINER_CODEC_ABGR VC_FOURCC('A','B','G','R')
83#define VC_CONTAINER_CODEC_BGRA VC_FOURCC('B','G','R','A')
84#define VC_CONTAINER_CODEC_RGB16 VC_FOURCC('R','G','B','2')
85#define VC_CONTAINER_CODEC_RGB24 VC_FOURCC('R','G','B','3')
86#define VC_CONTAINER_CODEC_RGB32 VC_FOURCC('R','G','B','4')
87#define VC_CONTAINER_CODEC_BGR16 VC_FOURCC('B','G','R','2')
88#define VC_CONTAINER_CODEC_BGR24 VC_FOURCC('B','G','R','3')
89#define VC_CONTAINER_CODEC_BGR32 VC_FOURCC('B','G','R','4')
90#define VC_CONTAINER_CODEC_YUVUV128 VC_FOURCC('S','A','N','D')
91
92#define VC_CONTAINER_CODEC_JPEG VC_FOURCC('j','p','e','g')
93#define VC_CONTAINER_CODEC_PNG VC_FOURCC('p','n','g',' ')
94#define VC_CONTAINER_CODEC_GIF VC_FOURCC('g','i','f',' ')
95#define VC_CONTAINER_CODEC_PPM VC_FOURCC('p','p','m',' ')
96#define VC_CONTAINER_CODEC_TGA VC_FOURCC('t','g','a',' ')
97#define VC_CONTAINER_CODEC_BMP VC_FOURCC('b','m','p',' ')
98
99/* Audio */
100#define VC_CONTAINER_CODEC_PCM_UNSIGNED_BE VC_FOURCC('P','C','M','U')
101#define VC_CONTAINER_CODEC_PCM_UNSIGNED_LE VC_FOURCC('p','c','m','u')
102#define VC_CONTAINER_CODEC_PCM_SIGNED_BE VC_FOURCC('P','C','M','S')
103#define VC_CONTAINER_CODEC_PCM_SIGNED_LE VC_FOURCC('p','c','m','s')
104#define VC_CONTAINER_CODEC_PCM_FLOAT_BE VC_FOURCC('P','C','M','F')
105#define VC_CONTAINER_CODEC_PCM_FLOAT_LE VC_FOURCC('p','c','m','f')
106/* Defines for native endianness */
107#ifdef VC_CONTAINER_IS_BIG_ENDIAN
108#define VC_CONTAINER_CODEC_PCM_UNSIGNED VC_CONTAINER_CODEC_PCM_UNSIGNED_BE
109#define VC_CONTAINER_CODEC_PCM_SIGNED VC_CONTAINER_CODEC_PCM_SIGNED_BE
110#define VC_CONTAINER_CODEC_PCM_FLOAT VC_CONTAINER_CODEC_PCM_FLOAT_BE
111#else
112#define VC_CONTAINER_CODEC_PCM_UNSIGNED VC_CONTAINER_CODEC_PCM_UNSIGNED_LE
113#define VC_CONTAINER_CODEC_PCM_SIGNED VC_CONTAINER_CODEC_PCM_SIGNED_LE
114#define VC_CONTAINER_CODEC_PCM_FLOAT VC_CONTAINER_CODEC_PCM_FLOAT_LE
115#endif
116
117#define VC_CONTAINER_CODEC_MPGA VC_FOURCC('m','p','g','a')
118#define VC_CONTAINER_CODEC_MP4A VC_FOURCC('m','p','4','a')
119#define VC_CONTAINER_CODEC_ALAW VC_FOURCC('a','l','a','w')
120#define VC_CONTAINER_CODEC_MULAW VC_FOURCC('u','l','a','w')
121#define VC_CONTAINER_CODEC_ADPCM_MS VC_FOURCC('m','s',0x0,0x2)
122#define VC_CONTAINER_CODEC_ADPCM_IMA_MS VC_FOURCC('m','s',0x0,0x1)
123#define VC_CONTAINER_CODEC_ADPCM_SWF VC_FOURCC('a','s','w','f')
124#define VC_CONTAINER_CODEC_WMA1 VC_FOURCC('w','m','a','1')
125#define VC_CONTAINER_CODEC_WMA2 VC_FOURCC('w','m','a','2')
126#define VC_CONTAINER_CODEC_WMAP VC_FOURCC('w','m','a','p')
127#define VC_CONTAINER_CODEC_WMAL VC_FOURCC('w','m','a','l')
128#define VC_CONTAINER_CODEC_WMAV VC_FOURCC('w','m','a','v')
129#define VC_CONTAINER_CODEC_AMRNB VC_FOURCC('a','m','r','n')
130#define VC_CONTAINER_CODEC_AMRWB VC_FOURCC('a','m','r','w')
131#define VC_CONTAINER_CODEC_AMRWBP VC_FOURCC('a','m','r','p')
132#define VC_CONTAINER_CODEC_AC3 VC_FOURCC('a','c','3',' ')
133#define VC_CONTAINER_CODEC_EAC3 VC_FOURCC('e','a','c','3')
134#define VC_CONTAINER_CODEC_DTS VC_FOURCC('d','t','s',' ')
135#define VC_CONTAINER_CODEC_MLP VC_FOURCC('m','l','p',' ')
136#define VC_CONTAINER_CODEC_FLAC VC_FOURCC('f','l','a','c')
137#define VC_CONTAINER_CODEC_VORBIS VC_FOURCC('v','o','r','b')
138#define VC_CONTAINER_CODEC_SPEEX VC_FOURCC('s','p','x',' ')
139#define VC_CONTAINER_CODEC_ATRAC3 VC_FOURCC('a','t','r','3')
140#define VC_CONTAINER_CODEC_ATRACX VC_FOURCC('a','t','r','x')
141#define VC_CONTAINER_CODEC_ATRACL VC_FOURCC('a','t','r','l')
142#define VC_CONTAINER_CODEC_MIDI VC_FOURCC('m','i','d','i')
143#define VC_CONTAINER_CODEC_EVRC VC_FOURCC('e','v','r','c')
144#define VC_CONTAINER_CODEC_NELLYMOSER VC_FOURCC('n','e','l','y')
145#define VC_CONTAINER_CODEC_QCELP VC_FOURCC('q','c','e','l')
146
147/* Text */
148#define VC_CONTAINER_CODEC_TEXT VC_FOURCC('t','e','x','t')
149#define VC_CONTAINER_CODEC_SSA VC_FOURCC('s','s','a',' ')
150#define VC_CONTAINER_CODEC_USF VC_FOURCC('u','s','f',' ')
151#define VC_CONTAINER_CODEC_VOBSUB VC_FOURCC('v','s','u','b')
152
153#define VC_CONTAINER_CODEC_UNKNOWN VC_FOURCC('u','n','k','n')
154
155/* Codec variants */
156
157/** ISO 14496-10 Annex B byte stream format */
158#define VC_CONTAINER_VARIANT_H264_DEFAULT 0
159/** ISO 14496-15 AVC format (used in mp4/mkv and other containers) */
160#define VC_CONTAINER_VARIANT_H264_AVC1 VC_FOURCC('a','v','c','C')
161/** Implicitly delineated NAL units without emulation prevention */
162#define VC_CONTAINER_VARIANT_H264_RAW VC_FOURCC('r','a','w',' ')
163
164/** MPEG 1/2 Audio - Layer unknown */
165#define VC_CONTAINER_VARIANT_MPGA_DEFAULT 0
166/** MPEG 1/2 Audio - Layer 1 */
167#define VC_CONTAINER_VARIANT_MPGA_L1 VC_FOURCC('l','1',' ',' ')
168/** MPEG 1/2 Audio - Layer 2 */
169#define VC_CONTAINER_VARIANT_MPGA_L2 VC_FOURCC('l','2',' ',' ')
170/** MPEG 1/2 Audio - Layer 3 */
171#define VC_CONTAINER_VARIANT_MPGA_L3 VC_FOURCC('l','3',' ',' ')
172
173/** Converts a WaveFormat ID into a VC_CONTAINER_FOURCC_T.
174 *
175 * \param waveformat_id WaveFormat ID to convert
176 * \return a valid VC_CONTAINER_FOURCC_T or VC_CONTAINER_CODEC_UNKNOWN if no mapping was found.
177 */
178VC_CONTAINER_FOURCC_T waveformat_to_codec(uint16_t waveformat_id);
179
180/** Converts a VC_CONTAINER_FOURCC_T into a WaveFormat ID.
181 *
182 * \param codec VC_CONTAINER_FOURCC_T to convert
183 * \return a valid WaveFormat ID of 0 if no mapping was found.
184 */
185uint16_t codec_to_waveformat(VC_CONTAINER_FOURCC_T codec);
186
187/** Tries to convert a generic fourcc into a VC_CONTAINER_FOURCC_T.
188 *
189 * \param fourcc fourcc to convert
190 * \return a valid VC_CONTAINER_FOURCC_T or VC_CONTAINER_CODEC_UNKNOWN if no mapping was found.
191 */
192VC_CONTAINER_FOURCC_T fourcc_to_codec(uint32_t fourcc);
193
194uint32_t codec_to_fourcc(VC_CONTAINER_FOURCC_T codec);
195
196/** Tries to convert VideoForWindows fourcc into a VC_CONTAINER_FOURCC_T.
197 *
198 * \param fourcc vfw fourcc to convert
199 * \return a valid VC_CONTAINER_FOURCC_T or VC_CONTAINER_CODEC_UNKNOWN if no mapping was found.
200 */
201VC_CONTAINER_FOURCC_T vfw_fourcc_to_codec(uint32_t fourcc);
202
203/** Tries to convert a VC_CONTAINER_FOURCC_T into a VideoForWindows fourcc.
204 *
205 * \param codec VC_CONTAINER_FOURCC_T to convert
206 * \return a valid vfw fourcc or 0 if no mapping was found.
207 */
208uint32_t codec_to_vfw_fourcc(VC_CONTAINER_FOURCC_T codec);
209
210#ifdef __cplusplus
211}
212#endif
213
214#endif /* VC_CONTAINERS_CODECS_H */
215