annotate mov.c @ 130:f607ed6aa365 libavformat

* support for AAC audio (esds decoding - using extradata) * using MOV_atom_t instead of 3 args * chunk parsers ordered alphabeticaly
author kabi
date Mon, 12 May 2003 10:59:18 +0000
parents b1843685a8f7
children 5bb5f3d201d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * MOV decoder.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 #include "avi.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #ifdef CONFIG_ZLIB
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 #include <zlib.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 * First version by Francois Revol revol@free.fr
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
28 *
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 * Features and limitations:
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
30 * - reads most of the QT files I have (at least the structure),
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 * the exceptions are .mov with zlib compressed headers ('cmov' section). It shouldn't be hard to implement.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32 * FIXED, Francois Revol, 07/17/2002
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 * - ffmpeg has nearly none of the usual QuickTime codecs,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34 * although I succesfully dumped raw and mp3 audio tracks off .mov files.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 * Sample QuickTime files with mp3 audio can be found at: http://www.3ivx.com/showcase.html
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 * - .mp4 parsing is still hazardous, although the format really is QuickTime with some minor changes
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 * (to make .mov parser crash maybe ?), despite what they say in the MPEG FAQ at
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 * http://mpeg.telecomitalialab.com/faq.htm
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 * - the code is quite ugly... maybe I won't do it recursive next time :-)
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
40 *
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 * Funny I didn't know about http://sourceforge.net/projects/qt-ffmpeg/
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 * when coding this :) (it's a writer anyway)
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
43 *
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 * Reference documents:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 * http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 * Apple:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 * http://developer.apple.com/techpubs/quicktime/qtdevdocs/QTFF/qtff.html
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 * http://developer.apple.com/techpubs/quicktime/qtdevdocs/PDF/QTFileFormat.pdf
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 * QuickTime is a trademark of Apple (AFAIK :))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 //#define DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54 /* allows chunk splitting - should work now... */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 /* in case you can't read a file, try commenting */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 #define MOV_SPLIT_CHUNKS
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 /* some streams in QT (and in MP4 mostly) aren't either video nor audio */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 /* so we first list them as this, then clean up the list of streams we give back, */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60 /* getting rid of these */
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
61 #define CODEC_TYPE_MOV_OTHER (enum CodecType) 2
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
63 static const CodecTag mov_video_tags[] = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64 /* { CODEC_ID_, MKTAG('c', 'v', 'i', 'd') }, *//* Cinepak */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 /* { CODEC_ID_H263, MKTAG('r', 'a', 'w', ' ') }, *//* Uncompressed RGB */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66 /* { CODEC_ID_H263, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */
101
0865b0aaa2af QT AVID 4CCs patch by ("Sebastien Bechet" <s dot bechet at av7 dot net>) (not tested)
mmu_man
parents: 85
diff changeset
67 /* { CODEC_ID_RAWVIDEO, MKTAG('A', 'V', 'U', 'I') }, *//* YUV with alpha-channel (AVID Uncompressed) */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 /* Graphics */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 /* Animation */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 /* Apple video */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 /* Kodak Photo CD */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74 { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'b') }, /* Motion-JPEG (format B) */
101
0865b0aaa2af QT AVID 4CCs patch by ("Sebastien Bechet" <s dot bechet at av7 dot net>) (not tested)
mmu_man
parents: 85
diff changeset
76 { CODEC_ID_MJPEG, MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */
0865b0aaa2af QT AVID 4CCs patch by ("Sebastien Bechet" <s dot bechet at av7 dot net>) (not tested)
mmu_man
parents: 85
diff changeset
77 /* { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, *//* MJPEG with alpha-channel (AVID ABVB/Truevision NuVista) */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 /* { CODEC_ID_GIF, MKTAG('g', 'i', 'f', ' ') }, *//* embedded gif files as frames (usually one "click to play movie" frame) */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 /* Sorenson video */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, /* Sorenson Video v1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, /* Sorenson Video v1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', 'i') }, /* Sorenson Video v1 (from QT specs)*/
129
b1843685a8f7 svq3 decoder by anonymous
michaelni
parents: 124
diff changeset
83 { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, /* Sorenson Video v3 */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, /* OpenDiVX *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86 /* { CODEC_ID_, MKTAG('I', 'V', '5', '0') }, *//* Indeo 5.0 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 { CODEC_ID_H263, MKTAG('h', '2', '6', '3') }, /* H263 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
101
0865b0aaa2af QT AVID 4CCs patch by ("Sebastien Bechet" <s dot bechet at av7 dot net>) (not tested)
mmu_man
parents: 85
diff changeset
90 /* { CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, *//* AVID dv */
124
a1ad0f8b75bf first pass at a new VP3 video decoder
tmmm
parents: 121
diff changeset
91 { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
92 { CODEC_ID_NONE, 0 },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 static const CodecTag mov_audio_tags[] = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 /* { CODEC_ID_PCM_S16BE, MKTAG('N', 'O', 'N', 'E') }, *//* uncompressed */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') }, /* 16 bits */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
98 /* { CODEC_ID_PCM_S8, MKTAG('t', 'w', 'o', 's') },*/ /* 8 bits */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
99 { CODEC_ID_PCM_U8, MKTAG('r', 'a', 'w', ' ') }, /* 8 bits unsigned */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') }, /* */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') }, /* */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') }, /* */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') }, /* IMA-4 ADPCM */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') }, /* Macintosh Audio Compression and Expansion 3:1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') }, /* Macintosh Audio Compression and Expansion 6:1 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 { CODEC_ID_MP2, MKTAG('.', 'm', 'p', '3') }, /* MPEG layer 3 */ /* sample files at http://www.3ivx.com/showcase.html use this tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
108 { CODEC_ID_MP2, 0x6D730055 }, /* MPEG layer 3 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 { CODEC_ID_MP2, 0x5500736D }, /* MPEG layer 3 *//* XXX: check endianness */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110 /* { CODEC_ID_OGG_VORBIS, MKTAG('O', 'g', 'g', 'S') }, *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 /* MP4 tags */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
112 { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, /* MPEG 4 AAC or audio ? */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
113 /* The standard for mpeg4 audio is still not normalised AFAIK anyway */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
114 { CODEC_ID_NONE, 0 },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
116
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
117 /* the QuickTime file format is quite convoluted...
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 * it has lots of index tables, each indexing something in another one...
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119 * Here we just use what is needed to read the chunks
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
120 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 typedef struct MOV_sample_to_chunk_tbl {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123 long first;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 long count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 long id;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
126 } MOV_sample_to_chunk_tbl;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
128 typedef struct {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
129 uint32_t type;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
130 int64_t offset;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
131 int64_t size; /* total size (excluding the size and type fields) */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
132 } MOV_atom_t;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
133
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
134 typedef struct {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
135 int seed;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
136 int flags;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
137 int size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
138 void* clrs;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
139 } MOV_ctab_t;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
140
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
141 typedef struct {
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
142 uint8_t version;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
143 uint32_t flags; // 24bit
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
144
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
145 /* 0x03 ESDescrTag */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
146 uint16_t es_id;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
147 #define MP4ODescrTag 0x01
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
148 #define MP4IODescrTag 0x02
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
149 #define MP4ESDescrTag 0x03
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
150 #define MP4DecConfigDescrTag 0x04
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
151 #define MP4DecSpecificDescrTag 0x05
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
152 #define MP4SLConfigDescrTag 0x06
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
153 #define MP4ContentIdDescrTag 0x07
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
154 #define MP4SupplContentIdDescrTag 0x08
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
155 #define MP4IPIPtrDescrTag 0x09
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
156 #define MP4IPMPPtrDescrTag 0x0A
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
157 #define MP4IPMPDescrTag 0x0B
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
158 #define MP4RegistrationDescrTag 0x0D
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
159 #define MP4ESIDIncDescrTag 0x0E
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
160 #define MP4ESIDRefDescrTag 0x0F
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
161 #define MP4FileIODescrTag 0x10
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
162 #define MP4FileODescrTag 0x11
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
163 #define MP4ExtProfileLevelDescrTag 0x13
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
164 #define MP4ExtDescrTagsStart 0x80
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
165 #define MP4ExtDescrTagsEnd 0xFE
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
166 uint8_t stream_priority;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
167
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
168 /* 0x04 DecConfigDescrTag */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
169 uint8_t object_type_id;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
170 uint8_t stream_type;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
171 /* XXX: really streamType is
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
172 * only 6bit, followed by:
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
173 * 1bit upStream
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
174 * 1bit reserved
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
175 */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
176 uint32_t buffer_size_db; // 24
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
177 uint32_t max_bitrate;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
178 uint32_t avg_bitrate;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
179
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
180 /* 0x05 DecSpecificDescrTag */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
181 uint8_t decoder_cfg_len;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
182 uint8_t *decoder_cfg;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
183
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
184 /* 0x06 SLConfigDescrTag */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
185 uint8_t sl_config_len;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
186 uint8_t *sl_config;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
187 } MOV_esds_t;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
188
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
189 struct MOVParseTableEntry;
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
190
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
191 typedef struct MOVStreamContext {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
192 int ffindex; /* the ffmpeg stream id */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
193 int is_ff_stream; /* Is this stream presented to ffmpeg ? i.e. is this an audio or video stream ? */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
194 long next_chunk;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
195 long chunk_count;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
196 int64_t *chunk_offsets;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
197 long sample_to_chunk_sz;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
198 MOV_sample_to_chunk_tbl *sample_to_chunk;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
199 long sample_to_chunk_index;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
200 long sample_size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201 long sample_count;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
202 long *sample_sizes;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
203 int time_scale;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 long current_sample;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 long left_in_chunk; /* how many samples before next chunk */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 /* specific MPEG4 header which is added at the beginning of the stream */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 int header_len;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
208 uint8_t *header_data;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
209 MOV_esds_t esds;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
210 } MOVStreamContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212 typedef struct MOVContext {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213 int mp4; /* set to 1 as soon as we are sure that the file is an .mp4 file (even some header parsing depends on this) */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 AVFormatContext *fc;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
215 int time_scale;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
216 int duration; /* duration of the longest track */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 int found_moov; /* when both 'moov' and 'mdat' sections has been found */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
218 int found_mdat; /* we suppose we have enough data to read the file */
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
219 int64_t mdat_size;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
220 int64_t mdat_offset;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
221 int total_streams;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
222 /* some streams listed here aren't presented to the ffmpeg API, since they aren't either video nor audio
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
223 * but we need the info to be able to skip data from those streams in the 'mdat' section
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
224 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
225 MOVStreamContext *streams[MAX_STREAMS];
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
226
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
227 int64_t next_chunk_offset;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
228 MOVStreamContext *partial; /* != 0 : there is still to read in the current chunk */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
229 int ctab_size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
230 MOV_ctab_t **ctab; /* color tables */
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
231 const struct MOVParseTableEntry *parse_table; /* could be eventually used to change the table */
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
232 /* NOTE: for recursion save to/ restore from local variable! */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
233 } MOVContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
234
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
235
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
236 /* XXX: it's the first time I make a recursive parser I think... sorry if it's ugly :P */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
237
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
238 /* those functions parse an atom */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
239 /* return code:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
240 1: found what I wanted, exit
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
241 0: continue to parse next atom
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
242 -1: error occured, exit
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
243 */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
244 typedef int (*mov_parse_function)(MOVContext *ctx, ByteIOContext *pb, MOV_atom_t atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
245
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
246 /* links atom IDs to parse functions */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
247 typedef struct MOVParseTableEntry {
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
248 uint32_t type;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
249 mov_parse_function func;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
250 } MOVParseTableEntry;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
251
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
252 #ifdef DEBUG
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
253 /*
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
254 * XXX: static sux, even more in a multithreaded environment...
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
255 * Avoid them. This is here just to help debugging.
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
256 */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
257 static int debug_indent = 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
258 void print_atom(const char *str, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
259 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
260 unsigned int tag, i;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
261 tag = (unsigned int) atom.type;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
262 i=debug_indent;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
263 if(tag == 0) tag = MKTAG('N', 'U', 'L', 'L');
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
264 while(i--)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
265 printf("|");
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
266 printf("parse:");
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
267 printf(" %s: tag=%c%c%c%c offset=0x%x size=0x%x\n",
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
268 str, tag & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
269 (tag >> 8) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
270 (tag >> 16) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
271 (tag >> 24) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
272 (unsigned int)atom.offset,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
273 (unsigned int)atom.size);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
274 assert((unsigned int)atom.size < 0x7fffffff);// catching errors
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
275 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
276 #else
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
277 #define print_atom(a,b)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
278 #endif
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
279
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
280
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
281 static int mov_read_leaf(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
282 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
283 print_atom("leaf", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
284
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
285 if (atom.size>1)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
286 url_fskip(pb, atom.size);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
287 /* url_seek(pb, atom_offset+atom.size, SEEK_SET); */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
288 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
289 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
290
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
291 static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
292 {
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
293 int64_t total_size = 0;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
294 MOV_atom_t a;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
295 int i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
296 int err = 0;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
297
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
298 #ifdef DEBUG
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
299 print_atom("default", atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
300 debug_indent++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
301 #endif
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
302
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
303 a.offset = atom.offset;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
304
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
305 if(atom.size < 0)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
306 atom.size = 0x0FFFFFFFFFFFFFFF;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
307 while(((total_size + 8) < atom.size) && !url_feof(pb) && !err) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
308 a.size = atom.size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
309 a.type=0L;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
310 if(atom.size >= 8) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
311 a.size = get_be32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
312 a.type = get_le32(pb);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
313 }
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
314 total_size += 8;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
315 a.offset += 8;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
316 //printf("type: %08x %.4s sz: %Lx %Lx %Lx\n", type, (char*)&type, size, atom.size, total_size);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
317 if (a.size == 1) { /* 64 bit extended size */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
318 a.size = get_be64(pb) - 8;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
319 a.offset += 8;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
320 total_size += 8;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
321 }
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
322 if (a.size == 0) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
323 a.size = atom.size - total_size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
324 if (a.size <= 8)
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
325 break;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
326 }
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
327 for (i = 0; c->parse_table[i].type != 0L
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
328 && c->parse_table[i].type != a.type; i++)
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
329 /* empty */;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
330
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
331 a.size -= 8;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
332 // printf(" i=%ld\n", i);
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
333 if (c->parse_table[i].type == 0) { /* skip leaf atoms data */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
334 // url_seek(pb, atom.offset+atom.size, SEEK_SET);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
335 #ifdef DEBUG
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
336 print_atom("unknown", a);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
337 #endif
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
338 url_fskip(pb, a.size);
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
339 } else {
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
340 #ifdef DEBUG
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
341 //char b[5] = { type & 0xff, (type >> 8) & 0xff, (type >> 16) & 0xff, (type >> 24) & 0xff, 0 };
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
342 //print_atom(b, type, offset, size);
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
343 #endif
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
344 err = (c->parse_table[i].func)(c, pb, a);
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
345 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
346
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
347 a.offset += a.size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
348 total_size += a.size;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
349 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
350
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
351 if (!err && total_size < atom.size && atom.size < 0x7ffff) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
352 //printf("RESET %Ld %Ld err:%d\n", atom.size, total_size, err);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
353 url_fskip(pb, atom.size - total_size);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
354 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
355
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
356 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
357 debug_indent--;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
358 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
359 return err;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
360 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
361
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
362 static int mov_read_ctab(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
363 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
364 unsigned int len;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
365 MOV_ctab_t *t;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
366 //url_fskip(pb, atom.size); // for now
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
367 c->ctab = av_realloc(c->ctab, ++c->ctab_size);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
368 t = c->ctab[c->ctab_size];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
369 t->seed = get_be32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
370 t->flags = get_be16(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
371 t->size = get_be16(pb) + 1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
372 len = 2 * t->size * 4;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
373 if (len > 0) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
374 t->clrs = av_malloc(len); // 16bit A R G B
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
375 if (t->clrs)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
376 get_buffer(pb, t->clrs, len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
377 }
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
378
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
379 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
380 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
381
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
382 static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
383 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
384 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
385 int len = 0;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
386 uint8_t *buf;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
387 uint32_t type;
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
388 uint32_t ctype;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
389
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
390 print_atom("hdlr", atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
391
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
392 get_byte(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
393 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
394
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
395 /* component type */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
396 ctype = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
397 type = get_le32(pb); /* component subtype */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
398
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
399 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
400 printf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
401 printf("stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
402 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
403 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
404 /* XXX: yeah this is ugly... */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
405 if(ctype == MKTAG('m', 'h', 'l', 'r')) { /* MOV */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
406 if(type == MKTAG('v', 'i', 'd', 'e'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
407 puts("hdlr: vide");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
408 else if(type == MKTAG('s', 'o', 'u', 'n'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
409 puts("hdlr: soun");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
410 } else if(ctype == 0) { /* MP4 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
411 if(type == MKTAG('v', 'i', 'd', 'e'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
412 puts("hdlr: vide");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
413 else if(type == MKTAG('s', 'o', 'u', 'n'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
414 puts("hdlr: soun");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
415 else if(type == MKTAG('o', 'd', 's', 'm'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
416 puts("hdlr: odsm");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
417 else if(type == MKTAG('s', 'd', 's', 'm'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
418 puts("hdlr: sdsm");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
419 } else puts("hdlr: meta");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
420 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
421
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
422 if(ctype == MKTAG('m', 'h', 'l', 'r')) { /* MOV */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
423 /* helps parsing the string hereafter... */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
424 c->mp4 = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
425 if(type == MKTAG('v', 'i', 'd', 'e'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
426 st->codec.codec_type = CODEC_TYPE_VIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
427 else if(type == MKTAG('s', 'o', 'u', 'n'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
428 st->codec.codec_type = CODEC_TYPE_AUDIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
429 } else if(ctype == 0) { /* MP4 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
430 /* helps parsing the string hereafter... */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
431 c->mp4 = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
432 if(type == MKTAG('v', 'i', 'd', 'e'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
433 st->codec.codec_type = CODEC_TYPE_VIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
434 else if(type == MKTAG('s', 'o', 'u', 'n'))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
435 st->codec.codec_type = CODEC_TYPE_AUDIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
436 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
437 get_be32(pb); /* component manufacture */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
438 get_be32(pb); /* component flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
439 get_be32(pb); /* component flags mask */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
440
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
441 if(atom.size <= 24)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
442 return 0; /* nothing left to read */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
443 /* XXX: MP4 uses a C string, not a pascal one */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
444 /* component name */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
445
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
446 if(c->mp4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
447 /* .mp4: C string */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
448 while(get_byte(pb) && (++len < (atom.size - 24)));
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
449 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
450 /* .mov: PASCAL string */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
451 len = get_byte(pb);
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
452 #ifdef DEBUG
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
453 buf = (uint8_t*) av_malloc(len+1);
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
454 if (buf) {
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
455 get_buffer(pb, buf, len);
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
456 buf[len] = '\0';
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
457 printf("**buf='%s'\n", buf);
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
458 av_free(buf);
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
459 } else
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
460 #endif
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
461 url_fskip(pb, len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
462 }
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
463
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
464 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
465 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
466
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
467 static int mov_mp4_read_descr_len(ByteIOContext *pb)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
468 {
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
469 int len = 0;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
470 int count = 4;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
471 while (count--) {
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
472 int c = get_byte(pb);
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
473 len = (len << 7) | (c & 0x7f);
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
474 if (!(c & 0x80))
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
475 break;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
476 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
477 return len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
478 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
479
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
480 static int mov_mp4_read_descr(ByteIOContext *pb, int *tag)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
481 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
482 int len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
483 *tag = get_byte(pb);
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
484 len = mov_mp4_read_descr_len(pb);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
485 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
486 printf("MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
487 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
488 return len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
489 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
490
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
491 static inline unsigned int get_be24(ByteIOContext *s)
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
492 {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
493 unsigned int val;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
494 val = get_byte(s) << 16;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
495 val |= get_byte(s) << 8;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
496 val |= get_byte(s);
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
497 return val;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
498 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
499
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
500 static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
501 {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
502 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
503 MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
504 int64_t start_pos = url_ftell(pb);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
505 int tag, len;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
506
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
507 print_atom("esds", atom);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
508
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
509 /* Well, broken but suffisant for some MP4 streams */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
510 get_be32(pb); /* version + flags */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
511 len = mov_mp4_read_descr(pb, &tag);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
512 if (tag == MP4ESDescrTag) {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
513 get_be16(pb); /* ID */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
514 get_byte(pb); /* priority */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
515 } else
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
516 get_be16(pb); /* ID */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
517
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
518 len = mov_mp4_read_descr(pb, &tag);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
519 if (tag == MP4DecConfigDescrTag) {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
520 sc->esds.object_type_id = get_byte(pb);
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
521 sc->esds.stream_type = get_byte(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
522 sc->esds.buffer_size_db = get_be24(pb);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
523 sc->esds.max_bitrate = get_be32(pb);
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
524 sc->esds.avg_bitrate = get_be32(pb);
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
525
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
526 len = mov_mp4_read_descr(pb, &tag);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
527 //printf("LEN %d TAG %d m:%d a:%d\n", len, tag, sc->esds.max_bitrate, sc->esds.avg_bitrate);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
528 if (tag == MP4DecSpecificDescrTag) {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
529 #ifdef DEBUG
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
530 printf("Specific MPEG4 header len=%d\n", len);
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
531 #endif
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
532 st->codec.extradata = (uint8_t*) av_mallocz(len);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
533 if (st->codec.extradata) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
534 get_buffer(pb, st->codec.extradata, len);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
535 st->codec.extradata_size = len;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
536 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
537 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
538 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
539 /* in any case, skip garbage */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
540 url_fskip(pb, atom.size - ((url_ftell(pb) - start_pos)));
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
541 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
542 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
543
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
544 /* this atom contains actual media data */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
545 static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
546 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
547 print_atom("mdat", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
548
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
549 if(atom.size == 0) /* wrong one (MP4) */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
550 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
551 c->found_mdat=1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
552 c->mdat_offset = atom.offset;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
553 c->mdat_size = atom.size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
554 if(c->found_moov)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
555 return 1; /* found both, just go */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
556 url_fskip(pb, atom.size);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
557 return 0; /* now go for moov */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
558 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
559
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
560 /* this atom should contain all header atoms */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
561 static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
562 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
563 int err;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
564
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
565 print_atom("moov", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
566
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
567 err = mov_read_default(c, pb, atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
568 /* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
569 /* so we don't parse the whole file if over a network */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
570 c->found_moov=1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
571 if(c->found_mdat)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
572 return 1; /* found both, just go */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
573 return 0; /* now go for mdat */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
574 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
575
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
576
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
577 static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
578 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
579 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
580
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
581 print_atom("mdhd", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
582
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
583 get_byte(pb); /* version */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
584
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
585 get_byte(pb); get_byte(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
586 get_byte(pb); /* flags */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
587
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
588 get_be32(pb); /* creation time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
589 get_be32(pb); /* modification time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
590
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
591 c->streams[c->total_streams]->time_scale = get_be32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
592
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
593 #ifdef DEBUG
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
594 printf("track[%i].time_scale = %i\n", c->fc->nb_streams-1, c->streams[c->total_streams]->time_scale); /* time scale */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
595 #endif
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
596 get_be32(pb); /* duration */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
597
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
598 get_be16(pb); /* language */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
599 get_be16(pb); /* quality */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
600
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
601 return 0;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
602 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
603
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
604 static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
605 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
606 print_atom("mvhd", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
607
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
608 get_byte(pb); /* version */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
609 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
610
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
611 get_be32(pb); /* creation time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
612 get_be32(pb); /* modification time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
613 c->time_scale = get_be32(pb); /* time scale */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
614 #ifdef DEBUG
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
615 printf("time scale = %i\n", c->time_scale);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
616 #endif
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
617 c->duration = get_be32(pb); /* duration */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
618 get_be32(pb); /* preferred scale */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
619
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
620 get_be16(pb); /* preferred volume */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
621
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
622 url_fskip(pb, 10); /* reserved */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
623
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
624 url_fskip(pb, 36); /* display matrix */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
625
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
626 get_be32(pb); /* preview time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
627 get_be32(pb); /* preview duration */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
628 get_be32(pb); /* poster time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
629 get_be32(pb); /* selection time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
630 get_be32(pb); /* selection duration */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
631 get_be32(pb); /* current time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
632 get_be32(pb); /* next track ID */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
633
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
634 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
635 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
636
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
637
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
638 static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
639 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
640 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
641 MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
642 int entries, i;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
643
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
644 print_atom("stco", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
645
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
646 get_byte(pb); /* version */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
647 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
648
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
649 entries = get_be32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
650 sc->chunk_count = entries;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
651 sc->chunk_offsets = (int64_t*) av_malloc(entries * sizeof(int64_t));
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
652 if (!sc->chunk_offsets)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
653 return -1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
654 if (atom.type == MKTAG('s', 't', 'c', 'o')) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
655 for(i=0; i<entries; i++) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
656 sc->chunk_offsets[i] = get_be32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
657 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
658 } else if (atom.type == MKTAG('c', 'o', '6', '4')) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
659 for(i=0; i<entries; i++) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
660 sc->chunk_offsets[i] = get_be64(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
661 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
662 } else
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
663 return -1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
664 #ifdef DEBUG
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
665 /*
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
666 for(i=0; i<entries; i++) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
667 printf("chunk offset=0x%Lx\n", sc->chunk_offsets[i]);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
668 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
669 */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
670 #endif
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
671 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
672 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
673
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
674 static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
675 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
676 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
677 MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
678 int entries, frames_per_sample;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
679 uint32_t format;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
680
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
681 print_atom("stsd", atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
682
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
683 get_byte(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
684 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
685
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
686 entries = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
687
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
688 while(entries--) {
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
689 enum CodecID id;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
690 int size = get_be32(pb); /* size */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
691 format = get_le32(pb); /* data format */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
692
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
693 get_be32(pb); /* reserved */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
694 get_be16(pb); /* reserved */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
695 get_be16(pb); /* index */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
696
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
697 /* for MPEG4: set codec type by looking for it */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
698 id = codec_get_id(mov_video_tags, format);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
699 if (id >= 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
700 AVCodec *codec;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
701 codec = avcodec_find_decoder(id);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
702 if (codec)
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
703 st->codec.codec_type = codec->type;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
704 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
705 #ifdef DEBUG
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
706 printf("size=%d 4CC= %c%c%c%c codec_type=%d\n",
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
707 size,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
708 (format >> 0) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
709 (format >> 8) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
710 (format >> 16) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
711 (format >> 24) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
712 st->codec.codec_type);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
713 #endif
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
714 st->codec.codec_tag = format;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
715 if(st->codec.codec_type==CODEC_TYPE_VIDEO) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
716 MOV_atom_t a = { 0, 0, 0 };
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
717 st->codec.codec_id = id;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
718 get_be16(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
719 get_be16(pb); /* revision level */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
720 get_be32(pb); /* vendor */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
721 get_be32(pb); /* temporal quality */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
722 get_be32(pb); /* spacial quality */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
723 st->codec.width = get_be16(pb); /* width */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
724 st->codec.height = get_be16(pb); /* height */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
725 #if 1
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
726 if (st->codec.codec_id == CODEC_ID_MPEG4) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
727 /* in some MPEG4 the width/height are not correct, so
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
728 we ignore this info */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
729 st->codec.width = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
730 st->codec.height = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
731 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
732 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
733 get_be32(pb); /* horiz resolution */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
734 get_be32(pb); /* vert resolution */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
735 get_be32(pb); /* data size, always 0 */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
736 frames_per_sample = get_be16(pb); /* frames per samples */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
737 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
738 printf("frames/samples = %d\n", frames_per_sample);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
739 #endif
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
740 get_buffer(pb, (uint8_t *)st->codec.codec_name, 32); /* codec name */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
741
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
742 st->codec.bits_per_sample = get_be16(pb); /* depth */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
743 st->codec.color_table_id = get_be16(pb); /* colortable id */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
744
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
745 st->codec.frame_rate = 25;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
746 st->codec.frame_rate_base = 1;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
747
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
748 size -= (16+8*4+2+32+2*2);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
749 #if 0
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
750 while (size >= 8) {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
751 MOV_atom_t a;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
752 int64_t start_pos;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
753
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
754 a.size = get_be32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
755 a.type = get_le32(pb);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
756 size -= 8;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
757 #ifdef DEBUG
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
758 printf("VIDEO: atom_type=%c%c%c%c atom.size=%Ld size_left=%d\n",
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
759 (a.type >> 0) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
760 (a.type >> 8) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
761 (a.type >> 16) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
762 (a.type >> 24) & 0xff,
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
763 a.size, size);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
764 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
765 start_pos = url_ftell(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
766
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
767 switch(a.type) {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
768 case MKTAG('e', 's', 'd', 's'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
769 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
770 int tag, len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
771 /* Well, broken but suffisant for some MP4 streams */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
772 get_be32(pb); /* version + flags */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
773 len = mov_mp4_read_descr(pb, &tag);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
774 if (tag == 0x03) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
775 /* MP4ESDescrTag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
776 get_be16(pb); /* ID */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
777 get_byte(pb); /* priority */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
778 len = mov_mp4_read_descr(pb, &tag);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
779 if (tag != 0x04)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
780 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
781 /* MP4DecConfigDescrTag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
782 get_byte(pb); /* objectTypeId */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
783 get_be32(pb); /* streamType + buffer size */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
784 get_be32(pb); /* max bit rate */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
785 get_be32(pb); /* avg bit rate */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
786 len = mp4_read_descr(pb, &tag);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
787 if (tag != 0x05)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
788 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
789 /* MP4DecSpecificDescrTag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
790 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
791 printf("Specific MPEG4 header len=%d\n", len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
792 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
793 sc->header_data = av_mallocz(len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
794 if (sc->header_data) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
795 get_buffer(pb, sc->header_data, len);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
796 sc->header_len = len;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
797 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
798 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
799 /* in any case, skip garbage */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
800 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
801 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
802 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
803 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
804 }
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
805 fail:
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
806 printf("ATOMENEWSIZE %Ld %d\n", atom.size, url_ftell(pb) - start_pos);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
807 if (atom.size > 8) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
808 url_fskip(pb, (atom.size - 8) -
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
809 ((url_ftell(pb) - start_pos)));
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
810 size -= atom.size - 8;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
811 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
812 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
813 if (size > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
814 /* unknown extension */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
815 url_fskip(pb, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
816 }
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
817 #else
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
818 a.size = size;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
819 mov_read_default(c, pb, a);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
820 #endif
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
821 } else {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
822 get_be16(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
823 get_be16(pb); /* revision level */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
824 get_be32(pb); /* vendor */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
825
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
826 st->codec.channels = get_be16(pb); /* channel count */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
827 st->codec.bits_per_sample = get_be16(pb); /* sample size */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
828
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
829 st->codec.codec_id = codec_get_id(mov_audio_tags, format);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
830 /* handle specific s8 codec */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
831 get_be16(pb); /* compression id = 0*/
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
832 get_be16(pb); /* packet size = 0 */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
833
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
834 st->codec.sample_rate = ((get_be32(pb) >> 16));
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
835 //printf("CODECID %d %d %.4s\n", st->codec.codec_id, CODEC_ID_PCM_S16BE, (char*)&format);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
836
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
837 switch (st->codec.codec_id) {
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
838 case CODEC_ID_PCM_S16BE:
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
839 if (st->codec.bits_per_sample == 8)
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
840 st->codec.codec_id = CODEC_ID_PCM_S8;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
841 /* fall */
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
842 case CODEC_ID_PCM_U8:
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
843 st->codec.bit_rate = st->codec.sample_rate * 8;
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
844 break;
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
845 default:
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
846 ;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
847 }
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
848 get_be32(pb); /* samples per packet */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
849 get_be32(pb); /* bytes per packet */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
850 get_be32(pb); /* bytes per frame */
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
851 get_be32(pb); /* bytes per sample */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
852
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
853 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
854 MOV_atom_t a = { format, url_ftell(pb), size - (16 + 20 + 16 + 8) };
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
855 mov_read_default(c, pb, a);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
856 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
857 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
858 }
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
859
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
860 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
861 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
862
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
863 static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
864 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
865 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
866 MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
867 int entries, i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
868
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
869 print_atom("stsc", atom);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
870
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
871 get_byte(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
872 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
873
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
874 entries = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
875 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
876 printf("track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
877 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
878 sc->sample_to_chunk_sz = entries;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
879 sc->sample_to_chunk = (MOV_sample_to_chunk_tbl*) av_malloc(entries * sizeof(MOV_sample_to_chunk_tbl));
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
880 if (!sc->sample_to_chunk)
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
881 return -1;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
882 for(i=0; i<entries; i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
883 sc->sample_to_chunk[i].first = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
884 sc->sample_to_chunk[i].count = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
885 sc->sample_to_chunk[i].id = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
886 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
887 /* printf("sample_to_chunk first=%ld count=%ld, id=%ld\n", sc->sample_to_chunk[i].first, sc->sample_to_chunk[i].count, sc->sample_to_chunk[i].id); */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
888 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
889 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
890 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
891 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
892
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
893 static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
894 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
895 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
896 MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
897 int entries, i;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
898
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
899 print_atom("stsz", atom);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
900
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
901 get_byte(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
902 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
903
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
904 sc->sample_size = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
905 entries = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
906 sc->sample_count = entries;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
907 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
908 printf("sample_size = %ld sample_count = %ld\n", sc->sample_size, sc->sample_count);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
909 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
910 if(sc->sample_size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
911 return 0; /* there isn't any table following */
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
912 sc->sample_sizes = (long*) av_malloc(entries * sizeof(long));
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
913 if (!sc->sample_sizes)
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
914 return -1;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
915 for(i=0; i<entries; i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
916 sc->sample_sizes[i] = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
917 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
918 /* printf("sample_sizes[]=%ld\n", sc->sample_sizes[i]); */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
919 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
920 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
921 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
922 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
923
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
924 static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
925 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
926 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
927 MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
928 int entries, i;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
929
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
930 print_atom("stts", atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
931
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
932 get_byte(pb); /* version */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
933 get_byte(pb); get_byte(pb); get_byte(pb); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
934 entries = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
935 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
936 printf("track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
937 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
938 for(i=0; i<entries; i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
939 int sample_duration;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
940
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
941 get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
942 sample_duration = get_be32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
943
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
944 if (!i && st->codec.codec_type==CODEC_TYPE_VIDEO) {
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
945 st->codec.frame_rate_base = sample_duration ? sample_duration : 1;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 65
diff changeset
946 st->codec.frame_rate = c->streams[c->total_streams]->time_scale;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
947 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
948 printf("VIDEO FRAME RATE= %i (sd= %i)\n", st->codec.frame_rate, sample_duration);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
949 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
950 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
951 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
952 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
953 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
954
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
955 static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
956 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
957 AVStream *st;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
958 MOVStreamContext *sc;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
959
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
960 print_atom("trak", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
961
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
962 st = av_new_stream(c->fc, c->fc->nb_streams);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
963 if (!st) return -2;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
964 sc = (MOVStreamContext*) av_mallocz(sizeof(MOVStreamContext));
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
965 if (!sc) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
966 av_free(st);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
967 return -1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
968 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
969
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
970 sc->sample_to_chunk_index = -1;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
971 st->priv_data = sc;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
972 st->codec.codec_type = CODEC_TYPE_MOV_OTHER;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
973 st->time_length = (c->duration * 1000) / c->time_scale; // time in miliseconds
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
974 c->streams[c->fc->nb_streams-1] = sc;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
975
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
976 return mov_read_default(c, pb, atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
977 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
978
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
979 static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
980 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
981 AVStream *st;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
982
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
983 print_atom("tkhd", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
984
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
985 st = c->fc->streams[c->fc->nb_streams-1];
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
986
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
987 get_byte(pb); /* version */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
988
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
989 get_byte(pb); get_byte(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
990 get_byte(pb); /* flags */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
991 /*
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
992 MOV_TRACK_ENABLED 0x0001
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
993 MOV_TRACK_IN_MOVIE 0x0002
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
994 MOV_TRACK_IN_PREVIEW 0x0004
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
995 MOV_TRACK_IN_POSTER 0x0008
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
996 */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
997
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
998 get_be32(pb); /* creation time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
999 get_be32(pb); /* modification time */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1000 st->id = (int)get_be32(pb); /* track id (NOT 0 !)*/
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1001 get_be32(pb); /* reserved */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1002 st->time_length = get_be32(pb) * 1000 / c->time_scale; /* duration */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1003 get_be32(pb); /* reserved */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1004 get_be32(pb); /* reserved */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1005
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1006 get_be16(pb); /* layer */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1007 get_be16(pb); /* alternate group */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1008 get_be16(pb); /* volume */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1009 get_be16(pb); /* reserved */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1010
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1011 url_fskip(pb, 36); /* display matrix */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1012
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1013 /* those are fixed-point */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1014 st->codec.width = get_be32(pb) >> 16; /* track width */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1015 st->codec.height = get_be32(pb) >> 16; /* track height */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1016
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1017 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1018 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1019
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1020 /* this atom should be null (from specs), but some buggy files put the 'moov' atom inside it... */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1021 /* like the files created with Adobe Premiere 5.0, for samples see */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1022 /* http://graphics.tudelft.nl/~wouter/publications/soundtests/ */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1023 static int mov_read_wide(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1024 {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1025 int err;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1026 uint32_t type;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1027
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1028 #ifdef DEBUG
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1029 print_atom("wide", atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1030 debug_indent++;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1031 #endif
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1032 if (atom.size < 8)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1033 return 0; /* continue */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1034 if (get_be32(pb) != 0) { /* 0 sized mdat atom... use the 'wide' atom size */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1035 url_fskip(pb, atom.size - 4);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1036 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1037 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1038 atom.type = get_le32(pb);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1039 atom.offset += 8;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1040 atom.size -= 8;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1041 if (type != MKTAG('m', 'd', 'a', 't')) {
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1042 url_fskip(pb, atom.size);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1043 return 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1044 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1045 err = mov_read_mdat(c, pb, atom);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1046 #ifdef DEBUG
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1047 debug_indent--;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1048 #endif
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1049 return err;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1050 }
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1051
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1052
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1053 #ifdef CONFIG_ZLIB
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
1054 static int null_read_packet(void *opaque, uint8_t *buf, int buf_size)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1055 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1056 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1057 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1058
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1059 static int mov_read_cmov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1060 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1061 ByteIOContext ctx;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1062 uint8_t *cmov_data;
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1063 uint8_t *moov_data; /* uncompressed data */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1064 long cmov_len, moov_len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1065 int ret;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1066
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1067 print_atom("cmov", atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1068
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1069 get_be32(pb); /* dcom atom */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1070 if (get_le32(pb) != MKTAG( 'd', 'c', 'o', 'm' ))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1071 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1072 if (get_le32(pb) != MKTAG( 'z', 'l', 'i', 'b' )) {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1073 dprintf("unknown compression for cmov atom !");
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1074 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1075 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1076 get_be32(pb); /* cmvd atom */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1077 if (get_le32(pb) != MKTAG( 'c', 'm', 'v', 'd' ))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1078 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1079 moov_len = get_be32(pb); /* uncompressed size */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1080 cmov_len = atom.size - 6 * 4;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1081
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1082 cmov_data = (uint8_t *) av_malloc(cmov_len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1083 if (!cmov_data)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1084 return -1;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1085 moov_data = (uint8_t *) av_malloc(moov_len);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1086 if (!moov_data) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1087 av_free(cmov_data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1088 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1089 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1090 get_buffer(pb, cmov_data, cmov_len);
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1091 if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1092 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1093 if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, null_read_packet, NULL, NULL) != 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1094 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1095 ctx.buf_end = ctx.buffer + moov_len;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1096 atom.type = MKTAG( 'm', 'o', 'o', 'v' );
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1097 atom.offset = 0;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1098 atom.size = moov_len;
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1099 ret = mov_read_default(c, &ctx, atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1100 av_free(moov_data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1101 av_free(cmov_data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1102 return ret;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1103 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1104 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1105
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1106 static const MOVParseTableEntry mov_default_parse_table[] = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1107 /* mp4 atoms */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1108 { MKTAG( 'c', 'o', '6', '4' ), mov_read_stco },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1109 { MKTAG( 'c', 'p', 'r', 't' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1110 { MKTAG( 'c', 'r', 'h', 'd' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1111 { MKTAG( 'c', 't', 't', 's' ), mov_read_leaf }, /* composition time to sample */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1112 { MKTAG( 'd', 'i', 'n', 'f' ), mov_read_default }, /* data information */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1113 { MKTAG( 'd', 'p', 'n', 'd' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1114 { MKTAG( 'd', 'r', 'e', 'f' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1115 { MKTAG( 'e', 'd', 't', 's' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1116 { MKTAG( 'e', 'l', 's', 't' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1117 { MKTAG( 'f', 'r', 'e', 'e' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1118 { MKTAG( 'h', 'd', 'l', 'r' ), mov_read_hdlr },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1119 { MKTAG( 'h', 'i', 'n', 't' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1120 { MKTAG( 'h', 'm', 'h', 'd' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1121 { MKTAG( 'i', 'o', 'd', 's' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1122 { MKTAG( 'm', 'd', 'a', 't' ), mov_read_mdat },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1123 { MKTAG( 'm', 'd', 'h', 'd' ), mov_read_mdhd },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1124 { MKTAG( 'm', 'd', 'i', 'a' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1125 { MKTAG( 'm', 'i', 'n', 'f' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1126 { MKTAG( 'm', 'o', 'o', 'v' ), mov_read_moov },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1127 { MKTAG( 'm', 'p', '4', 'a' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1128 { MKTAG( 'm', 'p', '4', 's' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1129 { MKTAG( 'm', 'p', '4', 'v' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1130 { MKTAG( 'm', 'p', 'o', 'd' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1131 { MKTAG( 'm', 'v', 'h', 'd' ), mov_read_mvhd },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1132 { MKTAG( 'n', 'm', 'h', 'd' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1133 { MKTAG( 'o', 'd', 'h', 'd' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1134 { MKTAG( 's', 'd', 'h', 'd' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1135 { MKTAG( 's', 'k', 'i', 'p' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1136 { MKTAG( 's', 'm', 'h', 'd' ), mov_read_leaf }, /* sound media info header */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1137 { MKTAG( 's', 't', 'b', 'l' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1138 { MKTAG( 's', 't', 'c', 'o' ), mov_read_stco },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1139 { MKTAG( 's', 't', 'd', 'p' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1140 { MKTAG( 's', 't', 's', 'c' ), mov_read_stsc },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1141 { MKTAG( 's', 't', 's', 'd' ), mov_read_stsd }, /* sample description */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1142 { MKTAG( 's', 't', 's', 'h' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1143 { MKTAG( 's', 't', 's', 's' ), mov_read_leaf }, /* sync sample */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1144 { MKTAG( 's', 't', 's', 'z' ), mov_read_stsz }, /* sample size */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1145 { MKTAG( 's', 't', 't', 's' ), mov_read_stts },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1146 { MKTAG( 't', 'k', 'h', 'd' ), mov_read_tkhd }, /* track header */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1147 { MKTAG( 't', 'r', 'a', 'k' ), mov_read_trak },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1148 { MKTAG( 't', 'r', 'e', 'f' ), mov_read_default }, /* not really */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1149 { MKTAG( 'u', 'd', 't', 'a' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1150 { MKTAG( 'u', 'r', 'l', ' ' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1151 { MKTAG( 'u', 'r', 'n', ' ' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1152 { MKTAG( 'u', 'u', 'i', 'd' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1153 { MKTAG( 'v', 'm', 'h', 'd' ), mov_read_leaf }, /* video media info header */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1154 { MKTAG( 'w', 'a', 'v', 'e' ), mov_read_default },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1155 /* extra mp4 */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1156 { MKTAG( 'M', 'D', 'E', 'S' ), mov_read_leaf },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1157 /* QT atoms */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1158 { MKTAG( 'c', 'h', 'a', 'p' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1159 { MKTAG( 'c', 'l', 'i', 'p' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1160 { MKTAG( 'c', 'r', 'g', 'n' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1161 { MKTAG( 'c', 't', 'a', 'b' ), mov_read_ctab },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1162 { MKTAG( 'e', 's', 'd', 's' ), mov_read_esds },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1163 { MKTAG( 'k', 'm', 'a', 't' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1164 { MKTAG( 'm', 'a', 't', 't' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1165 { MKTAG( 'r', 'd', 'r', 'f' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1166 { MKTAG( 'r', 'm', 'd', 'a' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1167 { MKTAG( 'r', 'm', 'd', 'r' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1168 { MKTAG( 'r', 'm', 'r', 'a' ), mov_read_default },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1169 { MKTAG( 's', 'c', 'p', 't' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1170 { MKTAG( 's', 's', 'r', 'c' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1171 { MKTAG( 's', 'y', 'n', 'c' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1172 { MKTAG( 't', 'c', 'm', 'd' ), mov_read_leaf },
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1173 { MKTAG( 'w', 'i', 'd', 'e' ), mov_read_wide }, /* place holder */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1174 //{ MKTAG( 'r', 'm', 'q', 'u' ), mov_read_leaf },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1175 #ifdef CONFIG_ZLIB
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1176 { MKTAG( 'c', 'm', 'o', 'v' ), mov_read_cmov },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1177 #else
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1178 { MKTAG( 'c', 'm', 'o', 'v' ), mov_read_leaf },
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1179 #endif
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1180 { 0L, mov_read_leaf }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1181 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1182
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1183 static void mov_free_stream_context(MOVStreamContext *sc)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1184 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1185 if(sc) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1186 av_free(sc->chunk_offsets);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1187 av_free(sc->sample_to_chunk);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1188 av_free(sc->sample_sizes);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1189 av_free(sc->header_data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1190 av_free(sc);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1191 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1192 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1193
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1194 static inline uint32_t mov_to_tag(uint8_t *buf)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1195 {
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1196 return MKTAG(buf[0], buf[1], buf[2], buf[3]);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1197 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1198
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1199 static inline uint32_t to_be32(uint8_t *buf)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1200 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1201 return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1202 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1203
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1204 /* XXX: is it sufficient ? */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1205 static int mov_probe(AVProbeData *p)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1206 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1207 unsigned int offset;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1208 uint32_t tag;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1209
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1210 /* check file header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1211 if (p->buf_size <= 12)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1212 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1213 offset = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1214 for(;;) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1215 /* ignore invalid offset */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1216 if ((offset + 8) > (unsigned int)p->buf_size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1217 return 0;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1218 tag = mov_to_tag(p->buf + offset + 4);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1219 switch(tag) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1220 case MKTAG( 'm', 'o', 'o', 'v' ):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1221 case MKTAG( 'w', 'i', 'd', 'e' ):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1222 case MKTAG( 'f', 'r', 'e', 'e' ):
24
215c0f0f916e Fix probing for some files (ew.mov, april.mov)
mmu_man
parents: 0
diff changeset
1223 case MKTAG( 'm', 'd', 'a', 't' ):
215c0f0f916e Fix probing for some files (ew.mov, april.mov)
mmu_man
parents: 0
diff changeset
1224 case MKTAG( 'p', 'n', 'o', 't' ): /* detect movs with preview pics like ew.mov and april.mov */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1225 return AVPROBE_SCORE_MAX;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1226 case MKTAG( 'f', 't', 'y', 'p' ):
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1227 case MKTAG( 's', 'k', 'i', 'p' ):
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1228 offset = to_be32(p->buf) + offset;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1229 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1230 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1231 /* unrecognized tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1232 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1233 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1234 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1235 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1236 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1237
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1238 static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1239 {
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1240 MOVContext *mov = (MOVContext *) s->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1241 ByteIOContext *pb = &s->pb;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1242 int i, j, nb, err;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1243 MOV_atom_t atom = { 0, 0, 0 };
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1244
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1245 mov->fc = s;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1246 mov->parse_table = mov_default_parse_table;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1247 #if 0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1248 /* XXX: I think we should auto detect */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1249 if(s->iformat->name[1] == 'p')
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1250 mov->mp4 = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1251 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1252 if(!url_is_streamed(pb)) /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1253 atom.size = url_filesize(url_fileno(pb));
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1254 else
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1255 atom.size = 0x7FFFFFFFFFFFFFFF;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1256
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1257 #ifdef DEBUG
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1258 printf("filesz=%Ld\n", atom.size);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1259 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1260
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1261 /* check MOV header */
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1262 err = mov_read_default(mov, pb, atom);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1263 if(err<0 || (!mov->found_moov || !mov->found_mdat)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1264 puts("header not found !!!");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1265 exit(1);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1266 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1267 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1268 printf("on_parse_exit_offset=%d\n", (int) url_ftell(pb));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1269 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1270 /* some cleanup : make sure we are on the mdat atom */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1271 if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1272 url_fseek(pb, mov->mdat_offset, SEEK_SET);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1273
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1274 mov->next_chunk_offset = mov->mdat_offset; /* initialise reading */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1275
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1276 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1277 printf("mdat_reset_offset=%d\n", (int) url_ftell(pb));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1278 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1279
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1280 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1281 printf("streams= %d\n", s->nb_streams);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1282 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1283 mov->total_streams = nb = s->nb_streams;
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1284
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1285 #if 1
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1286 for(i=0; i<s->nb_streams;) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1287 if(s->streams[i]->codec.codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1288 av_free(s->streams[i]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1289 for(j=i+1; j<s->nb_streams; j++)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1290 s->streams[j-1] = s->streams[j];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1291 s->nb_streams--;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1292 } else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1293 i++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1294 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1295 for(i=0; i<s->nb_streams;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1296 MOVStreamContext *sc;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1297 sc = (MOVStreamContext *)s->streams[i]->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1298 sc->ffindex = i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1299 sc->is_ff_stream = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1300 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1301 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1302 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1303 printf("real streams= %d\n", s->nb_streams);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1304 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1305 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1306 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1307
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1308 /* Yes, this is ugly... I didn't write the specs of QT :p */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1309 /* XXX:remove useless commented code sometime */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1310 static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1311 {
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1312 MOVContext *mov = (MOVContext *) s->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1313 MOVStreamContext *sc;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 25
diff changeset
1314 int64_t offset = 0x0FFFFFFFFFFFFFFF;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1315 int i;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1316 int size;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1317 size = 0x0FFFFFFF;
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1318
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1319 #ifdef MOV_SPLIT_CHUNKS
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1320 if (mov->partial) {
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1321
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1322 int idx;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1323
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1324 sc = mov->partial;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1325 idx = sc->sample_to_chunk_index;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1326
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1327 if (idx < 0) return 0;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1328 size = sc->sample_sizes[sc->current_sample];
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1329
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1330 sc->current_sample++;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1331 sc->left_in_chunk--;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1332
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1333 if (sc->left_in_chunk <= 0)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1334 mov->partial = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1335 offset = mov->next_chunk_offset;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1336 /* extract the sample */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1337
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1338 goto readchunk;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1339 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1340 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1341
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1342 again:
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1343 sc = 0;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1344 for(i=0; i<mov->total_streams; i++) {
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1345 MOVStreamContext *msc = mov->streams[i];
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1346 //printf("MOCHUNK %ld %d %p pos:%Ld\n", mov->streams[i]->next_chunk, mov->total_streams, mov->streams[i], url_ftell(&s->pb));
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1347 if ((msc->next_chunk < msc->chunk_count) && msc->next_chunk >= 0
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1348 && (msc->chunk_offsets[msc->next_chunk] < offset)) {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1349 sc = msc;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1350 offset = msc->chunk_offsets[msc->next_chunk];
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1351 //printf("SELETED %Ld i:%d\n", offset, i);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1352 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1353 }
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1354 if (!sc || offset==0x0FFFFFFFFFFFFFFF)
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1355 return -1;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1356
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1357 sc->next_chunk++;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1358
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1359 if(mov->next_chunk_offset < offset) { /* some meta data */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1360 url_fskip(&s->pb, (offset - mov->next_chunk_offset));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1361 mov->next_chunk_offset = offset;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1362 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1363
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1364 //printf("chunk: [%i] %lli -> %lli\n", st_id, mov->next_chunk_offset, offset);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1365 if(!sc->is_ff_stream) {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1366 url_fskip(&s->pb, (offset - mov->next_chunk_offset));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1367 mov->next_chunk_offset = offset;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1368 offset = 0x0FFFFFFFFFFFFFFF;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1369 goto again;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1370 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1371
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1372 /* now get the chunk size... */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1373
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1374 for(i=0; i<mov->total_streams; i++) {
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1375 MOVStreamContext *msc = mov->streams[i];
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1376 if ((msc->next_chunk < msc->chunk_count)
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1377 && ((msc->chunk_offsets[msc->next_chunk] - offset) < size))
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1378 size = msc->chunk_offsets[msc->next_chunk] - offset;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1379 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1380 #ifdef MOV_SPLIT_CHUNKS
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1381 /* split chunks into samples */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1382 if (sc->sample_size == 0) {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1383 int idx = sc->sample_to_chunk_index;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1384 if ((idx + 1 < sc->sample_to_chunk_sz)
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1385 && (sc->next_chunk >= sc->sample_to_chunk[idx + 1].first))
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1386 idx++;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1387 sc->sample_to_chunk_index = idx;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1388 if (idx >= 0 && sc->sample_to_chunk[idx].count != 1) {
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1389 mov->partial = sc;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1390 /* we'll have to get those samples before next chunk */
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1391 sc->left_in_chunk = sc->sample_to_chunk[idx].count - 1;
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1392 size = sc->sample_sizes[sc->current_sample];
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1393 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1394
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1395 sc->current_sample++;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1396 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1397 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1398
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1399 readchunk:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1400 //printf("chunk: [%i] %lli -> %lli (%i)\n", st_id, offset, offset + size, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1401 if(size == 0x0FFFFFFF)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1402 size = mov->mdat_size + mov->mdat_offset - offset;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1403 if(size < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1404 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1405 if(size == 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1406 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1407 url_fseek(&s->pb, offset, SEEK_SET);
118
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1408
79d651162d35 * fixed initialization and some memleak
kabi
parents: 101
diff changeset
1409 //printf("READCHUNK hlen: %d %d off: %Ld pos:%Ld\n", size, sc->header_len, offset, url_ftell(&s->pb));
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1410 if (sc->header_len > 0) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1411 av_new_packet(pkt, size + sc->header_len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1412 memcpy(pkt->data, sc->header_data, sc->header_len);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1413 get_buffer(&s->pb, pkt->data + sc->header_len, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1414 /* free header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1415 av_freep(&sc->header_data);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1416 sc->header_len = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1417 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1418 av_new_packet(pkt, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1419 get_buffer(&s->pb, pkt->data, pkt->size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1420 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1421 pkt->stream_index = sc->ffindex;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1422
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1423 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1424 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1425 printf("Packet (%d, %d, %ld) ", pkt->stream_index, st_id, pkt->size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1426 for(i=0; i<8; i++)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1427 printf("%02x ", pkt->data[i]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1428 for(i=0; i<8; i++)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1429 printf("%c ", (pkt->data[i]) & 0x7F);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1430 puts("");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1431 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1432 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1433
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1434 mov->next_chunk_offset = offset + size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1435
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1436 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1437 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1438
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1439 static int mov_read_close(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1440 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1441 int i;
121
b9bd706c1ac3 * simplified parameters for parse routines
kabi
parents: 118
diff changeset
1442 MOVContext *mov = (MOVContext *) s->priv_data;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1443 for(i=0; i<mov->total_streams; i++)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1444 mov_free_stream_context(mov->streams[i]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1445 for(i=0; i<s->nb_streams; i++)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1446 av_freep(&s->streams[i]);
130
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1447 /* free color tabs */
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1448 for(i=0; i<mov->ctab_size; i++)
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1449 av_freep(&mov->ctab[i]);
f607ed6aa365 * support for AAC audio (esds decoding - using extradata)
kabi
parents: 129
diff changeset
1450 av_freep(&mov->ctab);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1451 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1452 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1453
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1454 static AVInputFormat mov_iformat = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1455 "mov",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1456 "QuickTime/MPEG4 format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1457 sizeof(MOVContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1458 mov_probe,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1459 mov_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1460 mov_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1461 mov_read_close,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1462 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1463
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1464 int mov_init(void)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1465 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1466 av_register_input_format(&mov_iformat);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1467 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1468 }