[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2011, ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
| 34 | |
---|
[5] | 35 | |
---|
[2] | 36 | /** \file TEncSlice.h |
---|
| 37 | \brief slice encoder class (header) |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #ifndef __TENCSLICE__ |
---|
| 41 | #define __TENCSLICE__ |
---|
| 42 | |
---|
| 43 | // Include files |
---|
| 44 | #include "../TLibCommon/CommonDef.h" |
---|
| 45 | #include "../TLibCommon/TComList.h" |
---|
| 46 | #include "../TLibCommon/TComPic.h" |
---|
| 47 | #include "../TLibCommon/TComPicYuv.h" |
---|
| 48 | #include "TEncCu.h" |
---|
| 49 | #ifdef WEIGHT_PRED |
---|
| 50 | #include "WeightPredAnalysis.h" |
---|
| 51 | #endif |
---|
| 52 | |
---|
| 53 | class TEncTop; |
---|
| 54 | class TEncPic; |
---|
| 55 | |
---|
| 56 | // ==================================================================================================================== |
---|
| 57 | // Class definition |
---|
| 58 | // ==================================================================================================================== |
---|
| 59 | |
---|
| 60 | /// slice encoder class |
---|
| 61 | class TEncSlice |
---|
| 62 | #ifdef WEIGHT_PRED |
---|
| 63 | : public WeightPredAnalysis |
---|
| 64 | #endif |
---|
| 65 | { |
---|
| 66 | private: |
---|
| 67 | // encoder configuration |
---|
| 68 | TEncCfg* m_pcCfg; ///< encoder configuration class |
---|
| 69 | |
---|
| 70 | // pictures |
---|
| 71 | TComList<TComPic*>* m_pcListPic; ///< list of pictures |
---|
| 72 | TComPicYuv* m_apcPicYuvPred; ///< prediction picture buffer |
---|
| 73 | TComPicYuv* m_apcPicYuvResi; ///< residual picture buffer |
---|
| 74 | |
---|
| 75 | // processing units |
---|
| 76 | TEncPic* m_pcPicEncoder; ///< Pic encoder |
---|
| 77 | TEncCu* m_pcCuEncoder; ///< CU encoder |
---|
| 78 | |
---|
| 79 | // encoder search |
---|
| 80 | TEncSearch* m_pcPredSearch; ///< encoder search class |
---|
| 81 | |
---|
| 82 | // coding tools |
---|
| 83 | TEncEntropy* m_pcEntropyCoder; ///< entropy encoder |
---|
| 84 | TEncCavlc* m_pcCavlcCoder; ///< CAVLC encoder |
---|
| 85 | TEncSbac* m_pcSbacCoder; ///< SBAC encoder |
---|
| 86 | TEncBinCABAC* m_pcBinCABAC; ///< Bin encoder CABAC |
---|
| 87 | TComTrQuant* m_pcTrQuant; ///< transform & quantization |
---|
| 88 | |
---|
| 89 | // RD optimization |
---|
| 90 | TComBitCounter* m_pcBitCounter; ///< bit counter |
---|
| 91 | TComRdCost* m_pcRdCost; ///< RD cost computation |
---|
| 92 | TEncSbac*** m_pppcRDSbacCoder; ///< storage for SBAC-based RD optimization |
---|
| 93 | TEncSbac* m_pcRDGoOnSbacCoder; ///< go-on SBAC encoder |
---|
| 94 | UInt64 m_uiPicTotalBits; ///< total bits for the picture |
---|
| 95 | UInt64 m_uiPicDist; ///< total distortion for the picture |
---|
| 96 | Double m_dPicRdCost; ///< picture-level RD cost |
---|
| 97 | Double* m_pdRdPicLambda; ///< array of lambda candidates |
---|
| 98 | Double* m_pdRdPicQp; ///< array of picture QP candidates (double-type for lambda) |
---|
| 99 | Int* m_piRdPicQp; ///< array of picture QP candidates (int-type) |
---|
| 100 | |
---|
| 101 | UInt m_uiSliceIdx; |
---|
| 102 | public: |
---|
| 103 | TEncSlice(); |
---|
| 104 | virtual ~TEncSlice(); |
---|
| 105 | |
---|
| 106 | Void create ( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight, UChar uhTotalDepth ); |
---|
| 107 | Void destroy (); |
---|
| 108 | Void init ( TEncTop* pcEncTop ); |
---|
| 109 | |
---|
| 110 | /// preparation of slice encoding (reference marking, QP and lambda) |
---|
| 111 | Void initEncSlice ( TComPic* pcPic, TComSlice*& rpcSlice ); |
---|
| 112 | |
---|
| 113 | // compress and encode slice |
---|
| 114 | Void precompressSlice ( TComPic*& rpcPic ); ///< precompress slice for multi-loop opt. |
---|
| 115 | Void compressSlice ( TComPic*& rpcPic ); ///< analysis stage of slice |
---|
| 116 | Void encodeSlice ( TComPic*& rpcPic, TComBitstream*& rpcBitstream ); ///< entropy coding of slice |
---|
| 117 | |
---|
| 118 | // misc. functions |
---|
| 119 | Void setSearchRange ( TComSlice* pcSlice ); ///< set ME range adaptively |
---|
| 120 | UInt64 getTotalBits () { return m_uiPicTotalBits; } |
---|
| 121 | |
---|
| 122 | TEncCu* getCUEncoder() { return m_pcCuEncoder; } ///< CU encoder |
---|
| 123 | Void xDetermineStartAndBoundingCUAddr ( UInt& uiStartCUAddr, UInt& uiBoundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice ); |
---|
| 124 | UInt getSliceIdx() { return m_uiSliceIdx; } |
---|
| 125 | Void setSliceIdx(UInt i) { m_uiSliceIdx = i; } |
---|
| 126 | }; |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | #endif // __TENCSLICE__ |
---|
| 130 | |
---|