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 * 33 * Abstract 34 * Cisco OpenH264 encoder extension utilization interface for T26 35 * 36 * History 37 * 4/24/2009 Created 38 * 39 * 40 *************************************************************************/ 41 #if !defined(WELS_PLUS_WELSENCODEREXT_H) 42 #define WELS_PLUS_WELSENCODEREXT_H 43 44 #include "codec_api.h" 45 #include "codec_def.h" 46 #include "codec_app_def.h" 47 #include "welsCodecTrace.h" 48 #include "encoder_context.h" 49 #include "param_svc.h" 50 #include "extern.h" 51 #include "cpu.h" 52 53 //#define OUTPUT_BIT_STREAM 54 //#define DUMP_SRC_PICTURE 55 //#define REC_FRAME_COUNT 56 57 class ISVCEncoder; 58 namespace WelsEnc { 59 class CWelsH264SVCEncoder : public ISVCEncoder { 60 public: 61 CWelsH264SVCEncoder(); 62 virtual ~CWelsH264SVCEncoder(); 63 64 /* Interfaces override from ISVCEncoder */ 65 /* 66 * return: CM_RETURN: 0 - success; otherwise - failed; 67 */ 68 virtual int EXTAPI Initialize (const SEncParamBase* argv); 69 virtual int EXTAPI InitializeExt (const SEncParamExt* argv); 70 71 virtual int EXTAPI GetDefaultParams (SEncParamExt* argv); 72 73 virtual int EXTAPI Uninitialize(); 74 75 /* 76 * return: 0 - success; otherwise - failed; 77 */ 78 virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo); 79 virtual int EncodeFrameInternal (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo); 80 81 /* 82 * return: 0 - success; otherwise - failed; 83 */ 84 virtual int EXTAPI EncodeParameterSets (SFrameBSInfo* pBsInfo); 85 /* 86 * return: 0 - success; otherwise - failed; 87 */ 88 virtual int EXTAPI ForceIntraFrame (bool bIDR,int32_t iLayerId = -1); 89 90 /************************************************************************ 91 * InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,.. 92 ************************************************************************/ 93 /* 94 * return: CM_RETURN: 0 - success; otherwise - failed; 95 */ 96 virtual int EXTAPI SetOption (ENCODER_OPTION opt_id, void* option); 97 virtual int EXTAPI GetOption (ENCODER_OPTION opt_id, void* option); 98 99 private: 100 int InitializeInternal (SWelsSvcCodingParam* argv); 101 void TraceParamInfo(SEncParamExt *pParam); 102 void LogStatistics (const int64_t kiCurrentFrameTs,int32_t iMaxDid); 103 void UpdateStatistics(SFrameBSInfo* pBsInfo, const int64_t kiCurrentFrameMs); 104 105 sWelsEncCtx* m_pEncContext; 106 107 welsCodecTrace* m_pWelsTrace; 108 int32_t m_iMaxPicWidth; 109 int32_t m_iMaxPicHeight; 110 111 int32_t m_iCspInternal; 112 bool m_bInitialFlag; 113 114 #ifdef OUTPUT_BIT_STREAM 115 FILE* m_pFileBs; 116 FILE* m_pFileBsSize; 117 bool m_bSwitch; 118 int32_t m_iSwitchTimes; 119 #endif//OUTPUT_BIT_STREAM 120 121 #ifdef REC_FRAME_COUNT 122 int32_t m_uiCountFrameNum; 123 #endif//REC_FRAME_COUNT 124 125 void InitEncoder (void); 126 void DumpSrcPicture (const SSourcePicture* pSrcPic, const int iUsageType); 127 }; 128 } 129 #endif // !defined(WELS_PLUS_WELSENCODEREXT_H) 130