• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavformat/loasdec.c

Go to the documentation of this file.
00001 /*
00002  * LOAS AudioSyncStream demuxer
00003  * Copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at>
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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     //LCM of all possible AAC sample rates
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 };
Generated on Fri Feb 1 2013 14:34:52 for FFmpeg by doxygen 1.7.1