Ticket #365: patchlatm.diff

File patchlatm.diff, 4.6 KB (added by cehoyos, 5 years ago)
  • libavformat/Makefile

    diff --git a/libavformat/Makefile b/libavformat/Makefile
    index 9f5bfb4..3fa641b 100644
    a b OBJS-$(CONFIG_IV8_DEMUXER) += iv8.o 
    112112OBJS-$(CONFIG_IVF_DEMUXER)               += ivfdec.o riff.o 
    113113OBJS-$(CONFIG_IVF_MUXER)                 += ivfenc.o 
    114114OBJS-$(CONFIG_JV_DEMUXER)                += jvdec.o 
     115OBJS-$(CONFIG_LATM_DEMUXER)              += latmdec.o 
    115116OBJS-$(CONFIG_LMLM4_DEMUXER)             += lmlm4.o 
    116117OBJS-$(CONFIG_LXF_DEMUXER)               += lxfdec.o 
    117118OBJS-$(CONFIG_M4V_DEMUXER)               += m4vdec.o rawdec.o 
  • libavformat/allformats.c

    diff --git a/libavformat/allformats.c b/libavformat/allformats.c
    index a9fa117..a2e6a1f 100644
    a b void av_register_all(void) 
    113113    REGISTER_DEMUXER  (IV8, iv8); 
    114114    REGISTER_MUXDEMUX (IVF, ivf); 
    115115    REGISTER_DEMUXER  (JV, jv); 
     116    REGISTER_DEMUXER  (LATM, latm); 
    116117    REGISTER_DEMUXER  (LMLM4, lmlm4); 
    117118    REGISTER_DEMUXER  (LXF, lxf); 
    118119    REGISTER_MUXDEMUX (M4V, m4v); 
  • libavformat/latmdec.c

    diff --git a/libavformat/latmdec.c b/libavformat/latmdec.c
    index e69de29..e9a2b90 100644
    a b  
     1/* 
     2 * LATM demuxer 
     3 * Copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> 
     4 * Copyright (c) 2009 Robert Swain ( rob opendot cl ) 
     5 * 
     6 * This file is part of FFmpeg. 
     7 * 
     8 * FFmpeg is free software; you can redistribute it and/or 
     9 * modify it under the terms of the GNU Lesser General Public 
     10 * License as published by the Free Software Foundation; either 
     11 * version 2.1 of the License, or (at your option) any later version. 
     12 * 
     13 * FFmpeg is distributed in the hope that it will be useful, 
     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 
     19 * License along with FFmpeg; if not, write to the Free Software 
     20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 
     21 */ 
     22 
     23#include "libavutil/intreadwrite.h" 
     24#include "libavutil/internal.h" 
     25#include "avformat.h" 
     26#include "rawdec.h" 
     27 
     28 
     29static int latm_probe(AVProbeData *p) 
     30{ 
     31    int max_frames = 0, first_frames = 0; 
     32    int fsize, frames; 
     33    uint8_t *buf0 = p->buf; 
     34    uint8_t *buf2; 
     35    uint8_t *buf; 
     36    uint8_t *end = buf0 + p->buf_size - 4; 
     37    buf = buf0; 
     38 
     39    for(; buf < end; buf= buf2+1) { 
     40        buf2 = buf; 
     41 
     42        for(frames = 0; buf2 < end; frames++) { 
     43            uint32_t header = AV_RB16(buf2); 
     44            if((header&0xFFE0) != 0x56E0) 
     45                break; 
     46            fsize = ((AV_RB32(buf2) >> 8) & 0x1FFF) + 3; 
     47            if(fsize < 7) 
     48                break; 
     49            buf2 += fsize; 
     50        } 
     51        max_frames = FFMAX(max_frames, frames); 
     52        if(buf == buf0) 
     53            first_frames= frames; 
     54    } 
     55    if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; 
     56    else if(max_frames>500)return AVPROBE_SCORE_MAX/2; 
     57    else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; 
     58    else if(max_frames>=1) return 1; 
     59    else                   return 0; 
     60} 
     61 
     62static int latm_read_header(AVFormatContext *s, 
     63                                AVFormatParameters *ap) 
     64{ 
     65    AVStream *st; 
     66 
     67    st = av_new_stream(s, 0); 
     68    if (!st) 
     69        return AVERROR(ENOMEM); 
     70 
     71    st->codec->codec_type = AVMEDIA_TYPE_AUDIO; 
     72    st->codec->codec_id = s->iformat->value; 
     73    st->need_parsing = AVSTREAM_PARSE_FULL; 
     74 
     75    //LCM of all possible AAC sample rates 
     76    av_set_pts_info(st, 64, 1, 28224000); 
     77 
     78    return 0; 
     79} 
     80 
     81 
     82AVInputFormat ff_latm_demuxer = { 
     83    .name           = "latm", 
     84    .long_name      = NULL_IF_CONFIG_SMALL("LATM"), 
     85    .read_probe     = latm_probe, 
     86    .read_header    = latm_read_header, 
     87    .read_packet    = ff_raw_read_partial_packet, 
     88    .flags= AVFMT_GENERIC_INDEX, 
     89    .value = CODEC_ID_AAC_LATM, 
     90}; 
  • libavformat/utils.c

    diff --git a/libavformat/utils.c b/libavformat/utils.c
    index 38407b9..a4c4773 100644
    a b static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, AVProbeDa 
    369369        { "dts"      , CODEC_ID_DTS       , AVMEDIA_TYPE_AUDIO }, 
    370370        { "eac3"     , CODEC_ID_EAC3      , AVMEDIA_TYPE_AUDIO }, 
    371371        { "h264"     , CODEC_ID_H264      , AVMEDIA_TYPE_VIDEO }, 
     372        { "latm"     , CODEC_ID_AAC_LATM  , AVMEDIA_TYPE_AUDIO }, 
    372373        { "m4v"      , CODEC_ID_MPEG4     , AVMEDIA_TYPE_VIDEO }, 
    373374        { "mp3"      , CODEC_ID_MP3       , AVMEDIA_TYPE_AUDIO }, 
    374375        { "mpegvideo", CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO },