fourcc.c 17.1 KB
Newer Older
1
/*****************************************************************************
2
 * fourcc.c: libavcodec <-> libvlc conversion routines
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
4
 * Copyright (C) 1999-2009 VLC authors and VideoLAN
5 6 7 8 9
 * $Id$
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *          Gildas Bazin <gbazin@videolan.org>
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
10 11 12
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
13 14 15 16
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
17 18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
19
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
20 21 22
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24
 *****************************************************************************/

25 26 27 28 29 30 31
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <vlc_common.h>
#include <vlc_codec.h>

32
#include <libavcodec/avcodec.h>
33 34
#include "avcodec.h"

35
/*****************************************************************************
36
 * Codec fourcc -> libavcodec Codec_id mapping
37
 *****************************************************************************/
38
static const struct
39
{
40 41 42
    vlc_fourcc_t i_fourcc;
    unsigned i_codec;
    int i_cat;
43 44 45 46 47 48
} codecs_table[] =
{
    /*
     * Video Codecs
     */

49 50
    { VLC_CODEC_MPGV, AV_CODEC_ID_MPEG2VIDEO, VIDEO_ES },
    { VLC_CODEC_MPGV, AV_CODEC_ID_MPEG1VIDEO, VIDEO_ES },
51

52
    { VLC_CODEC_MP4V, AV_CODEC_ID_MPEG4, VIDEO_ES },
53 54
    /* 3ivx delta 3.5 Unsupported
     * putting it here gives extreme distorted images
55 56
    { VLC_FOURCC('3','I','V','1'), AV_CODEC_ID_MPEG4, VIDEO_ES },
    { VLC_FOURCC('3','i','v','1'), AV_CODEC_ID_MPEG4, VIDEO_ES }, */
57

58 59 60
    { VLC_CODEC_DIV1, AV_CODEC_ID_MSMPEG4V1, VIDEO_ES },
    { VLC_CODEC_DIV2, AV_CODEC_ID_MSMPEG4V2, VIDEO_ES },
    { VLC_CODEC_DIV3, AV_CODEC_ID_MSMPEG4V3, VIDEO_ES },
61

62 63 64 65 66 67
    { VLC_CODEC_SVQ1, AV_CODEC_ID_SVQ1, VIDEO_ES },
    { VLC_CODEC_SVQ3, AV_CODEC_ID_SVQ3, VIDEO_ES },
    { VLC_CODEC_H264, AV_CODEC_ID_H264, VIDEO_ES },
    { VLC_CODEC_H263, AV_CODEC_ID_H263, VIDEO_ES },
    { VLC_CODEC_H263I, AV_CODEC_ID_H263I,VIDEO_ES },
    { VLC_CODEC_H263P, AV_CODEC_ID_H263P,VIDEO_ES },
68

69
    { VLC_CODEC_FLV1, AV_CODEC_ID_FLV1, VIDEO_ES },
70

71 72
    { VLC_CODEC_H261, AV_CODEC_ID_H261, VIDEO_ES },
    { VLC_CODEC_FLIC, AV_CODEC_ID_FLIC, VIDEO_ES },
73

74 75 76
    { VLC_CODEC_MJPG, AV_CODEC_ID_MJPEG, VIDEO_ES },
    { VLC_CODEC_MJPGB, AV_CODEC_ID_MJPEGB,VIDEO_ES },
    { VLC_CODEC_LJPG, AV_CODEC_ID_LJPEG, VIDEO_ES },
77

78
    { VLC_CODEC_SP5X, AV_CODEC_ID_SP5X, VIDEO_ES },
79

80
    { VLC_CODEC_DV,   AV_CODEC_ID_DVVIDEO, VIDEO_ES },
81

82 83 84 85
    { VLC_CODEC_WMV1, AV_CODEC_ID_WMV1, VIDEO_ES },
    { VLC_CODEC_WMV2, AV_CODEC_ID_WMV2, VIDEO_ES },
    { VLC_CODEC_WMV3, AV_CODEC_ID_WMV3, VIDEO_ES },
    { VLC_CODEC_WMVP, AV_CODEC_ID_WMV3, VIDEO_ES },
86

87 88
    { VLC_CODEC_VC1,  AV_CODEC_ID_VC1, VIDEO_ES },
    { VLC_CODEC_WMVA, AV_CODEC_ID_VC1, VIDEO_ES },
89

90 91
    { VLC_CODEC_MSVIDEO1, AV_CODEC_ID_MSVIDEO1, VIDEO_ES },
    { VLC_CODEC_MSRLE, AV_CODEC_ID_MSRLE, VIDEO_ES },
92

93
    { VLC_CODEC_INDEO2, AV_CODEC_ID_INDEO2, VIDEO_ES },
94
    /* Indeo Video Codecs (Quality of this decoder on ppc is not good) */
95
    { VLC_CODEC_INDEO3, AV_CODEC_ID_INDEO3, VIDEO_ES },
96

97 98 99
    { VLC_CODEC_HUFFYUV, AV_CODEC_ID_HUFFYUV, VIDEO_ES },
    { VLC_CODEC_FFVHUFF, AV_CODEC_ID_FFVHUFF, VIDEO_ES },
    { VLC_CODEC_CYUV, AV_CODEC_ID_CYUV, VIDEO_ES },
100

101 102 103 104 105
    { VLC_CODEC_VP3, AV_CODEC_ID_VP3, VIDEO_ES },
    { VLC_CODEC_VP5, AV_CODEC_ID_VP5, VIDEO_ES },
    { VLC_CODEC_VP6, AV_CODEC_ID_VP6, VIDEO_ES },
    { VLC_CODEC_VP6F, AV_CODEC_ID_VP6F, VIDEO_ES },
    { VLC_CODEC_VP6A, AV_CODEC_ID_VP6A, VIDEO_ES },
106

107
    { VLC_CODEC_THEORA, AV_CODEC_ID_THEORA, VIDEO_ES },
108 109 110

#if ( !defined( WORDS_BIGENDIAN ) )
    /* Asus Video (Another thing that doesn't work on PPC) */
111 112
    { VLC_CODEC_ASV1, AV_CODEC_ID_ASV1, VIDEO_ES },
    { VLC_CODEC_ASV2, AV_CODEC_ID_ASV2, VIDEO_ES },
113 114
#endif

115
    { VLC_CODEC_FFV1, AV_CODEC_ID_FFV1, VIDEO_ES },
116

117
    { VLC_CODEC_VCR1, AV_CODEC_ID_VCR1, VIDEO_ES },
118

119
    { VLC_CODEC_CLJR, AV_CODEC_ID_CLJR, VIDEO_ES },
120 121

    /* Real Video */
122 123 124 125 126
    { VLC_CODEC_RV10, AV_CODEC_ID_RV10, VIDEO_ES },
    { VLC_CODEC_RV13, AV_CODEC_ID_RV10, VIDEO_ES },
    { VLC_CODEC_RV20, AV_CODEC_ID_RV20, VIDEO_ES },
    { VLC_CODEC_RV30, AV_CODEC_ID_RV30, VIDEO_ES },
    { VLC_CODEC_RV40, AV_CODEC_ID_RV40, VIDEO_ES },
127

128
    { VLC_CODEC_RPZA, AV_CODEC_ID_RPZA, VIDEO_ES },
129

130
    { VLC_CODEC_SMC, AV_CODEC_ID_SMC, VIDEO_ES },
131

132
    { VLC_CODEC_CINEPAK, AV_CODEC_ID_CINEPAK, VIDEO_ES },
133

134
    { VLC_CODEC_TSCC, AV_CODEC_ID_TSCC, VIDEO_ES },
135

136
    { VLC_CODEC_CSCD, AV_CODEC_ID_CSCD, VIDEO_ES },
137

138
    { VLC_CODEC_ZMBV, AV_CODEC_ID_ZMBV, VIDEO_ES },
139

140 141
    { VLC_CODEC_VMNC, AV_CODEC_ID_VMNC, VIDEO_ES },
    { VLC_CODEC_FRAPS, AV_CODEC_ID_FRAPS, VIDEO_ES },
142

143 144
    { VLC_CODEC_TRUEMOTION1, AV_CODEC_ID_TRUEMOTION1, VIDEO_ES },
    { VLC_CODEC_TRUEMOTION2, AV_CODEC_ID_TRUEMOTION2, VIDEO_ES },
145

146
    { VLC_CODEC_QTRLE, AV_CODEC_ID_QTRLE, VIDEO_ES },
147

148
    { VLC_CODEC_QDRAW, AV_CODEC_ID_QDRAW, VIDEO_ES },
149

150
    { VLC_CODEC_QPEG, AV_CODEC_ID_QPEG, VIDEO_ES },
151

152
    { VLC_CODEC_ULTI, AV_CODEC_ID_ULTI, VIDEO_ES },
153

154
    { VLC_CODEC_VIXL, AV_CODEC_ID_VIXL, VIDEO_ES },
155

156
    { VLC_CODEC_LOCO, AV_CODEC_ID_LOCO, VIDEO_ES },
157

158
    { VLC_CODEC_WNV1, AV_CODEC_ID_WNV1, VIDEO_ES },
159

160
    { VLC_CODEC_AASC, AV_CODEC_ID_AASC, VIDEO_ES },
161

162 163
    { VLC_CODEC_FLASHSV, AV_CODEC_ID_FLASHSV, VIDEO_ES },
    { VLC_CODEC_KMVC, AV_CODEC_ID_KMVC, VIDEO_ES },
164

165
    { VLC_CODEC_NUV, AV_CODEC_ID_NUV, VIDEO_ES },
166

167
    { VLC_CODEC_SMACKVIDEO, AV_CODEC_ID_SMACKVIDEO, VIDEO_ES },
168 169

    /* Chinese AVS - Untested */
170
    { VLC_CODEC_CAVS, AV_CODEC_ID_CAVS, VIDEO_ES },
171 172

    /* Untested yet */
173 174
    { VLC_CODEC_DNXHD, AV_CODEC_ID_DNXHD, VIDEO_ES },
    { VLC_CODEC_8BPS, AV_CODEC_ID_8BPS, VIDEO_ES },
175

176
    { VLC_CODEC_MIMIC, AV_CODEC_ID_MIMIC, VIDEO_ES },
177

178
    { VLC_CODEC_DIRAC, AV_CODEC_ID_DIRAC, VIDEO_ES },
179

180
    { VLC_CODEC_V210, AV_CODEC_ID_V210, VIDEO_ES },
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
181

182
    { VLC_CODEC_FRWU, AV_CODEC_ID_FRWU, VIDEO_ES },
183

184
    { VLC_CODEC_INDEO5, AV_CODEC_ID_INDEO5, VIDEO_ES },
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
185

186
    { VLC_CODEC_VP8, AV_CODEC_ID_VP8, VIDEO_ES },
187

188
    { VLC_CODEC_LAGARITH, AV_CODEC_ID_LAGARITH, VIDEO_ES },
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
189

190
    { VLC_CODEC_MXPEG, AV_CODEC_ID_MXPEG, VIDEO_ES },
Sébastien Escudier's avatar
Sébastien Escudier committed
191

192
    { VLC_CODEC_VBLE, AV_CODEC_ID_VBLE, VIDEO_ES },
193

194
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 1, 0 )
195
    { VLC_CODEC_CDXL, AV_CODEC_ID_CDXL, VIDEO_ES },
196
#endif
197

198
    { VLC_CODEC_UTVIDEO, AV_CODEC_ID_UTVIDEO, VIDEO_ES },
199

200
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 42, 0 )
201
    { VLC_CODEC_DXTORY, AV_CODEC_ID_DXTORY, VIDEO_ES },
202
#endif
203

204
#if LIBAVCODEC_VERSION_CHECK( 54, 16, 0, 27, 100 )
205
    { VLC_CODEC_MSS1, AV_CODEC_ID_MSS1, VIDEO_ES },
206
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
207

208
#if LIBAVCODEC_VERSION_CHECK( 54, 17, 0, 32, 100 )
209
    { VLC_CODEC_MSA1, AV_CODEC_ID_MSA1, VIDEO_ES },
210
#endif
211

212
#if LIBAVCODEC_VERSION_CHECK( 54, 18, 0, 34, 100 )
213
    { VLC_CODEC_TSC2, AV_CODEC_ID_TSCC2, VIDEO_ES },
214
#endif
215

216
#if LIBAVCODEC_VERSION_CHECK( 54, 20, 0, 37, 100 )
217
    { VLC_CODEC_MTS2, AV_CODEC_ID_MTS2, VIDEO_ES },
218
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
219

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
220
#if LIBAVCODEC_VERSION_CHECK( 54, 27, 0, 55, 100 )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
221
    { VLC_CODEC_MSS2, AV_CODEC_ID_MSS2, VIDEO_ES },
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
222 223
#endif

224
#if LIBAVCODEC_VERSION_CHECK( 55, 24, 0, 37, 100 )
225 226 227
    { VLC_CODEC_HEVC, AV_CODEC_ID_HEVC, VIDEO_ES },
#endif

228 229 230 231
#if LIBAVCODEC_VERSION_CHECK( 54, 41, 0, 89, 100 )
    { VLC_CODEC_VP9, AV_CODEC_ID_VP9, VIDEO_ES },
#endif

232 233
    /* Videogames Codecs */

234
    { VLC_CODEC_INTERPLAY, AV_CODEC_ID_INTERPLAY_VIDEO, VIDEO_ES },
235

236
    { VLC_CODEC_IDCIN, AV_CODEC_ID_IDCIN, VIDEO_ES },
237

238
    { VLC_CODEC_4XM, AV_CODEC_ID_4XM, VIDEO_ES },
239

240
    { VLC_CODEC_ROQ, AV_CODEC_ID_ROQ, VIDEO_ES },
241

242
    { VLC_CODEC_MDEC, AV_CODEC_ID_MDEC, VIDEO_ES },
243

244
    { VLC_CODEC_VMDVIDEO, AV_CODEC_ID_VMDVIDEO, VIDEO_ES },
245

246
    { VLC_CODEC_AMV, AV_CODEC_ID_AMV, VIDEO_ES },
247

248
    { VLC_CODEC_FLASHSV2, AV_CODEC_ID_FLASHSV2, VIDEO_ES },
249

250 251
    { VLC_CODEC_WMVP, AV_CODEC_ID_WMV3IMAGE, VIDEO_ES },
    { VLC_CODEC_WMVP2, AV_CODEC_ID_VC1IMAGE, VIDEO_ES },
252

253
    { VLC_CODEC_PRORES, AV_CODEC_ID_PRORES, VIDEO_ES },
254

255
    { VLC_CODEC_INDEO4, AV_CODEC_ID_INDEO4, VIDEO_ES },
256

257
    { VLC_CODEC_BMVVIDEO, AV_CODEC_ID_BMV_VIDEO, VIDEO_ES },
258

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
259 260 261 262
#if LIBAVCODEC_VERSION_CHECK( 55, 5, 0, 10, 100 )
    { VLC_CODEC_ICOD, AV_CODEC_ID_AIC, VIDEO_ES },
#endif

263 264 265 266 267
#if LIBAVCODEC_VERSION_CHECK( 55, 8, 0, 15, 100 )
    { VLC_CODEC_G2M4, AV_CODEC_ID_G2M, VIDEO_ES },
#endif


268 269
#if 0
/*    UNTESTED VideoGames*/
270
    { VLC_FOURCC('W','C','3','V'), AV_CODEC_ID_XAN_WC3,
271
      VIDEO_ES, "XAN wc3 Video" },
272
    { VLC_FOURCC('W','C','4','V'), AV_CODEC_ID_XAN_WC4,
273
      VIDEO_ES, "XAN wc4 Video" },
274
    { VLC_FOURCC('S','T','3','C'), AV_CODEC_ID_TXD,
275
      VIDEO_ES, "Renderware TeXture Dictionary" },
276
    { VLC_FOURCC('V','Q','A','V'), AV_CODEC_ID_WS_VQA,
277
      VIDEO_ES, "WestWood Vector Quantized Animation" },
278
    { VLC_FOURCC('T','S','E','Q'), AV_CODEC_ID_TIERTEXSEQVIDEO,
279
      VIDEO_ES, "Tiertex SEQ Video" },
280
    { VLC_FOURCC('D','X','A','1'), AV_CODEC_ID_DXA,
281
      VIDEO_ES, "Feeble DXA Video" },
282
    { VLC_FOURCC('D','C','I','V'), AV_CODEC_ID_DSICINVIDEO,
283
      VIDEO_ES, "Delphine CIN Video" },
284
    { VLC_FOURCC('T','H','P','V'), AV_CODEC_ID_THP,
285
      VIDEO_ES, "THP Video" },
286
    { VLC_FOURCC('B','E','T','H'), AV_CODEC_ID_BETHSOFTVID,
287
      VIDEO_ES, "THP Video" },
288
    { VLC_FOURCC('C','9','3','V'), AV_CODEC_ID_C93,
289 290 291 292 293 294
      VIDEO_ES, "THP Video" },
#endif

    /*
     *  Image codecs
     */
295 296 297 298 299 300
    { VLC_CODEC_PNG, AV_CODEC_ID_PNG, VIDEO_ES },
    { VLC_CODEC_PPM, AV_CODEC_ID_PPM, VIDEO_ES },
    { VLC_CODEC_PGM, AV_CODEC_ID_PGM, VIDEO_ES },
    { VLC_CODEC_PGMYUV, AV_CODEC_ID_PGMYUV, VIDEO_ES },
    { VLC_CODEC_PAM, AV_CODEC_ID_PAM, VIDEO_ES },
    { VLC_CODEC_JPEGLS, AV_CODEC_ID_JPEGLS, VIDEO_ES },
301

302
    { VLC_CODEC_BMP, AV_CODEC_ID_BMP, VIDEO_ES },
303

304 305 306 307 308
    { VLC_CODEC_TIFF, AV_CODEC_ID_TIFF, VIDEO_ES },
    { VLC_CODEC_GIF, AV_CODEC_ID_GIF, VIDEO_ES },
    { VLC_CODEC_TARGA, AV_CODEC_ID_TARGA, VIDEO_ES },
    { VLC_CODEC_SGI, AV_CODEC_ID_SGI, VIDEO_ES },
    { VLC_CODEC_JPEG2000, AV_CODEC_ID_JPEG2000, VIDEO_ES },
309 310 311 312

    /*
     *  Audio Codecs
     */
313
    /* WMA family */
314 315 316 317
    { VLC_CODEC_WMA1, AV_CODEC_ID_WMAV1, AUDIO_ES },
    { VLC_CODEC_WMA2, AV_CODEC_ID_WMAV2, AUDIO_ES },
    { VLC_CODEC_WMAP, AV_CODEC_ID_WMAPRO, AUDIO_ES },
    { VLC_CODEC_WMAS, AV_CODEC_ID_WMAVOICE, AUDIO_ES },
318

319
    { VLC_CODEC_DVAUDIO, AV_CODEC_ID_DVAUDIO, AUDIO_ES },
320

321 322
    { VLC_CODEC_MACE3, AV_CODEC_ID_MACE3, AUDIO_ES },
    { VLC_CODEC_MACE6, AV_CODEC_ID_MACE6, AUDIO_ES },
323

324 325
    { VLC_CODEC_MUSEPACK7, AV_CODEC_ID_MUSEPACK7, AUDIO_ES },
    { VLC_CODEC_MUSEPACK8, AV_CODEC_ID_MUSEPACK8, AUDIO_ES },
326

327 328
    { VLC_CODEC_RA_144, AV_CODEC_ID_RA_144, AUDIO_ES },
    { VLC_CODEC_RA_288, AV_CODEC_ID_RA_288, AUDIO_ES },
329

330 331
    { VLC_CODEC_A52, AV_CODEC_ID_AC3, AUDIO_ES },
    { VLC_CODEC_EAC3, AV_CODEC_ID_EAC3, AUDIO_ES },
332

333
    { VLC_CODEC_DTS, AV_CODEC_ID_DTS, AUDIO_ES },
334

335 336
    { VLC_CODEC_MPGA, AV_CODEC_ID_MP3, AUDIO_ES },
    { VLC_CODEC_MPGA, AV_CODEC_ID_MP2, AUDIO_ES },
337

338 339 340
    { VLC_CODEC_MP4A, AV_CODEC_ID_AAC, AUDIO_ES },
    { VLC_CODEC_ALS, AV_CODEC_ID_MP4ALS, AUDIO_ES },
    { VLC_CODEC_MP4A, AV_CODEC_ID_AAC_LATM, AUDIO_ES },
341

342
    { VLC_CODEC_INTERPLAY_DPCM, AV_CODEC_ID_INTERPLAY_DPCM, AUDIO_ES },
343

344
    { VLC_CODEC_ROQ_DPCM, AV_CODEC_ID_ROQ_DPCM, AUDIO_ES },
345

346
    { VLC_CODEC_DSICINAUDIO, AV_CODEC_ID_DSICINAUDIO, AUDIO_ES },
347

348 349 350 351 352 353 354 355 356 357
    { VLC_CODEC_ADPCM_4XM, AV_CODEC_ID_ADPCM_4XM, AUDIO_ES },
    { VLC_CODEC_ADPCM_EA, AV_CODEC_ID_ADPCM_EA, AUDIO_ES },
    { VLC_CODEC_ADPCM_XA, AV_CODEC_ID_ADPCM_XA, AUDIO_ES },
    { VLC_CODEC_ADPCM_ADX, AV_CODEC_ID_ADPCM_ADX, AUDIO_ES },
    { VLC_CODEC_ADPCM_IMA_WS, AV_CODEC_ID_ADPCM_IMA_WS, AUDIO_ES },
    { VLC_CODEC_ADPCM_MS, AV_CODEC_ID_ADPCM_MS, AUDIO_ES },
    { VLC_CODEC_ADPCM_IMA_WAV, AV_CODEC_ID_ADPCM_IMA_WAV, AUDIO_ES },
    { VLC_CODEC_ADPCM_IMA_AMV, AV_CODEC_ID_ADPCM_IMA_AMV, AUDIO_ES },
    { VLC_CODEC_ADPCM_IMA_QT, AV_CODEC_ID_ADPCM_IMA_QT, AUDIO_ES },
    { VLC_CODEC_ADPCM_YAMAHA, AV_CODEC_ID_ADPCM_YAMAHA, AUDIO_ES },
358

359
    { VLC_CODEC_VMDAUDIO, AV_CODEC_ID_VMDAUDIO, AUDIO_ES },
360

361 362
    { VLC_CODEC_ADPCM_G726, AV_CODEC_ID_ADPCM_G726, AUDIO_ES },
    { VLC_CODEC_ADPCM_SWF, AV_CODEC_ID_ADPCM_SWF, AUDIO_ES },
363

364 365
    { VLC_CODEC_AMR_NB, AV_CODEC_ID_AMR_NB, AUDIO_ES },
    { VLC_CODEC_AMR_WB, AV_CODEC_ID_AMR_WB, AUDIO_ES },
366

367 368
    { VLC_CODEC_GSM, AV_CODEC_ID_GSM, AUDIO_ES },
    { VLC_CODEC_GSM_MS, AV_CODEC_ID_GSM_MS, AUDIO_ES },
369

370
    { VLC_CODEC_QDM2, AV_CODEC_ID_QDM2, AUDIO_ES },
371

372
    { VLC_CODEC_COOK, AV_CODEC_ID_COOK, AUDIO_ES },
373

374
    { VLC_CODEC_TTA, AV_CODEC_ID_TTA, AUDIO_ES },
375

376
    { VLC_CODEC_WAVPACK, AV_CODEC_ID_WAVPACK, AUDIO_ES },
377

378
    { VLC_CODEC_ATRAC3, AV_CODEC_ID_ATRAC3, AUDIO_ES },
379

380
    { VLC_CODEC_IMC, AV_CODEC_ID_IMC, AUDIO_ES },
381

382
    { VLC_CODEC_TRUESPEECH, AV_CODEC_ID_TRUESPEECH, AUDIO_ES },
383

384
    { VLC_CODEC_NELLYMOSER, AV_CODEC_ID_NELLYMOSER, AUDIO_ES },
385

386
    { VLC_CODEC_VORBIS, AV_CODEC_ID_VORBIS, AUDIO_ES },
387

388 389 390 391 392 393 394
    { VLC_CODEC_QCELP, AV_CODEC_ID_QCELP, AUDIO_ES },
    { VLC_CODEC_SPEEX, AV_CODEC_ID_SPEEX, AUDIO_ES },
    { VLC_CODEC_TWINVQ, AV_CODEC_ID_TWINVQ, AUDIO_ES },
    { VLC_CODEC_ATRAC1, AV_CODEC_ID_ATRAC1, AUDIO_ES },
    { VLC_CODEC_SIPR, AV_CODEC_ID_SIPR, AUDIO_ES },
    { VLC_CODEC_ADPCM_G722, AV_CODEC_ID_ADPCM_G722, AUDIO_ES },
    { VLC_CODEC_BMVAUDIO, AV_CODEC_ID_BMV_AUDIO, AUDIO_ES },
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
395

396
    { VLC_CODEC_G723_1, AV_CODEC_ID_G723_1, AUDIO_ES },
397

398 399
    { VLC_CODEC_BD_LPCM, AV_CODEC_ID_PCM_BLURAY, AUDIO_ES },

400
    /* Lossless */
401
    { VLC_CODEC_FLAC, AV_CODEC_ID_FLAC, AUDIO_ES },
402

403
    { VLC_CODEC_ALAC, AV_CODEC_ID_ALAC, AUDIO_ES },
404

405
    { VLC_CODEC_APE, AV_CODEC_ID_APE, AUDIO_ES },
406

407
    { VLC_CODEC_SHORTEN, AV_CODEC_ID_SHORTEN, AUDIO_ES },
408

409 410
    { VLC_CODEC_TRUEHD, AV_CODEC_ID_TRUEHD, AUDIO_ES },
    { VLC_CODEC_MLP, AV_CODEC_ID_MLP, AUDIO_ES },
411

412
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 5, 0 )
413
    { VLC_CODEC_WMAL, AV_CODEC_ID_WMALOSSLESS, AUDIO_ES },
414
#endif
415

416
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 12, 0 )
417
    { VLC_CODEC_RALF, AV_CODEC_ID_RALF, AUDIO_ES },
418
#endif
419

420
#if LIBAVCODEC_VERSION_CHECK( 54, 14, 0, 26, 100 )
421
    { VLC_CODEC_INDEO_AUDIO, AV_CODEC_ID_IAC, AUDIO_ES },
422
#endif
423

424 425 426 427
#if LIBAVCODEC_VERSION_CHECK( 55, 15, 0, 24, 100 )
    { VLC_CODEC_METASOUND, AV_CODEC_ID_METASOUND, AUDIO_ES },
#endif

428
    /* PCM */
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
    { VLC_CODEC_S8, AV_CODEC_ID_PCM_S8, AUDIO_ES },
    { VLC_CODEC_U8, AV_CODEC_ID_PCM_U8, AUDIO_ES },
    { VLC_CODEC_S16L, AV_CODEC_ID_PCM_S16LE, AUDIO_ES },
    { VLC_CODEC_S16B, AV_CODEC_ID_PCM_S16BE, AUDIO_ES },
    { VLC_CODEC_U16L, AV_CODEC_ID_PCM_U16LE, AUDIO_ES },
    { VLC_CODEC_U16B, AV_CODEC_ID_PCM_U16BE, AUDIO_ES },
    { VLC_CODEC_S24L, AV_CODEC_ID_PCM_S24LE, AUDIO_ES },
    { VLC_CODEC_S24B, AV_CODEC_ID_PCM_S24BE, AUDIO_ES },
    { VLC_CODEC_U24L, AV_CODEC_ID_PCM_U24LE, AUDIO_ES },
    { VLC_CODEC_U24B, AV_CODEC_ID_PCM_U24BE, AUDIO_ES },
    { VLC_CODEC_S32L, AV_CODEC_ID_PCM_S32LE, AUDIO_ES },
    { VLC_CODEC_S32B, AV_CODEC_ID_PCM_S32BE, AUDIO_ES },
    { VLC_CODEC_U32L, AV_CODEC_ID_PCM_U32LE, AUDIO_ES },
    { VLC_CODEC_U32B, AV_CODEC_ID_PCM_U32BE, AUDIO_ES },
    { VLC_CODEC_ALAW, AV_CODEC_ID_PCM_ALAW, AUDIO_ES },
    { VLC_CODEC_MULAW, AV_CODEC_ID_PCM_MULAW, AUDIO_ES },
    { VLC_CODEC_S24DAUD, AV_CODEC_ID_PCM_S24DAUD, AUDIO_ES },
    { VLC_CODEC_F32L, AV_CODEC_ID_PCM_F32LE, AUDIO_ES },
    { VLC_CODEC_F64L, AV_CODEC_ID_PCM_F64LE, AUDIO_ES },
    { VLC_CODEC_F32B, AV_CODEC_ID_PCM_F32BE, AUDIO_ES },
    { VLC_CODEC_F64B, AV_CODEC_ID_PCM_F64BE, AUDIO_ES },
450

451
    /* Subtitle streams */
452 453 454 455 456 457 458
    { VLC_CODEC_BD_PG, AV_CODEC_ID_HDMV_PGS_SUBTITLE, SPU_ES },
    { VLC_CODEC_SPU, AV_CODEC_ID_DVD_SUBTITLE, SPU_ES },
    { VLC_CODEC_DVBS, AV_CODEC_ID_DVB_SUBTITLE, SPU_ES },
    { VLC_CODEC_SUBT, AV_CODEC_ID_TEXT, SPU_ES },
    { VLC_CODEC_XSUB, AV_CODEC_ID_XSUB, SPU_ES },
    { VLC_CODEC_SSA, AV_CODEC_ID_SSA, SPU_ES },
    { VLC_CODEC_TELETEXT, AV_CODEC_ID_DVB_TELETEXT, SPU_ES },
459 460
};

461 462 463
static const size_t codecs_count = sizeof (codecs_table)
                                 / sizeof (codecs_table[0]);

464
int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
465
                    unsigned *pi_ffmpeg_codec, const char **ppsz_name )
466
{
467
    i_fourcc = vlc_fourcc_GetCodec( UNKNOWN_ES, i_fourcc );
468
    for( unsigned i = 0; i < codecs_count; i++ )
469 470 471 472 473
    {
        if( codecs_table[i].i_fourcc == i_fourcc )
        {
            if( pi_cat ) *pi_cat = codecs_table[i].i_cat;
            if( pi_ffmpeg_codec ) *pi_ffmpeg_codec = codecs_table[i].i_codec;
474
            if( ppsz_name ) *ppsz_name = vlc_fourcc_GetDescription( UNKNOWN_ES, i_fourcc );//char *)codecs_table[i].psz_name;
475 476 477 478 479 480 481

            return true;
        }
    }
    return false;
}

482
int GetVlcFourcc( unsigned i_ffmpeg_codec, int *pi_cat,
483
                  vlc_fourcc_t *pi_fourcc, const char **ppsz_name )
484
{
485
    for( unsigned i = 0; i < codecs_count; i++ )
486 487 488 489 490
    {
        if( codecs_table[i].i_codec == i_ffmpeg_codec )
        {
            if( pi_cat ) *pi_cat = codecs_table[i].i_cat;
            if( pi_fourcc ) *pi_fourcc = codecs_table[i].i_fourcc;
491
            if( ppsz_name ) *ppsz_name = vlc_fourcc_GetDescription( codecs_table[i].i_cat, codecs_table[i].i_fourcc );
492 493 494 495 496 497

            return true;
        }
    }
    return false;
}