1 /*! 2 * \copy 3 * Copyright (c) 2009-2013, Cisco Systems 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * 32 * \file decoder.h 33 * 34 * \brief Interfaces introduced in decoder system architecture 35 * 36 * \date 03/10/2009 Created 37 * 38 ************************************************************************************* 39 */ 40 #ifndef WELS_DECODER_SYSTEM_ARCHITECTURE_H__ 41 #define WELS_DECODER_SYSTEM_ARCHITECTURE_H__ 42 43 #include "typedefs.h" 44 #include "decoder_context.h" 45 46 namespace WelsDec { 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif//__cplusplus 51 52 /*! 53 * \brief configure decoder parameters 54 */ 55 int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpParam); 56 57 /*! 58 * \brief fill in default values of decoder context 59 */ 60 void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx); 61 62 /* 63 * fill last decoded picture info 64 */ 65 void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo); 66 67 /*! 68 * \brief fill data fields in SPS and PPS default for decoder context 69 */ 70 void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx); 71 72 /*! 73 * \brief copy SpsPps from one Ctx to another ctx for threaded code 74 */ 75 void CopySpsPps (PWelsDecoderContext pFromCtx, PWelsDecoderContext pToCtx); 76 77 /*! 78 ************************************************************************************* 79 * \brief Initialize Wels decoder parameters and memory 80 * 81 * \param pCtx input context to be initialized at first stage 82 * \param pTraceHandle handle for trace 83 * \param pLo log info pointer 84 * 85 * \return 0 - successed 86 * \return 1 - failed 87 * 88 * \note N/A 89 ************************************************************************************* 90 */ 91 int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx); 92 93 /*! 94 ************************************************************************************* 95 * \brief Uninitialize Wels decoder parameters and memory 96 * 97 * \param pCtx input context to be uninitialized at release stage 98 * 99 * \return NONE 100 * 101 * \note N/A 102 ************************************************************************************* 103 */ 104 void WelsEndDecoder (PWelsDecoderContext pCtx); 105 106 /*! 107 ************************************************************************************* 108 * \brief First entrance to decoding core interface. 109 * 110 * \param pCtx decoder context 111 * \param pBufBs bit streaming buffer 112 * \param kBsLen size in bytes length of bit streaming buffer input 113 * \param ppDst picture payload data to be output 114 * \param pDstBufInfo buf information of ouput data 115 * 116 * \return 0 - successed 117 * \return 1 - failed 118 * 119 * \note N/A 120 ************************************************************************************* 121 */ 122 123 int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen, 124 uint8_t** ppDst, SBufferInfo* pDstBufInfo, SParserBsInfo* pDstBsInfo); 125 126 /* 127 * request memory blocks for decoder avc part 128 */ 129 int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight, 130 bool& bReallocFlag); 131 132 133 /* 134 * free memory dynamically allocated during decoder 135 */ 136 void WelsFreeDynamicMemory (PWelsDecoderContext pCtx); 137 138 /*! 139 * \brief make sure synchonozization picture resolution (get from slice header) among different parts (i.e, memory related and so on) 140 * over decoder internal 141 * ( MB coordinate and parts of data within decoder context structure ) 142 * \param pCtx Wels decoder context 143 * \param iMbWidth MB width 144 * \pram iMbHeight MB height 145 * \return 0 - successful; none 0 - something wrong 146 */ 147 int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight); 148 149 /*! 150 * \brief init decoder predictive function pointers including ASM functions during MB reconstruction 151 * \param pCtx Wels decoder context 152 * \param uiCpuFlag cpu assembly indication 153 */ 154 void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag); 155 156 /*! 157 * \brief init decoder internal function pointers including ASM functions 158 * \param pCtx Wels decoder context 159 * \param uiCpuFlag cpu assembly indication 160 */ 161 void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag); 162 163 void GetVclNalTemporalId (PWelsDecoderContext pCtx); //get the info that whether or not have VCL NAL in current AU, 164 //and if YES, get the temporal ID 165 166 //reset decoder number related statistics info 167 void ResetDecStatNums (SDecoderStatistics* pDecStat); 168 //update information when freezing occurs, including IDR/non-IDR number 169 void UpdateDecStatFreezingInfo (const bool kbIdrFlag, SDecoderStatistics* pDecStat); 170 //update information when no freezing occurs, including QP, correct IDR number, ECed IDR number 171 void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx); 172 //update decoder statistics information 173 void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput); 174 //Destroy picutre buffer 175 void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa); 176 //reset picture reodering buffer list 177 void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo, 178 const bool& bFullReset); 179 180 #ifdef __cplusplus 181 } 182 #endif//__cplusplus 183 184 } // namespace WelsDec 185 186 #endif//WELS_DECODER_SYSTEM_ARCHITECTURE_H__ 187