Mercurial > libavformat.hg
annotate ac3dec.c @ 6448:4775a49a6045 libavformat
split raw.c into rawdec.c and rawenc.c
author | aurel |
---|---|
date | Mon, 30 Aug 2010 23:16:35 +0000 |
parents | 8beba113f242 |
children |
rev | line source |
---|---|
885 | 1 /* |
6440 | 2 * RAW AC-3 and E-AC-3 demuxer |
3 * Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com> | |
0 | 4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
0 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
0 | 11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
0 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 20 */ |
3286 | 21 |
22 #include "libavutil/crc.h" | |
23 #include "libavcodec/ac3_parser.h" | |
0 | 24 #include "avformat.h" |
6448 | 25 #include "rawdec.h" |
0 | 26 |
3864
b31edc09d556
simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
jbr
parents:
3863
diff
changeset
|
27 static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id) |
1768 | 28 { |
2224 | 29 int max_frames, first_frames = 0, frames; |
1931 | 30 uint8_t *buf, *buf2, *end; |
31 AC3HeaderInfo hdr; | |
3238
db733a434b2c
change ff_ac3_parse_header() to take a GetBitContext instead of const char*
bwolowiec
parents:
3237
diff
changeset
|
32 GetBitContext gbc; |
3864
b31edc09d556
simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
jbr
parents:
3863
diff
changeset
|
33 enum CodecID codec_id = CODEC_ID_AC3; |
1768 | 34 |
1931 | 35 max_frames = 0; |
36 buf = p->buf; | |
2304
763527841a80
additional tweaks to AC3 probe function. give a higher score to a single frame
jbr
parents:
2303
diff
changeset
|
37 end = buf + p->buf_size; |
1931 | 38 |
39 for(; buf < end; buf++) { | |
40 buf2 = buf; | |
41 | |
42 for(frames = 0; buf2 < end; frames++) { | |
3238
db733a434b2c
change ff_ac3_parse_header() to take a GetBitContext instead of const char*
bwolowiec
parents:
3237
diff
changeset
|
43 init_get_bits(&gbc, buf2, 54); |
db733a434b2c
change ff_ac3_parse_header() to take a GetBitContext instead of const char*
bwolowiec
parents:
3237
diff
changeset
|
44 if(ff_ac3_parse_header(&gbc, &hdr) < 0) |
1931 | 45 break; |
3237
4fa7ec10b57e
Compute AC3 frame CRC for stronger raw AC3 format probing.
andoma
parents:
3235
diff
changeset
|
46 if(buf2 + hdr.frame_size > end || |
4fa7ec10b57e
Compute AC3 frame CRC for stronger raw AC3 format probing.
andoma
parents:
3235
diff
changeset
|
47 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2)) |
4fa7ec10b57e
Compute AC3 frame CRC for stronger raw AC3 format probing.
andoma
parents:
3235
diff
changeset
|
48 break; |
3862 | 49 if (hdr.bitstream_id > 10) |
3864
b31edc09d556
simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
jbr
parents:
3863
diff
changeset
|
50 codec_id = CODEC_ID_EAC3; |
1931 | 51 buf2 += hdr.frame_size; |
52 } | |
53 max_frames = FFMAX(max_frames, frames); | |
54 if(buf == p->buf) | |
55 first_frames = frames; | |
1768 | 56 } |
3864
b31edc09d556
simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
jbr
parents:
3863
diff
changeset
|
57 if(codec_id != expected_codec_id) return 0; |
5238
c872818a8e1f
Sync AC3 probe values with MP3 probe values, they have to avoid similar issues.
reimar
parents:
5191
diff
changeset
|
58 // keep this in sync with mp3 probe, both need to avoid |
c872818a8e1f
Sync AC3 probe values with MP3 probe values, they have to avoid similar issues.
reimar
parents:
5191
diff
changeset
|
59 // issues with MPEG-files! |
c872818a8e1f
Sync AC3 probe values with MP3 probe values, they have to avoid similar issues.
reimar
parents:
5191
diff
changeset
|
60 if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1; |
c872818a8e1f
Sync AC3 probe values with MP3 probe values, they have to avoid similar issues.
reimar
parents:
5191
diff
changeset
|
61 else if(max_frames>500)return AVPROBE_SCORE_MAX/2; |
c872818a8e1f
Sync AC3 probe values with MP3 probe values, they have to avoid similar issues.
reimar
parents:
5191
diff
changeset
|
62 else if(max_frames>=4) return AVPROBE_SCORE_MAX/4; |
1931 | 63 else if(max_frames>=1) return 1; |
64 else return 0; | |
1768 | 65 } |
66 | |
4206 | 67 #if CONFIG_AC3_DEMUXER |
3862 | 68 static int ac3_probe(AVProbeData *p) |
69 { | |
3864
b31edc09d556
simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
jbr
parents:
3863
diff
changeset
|
70 return ac3_eac3_probe(p, CODEC_ID_AC3); |
3862 | 71 } |
72 | |
1167 | 73 AVInputFormat ac3_demuxer = { |
0 | 74 "ac3", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3405
diff
changeset
|
75 NULL_IF_CONFIG_SMALL("raw AC-3"), |
0 | 76 0, |
1768 | 77 ac3_probe, |
6429 | 78 ff_raw_audio_read_header, |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
79 ff_raw_read_partial_packet, |
1756 | 80 .flags= AVFMT_GENERIC_INDEX, |
0 | 81 .extensions = "ac3", |
3268
319c36da904b
set demuxers .value and use common audio_read_header function
bcoudurier
parents:
3238
diff
changeset
|
82 .value = CODEC_ID_AC3, |
0 | 83 }; |
2022
4f62a7d9381a
Make the declaration of AVInputFormat ac3_demuxer conditional
diego
parents:
2021
diff
changeset
|
84 #endif |
0 | 85 |
6440 | 86 #if CONFIG_EAC3_DEMUXER |
87 static int eac3_probe(AVProbeData *p) | |
88 { | |
89 return ac3_eac3_probe(p, CODEC_ID_EAC3); | |
90 } | |
3272
07038dc492ab
Import Dirac demuxer/muxer from SoC branch; written by Marco Gerards,
lu_zero
parents:
3269
diff
changeset
|
91 |
3862 | 92 AVInputFormat eac3_demuxer = { |
93 "eac3", | |
94 NULL_IF_CONFIG_SMALL("raw E-AC-3"), | |
95 0, | |
96 eac3_probe, | |
6429 | 97 ff_raw_audio_read_header, |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
98 ff_raw_read_partial_packet, |
3862 | 99 .flags= AVFMT_GENERIC_INDEX, |
100 .extensions = "eac3", | |
101 .value = CODEC_ID_EAC3, | |
102 }; | |
103 #endif |