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 /* ------------------------------------------------------------------- */
20 /* MPEG-4 H263SampleEntry Class */
21 /* ------------------------------------------------------------------- */
22 /*********************************************************************************/
23 /*
24 H263SampleEntry
25 */
26
27
28 #define IMPLEMENT_H263SampleEntry
29
30 #include "h263sampleentry.h"
31 #include "h263decoderspecificinfo.h"
32 #include "atomutils.h"
33 #include "atomdefs.h"
34
35
H263SampleEntry(MP4_FF_FILE * fp,uint32 size,uint32 type)36 H263SampleEntry::H263SampleEntry(MP4_FF_FILE *fp, uint32 size, uint32 type)
37 : Atom(fp, size, type)
38 {
39 _pH263SpecificAtom = NULL;
40 _pH263decSpecificInfo = NULL;
41
42 if (_success)
43 {
44 _pparent = NULL;
45
46 // Read reserved values
47 if (!AtomUtils::read8read8(fp, _reserved[0], _reserved[1]))
48 _success = false;
49 if (!AtomUtils::read8read8(fp, _reserved[2], _reserved[3]))
50 _success = false;
51 if (!AtomUtils::read8read8(fp, _reserved[4], _reserved[5]))
52 _success = false;
53
54 if (!AtomUtils::read16(fp, _dataReferenceIndex))
55 _success = false;
56
57 // Read in all reserved members
58 for (int32 i = 0; i < 4; i++)
59 {
60 if (!AtomUtils::read32(fp, _reserved1[i]))
61 {
62 _success = false;
63 break;
64 }
65 }
66
67 if (_success)
68 {
69 if (!AtomUtils::read16(fp, _width))
70 _success = false;
71 if (!AtomUtils::read16(fp, _height))
72 _success = false;
73 if (!AtomUtils::read32(fp, _reserved3))
74 _success = false;
75 if (!AtomUtils::read32read32(fp, _reserved4, _reserved5))
76 _success = false;
77 if (!AtomUtils::read16(fp, _reserved6))
78 _success = false;
79
80 for (int32 i = 0; i < 32; i++)
81 {
82 if (!AtomUtils::read8(fp, _reserved7[i]))
83 {
84 _success = false;
85 break;
86 }
87 }
88
89 if (!AtomUtils::read16read16(fp, _reserved8, _reserved9))
90 _success = false;
91 }
92
93 if (_success)
94 {
95 uint32 atom_type = UNKNOWN_ATOM;
96 uint32 atom_size = 0;
97
98 AtomUtils::getNextAtomType(fp, atom_size, atom_type);
99
100 if (atom_type != H263_SPECIFIC_ATOM)
101 {
102 _success = false;
103 _mp4ErrorCode = READ_H263_SAMPLE_ENTRY_FAILED;
104 }
105 else
106 {
107 PV_MP4_FF_NEW(fp->auditCB, H263SpecficAtom, (fp, atom_size, atom_type), _pH263SpecificAtom);
108
109 if (_pH263SpecificAtom->MP4Success())
110 {
111 PV_MP4_FF_NEW(fp->auditCB, H263DecoderSpecificInfo, (fp, true), _pH263decSpecificInfo);
112
113 _pH263decSpecificInfo->_VendorCode = _pH263SpecificAtom->getVendorCode();
114 _pH263decSpecificInfo->_codec_version = _pH263SpecificAtom->getDecoderVersion();
115 _pH263decSpecificInfo->_codec_level = _pH263SpecificAtom->getCodecLevel();
116 _pH263decSpecificInfo->_codec_profile = _pH263SpecificAtom->getCodecProfile();
117 _pH263decSpecificInfo->_max_width = _width;
118 _pH263decSpecificInfo->_max_height = _height;
119 }
120 }
121 }
122 else
123 {
124 _mp4ErrorCode = READ_H263_SAMPLE_ENTRY_FAILED;
125 }
126 }
127 else
128 {
129 _mp4ErrorCode = READ_H263_SAMPLE_ENTRY_FAILED;
130 }
131
132 }
133
134 // Destructor
~H263SampleEntry()135 H263SampleEntry::~H263SampleEntry()
136 {
137 if (_pH263SpecificAtom != NULL)
138 {
139 PV_MP4_FF_DELETE(NULL, H263SpecficAtom, _pH263SpecificAtom);
140 }
141
142 if (_pH263decSpecificInfo != NULL)
143 {
144 PV_MP4_FF_DELETE(NULL, H263DecoderSpecificInfo, _pH263decSpecificInfo);
145 }
146 }
147