• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_AVCSampleDependency
19 
20 #include "avcsampledependency.h"
21 #include "atomutils.h"
22 #include "atomdefs.h"
23 
AVCSampleDependency(MP4_FF_FILE * fp,uint32 size,uint32 type,uint32 sample_count)24 AVCSampleDependency::AVCSampleDependency(MP4_FF_FILE *fp, uint32 size, uint32 type, uint32 sample_count)
25         : FullAtom(fp, size, type)
26 {
27     if (_success)
28     {
29 
30         PV_MP4_FF_ARRAY_NEW(NULL, uint16, (sample_count), _dependencycount);
31         if (_dependencycount == NULL)
32         {
33             _success = false;
34             _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
35             return;
36         }
37 
38         PV_MP4_FF_ARRAY_NEW(NULL, uint16, (sample_count), _relativesamplenumber);
39         if (_relativesamplenumber == NULL)
40         {
41             _success = false;
42             _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
43             return;
44         }
45 
46         for (uint32 idx = 0; idx < sample_count; idx++)
47         {
48             if (!AtomUtils::read16(fp, _dependencycount[idx]))
49             {
50                 _success = false;
51             }
52             for (uint32 i = 0; i < _dependencycount[idx]; i++)
53             {
54                 if (!AtomUtils::read16(fp, _relativesamplenumber[i]))
55                 {
56                     _success = false;
57                 }
58             }
59         }
60     }
61     if (!_success)
62     {
63         _mp4ErrorCode = READ_AVC_SAMPLE_DEPENDENCY_BOX_FAILED;
64     }
65 }
66 // Destructor
~AVCSampleDependency()67 AVCSampleDependency::~AVCSampleDependency()
68 {
69 }
70