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