Home | History | Annotate | Download | only in include
      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 /*     -------------------------------------------------------------------       */
     20 /*                        MPEG-4 CompositionOffsetAtom Class                          */
     21 /*     -------------------------------------------------------------------       */
     22 /*********************************************************************************/
     23 /*
     24     This atom gives difference between decoding time and composition time on each
     25     sample basis. This atom is optional and must be present only if Decoding time
     26     and Composition Time differ for any samples. As understood that Decoding time
     27     is always less than composition time, the offsets are termed as unsigned
     28     numbers such.
     29 */
     30 
     31 
     32 #ifndef COMPOSITIONOFFSETATOM_H_INCLUDED
     33 #define COMPOSITIONOFFSETATOM_H_INCLUDED
     34 
     35 #ifndef OSCL_FILE_IO_H_INCLUDED
     36 #include "oscl_file_io.h"
     37 #endif
     38 
     39 #ifndef FULLATOM_H_INCLUDED
     40 #include "fullatom.h"
     41 #endif
     42 
     43 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
     44 #include "oscl_scheduler_ao.h"
     45 #endif
     46 
     47 #include "oscl_scheduler.h"
     48 
     49 #define PV_ERROR -1
     50 
     51 class CompositionOffsetAtom : public FullAtom,
     52         public OsclTimerObject
     53 {
     54 
     55     public:
     56         CompositionOffsetAtom(MP4_FF_FILE *fp,
     57                               uint32 mediaType,
     58                               uint32 size,
     59                               uint32 type,
     60                               OSCL_wString& filename,
     61                               uint32 parsingMode = 0);
     62         virtual ~CompositionOffsetAtom();
     63 
     64         // Member gets and sets
     65         uint32 getEntryCount() const
     66         {
     67             return _entryCount;
     68         }
     69 
     70         uint32 getSampleCountAt(int32 index);
     71         int32 getSampleOffsetAt(int32 index);
     72         int32 getTimeOffsetForSampleNumberPeek(uint32 sampleNum);
     73         int32 getTimeOffsetForSampleNumber(uint32 num);
     74         int32 getTimeOffsetForSampleNumberGet(uint32 num);
     75         void setSamplesCount(uint32 SamplesCount);
     76 
     77         int32 resetStateVariables();
     78         int32 resetStateVariables(uint32 sampleNum);
     79 
     80         int32 resetPeekwithGet();
     81         uint32 getCurrPeekSampleCount()
     82         {
     83             return _currPeekSampleCount;
     84         }
     85 
     86         //Marker Table Related Functions
     87         int32 getTimeOffsetFromMT(uint32 samplenum, uint32 currEC, uint32 currSampleCount);
     88         int32 createMarkerTable();
     89         uint32 populateMarkerTable();
     90         void deleteMarkerTable();
     91 
     92     private:
     93         bool ParseEntryUnit(uint32 entry_cnt);
     94         void CheckAndParseEntry(uint32 i);
     95         // from OsclTimerObject
     96         void Run();
     97         uint32 _entryCount;
     98 
     99         uint32 *_psampleCountVec;
    100         uint32 *_psampleOffsetVec;
    101 
    102         //marker table related
    103         uint32 *MT_SampleCount;
    104         uint32 *MT_EntryCount;
    105         uint32 _iTotalNumSamplesInTrack;
    106         uint32 MT_Counter;
    107         uint32 addSampleCount;
    108         uint32 prevSampleCount;
    109         uint32 entrycountTraversed;
    110         uint32 MT_Table_Size;
    111         bool iMarkerTableCreation;
    112         uint32 refSample;
    113         uint32 MT_j;
    114 
    115         uint32 _mediaType;
    116 
    117         // For visual samples
    118         uint32 _currentTimestamp;
    119 
    120         MP4_FF_FILE *_fileptr;
    121 
    122         MP4_FF_FILE *_curr_fptr;
    123         uint32 *_stbl_fptr_vec;
    124         uint32 _stbl_buff_size;
    125         uint32 _curr_entry_point;
    126         uint32 _curr_buff_number;
    127         uint32 _next_buff_number;
    128 
    129         uint32  _parsed_entry_cnt;
    130         uint32 _currGetSampleCount;
    131         int32 _currGetIndex;
    132         int32 _currGetTimeOffset;
    133         uint32 _currPeekSampleCount;
    134         int32 _currPeekIndex;
    135         int32 _currPeekTimeOffset;
    136         uint32 _parsing_mode;
    137         PVLogger *iLogger, *iStateVarLogger, *iParsedDataLogger;
    138 };
    139 
    140 #endif  // COMPOSITIONOFFSETATOM_H_INCLUDED
    141 
    142