61
|
1 /*
|
|
2 * The contents of this file are subject to the Mozilla Public
|
|
3 * License Version 1.1 (the "License"); you may not use this file
|
|
4 * except in compliance with the License. You may obtain a copy of
|
|
5 * the License at http://www.mozilla.org/MPL/
|
|
6 *
|
|
7 * Software distributed under the License is distributed on an "AS
|
|
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
9 * implied. See the License for the specific language governing
|
|
10 * rights and limitations under the License.
|
|
11 *
|
|
12 * The Original Code is MPEG4IP.
|
|
13 *
|
|
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
|
|
15 * Portions created by Cisco Systems Inc. are
|
|
16 * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved.
|
|
17 *
|
|
18 * Contributor(s):
|
|
19 * Bill May wmay@cisco.com
|
|
20 */
|
|
21
|
|
22 #include "mp4common.h"
|
|
23
|
|
24 /*
|
|
25 * SizeTableProperty is a special version of the MP4TableProperty -
|
|
26 * the BytesProperty will need to set the value before it can read
|
|
27 * from the file
|
|
28 */
|
|
29 class SizeTableProperty : public MP4TableProperty
|
|
30 {
|
|
31 public:
|
|
32 SizeTableProperty(char *name, MP4IntegerProperty *pCountProperty) :
|
|
33 MP4TableProperty(name, pCountProperty) {};
|
|
34 protected:
|
|
35 void ReadEntry(MP4File *pFile, u_int32_t index) {
|
|
36 // Each table has a size, followed by the length field
|
|
37 // first, read the length
|
|
38 m_pProperties[0]->Read(pFile, index);
|
|
39 MP4IntegerProperty *pIntProp = (MP4IntegerProperty *)m_pProperties[0];
|
|
40 // set the size in the bytes property
|
|
41 MP4BytesProperty *pBytesProp = (MP4BytesProperty *)m_pProperties[1];
|
|
42 pBytesProp->SetValueSize(pIntProp->GetValue(index), index);
|
|
43 // And read the bytes
|
|
44 m_pProperties[1]->Read(pFile, index);
|
|
45 };
|
|
46 };
|
|
47
|
|
48 MP4AvcCAtom::MP4AvcCAtom()
|
|
49 : MP4Atom("avcC")
|
|
50 {
|
|
51 MP4BitfieldProperty *pCount;
|
|
52 MP4TableProperty *pTable;
|
|
53
|
|
54 AddProperty( new MP4Integer8Property("configurationVersion")); /* 0 */
|
|
55
|
|
56 AddProperty( new MP4Integer8Property("AVCProfileIndication")); /* 1 */
|
|
57
|
|
58 AddProperty( new MP4Integer8Property("profile_compatibility")); /* 2 */
|
|
59
|
|
60 AddProperty( new MP4Integer8Property("AVCLevelIndication")); /* 3 */
|
|
61
|
|
62 AddProperty( new MP4BitfieldProperty("reserved", 6)); /* 4 */
|
|
63 AddProperty( new MP4BitfieldProperty("lengthSizeMinusOne", 2)); /* 5 */
|
|
64 AddProperty( new MP4BitfieldProperty("reserved1", 3)); /* 6 */
|
|
65 pCount = new MP4BitfieldProperty("numOfSequenceParameterSets", 5);
|
|
66 AddProperty(pCount); /* 7 */
|
|
67
|
|
68 pTable = new SizeTableProperty("sequenceEntries", pCount);
|
|
69 AddProperty(pTable); /* 8 */
|
|
70 pTable->AddProperty(new MP4Integer16Property("sequenceParameterSetLength"));
|
|
71 pTable->AddProperty(new MP4BytesProperty("sequenceParameterSetNALUnit"));
|
|
72
|
|
73 MP4Integer8Property *pCount2 = new MP4Integer8Property("numOfPictureParameterSets");
|
|
74 AddProperty(pCount2); /* 9 */
|
|
75
|
|
76 pTable = new SizeTableProperty("pictureEntries", pCount2);
|
|
77 AddProperty(pTable); /* 10 */
|
|
78 pTable->AddProperty(new MP4Integer16Property("pictureParameterSetLength"));
|
|
79 pTable->AddProperty(new MP4BytesProperty("pictureParameterSetNALUnit"));
|
|
80 }
|
|
81
|
|
82 void MP4AvcCAtom::Generate()
|
|
83 {
|
|
84 MP4Atom::Generate();
|
|
85
|
|
86 ((MP4Integer8Property*)m_pProperties[0])->SetValue(1);
|
|
87
|
|
88 m_pProperties[4]->SetReadOnly(false);
|
|
89 ((MP4BitfieldProperty*)m_pProperties[4])->SetValue(0x3f);
|
|
90 m_pProperties[4]->SetReadOnly(true);
|
|
91
|
|
92 m_pProperties[6]->SetReadOnly(false);
|
|
93 ((MP4BitfieldProperty*)m_pProperties[6])->SetValue(0x7);
|
|
94 m_pProperties[6]->SetReadOnly(true);
|
|
95 #if 0
|
|
96 // property reserved4 has non-zero fixed values
|
|
97 static u_int8_t reserved4[4] = {
|
|
98 0x00, 0x18, 0xFF, 0xFF,
|
|
99 };
|
|
100 m_pProperties[7]->SetReadOnly(false);
|
|
101 ((MP4BytesProperty*)m_pProperties[7])->
|
|
102 SetValue(reserved4, sizeof(reserved4));
|
|
103 m_pProperties[7]->SetReadOnly(true);
|
|
104 #endif
|
|
105 }
|
|
106
|