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 AVC_DEC_H_INCLUDED
     19 #define AVC_DEC_H_INCLUDED
     20 
     21 #ifndef OMX_Component_h
     22 #include "OMX_Component.h"
     23 #endif
     24 
     25 #ifndef _AVCDEC_API_H_
     26 #include "avcdec_api.h"
     27 #endif
     28 
     29 #ifndef OSCL_MEM_H_INCLUDED
     30 #include "oscl_mem.h"
     31 #endif
     32 
     33 
     34 #define AVC_DEC_TIMESTAMP_ARRAY_SIZE 17
     35 
     36 class AVCCleanupObject_OMX
     37 {
     38         AVCHandle* ipavcHandle;
     39 
     40     public:
     41         AVCCleanupObject_OMX(AVCHandle* aAvcHandle = NULL)
     42         {
     43             ipavcHandle = aAvcHandle;
     44         }
     45 
     46         //! Use destructor to do all the clean up work
     47         ~AVCCleanupObject_OMX();
     48 };
     49 
     50 
     51 class AvcDecoder_OMX
     52 {
     53     public:
     54         AvcDecoder_OMX()
     55         {
     56             CurrInputTimestamp = 0;
     57             pDpbBuffer = NULL;
     58             FrameSize = 0;
     59             iAvcActiveFlag = OMX_FALSE;
     60             oscl_memset(DisplayTimestampArray, 0, sizeof(OMX_TICKS)*AVC_DEC_TIMESTAMP_ARRAY_SIZE);
     61         };
     62 
     63         ~AvcDecoder_OMX() { };
     64 
     65         AVCCleanupObject_OMX*   pCleanObject;
     66         AVCHandle       AvcHandle;
     67         AVCDecSPSInfo   SeqInfo;
     68         uint32          FrameSize;
     69         uint8*          pDpbBuffer;
     70         OMX_TICKS       DisplayTimestampArray[AVC_DEC_TIMESTAMP_ARRAY_SIZE];
     71         OMX_TICKS       CurrInputTimestamp;
     72         OMX_U32         InputBytesConsumed;
     73         OMX_BOOL        iAvcActiveFlag;
     74 
     75 
     76         OMX_ERRORTYPE AvcDecInit_OMX();
     77 
     78         OMX_BOOL AvcDecodeVideo_OMX(OMX_U8* aOutBuffer, OMX_U32* aOutputLength,
     79                                     OMX_U8** aInputBuf, OMX_U32* aInBufSize,
     80                                     OMX_PARAM_PORTDEFINITIONTYPE* aPortParam,
     81                                     OMX_S32* iFrameCount, OMX_BOOL aMarkerFlag,
     82                                     OMX_TICKS* aOutTimestamp,
     83                                     OMX_BOOL *aResizeFlag);
     84 
     85         OMX_ERRORTYPE AvcDecDeinit_OMX();
     86 
     87         OMX_BOOL InitializeVideoDecode_OMX();
     88 
     89         OMX_BOOL FlushOutput_OMX(OMX_U8* aOutBuffer, OMX_U32* aOutputLength, OMX_TICKS* aOutTimestamp, OMX_S32 OldWidth, OMX_S32 OldHeight);
     90 
     91         AVCDec_Status GetNextFullNAL_OMX(uint8** aNalBuffer, int32* aNalSize, OMX_U8* aInputBuf, OMX_U32* aInBufSize);
     92 
     93         static int32 AllocateBuffer_OMX(void* aUserData, int32 i, uint8** aYuvBuffer);
     94 
     95         static int32 ActivateSPS_OMX(void* aUserData, uint aSizeInMbs, uint aNumBuffers);
     96 
     97         int32 NSAllocateBuffer_OMX(void* aUserData, int32 i, uint8** aYuvBuffer);
     98 
     99         int32 NSActivateSPS_OMX(void* aUserData, uint aSizeInMbs, uint aNumBuffers);
    100 
    101         void ResetDecoder(); // for repositioning
    102 };
    103 
    104 typedef class AvcDecoder_OMX AvcDecoder_OMX;
    105 
    106 #endif  //#ifndef AVC_DEC_H_INCLUDED
    107 
    108