2 * Copyright 2009-2010 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
7 #include "EncoderTable.h"
10 #if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8))
11 #define AV_CODEC_ID_NONE CODEC_ID_NONE
12 #define AV_CODEC_ID_PCM_F32LE CODEC_ID_PCM_F32LE
13 #define AV_CODEC_ID_PCM_F64LE CODEC_ID_PCM_F64LE
14 #define AV_CODEC_ID_PCM_S32LE CODEC_ID_PCM_S32LE
15 #define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE
16 #define AV_CODEC_ID_PCM_U8 CODEC_ID_PCM_U8
17 #define AV_CODEC_ID_PCM_F32BE CODEC_ID_PCM_F32BE
18 #define AV_CODEC_ID_PCM_F64BE CODEC_ID_PCM_F64BE
19 #define AV_CODEC_ID_PCM_S32BE CODEC_ID_PCM_S32BE
20 #define AV_CODEC_ID_PCM_S16BE CODEC_ID_PCM_S16BE
21 #define AV_CODEC_ID_AAC CODEC_ID_AAC
22 #define AV_CODEC_ID_AC3 CODEC_ID_AC3
23 #define AV_CODEC_ID_DVVIDEO CODEC_ID_DVVIDEO
24 #define AV_CODEC_ID_FLAC CODEC_ID_FLAC
25 #define AV_CODEC_ID_MJPEG CODEC_ID_MJPEG
26 #define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO
27 #define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
28 #define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
29 #define AV_CODEC_ID_THEORA CODEC_ID_THEORA
34 const EncoderDescription gEncoderTable
[] = {
44 B_ANY_FORMAT_FAMILY
, // TODO: Hm, actually not really /any/ family...
46 B_MEDIA_ENCODED_VIDEO
,
54 AV_CODEC_ID_MPEG1VIDEO
,
59 B_MEDIA_ENCODED_VIDEO
,
67 AV_CODEC_ID_MPEG2VIDEO
,
72 B_MEDIA_ENCODED_VIDEO
,
85 B_MEDIA_ENCODED_VIDEO
,
98 B_MEDIA_ENCODED_VIDEO
,
103 "MJPEG (Motion JPEG)",
111 B_MEDIA_ENCODED_VIDEO
,
118 "Free Lossless Audio Codec (FLAC)",
126 B_MEDIA_ENCODED_AUDIO
,
131 "Advanced Audio Coding (AAC)",
137 B_MPEG_FORMAT_FAMILY
,
139 B_MEDIA_ENCODED_AUDIO
,
152 B_MEDIA_ENCODED_AUDIO
,
157 "Dolby Digital (AC-3)",
165 B_MEDIA_ENCODED_AUDIO
,
171 "Apple Lossless Audio Codec",
179 B_MEDIA_ENCODED_AUDIO
,
184 "Adaptive Transform Acoustic Coding",
192 B_MEDIA_ENCODED_AUDIO
,
197 "MPEG Layer III (MP3)",
205 B_MEDIA_ENCODED_AUDIO
,
218 B_MEDIA_ENCODED_AUDIO
,
231 B_MEDIA_ENCODED_AUDIO
,
236 "Windows Media Audio (WMA)",
244 B_MEDIA_ENCODED_AUDIO
,
257 B_MEDIA_ENCODED_AUDIO
,
263 const size_t gEncoderCount
= sizeof(gEncoderTable
) / sizeof(EncoderDescription
);
267 raw_audio_codec_id_for(const media_format
& format
)
269 if (format
.type
!= B_MEDIA_RAW_AUDIO
)
270 return AV_CODEC_ID_NONE
;
272 if (format
.u
.raw_audio
.byte_order
== B_MEDIA_LITTLE_ENDIAN
) {
273 switch (format
.u
.raw_audio
.format
) {
274 case media_raw_audio_format::B_AUDIO_FLOAT
:
275 return AV_CODEC_ID_PCM_F32LE
;
276 case media_raw_audio_format::B_AUDIO_DOUBLE
:
277 return AV_CODEC_ID_PCM_F64LE
;
278 case media_raw_audio_format::B_AUDIO_INT
:
279 return AV_CODEC_ID_PCM_S32LE
;
280 case media_raw_audio_format::B_AUDIO_SHORT
:
281 return AV_CODEC_ID_PCM_S16LE
;
282 case media_raw_audio_format::B_AUDIO_UCHAR
:
283 return AV_CODEC_ID_PCM_U8
;
285 return AV_CODEC_ID_NONE
;
288 switch (format
.u
.raw_audio
.format
) {
289 case media_raw_audio_format::B_AUDIO_FLOAT
:
290 return AV_CODEC_ID_PCM_F32BE
;
291 case media_raw_audio_format::B_AUDIO_DOUBLE
:
292 return AV_CODEC_ID_PCM_F64BE
;
293 case media_raw_audio_format::B_AUDIO_INT
:
294 return AV_CODEC_ID_PCM_S32BE
;
295 case media_raw_audio_format::B_AUDIO_SHORT
:
296 return AV_CODEC_ID_PCM_S16BE
;
297 case media_raw_audio_format::B_AUDIO_UCHAR
:
298 return AV_CODEC_ID_PCM_U8
;
300 return AV_CODEC_ID_NONE
;