Mercurial > libavformat.hg
comparison raw.c @ 6440:8beba113f242 libavformat
move ac3/eac3 demuxer to its own file
author | aurel |
---|---|
date | Sun, 29 Aug 2010 22:02:47 +0000 |
parents | 4053f191ae61 |
children | d23c128f1f51 |
comparison
equal
deleted
inserted
replaced
6439:4053f191ae61 | 6440:8beba113f242 |
---|---|
18 * You should have received a copy of the GNU Lesser General Public | 18 * You should have received a copy of the GNU Lesser General Public |
19 * License along with FFmpeg; if not, write to the Free Software | 19 * License along with FFmpeg; if not, write to the Free Software |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 */ | 21 */ |
22 | 22 |
23 #include "libavutil/crc.h" | |
24 #include "libavcodec/ac3_parser.h" | |
25 #include "libavcodec/get_bits.h" | 23 #include "libavcodec/get_bits.h" |
26 #include "libavcodec/bytestream.h" | 24 #include "libavcodec/bytestream.h" |
27 #include "avformat.h" | 25 #include "avformat.h" |
28 #include "raw.h" | 26 #include "raw.h" |
29 #include "id3v2.h" | 27 #include "id3v2.h" |
239 | 237 |
240 return 0; | 238 return 0; |
241 } | 239 } |
242 #endif | 240 #endif |
243 | 241 |
244 #if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER | |
245 static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id) | |
246 { | |
247 int max_frames, first_frames = 0, frames; | |
248 uint8_t *buf, *buf2, *end; | |
249 AC3HeaderInfo hdr; | |
250 GetBitContext gbc; | |
251 enum CodecID codec_id = CODEC_ID_AC3; | |
252 | |
253 max_frames = 0; | |
254 buf = p->buf; | |
255 end = buf + p->buf_size; | |
256 | |
257 for(; buf < end; buf++) { | |
258 buf2 = buf; | |
259 | |
260 for(frames = 0; buf2 < end; frames++) { | |
261 init_get_bits(&gbc, buf2, 54); | |
262 if(ff_ac3_parse_header(&gbc, &hdr) < 0) | |
263 break; | |
264 if(buf2 + hdr.frame_size > end || | |
265 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2)) | |
266 break; | |
267 if (hdr.bitstream_id > 10) | |
268 codec_id = CODEC_ID_EAC3; | |
269 buf2 += hdr.frame_size; | |
270 } | |
271 max_frames = FFMAX(max_frames, frames); | |
272 if(buf == p->buf) | |
273 first_frames = frames; | |
274 } | |
275 if(codec_id != expected_codec_id) return 0; | |
276 // keep this in sync with mp3 probe, both need to avoid | |
277 // issues with MPEG-files! | |
278 if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1; | |
279 else if(max_frames>500)return AVPROBE_SCORE_MAX/2; | |
280 else if(max_frames>=4) return AVPROBE_SCORE_MAX/4; | |
281 else if(max_frames>=1) return 1; | |
282 else return 0; | |
283 } | |
284 #endif | |
285 | |
286 #if CONFIG_AC3_DEMUXER | |
287 static int ac3_probe(AVProbeData *p) | |
288 { | |
289 return ac3_eac3_probe(p, CODEC_ID_AC3); | |
290 } | |
291 #endif | |
292 | |
293 #if CONFIG_EAC3_DEMUXER | |
294 static int eac3_probe(AVProbeData *p) | |
295 { | |
296 return ac3_eac3_probe(p, CODEC_ID_EAC3); | |
297 } | |
298 #endif | |
299 | |
300 /* Note: Do not forget to add new entries to the Makefile as well. */ | 242 /* Note: Do not forget to add new entries to the Makefile as well. */ |
301 | |
302 #if CONFIG_AC3_DEMUXER | |
303 AVInputFormat ac3_demuxer = { | |
304 "ac3", | |
305 NULL_IF_CONFIG_SMALL("raw AC-3"), | |
306 0, | |
307 ac3_probe, | |
308 ff_raw_audio_read_header, | |
309 ff_raw_read_partial_packet, | |
310 .flags= AVFMT_GENERIC_INDEX, | |
311 .extensions = "ac3", | |
312 .value = CODEC_ID_AC3, | |
313 }; | |
314 #endif | |
315 | 243 |
316 #if CONFIG_AC3_MUXER | 244 #if CONFIG_AC3_MUXER |
317 AVOutputFormat ac3_muxer = { | 245 AVOutputFormat ac3_muxer = { |
318 "ac3", | 246 "ac3", |
319 NULL_IF_CONFIG_SMALL("raw AC-3"), | 247 NULL_IF_CONFIG_SMALL("raw AC-3"), |
368 CODEC_ID_DTS, | 296 CODEC_ID_DTS, |
369 CODEC_ID_NONE, | 297 CODEC_ID_NONE, |
370 NULL, | 298 NULL, |
371 ff_raw_write_packet, | 299 ff_raw_write_packet, |
372 .flags= AVFMT_NOTIMESTAMPS, | 300 .flags= AVFMT_NOTIMESTAMPS, |
373 }; | |
374 #endif | |
375 | |
376 #if CONFIG_EAC3_DEMUXER | |
377 AVInputFormat eac3_demuxer = { | |
378 "eac3", | |
379 NULL_IF_CONFIG_SMALL("raw E-AC-3"), | |
380 0, | |
381 eac3_probe, | |
382 ff_raw_audio_read_header, | |
383 ff_raw_read_partial_packet, | |
384 .flags= AVFMT_GENERIC_INDEX, | |
385 .extensions = "eac3", | |
386 .value = CODEC_ID_EAC3, | |
387 }; | 301 }; |
388 #endif | 302 #endif |
389 | 303 |
390 #if CONFIG_EAC3_MUXER | 304 #if CONFIG_EAC3_MUXER |
391 AVOutputFormat eac3_muxer = { | 305 AVOutputFormat eac3_muxer = { |