1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 /*
19 This PVA_FF_VisualSampleEntry Class is used for visual streams.
20 */
21
22
23 #define IMPLEMENT_H263SampleEntry
24
25 #include "h263sampleentry.h"
26 #include "atomutils.h"
27 #include "a_atomdefs.h"
28
29 // Constructor
PVA_FF_H263SampleEntry()30 PVA_FF_H263SampleEntry::PVA_FF_H263SampleEntry()
31 : PVA_FF_SampleEntry(FourCharConstToUint32('s', '2', '6', '3'))
32 {
33 init();
34 recomputeSize();
35 }
36
37 // Destructor
~PVA_FF_H263SampleEntry()38 PVA_FF_H263SampleEntry::~PVA_FF_H263SampleEntry()
39 {
40 PV_MP4_FF_DELETE(NULL, PVA_FF_H263SpecficAtom, pH263SpecificAtom);
41 }
42
43 void
init()44 PVA_FF_H263SampleEntry::init()
45 {
46 int32 i;
47
48 for (i = 0; i < 4; i++)
49 {
50 _reserved1[i] = 0;
51 }
52
53 _reserved2 = 0x00b00090;
54 _reserved3 = 0x00480000;
55 _reserved4 = 0x00480000;
56 _reserved5 = 0;
57 _reserved6 = 1;
58
59 for (i = 0; i < 32; i++)
60 {
61 _reserved7[i] = 0;
62 }
63
64 _reserved8 = 24;
65 _reserved9 = -1; // (16) SIGNED!
66
67 PV_MP4_FF_NEW(fp->auditCB, PVA_FF_H263SpecficAtom, (), pH263SpecificAtom);
68 }
69
70 // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
71 bool
renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP * fp)72 PVA_FF_H263SampleEntry::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
73 {
74 int32 rendered = 0;
75 int32 i;
76
77 if (!renderAtomBaseMembers(fp))
78 {
79 return false;
80 }
81 rendered += getDefaultSize();
82
83 // From PVA_FF_SampleEntry base class
84 for (i = 0; i < 6; i++)
85 {
86 if (!PVA_FF_AtomUtils::render8(fp, _reserved[i]))
87 {
88 return false;
89 }
90 rendered += 1;
91 }
92
93 if (!PVA_FF_AtomUtils::render16(fp, _dataReferenceIndex))
94 {
95 return false;
96 }
97
98 for (i = 0; i < 4; i++)
99 {
100 if (!PVA_FF_AtomUtils::render32(fp, _reserved1[i]))
101 {
102 return false;
103 }
104 rendered += 4;
105 }
106
107 if (!PVA_FF_AtomUtils::render32(fp, _reserved2))
108 {
109 return false;
110 }
111 if (!PVA_FF_AtomUtils::render32(fp, _reserved3))
112 {
113 return false;
114 }
115 if (!PVA_FF_AtomUtils::render32(fp, _reserved4))
116 {
117 return false;
118 }
119 if (!PVA_FF_AtomUtils::render32(fp, _reserved5))
120 {
121 return false;
122 }
123 rendered += 16;
124
125 if (!PVA_FF_AtomUtils::render16(fp, _reserved6))
126 {
127 return false;
128 }
129 rendered += 2;
130
131 for (i = 0; i < 32; i++)
132 {
133 if (!PVA_FF_AtomUtils::render8(fp, _reserved7[i]))
134 {
135 return false;
136 }
137 }
138 rendered += 32;
139
140 if (!PVA_FF_AtomUtils::render16(fp, _reserved8))
141 {
142 return false;
143 }
144 if (!PVA_FF_AtomUtils::render16(fp, _reserved9))
145 {
146 return false;
147 }
148 rendered += 4;
149
150 if (!pH263SpecificAtom->renderToFileStream(fp))
151 {
152 return false;
153 }
154 rendered += pH263SpecificAtom->getSize();
155
156 return true;
157 }
158
159 void
recomputeSize()160 PVA_FF_H263SampleEntry::recomputeSize()
161 {
162 int32 size = getDefaultSize();
163
164 size += 8; // For reserved and dataRefIndex of PVA_FF_SampleEntry base class
165
166 size += 16; // For reserved1[4]
167 size += 16; // For reserved2 - reserved5
168 size += 2; // For reserved6
169 size += 32; // For reserved7[32]
170 size += 2; // For reserved8
171 size += 2; // For reserved9
172
173 size += pH263SpecificAtom->getSize();
174
175 _size = size;
176
177 // Update size of parent
178 if (_pparent != NULL)
179 {
180 _pparent->recomputeSize();
181 }
182 }
183
184