• 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 /*
19     This PVA_FF_SampleSizeAtom Class contains the sample count and a table giving the
20     size of each sample.
21 */
22 
23 
24 #ifndef __SampleToChunkAtom_H__
25 #define __SampleToChunkAtom_H__
26 
27 #define PV_ERROR -1
28 
29 #include "fullatom.h"
30 
31 
32 class PVA_FF_SampleToChunkAtom : public PVA_FF_FullAtom
33 {
34 
35     public:
36         PVA_FF_SampleToChunkAtom(uint32 mediaType,
37                                  uint32 fileAuthoringFlags); // Constructor
38         virtual ~PVA_FF_SampleToChunkAtom();
39 
40         // Member gets and sets
getEntryCount()41         uint32 getEntryCount() const
42         {
43             return _entryCount;
44         }
45 
46         // Returns whether or not the new sample is the start of a new chunk
47         bool nextSample(int32 index, uint32 size = 0, bool oChunkStart = false);
48 
getNextChunkNumber()49         uint32 getNextChunkNumber()
50         {
51             return _currentChunkNumber++;
52         }
53 
54         int32 getSampleDescriptionIndexAt(uint32 index);
55 
56         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
57         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
58 
59     private:
60         // Adding to and getting first chunk, samples per chunk, and sample
61         // description index values
62         void addChunkEntry(uint32 chunk, uint32 samples, uint32 index);
63         void replaceLastChunkEntry(uint32 chunk, uint32 samples, uint32 index);
64         bool isNewChunk(uint32 size, int32 index);
65 
66         virtual void recomputeSize();
67 
68         uint32 _entryCount;
69         Oscl_Vector<uint32, OsclMemAllocator>* _pfirstChunkVec;
70         Oscl_Vector<uint32, OsclMemAllocator>* _psamplesPerChunkVec;
71         Oscl_Vector<uint32, OsclMemAllocator>* _psampleDescriptionIndexVec;
72 
73         int32 _mediaType;
74 
75         uint32 _currentChunkNumSamples;
76         uint32 _currentChunkDataSize; // Ad up all sample sizes for the current chunk
77         uint32 _currentChunkNumber;
78 
79         uint32 _maxNumSamplesPerChunk;
80         uint32 _maxChunkDataSize;
81         int32 _currIndex;
82 
83         static const int32 DEFAULT_MAX_NUM_SAMPLES_PER_CHUNK;
84         static const int32 DEFAULT_MAX_CHUNK_DATA_SIZE;
85 
86         bool _oInterLeaveMode;
87 };
88 
89 
90 #endif
91 
92