Browse code

Add LOAS demuxer.

Carl Eugen Hoyos authored on 2011/08/20 07:27:38
Showing 6 changed files
... ...
@@ -43,6 +43,7 @@ easier to use. The changes are:
43 43
       '-preset <presetname>'.
44 44
     * -intra option was removed, it's equivalent to -g 0.
45 45
 - XMV demuxer
46
+- LOAS demuxer
46 47
 
47 48
 
48 49
 version 0.8:
... ...
@@ -120,6 +120,8 @@ library:
120 120
     @tab A format used by libvpx
121 121
 @item LMLM4                     @tab   @tab X
122 122
     @tab Used by Linux Media Labs MPEG-4 PCI boards
123
+@item LOAS                      @tab   @tab X
124
+    @tab contains LATM multiplexed AAC audio
123 125
 @item LXF                       @tab   @tab X
124 126
     @tab VR native stream format, used by Leitch/Harris' video servers.
125 127
 @item Matroska                  @tab X @tab X
... ...
@@ -113,6 +113,7 @@ OBJS-$(CONFIG_IVF_DEMUXER)               += ivfdec.o riff.o
113 113
 OBJS-$(CONFIG_IVF_MUXER)                 += ivfenc.o
114 114
 OBJS-$(CONFIG_JV_DEMUXER)                += jvdec.o
115 115
 OBJS-$(CONFIG_LMLM4_DEMUXER)             += lmlm4.o
116
+OBJS-$(CONFIG_LOAS_DEMUXER)              += loasdec.o
116 117
 OBJS-$(CONFIG_LXF_DEMUXER)               += lxfdec.o
117 118
 OBJS-$(CONFIG_M4V_DEMUXER)               += m4vdec.o rawdec.o
118 119
 OBJS-$(CONFIG_M4V_MUXER)                 += rawenc.o
... ...
@@ -114,6 +114,7 @@ void av_register_all(void)
114 114
     REGISTER_MUXDEMUX (IVF, ivf);
115 115
     REGISTER_DEMUXER  (JV, jv);
116 116
     REGISTER_DEMUXER  (LMLM4, lmlm4);
117
+    REGISTER_DEMUXER  (LOAS, loas);
117 118
     REGISTER_DEMUXER  (LXF, lxf);
118 119
     REGISTER_MUXDEMUX (M4V, m4v);
119 120
     REGISTER_MUXER    (MD5, md5);
120 121
new file mode 100644
... ...
@@ -0,0 +1,88 @@
0
+/*
1
+ * LOAS AudioSyncStream demuxer
2
+ * Copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at>
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#include "libavutil/intreadwrite.h"
22
+#include "libavutil/internal.h"
23
+#include "avformat.h"
24
+#include "rawdec.h"
25
+
26
+static int loas_probe(AVProbeData *p)
27
+{
28
+    int max_frames = 0, first_frames = 0;
29
+    int fsize, frames;
30
+    uint8_t *buf0 = p->buf;
31
+    uint8_t *buf2;
32
+    uint8_t *buf;
33
+    uint8_t *end = buf0 + p->buf_size - 3;
34
+    buf = buf0;
35
+
36
+    for(; buf < end; buf= buf2+1) {
37
+        buf2 = buf;
38
+
39
+        for(frames = 0; buf2 < end; frames++) {
40
+            uint32_t header = AV_RB24(buf2);
41
+            if((header >> 13) != 0x2B7)
42
+                break;
43
+            fsize = (header & 0x1FFF) + 3;
44
+            if(fsize < 7)
45
+                break;
46
+            fsize = FFMIN(fsize, end - buf2);
47
+            buf2 += fsize;
48
+        }
49
+        max_frames = FFMAX(max_frames, frames);
50
+        if(buf == buf0)
51
+            first_frames= frames;
52
+    }
53
+    if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
54
+    else if(max_frames>100)return AVPROBE_SCORE_MAX/2;
55
+    else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
56
+    else if(max_frames>=1) return 1;
57
+    else                   return 0;
58
+}
59
+
60
+static int loas_read_header(AVFormatContext *s,
61
+                            AVFormatParameters *ap)
62
+{
63
+    AVStream *st;
64
+
65
+    st = av_new_stream(s, 0);
66
+    if (!st)
67
+        return AVERROR(ENOMEM);
68
+
69
+    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
70
+    st->codec->codec_id = s->iformat->value;
71
+    st->need_parsing = AVSTREAM_PARSE_FULL;
72
+
73
+    //LCM of all possible AAC sample rates
74
+    av_set_pts_info(st, 64, 1, 28224000);
75
+
76
+    return 0;
77
+}
78
+
79
+AVInputFormat ff_loas_demuxer = {
80
+    .name           = "loas",
81
+    .long_name      = NULL_IF_CONFIG_SMALL("LOAS AudioSyncStream"),
82
+    .read_probe     = loas_probe,
83
+    .read_header    = loas_read_header,
84
+    .read_packet    = ff_raw_read_partial_packet,
85
+    .flags= AVFMT_GENERIC_INDEX,
86
+    .value = CODEC_ID_AAC_LATM,
87
+};
... ...
@@ -24,7 +24,7 @@
24 24
 #include "libavutil/avutil.h"
25 25
 
26 26
 #define LIBAVFORMAT_VERSION_MAJOR 53
27
-#define LIBAVFORMAT_VERSION_MINOR  8
27
+#define LIBAVFORMAT_VERSION_MINOR  9
28 28
 #define LIBAVFORMAT_VERSION_MICRO  0
29 29
 
30 30
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \