1 /* 2 * Copyright 2009-2010 Stephan Aßmus <superstippi@gmx.de> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "EncoderTable.h" 8 9 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 31 32 33 34 const EncoderDescription gEncoderTable[] = { 35 // Video codecs 36 { 37 { 38 "MPEG-4 video", 39 "mpeg4", 40 0, 41 AV_CODEC_ID_MPEG4, 42 { 0 } 43 }, 44 B_ANY_FORMAT_FAMILY, // TODO: Hm, actually not really /any/ family... 45 B_MEDIA_RAW_VIDEO, 46 B_MEDIA_ENCODED_VIDEO, 47 23 48 }, 49 { 50 { 51 "MPEG-1 video", 52 "mpeg1video", 53 0, 54 AV_CODEC_ID_MPEG1VIDEO, 55 { 0 } 56 }, 57 B_MPEG_FORMAT_FAMILY, 58 B_MEDIA_RAW_VIDEO, 59 B_MEDIA_ENCODED_VIDEO, 60 10 61 }, 62 { 63 { 64 "MPEG-2 video", 65 "mpeg2video", 66 0, 67 AV_CODEC_ID_MPEG2VIDEO, 68 { 0 } 69 }, 70 B_MPEG_FORMAT_FAMILY, 71 B_MEDIA_RAW_VIDEO, 72 B_MEDIA_ENCODED_VIDEO, 73 15 74 }, 75 { 76 { 77 "Theora video", 78 "theora", 79 0, 80 AV_CODEC_ID_THEORA, 81 { 0 } 82 }, 83 B_ANY_FORMAT_FAMILY, 84 B_MEDIA_RAW_VIDEO, 85 B_MEDIA_ENCODED_VIDEO, 86 18 87 }, 88 { 89 { 90 "DV (Digital Video)", 91 "dvvideo", 92 0, 93 AV_CODEC_ID_DVVIDEO, 94 { 0 } 95 }, 96 B_MISC_FORMAT_FAMILY, 97 B_MEDIA_RAW_VIDEO, 98 B_MEDIA_ENCODED_VIDEO, 99 5 100 }, 101 { 102 { 103 "MJPEG (Motion JPEG)", 104 "mjpeg", 105 0, 106 AV_CODEC_ID_MJPEG, 107 { 0 } 108 }, 109 B_ANY_FORMAT_FAMILY, 110 B_MEDIA_RAW_VIDEO, 111 B_MEDIA_ENCODED_VIDEO, 112 5 113 }, 114 115 // Audio codecs 116 { 117 { 118 "Free Lossless Audio Codec (FLAC)", 119 "flac", 120 0, 121 AV_CODEC_ID_FLAC, 122 { 0 } 123 }, 124 B_ANY_FORMAT_FAMILY, 125 B_MEDIA_RAW_AUDIO, 126 B_MEDIA_ENCODED_AUDIO, 127 10 128 }, 129 { 130 { 131 "Advanced Audio Coding (AAC)", 132 "aac", 133 0, 134 AV_CODEC_ID_AAC, 135 { 0 } 136 }, 137 B_MPEG_FORMAT_FAMILY, 138 B_MEDIA_RAW_AUDIO, 139 B_MEDIA_ENCODED_AUDIO, 140 10 141 }, 142 { 143 { 144 "Raw audio", 145 "pcm", 146 0, 147 0, 148 { 0 } 149 }, 150 B_WAV_FORMAT_FAMILY, 151 B_MEDIA_RAW_AUDIO, 152 B_MEDIA_ENCODED_AUDIO, 153 1 154 }, 155 { 156 { 157 "Dolby Digital (AC-3)", 158 "ac3", 159 0, 160 AV_CODEC_ID_AC3, 161 { 0 } 162 }, 163 B_ANY_FORMAT_FAMILY, 164 B_MEDIA_RAW_AUDIO, 165 B_MEDIA_ENCODED_AUDIO, 166 10 167 }, 168 #if 0 169 { 170 { 171 "Apple Lossless Audio Codec", 172 "alac", 173 0, 174 CODEC_ID_ALAC, 175 { 0 } 176 }, 177 B_ANY_FORMAT_FAMILY, 178 B_MEDIA_RAW_AUDIO, 179 B_MEDIA_ENCODED_AUDIO, 180 10 181 }, 182 { 183 { 184 "Adaptive Transform Acoustic Coding", 185 "atrac", 186 0, 187 CODEC_ID_ATRAC3, 188 { 0 } 189 }, 190 B_ANY_FORMAT_FAMILY, 191 B_MEDIA_RAW_AUDIO, 192 B_MEDIA_ENCODED_AUDIO, 193 10 194 }, 195 { 196 { 197 "MPEG Layer III (MP3)", 198 "mp3", 199 0, 200 CODEC_ID_MP3, 201 { 0 } 202 }, 203 B_ANY_FORMAT_FAMILY, 204 B_MEDIA_RAW_AUDIO, 205 B_MEDIA_ENCODED_AUDIO, 206 10 207 }, 208 { 209 { 210 "Monkey's Audio", 211 "ape", 212 0, 213 CODEC_ID_APE, 214 { 0 } 215 }, 216 B_ANY_FORMAT_FAMILY, 217 B_MEDIA_RAW_AUDIO, 218 B_MEDIA_ENCODED_AUDIO, 219 10 220 }, 221 { 222 { 223 "Musepack", 224 "mpc", 225 0, 226 CODEC_ID_MUSEPACK8, 227 { 0 } 228 }, 229 B_ANY_FORMAT_FAMILY, 230 B_MEDIA_RAW_AUDIO, 231 B_MEDIA_ENCODED_AUDIO, 232 10 233 }, 234 { 235 { 236 "Windows Media Audio (WMA)", 237 "wma", 238 0, 239 CODEC_ID_WMAV2, 240 { 0 } 241 }, 242 B_ANY_FORMAT_FAMILY, 243 B_MEDIA_RAW_AUDIO, 244 B_MEDIA_ENCODED_AUDIO, 245 10 246 }, 247 { 248 { 249 "Vorbis audio", 250 "vorbis", 251 0, 252 CODEC_ID_VORBIS, 253 { 0 } 254 }, 255 B_ANY_FORMAT_FAMILY, 256 B_MEDIA_RAW_AUDIO, 257 B_MEDIA_ENCODED_AUDIO, 258 10 259 } 260 #endif 261 }; 262 263 const size_t gEncoderCount = sizeof(gEncoderTable) / sizeof(EncoderDescription); 264 265 266 /*static*/ CodecID 267 raw_audio_codec_id_for(const media_format& format) 268 { 269 if (format.type != B_MEDIA_RAW_AUDIO) 270 return AV_CODEC_ID_NONE; 271 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; 286 } 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; 301 } 302 } 303 } 304 305 306 307