contrib: gnutls: Drop pkgconfig patch for macOS
[vlc.git] / modules / codec / avcodec / fourcc.c
1 /*****************************************************************************
2  * fourcc.c: libavcodec <-> libvlc conversion routines
3  *****************************************************************************
4  * Copyright (C) 1999-2009 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Gildas Bazin <gbazin@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28
29 #include <vlc_common.h>
30 #include <vlc_codec.h>
31
32 #include <libavcodec/avcodec.h>
33 #include "avcodec.h"
34
35 /*****************************************************************************
36  * Codec fourcc -> libavcodec Codec_id mapping
37  * Sorted by AVCodecID enumeration order
38  *****************************************************************************/
39 struct vlc_avcodec_fourcc
40 {
41     vlc_fourcc_t i_fourcc;
42     unsigned i_codec;
43 };
44
45 /*
46  * Video Codecs
47  */
48 static const struct vlc_avcodec_fourcc video_codecs[] =
49 {
50     { VLC_CODEC_MP1V, AV_CODEC_ID_MPEG1VIDEO },
51     { VLC_CODEC_MP2V, AV_CODEC_ID_MPEG2VIDEO }, /* prefer MPEG2 over MPEG1 */
52     { VLC_CODEC_MPGV, AV_CODEC_ID_MPEG2VIDEO }, /* prefer MPEG2 over MPEG1 */
53     /* AV_CODEC_ID_MPEG2VIDEO_XVMC */
54     { VLC_CODEC_H261, AV_CODEC_ID_H261 },
55     { VLC_CODEC_H263, AV_CODEC_ID_H263 },
56     { VLC_CODEC_RV10, AV_CODEC_ID_RV10 },
57     { VLC_CODEC_RV13, AV_CODEC_ID_RV10 },
58     { VLC_CODEC_RV20, AV_CODEC_ID_RV20 },
59     { VLC_CODEC_MJPG, AV_CODEC_ID_MJPEG },
60     { VLC_CODEC_MJPGB, AV_CODEC_ID_MJPEGB },
61     { VLC_CODEC_LJPG, AV_CODEC_ID_LJPEG },
62     { VLC_CODEC_SP5X, AV_CODEC_ID_SP5X },
63     { VLC_CODEC_JPEGLS, AV_CODEC_ID_JPEGLS },
64     { VLC_CODEC_MP4V, AV_CODEC_ID_MPEG4 },
65     /* AV_CODEC_ID_RAWVIDEO */
66     { VLC_CODEC_DIV1, AV_CODEC_ID_MSMPEG4V1 },
67     { VLC_CODEC_DIV2, AV_CODEC_ID_MSMPEG4V2 },
68     { VLC_CODEC_DIV3, AV_CODEC_ID_MSMPEG4V3 },
69     { VLC_CODEC_WMV1, AV_CODEC_ID_WMV1 },
70     { VLC_CODEC_WMV2, AV_CODEC_ID_WMV2 },
71     { VLC_CODEC_H263P, AV_CODEC_ID_H263P },
72     { VLC_CODEC_H263I, AV_CODEC_ID_H263I },
73     { VLC_CODEC_FLV1, AV_CODEC_ID_FLV1 },
74     { VLC_CODEC_SVQ1, AV_CODEC_ID_SVQ1 },
75     { VLC_CODEC_SVQ3, AV_CODEC_ID_SVQ3 },
76     { VLC_CODEC_DV, AV_CODEC_ID_DVVIDEO },
77     { VLC_CODEC_HUFFYUV, AV_CODEC_ID_HUFFYUV },
78     { VLC_CODEC_CYUV, AV_CODEC_ID_CYUV },
79     { VLC_CODEC_H264, AV_CODEC_ID_H264 },
80     { VLC_CODEC_INDEO3, AV_CODEC_ID_INDEO3 },
81     { VLC_CODEC_VP3, AV_CODEC_ID_VP3 },
82     { VLC_CODEC_THEORA, AV_CODEC_ID_THEORA },
83 #if ( !defined( WORDS_BIGENDIAN ) )
84     /* Asus Video (Another thing that doesn't work on PPC) */
85     { VLC_CODEC_ASV1, AV_CODEC_ID_ASV1 },
86     { VLC_CODEC_ASV2, AV_CODEC_ID_ASV2 },
87 #endif
88     { VLC_CODEC_FFV1, AV_CODEC_ID_FFV1 },
89     { VLC_CODEC_4XM, AV_CODEC_ID_4XM },
90     { VLC_CODEC_VCR1, AV_CODEC_ID_VCR1 },
91     { VLC_CODEC_CLJR, AV_CODEC_ID_CLJR },
92     { VLC_CODEC_MDEC, AV_CODEC_ID_MDEC },
93     { VLC_CODEC_ROQ, AV_CODEC_ID_ROQ },
94     { VLC_CODEC_INTERPLAY, AV_CODEC_ID_INTERPLAY_VIDEO },
95     { VLC_CODEC_XAN_WC3, AV_CODEC_ID_XAN_WC3 },
96     { VLC_CODEC_XAN_WC4, AV_CODEC_ID_XAN_WC4 },
97     { VLC_CODEC_RPZA, AV_CODEC_ID_RPZA },
98     { VLC_CODEC_CINEPAK, AV_CODEC_ID_CINEPAK },
99     { VLC_CODEC_WS_VQA, AV_CODEC_ID_WS_VQA },
100     { VLC_CODEC_MSRLE, AV_CODEC_ID_MSRLE },
101     { VLC_CODEC_MSVIDEO1, AV_CODEC_ID_MSVIDEO1 },
102     { VLC_CODEC_IDCIN, AV_CODEC_ID_IDCIN },
103     { VLC_CODEC_8BPS, AV_CODEC_ID_8BPS },
104     { VLC_CODEC_SMC, AV_CODEC_ID_SMC },
105     { VLC_CODEC_FLIC, AV_CODEC_ID_FLIC },
106     { VLC_CODEC_TRUEMOTION1, AV_CODEC_ID_TRUEMOTION1 },
107     { VLC_CODEC_VMDVIDEO, AV_CODEC_ID_VMDVIDEO },
108     { VLC_CODEC_LCL_MSZH, AV_CODEC_ID_MSZH },
109     { VLC_CODEC_LCL_ZLIB, AV_CODEC_ID_ZLIB },
110     { VLC_CODEC_QTRLE, AV_CODEC_ID_QTRLE },
111     { VLC_CODEC_TSCC, AV_CODEC_ID_TSCC },
112     { VLC_CODEC_ULTI, AV_CODEC_ID_ULTI },
113     { VLC_CODEC_QDRAW, AV_CODEC_ID_QDRAW },
114     { VLC_CODEC_VIXL, AV_CODEC_ID_VIXL },
115     { VLC_CODEC_QPEG, AV_CODEC_ID_QPEG },
116     { VLC_CODEC_PNG, AV_CODEC_ID_PNG },
117     { VLC_CODEC_PPM, AV_CODEC_ID_PPM },
118     /* AV_CODEC_ID_PBM */
119     { VLC_CODEC_PGM, AV_CODEC_ID_PGM },
120     { VLC_CODEC_PGMYUV, AV_CODEC_ID_PGMYUV },
121     { VLC_CODEC_PAM, AV_CODEC_ID_PAM },
122     { VLC_CODEC_FFVHUFF, AV_CODEC_ID_FFVHUFF },
123     { VLC_CODEC_RV30, AV_CODEC_ID_RV30 },
124     { VLC_CODEC_RV40, AV_CODEC_ID_RV40 },
125     { VLC_CODEC_VC1,  AV_CODEC_ID_VC1 },
126     { VLC_CODEC_WMVA, AV_CODEC_ID_VC1 },
127     { VLC_CODEC_WMV3, AV_CODEC_ID_WMV3 },
128     { VLC_CODEC_WMVP, AV_CODEC_ID_WMV3 },
129     { VLC_CODEC_LOCO, AV_CODEC_ID_LOCO },
130     { VLC_CODEC_WNV1, AV_CODEC_ID_WNV1 },
131     { VLC_CODEC_AASC, AV_CODEC_ID_AASC },
132     { VLC_CODEC_INDEO2, AV_CODEC_ID_INDEO2 },
133     { VLC_CODEC_FRAPS, AV_CODEC_ID_FRAPS },
134     { VLC_CODEC_TRUEMOTION2, AV_CODEC_ID_TRUEMOTION2 },
135     { VLC_CODEC_BMP, AV_CODEC_ID_BMP },
136     { VLC_CODEC_CSCD, AV_CODEC_ID_CSCD },
137     { VLC_CODEC_MMVIDEO, AV_CODEC_ID_MMVIDEO },
138     { VLC_CODEC_ZMBV, AV_CODEC_ID_ZMBV },
139     { VLC_CODEC_AVS, AV_CODEC_ID_AVS },
140     { VLC_CODEC_SMACKVIDEO, AV_CODEC_ID_SMACKVIDEO },
141     { VLC_CODEC_NUV, AV_CODEC_ID_NUV },
142     { VLC_CODEC_KMVC, AV_CODEC_ID_KMVC },
143     { VLC_CODEC_FLASHSV, AV_CODEC_ID_FLASHSV },
144     { VLC_CODEC_CAVS, AV_CODEC_ID_CAVS },
145     { VLC_CODEC_JPEG2000, AV_CODEC_ID_JPEG2000 },
146     { VLC_CODEC_VMNC, AV_CODEC_ID_VMNC },
147     { VLC_CODEC_VP5, AV_CODEC_ID_VP5 },
148     { VLC_CODEC_VP6, AV_CODEC_ID_VP6 },
149     { VLC_CODEC_VP6F, AV_CODEC_ID_VP6F },
150     { VLC_CODEC_TARGA, AV_CODEC_ID_TARGA },
151     { VLC_CODEC_DSICINVIDEO, AV_CODEC_ID_DSICINVIDEO },
152     { VLC_CODEC_TIERTEXSEQVIDEO, AV_CODEC_ID_TIERTEXSEQVIDEO },
153     { VLC_CODEC_TIFF, AV_CODEC_ID_TIFF },
154     { VLC_CODEC_GIF, AV_CODEC_ID_GIF },
155     { VLC_CODEC_DXA, AV_CODEC_ID_DXA },
156     { VLC_CODEC_DNXHD, AV_CODEC_ID_DNXHD },
157     { VLC_CODEC_THP, AV_CODEC_ID_THP },
158     { VLC_CODEC_SGI, AV_CODEC_ID_SGI },
159     { VLC_CODEC_C93, AV_CODEC_ID_C93 },
160     { VLC_CODEC_BETHSOFTVID, AV_CODEC_ID_BETHSOFTVID },
161     /* AV_CODEC_ID_PTX */
162     { VLC_CODEC_TXD, AV_CODEC_ID_TXD },
163     { VLC_CODEC_VP6A, AV_CODEC_ID_VP6A },
164     { VLC_CODEC_AMV, AV_CODEC_ID_AMV },
165     { VLC_CODEC_VB, AV_CODEC_ID_VB },
166     { VLC_CODEC_PCX, AV_CODEC_ID_PCX },
167     /* AV_CODEC_ID_SUNRAST */
168     { VLC_CODEC_INDEO4, AV_CODEC_ID_INDEO4 },
169     { VLC_CODEC_INDEO5, AV_CODEC_ID_INDEO5 },
170     { VLC_CODEC_MIMIC, AV_CODEC_ID_MIMIC },
171     { VLC_CODEC_RL2, AV_CODEC_ID_RL2 },
172     { VLC_CODEC_ESCAPE124, AV_CODEC_ID_ESCAPE124 },
173     { VLC_CODEC_DIRAC, AV_CODEC_ID_DIRAC },
174     { VLC_CODEC_BFI, AV_CODEC_ID_BFI },
175     { VLC_CODEC_CMV, AV_CODEC_ID_CMV },
176     { VLC_CODEC_MOTIONPIXELS, AV_CODEC_ID_MOTIONPIXELS },
177     { VLC_CODEC_TGV, AV_CODEC_ID_TGV },
178     { VLC_CODEC_TGQ, AV_CODEC_ID_TGQ },
179     { VLC_CODEC_TQI, AV_CODEC_ID_TQI },
180     { VLC_CODEC_AURA, AV_CODEC_ID_AURA },
181     /* AV_CODEC_ID_AURA2 */
182     /* AV_CODEC_ID_V210X */
183     { VLC_CODEC_TMV, AV_CODEC_ID_TMV },
184     { VLC_CODEC_V210, AV_CODEC_ID_V210 },
185     /* AV_CODEC_ID_DPX */
186     { VLC_CODEC_MAD, AV_CODEC_ID_MAD },
187     { VLC_CODEC_FRWU, AV_CODEC_ID_FRWU },
188     { VLC_CODEC_FLASHSV2, AV_CODEC_ID_FLASHSV2 },
189     /* AV_CODEC_ID_CDGRAPHICS */
190     /* AV_CODEC_ID_R210 */
191     { VLC_CODEC_ANM, AV_CODEC_ID_ANM },
192     { VLC_CODEC_BINKVIDEO, AV_CODEC_ID_BINKVIDEO },
193     /* AV_CODEC_ID_IFF_ILBM */
194     /* AV_CODEC_ID_IFF_BYTERUN1 */
195     { VLC_CODEC_KGV1, AV_CODEC_ID_KGV1 },
196     { VLC_CODEC_YOP, AV_CODEC_ID_YOP },
197     { VLC_CODEC_VP8, AV_CODEC_ID_VP8 },
198     /* AV_CODEC_ID_PICTOR */
199     /* AV_CODEC_ID_ANSI */
200     /* AV_CODEC_ID_A64_MULTI */
201     /* AV_CODEC_ID_A64_MULTI5 */
202     /* AV_CODEC_ID_R10K */
203     { VLC_CODEC_MXPEG, AV_CODEC_ID_MXPEG },
204     { VLC_CODEC_LAGARITH, AV_CODEC_ID_LAGARITH },
205     { VLC_CODEC_PRORES, AV_CODEC_ID_PRORES },
206     { VLC_CODEC_JV, AV_CODEC_ID_JV },
207     { VLC_CODEC_DFA, AV_CODEC_ID_DFA },
208     { VLC_CODEC_WMVP, AV_CODEC_ID_WMV3IMAGE },
209     { VLC_CODEC_WMVP2, AV_CODEC_ID_VC1IMAGE },
210     { VLC_CODEC_UTVIDEO, AV_CODEC_ID_UTVIDEO },
211     { VLC_CODEC_BMVVIDEO, AV_CODEC_ID_BMV_VIDEO },
212     { VLC_CODEC_VBLE, AV_CODEC_ID_VBLE },
213     { VLC_CODEC_DXTORY, AV_CODEC_ID_DXTORY },
214     /* AV_CODEC_ID_V410 */
215     /* AV_CODEC_ID_XWD */
216     { VLC_CODEC_CDXL, AV_CODEC_ID_CDXL },
217     /* AV_CODEC_ID_XBM */
218     /* AV_CODEC_ID_ZEROCODEC */
219     { VLC_CODEC_MSS1, AV_CODEC_ID_MSS1 },
220     { VLC_CODEC_MSA1, AV_CODEC_ID_MSA1 },
221     { VLC_CODEC_TSC2, AV_CODEC_ID_TSCC2 },
222     { VLC_CODEC_MTS2, AV_CODEC_ID_MTS2 },
223     { VLC_CODEC_CLLC, AV_CODEC_ID_CLLC },
224     { VLC_CODEC_MSS2, AV_CODEC_ID_MSS2 },
225     { VLC_CODEC_VP9, AV_CODEC_ID_VP9 },
226     { VLC_CODEC_ICOD, AV_CODEC_ID_AIC },
227     /* AV_CODEC_ID_ESCAPE130 */
228     { VLC_CODEC_G2M4, AV_CODEC_ID_G2M },
229     { VLC_CODEC_G2M2, AV_CODEC_ID_G2M },
230     { VLC_CODEC_G2M3, AV_CODEC_ID_G2M },
231     /* AV_CODEC_ID_WEBP */
232     { VLC_CODEC_HNM4_VIDEO, AV_CODEC_ID_HNM4_VIDEO },
233     { VLC_CODEC_HEVC, AV_CODEC_ID_HEVC },
234
235     { VLC_CODEC_FIC , AV_CODEC_ID_FIC },
236     /* AV_CODEC_ID_ALIAS_PIX */
237     /* AV_CODEC_ID_BRENDER_PIX */
238     /* AV_CODEC_ID_PAF_VIDEO */
239     /* AV_CODEC_ID_EXR */
240
241     { VLC_CODEC_VP7 , AV_CODEC_ID_VP7 },
242     /* AV_CODEC_ID_SANM */
243     /* AV_CODEC_ID_SGIRLE */
244     /* AV_CODEC_ID_MVC1 */
245     /* AV_CODEC_ID_MVC2 */
246     { VLC_CODEC_HQX, AV_CODEC_ID_HQX },
247
248     { VLC_CODEC_TDSC, AV_CODEC_ID_TDSC },
249
250     { VLC_CODEC_HQ_HQA, AV_CODEC_ID_HQ_HQA },
251
252     { VLC_CODEC_HAP, AV_CODEC_ID_HAP },
253     /* AV_CODEC_ID_DDS */
254
255     { VLC_CODEC_DXV, AV_CODEC_ID_DXV },
256
257     /* ffmpeg only: AV_CODEC_ID_BRENDER_PIX */
258     /* ffmpeg only: AV_CODEC_ID_Y41P */
259     /* ffmpeg only: AV_CODEC_ID_EXR */
260     /* ffmpeg only: AV_CODEC_ID_AVRP */
261     /* ffmpeg only: AV_CODEC_ID_012V */
262     /* ffmpeg only: AV_CODEC_ID_AVUI */
263     /* ffmpeg only: AV_CODEC_ID_AYUV */
264     /* ffmpeg only: AV_CODEC_ID_TARGA_Y216 */
265     /* ffmpeg only: AV_CODEC_ID_V308 */
266     /* ffmpeg only: AV_CODEC_ID_V408 */
267     /* ffmpeg only: AV_CODEC_ID_YUV4 */
268     /* ffmpeg only: AV_CODEC_ID_SANM */
269     /* ffmpeg only: AV_CODEC_ID_PAF_VIDEO */
270     /* ffmpeg only: AV_CODEC_ID_AVRN */
271     /* ffmpeg only: AV_CODEC_ID_CPIA */
272     /* ffmpeg only: AV_CODEC_ID_XFACE */
273     /* ffmpeg only: AV_CODEC_ID_SGIRLE */
274     /* ffmpeg only: AV_CODEC_ID_MVC1 */
275     /* ffmpeg only: AV_CODEC_ID_MVC2 */
276     /* ffmpeg only: AV_CODEC_ID_SNOW */
277     /* ffmpeg only: AV_CODEC_ID_SMVJPEG */
278
279 #if LIBAVCODEC_VERSION_CHECK( 57, 999, 999, 70, 100 )
280     { VLC_CODEC_PIXLET, AV_CODEC_ID_PIXLET },
281 #endif
282
283 #if LIBAVCODEC_VERSION_CHECK( 57, 999, 999, 71, 101 )
284     { VLC_CODEC_SPEEDHQ, AV_CODEC_ID_SPEEDHQ },
285 #endif
286
287 #if LIBAVCODEC_VERSION_CHECK( 57, 999, 999, 79, 100 )
288     { VLC_CODEC_FMVC, AV_CODEC_ID_FMVC },
289 #endif
290 };
291
292 /*
293  *  Audio Codecs
294  */
295 static const struct vlc_avcodec_fourcc audio_codecs[] =
296 {
297     /* PCM */
298     { VLC_CODEC_S16L, AV_CODEC_ID_PCM_S16LE },
299     { VLC_CODEC_S16B, AV_CODEC_ID_PCM_S16BE },
300     { VLC_CODEC_U16L, AV_CODEC_ID_PCM_U16LE },
301     { VLC_CODEC_U16B, AV_CODEC_ID_PCM_U16BE },
302     { VLC_CODEC_S8, AV_CODEC_ID_PCM_S8 },
303     { VLC_CODEC_U8, AV_CODEC_ID_PCM_U8 },
304     { VLC_CODEC_MULAW, AV_CODEC_ID_PCM_MULAW },
305     { VLC_CODEC_ALAW, AV_CODEC_ID_PCM_ALAW },
306     { VLC_CODEC_S32L, AV_CODEC_ID_PCM_S32LE },
307     { VLC_CODEC_S32B, AV_CODEC_ID_PCM_S32BE },
308     { VLC_CODEC_U32L, AV_CODEC_ID_PCM_U32LE },
309     { VLC_CODEC_U32B, AV_CODEC_ID_PCM_U32BE },
310     { VLC_CODEC_S24L, AV_CODEC_ID_PCM_S24LE },
311     { VLC_CODEC_S24B, AV_CODEC_ID_PCM_S24BE },
312     { VLC_CODEC_U24L, AV_CODEC_ID_PCM_U24LE },
313     { VLC_CODEC_U24B, AV_CODEC_ID_PCM_U24BE },
314     { VLC_CODEC_S24DAUD, AV_CODEC_ID_PCM_S24DAUD },
315     /* AV_CODEC_ID_PCM_ZORK */
316     { VLC_CODEC_S16L_PLANAR, AV_CODEC_ID_PCM_S16LE_PLANAR },
317     /* AV_CODEC_ID_PCM_DVD */
318     { VLC_CODEC_F32B, AV_CODEC_ID_PCM_F32BE },
319     { VLC_CODEC_F32L, AV_CODEC_ID_PCM_F32LE },
320     { VLC_CODEC_F64B, AV_CODEC_ID_PCM_F64BE },
321     { VLC_CODEC_F64L, AV_CODEC_ID_PCM_F64LE },
322     { VLC_CODEC_BD_LPCM, AV_CODEC_ID_PCM_BLURAY },
323     /* AV_CODEC_ID_PCM_LXF */
324     /* AV_CODEC_ID_S302M */
325     /* AV_CODEC_ID_PCM_S8_PLANAR */
326     /* AV_CODEC_ID_PCM_S24LE_PLANAR */
327     /* AV_CODEC_ID_PCM_S32LE_PLANAR */
328     /* ffmpeg only: AV_CODEC_ID_PCM_S16BE_PLANAR */
329
330     /* ADPCM */
331     { VLC_CODEC_ADPCM_IMA_QT, AV_CODEC_ID_ADPCM_IMA_QT },
332     { VLC_CODEC_ADPCM_IMA_WAV, AV_CODEC_ID_ADPCM_IMA_WAV },
333     /* AV_CODEC_ID_ADPCM_IMA_DK3 */
334     /* AV_CODEC_ID_ADPCM_IMA_DK4 */
335     { VLC_CODEC_ADPCM_IMA_WS, AV_CODEC_ID_ADPCM_IMA_WS },
336     /* AV_CODEC_ID_ADPCM_IMA_SMJPEG */
337     { VLC_CODEC_ADPCM_MS, AV_CODEC_ID_ADPCM_MS },
338     { VLC_CODEC_ADPCM_4XM, AV_CODEC_ID_ADPCM_4XM },
339     { VLC_CODEC_ADPCM_XA, AV_CODEC_ID_ADPCM_XA },
340     { VLC_CODEC_ADPCM_ADX, AV_CODEC_ID_ADPCM_ADX },
341     { VLC_CODEC_ADPCM_EA, AV_CODEC_ID_ADPCM_EA },
342     { VLC_CODEC_ADPCM_G726, AV_CODEC_ID_ADPCM_G726 },
343     { VLC_CODEC_ADPCM_CREATIVE, AV_CODEC_ID_ADPCM_CT },
344     { VLC_CODEC_ADPCM_SWF, AV_CODEC_ID_ADPCM_SWF },
345     { VLC_CODEC_ADPCM_YAMAHA, AV_CODEC_ID_ADPCM_YAMAHA },
346     { VLC_CODEC_ADPCM_SBPRO_4, AV_CODEC_ID_ADPCM_SBPRO_4 },
347     { VLC_CODEC_ADPCM_SBPRO_3, AV_CODEC_ID_ADPCM_SBPRO_3 },
348     { VLC_CODEC_ADPCM_SBPRO_2, AV_CODEC_ID_ADPCM_SBPRO_2 },
349     { VLC_CODEC_ADPCM_THP, AV_CODEC_ID_ADPCM_THP },
350     { VLC_CODEC_ADPCM_IMA_AMV, AV_CODEC_ID_ADPCM_IMA_AMV },
351     { VLC_CODEC_ADPCM_EA_R1, AV_CODEC_ID_ADPCM_EA_R1 },
352     /* AV_CODEC_ID_ADPCM_EA_R3 */
353     /* AV_CODEC_ID_ADPCM_EA_R2 */
354     { VLC_CODEC_ADPCM_IMA_EA_SEAD, AV_CODEC_ID_ADPCM_IMA_EA_SEAD },
355     /* AV_CODEC_ID_ADPCM_IMA_EA_EACS */
356     /* AV_CODEC_ID_ADPCM_EA_XAS */
357     /* AV_CODEC_ID_ADPCM_EA_MAXIS_XA */
358     /* AV_CODEC_ID_ADPCM_IMA_ISS */
359     { VLC_CODEC_ADPCM_G722, AV_CODEC_ID_ADPCM_G722 },
360     { VLC_CODEC_ADPCM_IMA_APC, AV_CODEC_ID_ADPCM_IMA_APC },
361     /* ffmpeg only: AV_CODEC_ID_VIMA */
362     /* ffmpeg only: AV_CODEC_ID_ADPCM_AFC */
363     /* ffmpeg only: AV_CODEC_ID_ADPCM_IMA_OKI */
364     /* ffmpeg only: AV_CODEC_ID_ADPCM_DTK */
365     /* ffmpeg only: AV_CODEC_ID_ADPCM_IMA_RAD */
366     /* ffmpeg only: AV_CODEC_ID_ADPCM_G726LE */
367
368     /* AMR */
369     { VLC_CODEC_AMR_NB, AV_CODEC_ID_AMR_NB },
370     { VLC_CODEC_AMR_WB, AV_CODEC_ID_AMR_WB },
371
372     /* RealAudio */
373     { VLC_CODEC_RA_144, AV_CODEC_ID_RA_144 },
374     { VLC_CODEC_RA_288, AV_CODEC_ID_RA_288 },
375
376     /* DPCM */
377     { VLC_CODEC_ROQ_DPCM, AV_CODEC_ID_ROQ_DPCM },
378     { VLC_CODEC_INTERPLAY_DPCM, AV_CODEC_ID_INTERPLAY_DPCM },
379     /* AV_CODEC_ID_XAN_DPCM */
380     /* AV_CODEC_ID_SOL_DPCM */
381
382     /* audio codecs */
383     { VLC_CODEC_MPGA, AV_CODEC_ID_MP2 },
384     { VLC_CODEC_MP2, AV_CODEC_ID_MP2 },
385     { VLC_CODEC_MP3, AV_CODEC_ID_MP3 },
386     { VLC_CODEC_MP4A, AV_CODEC_ID_AAC },
387     { VLC_CODEC_A52, AV_CODEC_ID_AC3 },
388     { VLC_CODEC_DTS, AV_CODEC_ID_DTS },
389     { VLC_CODEC_VORBIS, AV_CODEC_ID_VORBIS },
390     { VLC_CODEC_DVAUDIO, AV_CODEC_ID_DVAUDIO },
391     { VLC_CODEC_WMA1, AV_CODEC_ID_WMAV1 },
392     { VLC_CODEC_WMA2, AV_CODEC_ID_WMAV2 },
393     { VLC_CODEC_MACE3, AV_CODEC_ID_MACE3 },
394     { VLC_CODEC_MACE6, AV_CODEC_ID_MACE6 },
395     { VLC_CODEC_VMDAUDIO, AV_CODEC_ID_VMDAUDIO },
396     { VLC_CODEC_FLAC, AV_CODEC_ID_FLAC },
397     /* AV_CODEC_ID_MP3ADU */
398     /* AV_CODEC_ID_MP3ON4 */
399     { VLC_CODEC_SHORTEN, AV_CODEC_ID_SHORTEN },
400     { VLC_CODEC_ALAC, AV_CODEC_ID_ALAC },
401     /* AV_CODEC_ID_WESTWOOD_SND1 */
402     { VLC_CODEC_GSM, AV_CODEC_ID_GSM },
403     { VLC_CODEC_QDM2, AV_CODEC_ID_QDM2 },
404 #if LIBAVCODEC_VERSION_CHECK( 57, 999, 999, 71, 100 )
405     { VLC_CODEC_QDMC, AV_CODEC_ID_QDMC },
406 #endif
407     { VLC_CODEC_COOK, AV_CODEC_ID_COOK },
408     { VLC_CODEC_TRUESPEECH, AV_CODEC_ID_TRUESPEECH },
409     { VLC_CODEC_TTA, AV_CODEC_ID_TTA },
410     { VLC_CODEC_SMACKAUDIO, AV_CODEC_ID_SMACKAUDIO },
411     { VLC_CODEC_QCELP, AV_CODEC_ID_QCELP },
412     { VLC_CODEC_WAVPACK, AV_CODEC_ID_WAVPACK },
413     { VLC_CODEC_DSICINAUDIO, AV_CODEC_ID_DSICINAUDIO },
414     { VLC_CODEC_IMC, AV_CODEC_ID_IMC },
415     { VLC_CODEC_MUSEPACK7, AV_CODEC_ID_MUSEPACK7 },
416     { VLC_CODEC_MLP, AV_CODEC_ID_MLP },
417     { VLC_CODEC_GSM_MS, AV_CODEC_ID_GSM_MS },
418     { VLC_CODEC_ATRAC3, AV_CODEC_ID_ATRAC3 },
419     { VLC_CODEC_APE, AV_CODEC_ID_APE },
420     { VLC_CODEC_NELLYMOSER, AV_CODEC_ID_NELLYMOSER },
421     { VLC_CODEC_MUSEPACK8, AV_CODEC_ID_MUSEPACK8 },
422     { VLC_CODEC_SPEEX, AV_CODEC_ID_SPEEX },
423     { VLC_CODEC_WMAS, AV_CODEC_ID_WMAVOICE },
424     { VLC_CODEC_WMAP, AV_CODEC_ID_WMAPRO },
425     { VLC_CODEC_WMAL, AV_CODEC_ID_WMALOSSLESS },
426     { VLC_CODEC_ATRAC3P, AV_CODEC_ID_ATRAC3P },
427     { VLC_CODEC_EAC3, AV_CODEC_ID_EAC3 },
428     { VLC_CODEC_SIPR, AV_CODEC_ID_SIPR },
429     /* AV_CODEC_ID_MP1 */
430     { VLC_CODEC_TWINVQ, AV_CODEC_ID_TWINVQ },
431     { VLC_CODEC_TRUEHD, AV_CODEC_ID_TRUEHD },
432     { VLC_CODEC_ALS, AV_CODEC_ID_MP4ALS },
433     { VLC_CODEC_ATRAC1, AV_CODEC_ID_ATRAC1 },
434     { VLC_CODEC_BINKAUDIO_RDFT, AV_CODEC_ID_BINKAUDIO_RDFT },
435     { VLC_CODEC_BINKAUDIO_DCT, AV_CODEC_ID_BINKAUDIO_DCT },
436     { VLC_CODEC_MP4A, AV_CODEC_ID_AAC_LATM },
437     /* AV_CODEC_ID_QDMC */
438     /* AV_CODEC_ID_CELT */
439     { VLC_CODEC_G723_1, AV_CODEC_ID_G723_1 },
440     /* AV_CODEC_ID_G729 */
441     /* AV_CODEC_ID_8SVX_EXP */
442     /* AV_CODEC_ID_8SVX_FIB */
443     { VLC_CODEC_BMVAUDIO, AV_CODEC_ID_BMV_AUDIO },
444     { VLC_CODEC_RALF, AV_CODEC_ID_RALF },
445     { VLC_CODEC_INDEO_AUDIO, AV_CODEC_ID_IAC },
446     /* AV_CODEC_ID_ILBC */
447     { VLC_CODEC_OPUS, AV_CODEC_ID_OPUS },
448     /* AV_CODEC_ID_COMFORT_NOISE */
449     { VLC_CODEC_TAK, AV_CODEC_ID_TAK },
450     { VLC_CODEC_METASOUND, AV_CODEC_ID_METASOUND },
451     /* AV_CODEC_ID_PAF_AUDIO */
452     { VLC_CODEC_ON2AVC, AV_CODEC_ID_ON2AVC },
453
454     /* ffmpeg only: AV_CODEC_ID_FFWAVESYNTH */
455     /* ffmpeg only: AV_CODEC_ID_SONIC */
456     /* ffmpeg only: AV_CODEC_ID_SONIC_LS */
457     /* ffmpeg only: AV_CODEC_ID_PAF_AUDIO */
458     /* ffmpeg only: AV_CODEC_ID_EVRC */
459     /* ffmpeg only: AV_CODEC_ID_SMV */
460 };
461
462 /* Subtitle streams */
463 static const struct vlc_avcodec_fourcc spu_codecs[] =
464 {
465     { VLC_CODEC_SPU, AV_CODEC_ID_DVD_SUBTITLE },
466     { VLC_CODEC_DVBS, AV_CODEC_ID_DVB_SUBTITLE },
467     { VLC_CODEC_SUBT, AV_CODEC_ID_TEXT },
468     { VLC_CODEC_XSUB, AV_CODEC_ID_XSUB },
469     { VLC_CODEC_SSA, AV_CODEC_ID_SSA },
470     /* AV_CODEC_ID_MOV_TEXT */
471     { VLC_CODEC_BD_PG, AV_CODEC_ID_HDMV_PGS_SUBTITLE },
472 #if LIBAVCODEC_VERSION_CHECK( 57, 999, 999, 71, 100 )
473     { VLC_CODEC_BD_TEXT, AV_CODEC_ID_HDMV_TEXT_SUBTITLE },
474 #endif
475     { VLC_CODEC_TELETEXT, AV_CODEC_ID_DVB_TELETEXT },
476     /* AV_CODEC_ID_SRT */
477     /* ffmpeg only: AV_CODEC_ID_MICRODVD */
478     /* ffmpeg only: AV_CODEC_ID_EIA_608 */
479     /* ffmpeg only: AV_CODEC_ID_JACOSUB */
480     /* ffmpeg only: AV_CODEC_ID_SAMI */
481     /* ffmpeg only: AV_CODEC_ID_REALTEXT */
482     /* ffmpeg only: AV_CODEC_ID_SUBVIEWER1 */
483     /* ffmpeg only: AV_CODEC_ID_SUBVIEWER */
484     /* ffmpeg only: AV_CODEC_ID_SUBRIP */
485     /* ffmpeg only: AV_CODEC_ID_WEBVTT */
486     /* ffmpeg only: AV_CODEC_ID_MPL2 */
487     /* ffmpeg only: AV_CODEC_ID_VPLAYER */
488     /* ffmpeg only: AV_CODEC_ID_PJS */
489     /* ffmpeg only: AV_CODEC_ID_ASS */
490 };
491
492 bool GetFfmpegCodec( enum es_format_category_e cat, vlc_fourcc_t i_fourcc,
493                      unsigned *pi_ffmpeg_codec, const char **ppsz_name )
494 {
495     const struct vlc_avcodec_fourcc *base;
496     size_t count;
497
498     switch( cat )
499     {
500         case VIDEO_ES:
501             base = video_codecs;
502             count = ARRAY_SIZE(video_codecs);
503             break;
504         case AUDIO_ES:
505             base = audio_codecs;
506             count = ARRAY_SIZE(audio_codecs);
507             break;
508         case SPU_ES:
509             base = spu_codecs;
510             count = ARRAY_SIZE(spu_codecs);
511             break;
512         default:
513             base = NULL;
514             count = 0;
515     }
516
517     i_fourcc = vlc_fourcc_GetCodec( cat, i_fourcc );
518
519     for( size_t i = 0; i < count; i++ )
520     {
521         if( base[i].i_fourcc == i_fourcc )
522         {
523             if( pi_ffmpeg_codec != NULL )
524                 *pi_ffmpeg_codec = base[i].i_codec;
525             if( ppsz_name )
526                 *ppsz_name = vlc_fourcc_GetDescription( cat, i_fourcc );
527             return true;
528         }
529     }
530     return false;
531 }
532
533 vlc_fourcc_t GetVlcFourcc( unsigned i_ffmpeg_codec )
534 {
535     for( size_t i = 0; i < ARRAY_SIZE(video_codecs); i++ )
536     {
537         if( video_codecs[i].i_codec == i_ffmpeg_codec )
538             return video_codecs[i].i_fourcc;
539     }
540     for( size_t i = 0; i < ARRAY_SIZE(audio_codecs); i++ )
541     {
542         if( audio_codecs[i].i_codec == i_ffmpeg_codec )
543             return audio_codecs[i].i_fourcc;
544     }
545     for( size_t i = 0; i < ARRAY_SIZE(spu_codecs); i++ )
546     {
547         if( spu_codecs[i].i_codec == i_ffmpeg_codec )
548             return spu_codecs[i].i_fourcc;
549     }
550     return VLC_CODEC_UNKNOWN;
551 }