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 #ifndef __AVCConfigurationAtom_H__
     19 #define __AVCConfigurationAtom_H__
     20 
     21 #include "atom.h"
     22 #include "atomutils.h"
     23 #include "oscl_file_io.h"
     24 
     25 
     26 #ifndef OSCL_VECTOR_H_INCLUDED
     27 #include "oscl_vector.h"
     28 #endif
     29 
     30 #define NAL_UNIT_LENGTH 255
     31 
     32 class PVA_FF_AVCConfigurationAtom : public PVA_FF_Atom
     33 {
     34 
     35     public:
     36         class PVA_FF_ParameterSet
     37         {
     38             public:
     39                 PVA_FF_ParameterSet()
     40                 {
     41                     _parameterSetLength = 0;
     42                     _pParameterSet = NULL;
     43                 };
     44 
     45                 PVA_FF_ParameterSet(uint16 length, uint8* sample)
     46                 {
     47                     _parameterSetLength = 0;
     48                     _pParameterSet = NULL;
     49 
     50 
     51                     if ((int16)(length) > 0)
     52                     {
     53                         _parameterSetLength = length;
     54 
     55                         PV_MP4_FF_ARRAY_NEW(NULL, uint8, _parameterSetLength, _pParameterSet);
     56 
     57 
     58 
     59                         uint8* temp = sample;
     60                         for (int32 i = 0; i < _parameterSetLength; i++)
     61                         {
     62                             _pParameterSet[i] = temp[i];
     63                         }
     64 
     65 
     66 
     67                     }
     68                 }
     69                 virtual ~PVA_FF_ParameterSet()
     70                 {
     71                     //_pParameterSet = NULL;
     72                     PV_MP4_ARRAY_DELETE(NULL, _pParameterSet);
     73                 }
     74 
     75                 uint16 getParameterSetLength()
     76                 {
     77                     return _parameterSetLength;
     78                 }
     79 
     80                 uint8* getParameterSet()
     81                 {
     82                     return _pParameterSet;
     83                 }
     84 
     85 
     86 
     87             private:
     88                 uint16 _parameterSetLength;
     89                 uint8 *_pParameterSet;
     90         };
     91 
     92 
     93         PVA_FF_AVCConfigurationAtom(uint8 profile = 1, uint8 profileComp = 0xFF, uint8 level = 0xFF);
     94         virtual ~PVA_FF_AVCConfigurationAtom();
     95         void setSample(void* samp, uint32 size);
     96         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
     97         virtual void recomputeSize();
     98         virtual uint32 getSize();
     99         bool checkIfPSWritten()
    100         {
    101             if (_lengthSize != 0)
    102                 return false;
    103             else
    104                 return true;
    105 
    106         }
    107     private:
    108         uint8* _sample;
    109         uint8 _configurationVersion;
    110         uint8 _avcProfileIndication;
    111         uint8 _profileCompatibility;
    112         uint8 _avcLevelIndication;
    113         uint8 _lengthSize;
    114         uint8 _numSequenceParameterSets;
    115         uint8 _numPictureParameterSets;
    116         uint8* _pPictureParameterSet;
    117         uint8* _pSequenceParameterSet;
    118         uint8 _reserved_zero_5bits;
    119         uint16 _seqParameterSetLen;
    120         uint16 _picParameterSetLen;
    121         uint32 _totalSeqParameterSetLength;
    122         uint32 _totalPicutureParameterSetLength;
    123         Oscl_Vector<PVA_FF_ParameterSet*, OsclMemAllocator> *_sequenceParameterSetVec;
    124         Oscl_Vector<PVA_FF_ParameterSet*, OsclMemAllocator> *_pictureParameterSetVec;
    125 
    126 
    127 
    128 };
    129 
    130 
    131 #endif
    132