• 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 "avcsampledependencytype.h"
21 #include "atomutils.h"
22 #include "atomdefs.h"
23 
AVCSampleDependencyType(MP4_FF_FILE * fp,uint32 size,uint32 type,uint32 sample_count)24 AVCSampleDependencyType::AVCSampleDependencyType(MP4_FF_FILE *fp, uint32 size, uint32 type, uint32 sample_count)
25         : FullAtom(size, _version, flags)
26 {
27     OSCL_UNUSED_ARG(type);
28     if (_success)
29     {
30         if (_version == 0)
31         {
32 
33             PV_MP4_FF_ARRAY_NEW(NULL, uint8, (sample_count), _reserved);
34 
35             if (_reserved == NULL)
36             {
37                 _success = false;
38                 _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
39                 return;
40             }
41 
42             PV_MP4_FF_ARRAY_NEW(NULL, uint8, (sample_count), _sample_depends_on);
43 
44             if (_sample_depends_on == NULL)
45             {
46                 _success = false;
47                 _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
48                 return;
49             }
50 
51             PV_MP4_FF_ARRAY_NEW(NULL, uint8, (sample_count), _sample_is_depended_on);
52 
53             if (_sample_is_depended_on == NULL)
54             {
55                 _success = false;
56                 _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
57                 return;
58             }
59 
60             for (uint32 idx = 0; idx < sample_count; idx++)
61             {
62                 if (!AtomUtils::read8(fp, _reserved[idx]))
63                 {
64                     _success = false;
65                 }
66 
67                 _sample_depends_on[idx] = (uint8)(_reserved[idx] & ~0xF3);
68                 _sample_is_depended_on[idx] = (uint8)(_reserved[idx] & ~0xFC);
69             }
70         }
71     }
72     if (!_success)
73     {
74         _mp4ErrorCode = READ_AVC_SAMPLE_DEPENDENCY_TYPE_BOX_FAILED;
75     }
76 }
77 // Destructor
~AVCSampleDependencyType()78 AVCSampleDependencyType::~AVCSampleDependencyType()
79 {
80     if (_reserved != NULL)
81         PV_MP4_ARRAY_DELETE(NULL, _reserved);
82 
83     if (_sample_depends_on != NULL)
84         PV_MP4_ARRAY_DELETE(NULL, _sample_depends_on);
85 
86     if (_sample_is_depended_on != NULL)
87         PV_MP4_ARRAY_DELETE(NULL, _sample_is_depended_on);
88 }
89