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 encoder.h 33 * 34 * \brief core encoder 35 * 36 * \date 5/14/2009 37 * 38 ************************************************************************************* 39 */ 40 #if !defined(WELS_CORE_ENCODER_H__) 41 #define WELS_CORE_ENCODER_H__ 42 43 #include "encoder_context.h" 44 45 namespace WelsEnc { 46 /*! 47 * \brief request specific memory for SVC 48 * \param pEncCtx sWelsEncCtx* 49 * \return successful - 0; otherwise none 0 for failed 50 */ 51 int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingParasetList); 52 53 /*! 54 * \brief free memory in SVC core encoder 55 * \param pEncCtx sWelsEncCtx** 56 * \return none 57 */ 58 void FreeMemorySvc (sWelsEncCtx** ppCtx); 59 60 /*! 61 * \brief allocate or reallocate the output bs buffer 62 * \return: successful - 0; otherwise none 0 for failed 63 */ 64 int32_t AllocateBsOutputBuffer (CMemoryAlign* pMa, const int32_t iNeededLen, int32_t iOrigLen, const char* kpTag, 65 uint8_t*& pOutputBuffer); 66 //TODO: to finish this function and call it 67 68 /*! 69 * \brief initialize function pointers that potentially used in Wels encoding 70 * \param pEncCtx sWelsEncCtx* 71 * \return successful - 0; otherwise none 0 for failed 72 */ 73 int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* _param, uint32_t uiCpuFlag); 74 75 ///*! 76 // * \brief decide frame type (IDR/P frame) 77 // * \param uiFrameType frame type output 78 // * \param frame_idx frame index elapsed currently 79 // * \param idr IDR interval 80 // * \return successful - 0; otherwise none 0 for failed 81 // */ 82 /*! 83 * \brief initialize frame coding 84 */ 85 void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType, const int32_t kiDidx); 86 void LoadBackFrameNum (sWelsEncCtx* pEncCtx, const int32_t kiDidx); 87 88 EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum, const int32_t kiDidx, 89 bool bSkipFrameFlag); 90 void InitBitStream (sWelsEncCtx* pEncCtx); 91 int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize); 92 /*! 93 * \brief Dump reconstruction for dependency layer 94 */ 95 96 extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend, 97 SDqLayer* pDqLayer, bool bSimulCastAVC); 98 99 /*! 100 * \brief Dump the reconstruction pictures 101 */ 102 void DumpRecFrame (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer); 103 104 105 /*! 106 * \brief encode overall slices pData in a frame 107 * \param pEncCtx sWelsEncCtx*, encoder context 108 * \param count_slice_num count number of slices in a frame 109 * \param eNalType EWelsNalUnitType for a frame 110 * \param nal_idc EWelsNalRefIdc for a frame 111 * \return successful - 0; otherwise none 0 for failed 112 */ 113 int32_t EncodeFrame (sWelsEncCtx* pEncCtx, 114 const int32_t kiSliceNumCount, 115 const EWelsNalUnitType keNalType, 116 const EWelsNalRefIdc keNalIdc); 117 118 119 /********************************************************************************** 120 * memzero Function 121 ***********************************************************************************/ 122 void WelsSetMemZero_c (void* pDst, int32_t iSize); // confirmed_safe_unsafe_usage 123 124 #if defined(__cplusplus) 125 extern "C" { 126 #endif//__cplusplus 127 128 #ifdef X86_ASM 129 void WelsSetMemZeroAligned64_sse2 (void* pDst, int32_t iSize); 130 void WelsSetMemZeroSize64_mmx (void* pDst, int32_t iSize); 131 void WelsSetMemZeroSize8_mmx (void* pDst, int32_t iSize); 132 void WelsPrefetchZero_mmx (int8_t const* kpDst); 133 #elif defined(HAVE_NEON) 134 void WelsSetMemZero_neon (void* pDst, int32_t iSize); 135 #elif defined(HAVE_NEON_AARCH64) 136 void WelsSetMemZero_AArch64_neon (void* pDst, int32_t iSize); 137 #endif 138 139 #if defined(__cplusplus) 140 } 141 #endif//__cplusplus 142 143 /********************************************************************************** 144 * Function points type 145 ***********************************************************************************/ 146 } 147 148 #endif//WELS_CORE_ENCODER_H__ 149