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_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
20 video stream
21 */
22
23 #define __IMPLEMENT_DecoderSpecificInfo__
24
25 #include "decoderspecificinfo.h"
26
27 #include "atomutils.h"
28
29 // Constructor
PVA_FF_DecoderSpecificInfo()30 PVA_FF_DecoderSpecificInfo::PVA_FF_DecoderSpecificInfo()
31 : PVA_FF_BaseDescriptor(0x05)
32 {
33 _infoSize = 0;
34 _pinfo = NULL;
35 }
36
37
38 // Constructor
PVA_FF_DecoderSpecificInfo(uint8 * pdata,uint32 size)39 PVA_FF_DecoderSpecificInfo::PVA_FF_DecoderSpecificInfo(uint8 *pdata, uint32 size)
40 : PVA_FF_BaseDescriptor(0x05)
41 {
42 _infoSize = size;
43 _pinfo = (uint8 *)OSCL_MALLOC(_infoSize);
44
45 oscl_memcpy(_pinfo, pdata, _infoSize);
46 recomputeSize();
47 }
48
49 // Constructor
PVA_FF_DecoderSpecificInfo(PVA_FF_TextSampleDescInfo * pdata,uint32 size)50 PVA_FF_DecoderSpecificInfo::PVA_FF_DecoderSpecificInfo(PVA_FF_TextSampleDescInfo *pdata, uint32 size)
51 : PVA_FF_BaseDescriptor(0x05)
52 {
53 _infoSize = size;
54 _pinfo = (uint8 *)OSCL_MALLOC(_infoSize);
55
56 oscl_memcpy(_pinfo, pdata, _infoSize);
57 recomputeSize();
58 }
59
60
61 // Destructor
~PVA_FF_DecoderSpecificInfo()62 PVA_FF_DecoderSpecificInfo::~PVA_FF_DecoderSpecificInfo()
63 {
64
65 OSCL_FREE(_pinfo);
66 _pinfo = NULL;
67 }
68
69 void
addInfo(uint8 * info,uint32 size)70 PVA_FF_DecoderSpecificInfo::addInfo(uint8 *info, uint32 size)
71 {
72 _infoSize = size;
73 _pinfo = (uint8 *)oscl_malloc(_infoSize);
74
75 oscl_memcpy(_pinfo, info, _infoSize);
76 }
77
78
79 bool
renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP * fp)80 PVA_FF_DecoderSpecificInfo::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
81 {
82 // Render base descriptor packed size and tag
83 if (!renderBaseDescriptorMembers(fp))
84 {
85 return false;
86 }
87
88 // Render decoder specific info payload
89 if (!PVA_FF_AtomUtils::renderByteData(fp, _infoSize, _pinfo))
90 {
91 return false;
92 }
93
94 return true;
95 }
96
97 void
recomputeSize()98 PVA_FF_DecoderSpecificInfo::recomputeSize()
99 {
100 int32 contents = _infoSize; // Size of decoder specific info payload
101
102 _sizeOfClass = contents;
103 _sizeOfSizeField = PVA_FF_AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(contents);
104
105 // Have the parent descriptor recompute its size based on this update
106 if (_pparent != NULL)
107 {
108 _pparent->recomputeSize();
109 }
110 }
111
112
113