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 #define IMPLEMENT_AVCSampleToGroup
19
20 #include "avcsampletogroupbox.h"
21 #include "atomutils.h"
22 #include "atomdefs.h"
23
AVCSampleToGroup(MP4_FF_FILE * fp,uint32 size,uint32 type)24 AVCSampleToGroup::AVCSampleToGroup(MP4_FF_FILE *fp, uint32 size, uint32 type)
25 : FullAtom(fp, _size, type)
26 {
27 OSCL_UNUSED_ARG(size);
28 uint32 count = _size - DEFAULT_ATOM_SIZE;
29 if (_success)
30 {
31
32 if (!AtomUtils::read32(fp, _grouping_type))
33 {
34 _success = false;
35 }
36 count -= 4;
37
38 if (!AtomUtils::read32(fp, _entry_count))
39 {
40 _success = false;
41 }
42 count -= 4;
43
44 PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entry_count), _samplecountVec);
45 PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entry_count), _group_description_indexVec);
46
47 uint32 samplecount = 0;
48 uint32 GDIndex = 0;
49
50 for (uint32 idx = 0; idx < _entry_count; idx++)
51 {
52 if (!AtomUtils::read32(fp, samplecount))
53 {
54 _success = false;
55 }
56 _samplecountVec[idx] = samplecount;
57
58 if (!AtomUtils::read32(fp, GDIndex))
59 {
60 _success = false;
61 }
62 _group_description_indexVec[ idx ] = GDIndex;
63 }
64 }
65 if (!_success)
66 {
67 _mp4ErrorCode = READ_AVC_SAMPLE_TO_GROUP_BOX_FAILED;
68 }
69 }
70
~AVCSampleToGroup()71 AVCSampleToGroup::~AVCSampleToGroup()
72 {
73 if (_samplecountVec != NULL)
74 PV_MP4_ARRAY_DELETE(NULL, _samplecountVec);
75
76 if (_group_description_indexVec != NULL)
77 PV_MP4_ARRAY_DELETE(NULL, _group_description_indexVec);
78 }
79