openh264/codec/encoder/core/inc/encoder.h

144 lines
4.9 KiB
C
Raw Normal View History

2013-12-09 13:51:09 +01:00
/*!
* \copy
* Copyright (c) 2009-2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* \file encoder.h
*
* \brief core encoder
*
* \date 5/14/2009
*
*************************************************************************************
*/
#if !defined(WELS_CORE_ENCODER_H__)
#define WELS_CORE_ENCODER_H__
#include "encoder_context.h"
namespace WelsSVCEnc {
/*!
* \brief request specific memory for SVC
* \param pEncCtx sWelsEncCtx*
* \return successful - 0; otherwise none 0 for failed
*/
int32_t RequestMemorySvc (sWelsEncCtx** ppCtx);
2013-12-09 13:51:09 +01:00
/*!
* \brief free memory in SVC core encoder
* \param pEncCtx sWelsEncCtx**
* \return none
*/
void FreeMemorySvc (sWelsEncCtx** ppCtx);
2013-12-09 13:51:09 +01:00
2014-02-20 07:50:04 +01:00
/*!
* \brief allocate or reallocate the output bs buffer
* \return: successful - 0; otherwise none 0 for failed
*/
2014-05-06 04:30:21 +02:00
int32_t AllocateBsOutputBuffer (CMemoryAlign* pMa, const int32_t iNeededLen, int32_t iOrigLen, const char* kpTag,
uint8_t*& pOutputBuffer);
2014-02-20 07:50:04 +01:00
//TODO: to finish this function and call it
2013-12-09 13:51:09 +01:00
/*!
* \brief initialize function pointers that potentially used in Wels encoding
* \param pEncCtx sWelsEncCtx*
* \return successful - 0; otherwise none 0 for failed
*/
int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* _param, uint32_t uiCpuFlag);
2013-12-09 13:51:09 +01:00
///*!
// * \brief decide frame type (IDR/P frame)
2013-12-09 13:51:09 +01:00
// * \param uiFrameType frame type output
// * \param frame_idx frame index elapsed currently
// * \param idr IDR interval
// * \return successful - 0; otherwise none 0 for failed
// */
/*!
* \brief initialize frame coding
2013-12-09 13:51:09 +01:00
*/
void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType);
2013-12-09 13:51:09 +01:00
EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum);
2014-03-31 11:14:00 +02:00
2014-06-16 11:17:24 +02:00
int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize);
2013-12-09 13:51:09 +01:00
/*!
* \brief Dump reconstruction for dependency layer
*/
extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend);
2013-12-09 13:51:09 +01:00
/*!
* \brief Dump the reconstruction pictures
*/
void DumpRecFrame (SPicture* pSrcPic, const char* kpFileName, bool bAppend);
2013-12-09 13:51:09 +01:00
/*!
* \brief encode overall slices pData in a frame
* \param pEncCtx sWelsEncCtx*, encoder context
* \param count_slice_num count number of slices in a frame
* \param eNalType EWelsNalUnitType for a frame
* \param nal_idc EWelsNalRefIdc for a frame
* \return successful - 0; otherwise none 0 for failed
*/
int32_t EncodeFrame (sWelsEncCtx* pEncCtx,
const int32_t kiSliceNumCount,
const EWelsNalUnitType keNalType,
const EWelsNalRefIdc keNalIdc);
2013-12-09 13:51:09 +01:00
/**********************************************************************************
* memzero Function
2013-12-09 13:51:09 +01:00
***********************************************************************************/
void WelsSetMemZero_c (void* pDst, int32_t iSize); // confirmed_safe_unsafe_usage
2013-12-09 13:51:09 +01:00
#if defined(__cplusplus)
extern "C" {
#endif//__cplusplus
#ifdef X86_ASM
void WelsSetMemZeroAligned64_sse2 (void* pDst, int32_t iSize);
void WelsSetMemZeroSize64_mmx (void* pDst, int32_t iSize);
void WelsSetMemZeroSize8_mmx (void* pDst, int32_t iSize);
void WelsPrefetchZero_mmx (int8_t const* kpDst);
2014-03-04 09:49:34 +01:00
#elif defined(HAVE_NEON)
2014-05-06 04:30:21 +02:00
void WelsSetMemZero_neon (void* pDst, int32_t iSize);
2013-12-09 13:51:09 +01:00
#endif
#if defined(__cplusplus)
}
#endif//__cplusplus
/**********************************************************************************
* Function points type
***********************************************************************************/
}
#endif//WELS_CORE_ENCODER_H__