annotate Input/aac/libmp4v2/atom_tfhd.cpp @ 2:6efb9e514224 trunk

[svn] Import AAC stuff.
author nenolod
date Mon, 24 Oct 2005 10:44:27 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
1 /*
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
2 * The contents of this file are subject to the Mozilla Public
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
3 * License Version 1.1 (the "License"); you may not use this file
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
4 * except in compliance with the License. You may obtain a copy of
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
5 * the License at http://www.mozilla.org/MPL/
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
6 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
7 * Software distributed under the License is distributed on an "AS
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
9 * implied. See the License for the specific language governing
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
10 * rights and limitations under the License.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
11 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
12 * The Original Code is MPEG4IP.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
13 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
15 * Portions created by Cisco Systems Inc. are
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
16 * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
17 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
18 * Contributor(s):
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
19 * Dave Mackie dmackie@cisco.com
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
20 */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
21
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
22 #include "mp4common.h"
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
23
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
24 MP4TfhdAtom::MP4TfhdAtom()
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
25 : MP4Atom("tfhd")
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
26 {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
27 AddVersionAndFlags(); /* 0, 1 */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
28 AddProperty( /* 2 */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
29 new MP4Integer32Property("trackId"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
30 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
31
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
32 void MP4TfhdAtom::AddProperties(u_int32_t flags)
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
33 {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
34 if (flags & 0x01) {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
35 // note this property is signed 64!
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
36 AddProperty(
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
37 new MP4Integer64Property("baseDataOffset"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
38 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
39 if (flags & 0x02) {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
40 AddProperty(
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
41 new MP4Integer32Property("sampleDescriptionIndex"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
42 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
43 if (flags & 0x08) {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
44 AddProperty(
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
45 new MP4Integer32Property("defaultSampleDuration"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
46 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
47 if (flags & 0x10) {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
48 AddProperty(
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
49 new MP4Integer32Property("defaultSampleSize"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
50 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
51 if (flags & 0x20) {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
52 AddProperty(
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
53 new MP4Integer32Property("defaultSampleFlags"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
54 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
55 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
56
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
57 void MP4TfhdAtom::Read()
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
58 {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
59 /* read atom version, flags, and trackId */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
60 ReadProperties(0, 3);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
61
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
62 /* need to create the properties based on the atom flags */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
63 AddProperties(GetFlags());
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
64
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
65 /* now we can read the remaining properties */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
66 ReadProperties(3);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
67
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
68 Skip(); // to end of atom
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
69 }