00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavutil/intreadwrite.h"
00023 #include "libavutil/internal.h"
00024 #include "avformat.h"
00025 #include "internal.h"
00026 #include "rawdec.h"
00027
00028 static int loas_probe(AVProbeData *p)
00029 {
00030 int max_frames = 0, first_frames = 0;
00031 int fsize, frames;
00032 uint8_t *buf0 = p->buf;
00033 uint8_t *buf2;
00034 uint8_t *buf;
00035 uint8_t *end = buf0 + p->buf_size - 3;
00036 buf = buf0;
00037
00038 for(; buf < end; buf= buf2+1) {
00039 buf2 = buf;
00040
00041 for(frames = 0; buf2 < end; frames++) {
00042 uint32_t header = AV_RB24(buf2);
00043 if((header >> 13) != 0x2B7)
00044 break;
00045 fsize = (header & 0x1FFF) + 3;
00046 if(fsize < 7)
00047 break;
00048 fsize = FFMIN(fsize, end - buf2);
00049 buf2 += fsize;
00050 }
00051 max_frames = FFMAX(max_frames, frames);
00052 if(buf == buf0)
00053 first_frames= frames;
00054 }
00055 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
00056 else if(max_frames>100)return AVPROBE_SCORE_MAX/2;
00057 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
00058 else if(max_frames>=1) return 1;
00059 else return 0;
00060 }
00061
00062 static int loas_read_header(AVFormatContext *s,
00063 AVFormatParameters *ap)
00064 {
00065 AVStream *st;
00066
00067 st = avformat_new_stream(s, NULL);
00068 if (!st)
00069 return AVERROR(ENOMEM);
00070
00071 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
00072 st->codec->codec_id = s->iformat->value;
00073 st->need_parsing = AVSTREAM_PARSE_FULL;
00074
00075
00076 avpriv_set_pts_info(st, 64, 1, 28224000);
00077
00078 return 0;
00079 }
00080
00081 AVInputFormat ff_loas_demuxer = {
00082 .name = "loas",
00083 .long_name = NULL_IF_CONFIG_SMALL("LOAS AudioSyncStream"),
00084 .read_probe = loas_probe,
00085 .read_header = loas_read_header,
00086 .read_packet = ff_raw_read_partial_packet,
00087 .flags= AVFMT_GENERIC_INDEX,
00088 .value = CODEC_ID_AAC_LATM,
00089 };