00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "libavutil/intreadwrite.h"
00024 #include "avformat.h"
00025 #include "rawdec.h"
00026 #include "id3v1.h"
00027
00028
00029 static int adts_aac_probe(AVProbeData *p)
00030 {
00031 int max_frames = 0, first_frames = 0;
00032 int fsize, frames;
00033 uint8_t *buf0 = p->buf;
00034 uint8_t *buf2;
00035 uint8_t *buf;
00036 uint8_t *end = buf0 + p->buf_size - 7;
00037
00038 buf = buf0;
00039
00040 for(; buf < end; buf= buf2+1) {
00041 buf2 = buf;
00042
00043 for(frames = 0; buf2 < end; frames++) {
00044 uint32_t header = AV_RB16(buf2);
00045 if((header&0xFFF6) != 0xFFF0)
00046 break;
00047 fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
00048 if(fsize < 7)
00049 break;
00050 buf2 += fsize;
00051 }
00052 max_frames = FFMAX(max_frames, frames);
00053 if(buf == buf0)
00054 first_frames= frames;
00055 }
00056 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
00057 else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
00058 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
00059 else if(max_frames>=1) return 1;
00060 else return 0;
00061 }
00062
00063 static int adts_aac_read_header(AVFormatContext *s,
00064 AVFormatParameters *ap)
00065 {
00066 AVStream *st;
00067
00068 st = av_new_stream(s, 0);
00069 if (!st)
00070 return AVERROR(ENOMEM);
00071
00072 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
00073 st->codec->codec_id = s->iformat->value;
00074 st->need_parsing = AVSTREAM_PARSE_FULL;
00075
00076 ff_id3v1_read(s);
00077
00078
00079 av_set_pts_info(st, 64, 1, 28224000);
00080
00081 return 0;
00082 }
00083
00084 AVInputFormat ff_aac_demuxer = {
00085 "aac",
00086 NULL_IF_CONFIG_SMALL("raw ADTS AAC"),
00087 0,
00088 adts_aac_probe,
00089 adts_aac_read_header,
00090 ff_raw_read_partial_packet,
00091 .flags= AVFMT_GENERIC_INDEX,
00092 .extensions = "aac",
00093 .value = CODEC_ID_AAC,
00094 };