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 PV_AVIFILE_TYPEDEFS_H_INCLUDED
     19 #define PV_AVIFILE_TYPEDEFS_H_INCLUDED
     20 
     21 #ifndef OSCLCONFIG_LIMITS_TYPEDEFS_H_INCLUDED
     22 #include "osclconfig_limits_typedefs.h"
     23 #endif
     24 
     25 #ifndef OSCL_BASE_H_INCLUDED
     26 #include "oscl_base.h"
     27 #endif
     28 
     29 #ifndef OSCL_STRING_UTILS_H_INCLUDED
     30 #include "oscl_string_utils.h"
     31 #endif
     32 
     33 #ifndef OSCL_STDSTRING_H_INCLUDED
     34 #include "oscl_stdstring.h"
     35 #endif
     36 
     37 #ifndef OSCL_TYPES_H_INCLUDED
     38 #include "oscl_types.h"
     39 #endif
     40 
     41 #ifndef OSCL_BYTE_ORDER_H_INCLUDED
     42 #include "oscl_byte_order.h"
     43 #endif
     44 
     45 #ifndef OSCL_MEM_H_INCLUDED
     46 #include "oscl_mem.h"
     47 #endif
     48 
     49 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
     50 #include "oscl_string_containers.h"
     51 #endif
     52 
     53 #ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED
     54 #include "oscl_refcounter_memfrag.h"
     55 #endif
     56 
     57 #ifndef OSCL_VECTOR_H_INCLUDED
     58 #include "oscl_vector.h"
     59 #endif
     60 
     61 #ifndef OSCL_FILE_IO_H_INCLUDED
     62 #include "oscl_file_io.h"
     63 #endif
     64 
     65 #ifndef PVFILE_H_INCLUDED
     66 #include "pvfile.h"
     67 #endif
     68 
     69 
     70 #ifndef PV_AVIFILE_STATUS
     71 #include "pv_avifile_status.h"
     72 #endif
     73 
     74 //avi file parser specific typedefines
     75 const uint32   CHUNK_SIZE               = 4;
     76 const uint32   RES_BYTES_SZ             = 4;
     77 const uint32   MAX_STRN_SZ              = 100;
     78 const uint32   OFFSET_FROM_MOVI_LST     = 4;
     79 const uint32   MAX_COLOR_TABLE_SIZE     = 256;
     80 const uint32   BIT_COUNT1               = 1;
     81 const uint32   BIT_COUNT2               = 2;
     82 const uint32   BIT_COUNT4               = 4;
     83 const uint32   BIT_COUNT8               = 8;
     84 const uint32   BIT_COUNT16              = 16;
     85 const uint32   BIT_COUNT24              = 24;
     86 const uint32   BIT_COUNT32              = 32;
     87 
     88 #define MAKE_FOURCC(a , b, c, d)        ((uint32(a) << 24) | (uint32(b) << 16) | (uint32(c) << 8) | uint32(d))
     89 
     90 const uint32    RIFF    MAKE_FOURCC('R', 'I', 'F', 'F');
     91 const uint32    AVI     MAKE_FOURCC('A', 'V', 'I', ' ');
     92 const uint32    LIST    MAKE_FOURCC('L', 'I', 'S', 'T');
     93 const uint32    HDRL    MAKE_FOURCC('h', 'd', 'r', 'l');
     94 const uint32    AVIH    MAKE_FOURCC('a', 'v', 'i', 'h');
     95 const uint32    STRL    MAKE_FOURCC('s', 't', 'r', 'l');
     96 const uint32    STRH    MAKE_FOURCC('s', 't', 'r', 'h');
     97 const uint32    STRF    MAKE_FOURCC('s', 't', 'r', 'f');
     98 const uint32    STRN    MAKE_FOURCC('s', 't', 'r', 'n');
     99 const uint32    STRD    MAKE_FOURCC('s', 't', 'r', 'd');
    100 const uint32    IDX1    MAKE_FOURCC('i', 'd', 'x', '1');
    101 const uint32    INDX    MAKE_FOURCC('i', 'n', 'd', 'x');
    102 const uint32    VIDS    MAKE_FOURCC('v', 'i', 'd', 's');
    103 const uint32    AUDS    MAKE_FOURCC('a', 'u', 'd', 's');
    104 const uint32    MIDS    MAKE_FOURCC('m', 'i', 'd', 's');
    105 const uint32    TXTS    MAKE_FOURCC('t', 'x', 't', 's');
    106 const uint32    DIB     MAKE_FOURCC('D', 'I', 'B', ' ');    //Device-independent Bit Map
    107 const uint32    MOVI    MAKE_FOURCC('m', 'o', 'v', 'i');
    108 const uint32    JUNK    MAKE_FOURCC('J', 'U', 'N', 'K');
    109 
    110 
    111 #define WAVE_FORMAT_UNKNOWN             (0x0000)
    112 
    113 //following are defined by Microsoft
    114 #ifndef WAVE_FORMAT_PCM
    115 #define WAVE_FORMAT_PCM                 (0x0001)
    116 #define WAVE_FORMAT_ADPCM               (0x0002)
    117 #define WAVE_FORMAT_IBM_CVSD            (0x0005)
    118 #define WAVE_FORMAT_ALAW                (0x0006)
    119 #define WAVE_FORMAT_MULAW               (0x0007)
    120 #define WAVE_FORMAT_OKI_ADPCM           (0x0010)
    121 #define WAVE_FORMAT_DVI_ADPCM           (0x0011)
    122 #define WAVE_FORMAT_DIGISTD             (0x0015)
    123 #define WAVE_FORMAT_DIGIFIX             (0x0016)
    124 #define WAVE_FORMAT_YAMAHA_ADPCM        (0x0020)
    125 #define WAVE_FORMAT_DSP_TRUESPEECH      (0x0022)
    126 #define WAVE_FORMAT_GSM610              (0x0031)
    127 #endif
    128 #define IBM_FORMAT_MULAW                (0x0101)
    129 #define IBM_FORMAT_ALAW                 (0x0102)
    130 #define IBM_FORMAT_ADPCM                (0x0103)
    131 
    132 #ifndef BI_RGB
    133 #define BI_RGB            0
    134 #endif
    135 #ifndef BI_REL4
    136 #define BI_REL4           1
    137 #endif
    138 #ifndef BI_REL8
    139 #define BI_REL8           2
    140 #endif
    141 #ifndef BI_BITFIELDS
    142 #define BI_BITFIELDS      3
    143 #endif
    144 #ifndef BI_ALPHABITFIELDS
    145 #define BI_ALPHABITFIELDS 4
    146 #endif
    147 
    148 class   PVAviFileParserStatus;
    149 class   PVAviFileParser;
    150 class   PVAviFileHeader;
    151 class   PVAviFileIdxChunk;
    152 
    153 typedef enum
    154 {
    155     PV_2_AUDIO,
    156     PV_2_VIDEO,
    157     MIDI,
    158     TEXT,
    159     UNKNOWN
    160 } StreamType;
    161 
    162 
    163 //avih flags
    164 const uint32    AVIF_COPYRIGHTED        = 0x01000000;
    165 const uint32    AVIF_HASINDEX           = 0x10000000;
    166 const uint32    AVIF_ISINTERLEAVED      = 0x100000;
    167 const uint32    AVIF_MUSTUSEINDEX       = 0x010000;
    168 const uint32    AVIF_WASCAPTUREFILE     = 0x100;
    169 
    170 //strh flags
    171 const uint32    AVISF_DISABLED          = 0x01000000;
    172 const uint32    AVISF_VIDEO_PALCHANGES  = 0x10000000;
    173 
    174 //idx1 flags
    175 const uint32    AVIIF_KEYFRAME          = 0x01000000;
    176 const uint32    AVIIF_LIST              = 0x10000000;
    177 const uint32    AVIIF_NO_TIME           = 0x100000;
    178 
    179 typedef struct
    180 {
    181     uint16 left;
    182     uint16 top;
    183     uint16 right;
    184     uint16 bottom;
    185 } rcFrameType;
    186 
    187 
    188 //structure to store information present in avi file main header
    189 class PVAviFileMainHeaderStruct
    190 {
    191 
    192     public:
    193         //constructor
    194         PVAviFileMainHeaderStruct()
    195         {
    196             iMicroSecPerFrame = 0;
    197             iMaxBytesPerSec = 0;
    198             iPadding = 0;
    199             iFlags = 0;
    200             iIsAVIFileCopyrighted = false;
    201             iAVIFileHasIndxTbl = false;
    202             iISAVIFileInterleaved = false;
    203             iAVIFileMustUseIndex = false;
    204             iAVIFileWasCaptureFile = false;
    205             iTotalFrames = 0;
    206             iInitialFrames = 0;
    207             iStreams = 0;
    208             iSuggestedBufferSize = 0;
    209             iWidth = 0;
    210             iHeight = 0;
    211 
    212         };
    213 
    214         //destructor
    215         ~PVAviFileMainHeaderStruct()
    216         {
    217             iMicroSecPerFrame = 0;
    218             iMaxBytesPerSec = 0;
    219             iPadding = 0;
    220             iFlags = 0;
    221             iIsAVIFileCopyrighted = false;
    222             iAVIFileHasIndxTbl = false;
    223             iISAVIFileInterleaved = false;
    224             iAVIFileMustUseIndex = false;
    225             iAVIFileWasCaptureFile = false;
    226             iTotalFrames = 0;
    227             iInitialFrames = 0;
    228             iStreams = 0;
    229             iSuggestedBufferSize = 0;
    230             iWidth = 0;
    231             iHeight = 0;
    232 
    233         };
    234 
    235         bool    iIsAVIFileCopyrighted;
    236         bool    iAVIFileHasIndxTbl;
    237         bool    iISAVIFileInterleaved;
    238         bool    iAVIFileMustUseIndex;
    239         bool    iAVIFileWasCaptureFile;
    240         uint32  iMicroSecPerFrame;
    241         uint32  iMaxBytesPerSec;
    242         uint32  iPadding;
    243         uint32  iFlags;
    244         uint32  iTotalFrames;
    245         uint32  iInitialFrames;
    246         uint32  iStreams;
    247         uint32  iSuggestedBufferSize;
    248         uint32  iWidth;
    249         uint32  iHeight;
    250         uint32  iReserved[RES_BYTES_SZ];
    251 
    252 };
    253 
    254 //structure to store stream specific information
    255 class PVAviFileStreamHeaderStruct
    256 {
    257 
    258     public:
    259         //constructor
    260         PVAviFileStreamHeaderStruct()
    261         {
    262             iStreamTypeFCC = 0;
    263             iFlags = 0;
    264             iIsVidPalChangeAvailable = false;
    265             iAVISF_Disabled = false;
    266             iPriority = 0;
    267             iLanguage = 0;
    268             iInitFrames = 0;
    269             iScale = 0;
    270             iRate = 0;
    271             iStart = 0;
    272             iLength = 0;
    273             iSugBufSize = 0;
    274             iQuality = 0;
    275             iSampleSize = 0;
    276             iSamplingRate = 0;
    277 
    278         };
    279 
    280         //destructor
    281         ~PVAviFileStreamHeaderStruct()
    282         {
    283             iStreamTypeFCC = 0;
    284             iFlags = 0;
    285             iIsVidPalChangeAvailable = false;
    286             iAVISF_Disabled = false;
    287             iPriority = 0;
    288             iLanguage = 0;
    289             iInitFrames = 0;
    290             iScale = 0;
    291             iRate = 0;
    292             iStart = 0;
    293             iLength = 0;
    294             iSugBufSize = 0;
    295             iQuality = 0;
    296             iSampleSize = 0;
    297             iSamplingRate = 0;
    298         }
    299 
    300 
    301         uint32  iStreamTypeFCC;
    302         uint32  iFlags;
    303         bool    iIsVidPalChangeAvailable;
    304         bool    iAVISF_Disabled;
    305 
    306         //stores codec type info for Audio and Video Stream.
    307         uint8       iStreamHandler[CHUNK_SIZE];
    308         uint16      iPriority;
    309         uint16      iLanguage;
    310         uint32      iInitFrames;
    311         uint32      iScale;
    312         uint32      iRate;
    313         uint32      iStart;
    314         uint32      iLength;    //Duration of stream
    315         uint32      iSugBufSize;
    316         uint32      iQuality;
    317         uint32      iSampleSize;
    318         rcFrameType ircFrame;
    319         OsclFloat   iSamplingRate;
    320 
    321 };
    322 
    323 
    324 typedef enum
    325 {
    326     DIVX,
    327     CINEPACK,
    328     INDEO,
    329     DV,
    330     MJPEG,
    331     RGB,
    332     YUV,
    333     MP3,
    334     PCM,
    335     ADPCM
    336 } StreamHandlerType;
    337 
    338 typedef struct
    339 {
    340     uint32  chunkId;
    341     uint32  flags;
    342     uint32  offset;
    343     uint32  size;
    344     bool    isKeyFrame;
    345     bool    ifRecList;
    346     bool    ifNoTime;
    347 
    348 } IdxTblType;
    349 
    350 typedef struct
    351 {
    352     uint8 Red;
    353     uint8 Green;
    354     uint8 Blue;
    355     uint8 Flags;   //alpha entry
    356 } PalletEntryStruct;
    357 
    358 typedef struct
    359 {
    360     uint8  FirstEntry;
    361     uint8  NumEntries;
    362     uint32 Flags;
    363     Oscl_Vector<PalletEntryStruct, OsclMemAllocator> NewEntry;
    364 
    365 } AviPalChangeStruct;
    366 
    367 
    368 typedef struct
    369 {
    370     uint32  BiSize;
    371     uint32  BiWidth;
    372     uint32  BiHeight;
    373     uint16    BiPlanes;
    374     uint16    BiBitCount;
    375     uint32    BiCompression;
    376     uint32    BiSizeImage;
    377     uint32    BiXPelsPerMeter;
    378     uint32    BiYPelsPerMeter;
    379     uint32    BiClrUsed;
    380     uint32    BiClrImportant;
    381 } BitmapInfoHhr;
    382 
    383 
    384 typedef struct
    385 {
    386     uint8   Blue;
    387     uint8   Green;
    388     uint8   Red;
    389     uint8   Reserved;
    390 
    391 } RGBQuad;
    392 
    393 typedef struct
    394 {
    395     BitmapInfoHhr BmiHeader;
    396     uint32 BmiColorsCount;  //number of RGBQuads actually present
    397     RGBQuad BmiColors[MAX_COLOR_TABLE_SIZE];
    398 
    399 } BitMapInfoStruct;
    400 
    401 typedef struct
    402 {
    403     uint16    FormatTag;
    404     uint16    Channels;
    405     uint32    SamplesPerSec;
    406     uint32    AvgBytesPerSec;
    407     uint16    BlockAlign;
    408     uint16    BitsPerSample;
    409     uint16    Size;
    410 
    411 } WaveFormatExStruct;
    412 
    413 #endif      //#ifndef PV_AVIFILE_TYPEDEFS_H_INCLUDED
    414 
    415