Mercurial > libavformat.hg
annotate aacdec.c @ 6483:ac299df18642 libavformat
Add an AVOption max_delay for AVFormatContext->max_delay
This can currently also be set via -muxdelay in ffmpeg for muxers,
but not for demuxers (nor for demuxers in ffplay) - this patch
allows it to be set in all those cases.
author | mstorsjo |
---|---|
date | Fri, 24 Sep 2010 18:04:21 +0000 |
parents | 5d5fbab4d608 |
children |
rev | line source |
---|---|
885 | 1 /* |
6424 | 2 * raw ADTS AAC demuxer |
3 * Copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> | |
4 * Copyright (c) 2009 Robert Swain ( rob opendot cl ) | |
0 | 5 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
6 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
7 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
0 | 9 * modify it under the terms of the GNU Lesser General Public |
10 * 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
|
11 * version 2.1 of the License, or (at your option) any later version. |
0 | 12 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
0 | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * 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
|
19 * 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
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 21 */ |
3286 | 22 |
6424 | 23 #include "libavutil/intreadwrite.h" |
0 | 24 #include "avformat.h" |
6448 | 25 #include "rawdec.h" |
4254 | 26 #include "id3v2.h" |
5046
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
27 #include "id3v1.h" |
0 | 28 |
1078
0bc9422cc0ad
Raw flac muxer, patch by Justin Ruggles (jruggle earthlink net). Can be
banan
parents:
1070
diff
changeset
|
29 |
4055 | 30 static int adts_aac_probe(AVProbeData *p) |
31 { | |
32 int max_frames = 0, first_frames = 0; | |
33 int fsize, frames; | |
4254 | 34 uint8_t *buf0 = p->buf; |
4055 | 35 uint8_t *buf2; |
4254 | 36 uint8_t *buf; |
37 uint8_t *end = buf0 + p->buf_size - 7; | |
38 | |
6121
81614e9b541b
Generalize ID3v2 functions to support ID3v2-like ID headers with a
cehoyos
parents:
6120
diff
changeset
|
39 if (ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC)) { |
4254 | 40 buf0 += ff_id3v2_tag_len(buf0); |
41 } | |
42 buf = buf0; | |
4055 | 43 |
44 for(; buf < end; buf= buf2+1) { | |
45 buf2 = buf; | |
46 | |
47 for(frames = 0; buf2 < end; frames++) { | |
48 uint32_t header = AV_RB16(buf2); | |
49 if((header&0xFFF6) != 0xFFF0) | |
50 break; | |
51 fsize = (AV_RB32(buf2+3)>>13) & 0x8FFF; | |
52 if(fsize < 7) | |
53 break; | |
54 buf2 += fsize; | |
55 } | |
56 max_frames = FFMAX(max_frames, frames); | |
4254 | 57 if(buf == buf0) |
4055 | 58 first_frames= frames; |
59 } | |
60 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; | |
61 else if(max_frames>500)return AVPROBE_SCORE_MAX/2; | |
62 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; | |
63 else if(max_frames>=1) return 1; | |
64 else return 0; | |
65 } | |
5046
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
66 |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
67 static int adts_aac_read_header(AVFormatContext *s, |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
68 AVFormatParameters *ap) |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
69 { |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
70 AVStream *st; |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
71 |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
72 st = av_new_stream(s, 0); |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
73 if (!st) |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
74 return AVERROR(ENOMEM); |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
75 |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5657
diff
changeset
|
76 st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
5046
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
77 st->codec->codec_id = s->iformat->value; |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
78 st->need_parsing = AVSTREAM_PARSE_FULL; |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
79 |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
80 ff_id3v1_read(s); |
6121
81614e9b541b
Generalize ID3v2 functions to support ID3v2-like ID headers with a
cehoyos
parents:
6120
diff
changeset
|
81 ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); |
5046
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
82 |
6470
5d5fbab4d608
adts demuxer: Set the time base to be the LCM of all ADTS sample rates.
alexc
parents:
6448
diff
changeset
|
83 //LCM of all possible ADTS sample rates |
5d5fbab4d608
adts demuxer: Set the time base to be the LCM of all ADTS sample rates.
alexc
parents:
6448
diff
changeset
|
84 av_set_pts_info(st, 64, 1, 28224000); |
5d5fbab4d608
adts demuxer: Set the time base to be the LCM of all ADTS sample rates.
alexc
parents:
6448
diff
changeset
|
85 |
5046
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
86 return 0; |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
87 } |
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
88 |
3546
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
89 AVInputFormat aac_demuxer = { |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
90 "aac", |
4501 | 91 NULL_IF_CONFIG_SMALL("raw ADTS AAC"), |
3405 | 92 0, |
4055 | 93 adts_aac_probe, |
5046
b4b0df2c408b
Add support for id3 tag parsing for ADTS AAC streams
superdump
parents:
4901
diff
changeset
|
94 adts_aac_read_header, |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
95 ff_raw_read_partial_packet, |
3405 | 96 .flags= AVFMT_GENERIC_INDEX, |
3546
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
97 .extensions = "aac", |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
98 .value = CODEC_ID_AAC, |
1070
26d75e74c7b7
Add support for raw flac decoding based on the .flac suffix of input files.
banan
parents:
1003
diff
changeset
|
99 }; |