3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / plugins / ffmpeg / EncoderTable.cpp
blob2b300e612eff5c1daf8bcc2451a7b2e45abdfe32
1 /*
2 * Copyright 2009-2010 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
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
30 #endif
34 const EncoderDescription gEncoderTable[] = {
35 // Video codecs
38 "MPEG-4 video",
39 "mpeg4",
41 AV_CODEC_ID_MPEG4,
42 { 0 }
44 B_ANY_FORMAT_FAMILY, // TODO: Hm, actually not really /any/ family...
45 B_MEDIA_RAW_VIDEO,
46 B_MEDIA_ENCODED_VIDEO,
51 "MPEG-1 video",
52 "mpeg1video",
54 AV_CODEC_ID_MPEG1VIDEO,
55 { 0 }
57 B_MPEG_FORMAT_FAMILY,
58 B_MEDIA_RAW_VIDEO,
59 B_MEDIA_ENCODED_VIDEO,
64 "MPEG-2 video",
65 "mpeg2video",
67 AV_CODEC_ID_MPEG2VIDEO,
68 { 0 }
70 B_MPEG_FORMAT_FAMILY,
71 B_MEDIA_RAW_VIDEO,
72 B_MEDIA_ENCODED_VIDEO,
77 "Theora video",
78 "theora",
80 AV_CODEC_ID_THEORA,
81 { 0 }
83 B_ANY_FORMAT_FAMILY,
84 B_MEDIA_RAW_VIDEO,
85 B_MEDIA_ENCODED_VIDEO,
90 "DV (Digital Video)",
91 "dvvideo",
93 AV_CODEC_ID_DVVIDEO,
94 { 0 }
96 B_MISC_FORMAT_FAMILY,
97 B_MEDIA_RAW_VIDEO,
98 B_MEDIA_ENCODED_VIDEO,
103 "MJPEG (Motion JPEG)",
104 "mjpeg",
106 AV_CODEC_ID_MJPEG,
107 { 0 }
109 B_ANY_FORMAT_FAMILY,
110 B_MEDIA_RAW_VIDEO,
111 B_MEDIA_ENCODED_VIDEO,
115 // Audio codecs
118 "Free Lossless Audio Codec (FLAC)",
119 "flac",
121 AV_CODEC_ID_FLAC,
122 { 0 }
124 B_ANY_FORMAT_FAMILY,
125 B_MEDIA_RAW_AUDIO,
126 B_MEDIA_ENCODED_AUDIO,
131 "Advanced Audio Coding (AAC)",
132 "aac",
134 AV_CODEC_ID_AAC,
135 { 0 }
137 B_MPEG_FORMAT_FAMILY,
138 B_MEDIA_RAW_AUDIO,
139 B_MEDIA_ENCODED_AUDIO,
144 "Raw audio",
145 "pcm",
148 { 0 }
150 B_WAV_FORMAT_FAMILY,
151 B_MEDIA_RAW_AUDIO,
152 B_MEDIA_ENCODED_AUDIO,
157 "Dolby Digital (AC-3)",
158 "ac3",
160 AV_CODEC_ID_AC3,
161 { 0 }
163 B_ANY_FORMAT_FAMILY,
164 B_MEDIA_RAW_AUDIO,
165 B_MEDIA_ENCODED_AUDIO,
168 #if 0
171 "Apple Lossless Audio Codec",
172 "alac",
174 CODEC_ID_ALAC,
175 { 0 }
177 B_ANY_FORMAT_FAMILY,
178 B_MEDIA_RAW_AUDIO,
179 B_MEDIA_ENCODED_AUDIO,
184 "Adaptive Transform Acoustic Coding",
185 "atrac",
187 CODEC_ID_ATRAC3,
188 { 0 }
190 B_ANY_FORMAT_FAMILY,
191 B_MEDIA_RAW_AUDIO,
192 B_MEDIA_ENCODED_AUDIO,
197 "MPEG Layer III (MP3)",
198 "mp3",
200 CODEC_ID_MP3,
201 { 0 }
203 B_ANY_FORMAT_FAMILY,
204 B_MEDIA_RAW_AUDIO,
205 B_MEDIA_ENCODED_AUDIO,
210 "Monkey's Audio",
211 "ape",
213 CODEC_ID_APE,
214 { 0 }
216 B_ANY_FORMAT_FAMILY,
217 B_MEDIA_RAW_AUDIO,
218 B_MEDIA_ENCODED_AUDIO,
223 "Musepack",
224 "mpc",
226 CODEC_ID_MUSEPACK8,
227 { 0 }
229 B_ANY_FORMAT_FAMILY,
230 B_MEDIA_RAW_AUDIO,
231 B_MEDIA_ENCODED_AUDIO,
236 "Windows Media Audio (WMA)",
237 "wma",
239 CODEC_ID_WMAV2,
240 { 0 }
242 B_ANY_FORMAT_FAMILY,
243 B_MEDIA_RAW_AUDIO,
244 B_MEDIA_ENCODED_AUDIO,
249 "Vorbis audio",
250 "vorbis",
252 CODEC_ID_VORBIS,
253 { 0 }
255 B_ANY_FORMAT_FAMILY,
256 B_MEDIA_RAW_AUDIO,
257 B_MEDIA_ENCODED_AUDIO,
260 #endif
263 const size_t gEncoderCount = sizeof(gEncoderTable) / sizeof(EncoderDescription);
266 /*static*/ CodecID
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;
284 default:
285 return AV_CODEC_ID_NONE;
287 } else {
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;
299 default:
300 return AV_CODEC_ID_NONE;