1 /* ----------------------------------------------------------------------------- 2 The copyright in this software is being made available under the BSD 3 License, included below. No patent rights, trademark rights and/or 4 other Intellectual Property Rights other than the copyrights concerning 5 the Software are granted under this license. 6 7 For any license concerning other Intellectual Property rights than the software, 8 especially patent licenses, a separate Agreement needs to be closed. 9 For more information please contact: 10 11 Fraunhofer Heinrich Hertz Institute 12 Einsteinufer 37 13 10587 Berlin, Germany 14 www.hhi.fraunhofer.de/vvc 15 vvc@hhi.fraunhofer.de 16 17 Copyright (c) 2018-2021, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. 18 All rights reserved. 19 20 Redistribution and use in source and binary forms, with or without 21 modification, are permitted provided that the following conditions are met: 22 23 * Redistributions of source code must retain the above copyright notice, 24 this list of conditions and the following disclaimer. 25 * Redistributions in binary form must reproduce the above copyright notice, 26 this list of conditions and the following disclaimer in the documentation 27 and/or other materials provided with the distribution. 28 * Neither the name of Fraunhofer nor the names of its contributors may 29 be used to endorse or promote products derived from this software without 30 specific prior written permission. 31 32 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 36 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 37 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 40 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 41 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 42 THE POSSIBILITY OF SUCH DAMAGE. 43 44 45 ------------------------------------------------------------------------------------------- */ 46 47 /** \file Reshape.h 48 \brief reshaping header and class (header) 49 */ 50 51 #pragma once 52 53 #include "CommonDef.h" 54 #include "Rom.h" 55 #include "CommonLib/Picture.h" 56 57 namespace vvdec 58 { 59 60 // ==================================================================================================================== 61 // Class definition 62 // ==================================================================================================================== 63 64 class Reshape 65 { 66 protected: 67 SliceReshapeInfo m_sliceReshapeInfo; 68 Pel* m_invLUT; 69 Pel* m_fwdLUT; 70 std::vector<int> m_chromaAdjHelpLUT; 71 std::vector<uint16_t> m_binCW; 72 uint16_t m_initCW; 73 std::vector<Pel> m_reshapePivot; 74 std::vector<Pel> m_inputPivot; 75 std::vector<int32_t> m_fwdScaleCoef; 76 std::vector<int32_t> m_invScaleCoef; 77 int m_lumaBD; 78 int m_reshapeLUTSize; 79 int m_chromaScale; 80 int m_vpduX; 81 int m_vpduY; 82 public: 83 Reshape(); 84 ~Reshape(); 85 86 void createDec(int bitDepth); 87 void destroy(); 88 89 void initSlice( int nalUnitLayerId, const PicHeader& picHeader, const VPS& vps ); 90 void rspLine( CodingStructure &cs, int ln, const int offset ) const; 91 void rspCtu ( CodingStructure &cs, int col, int ln, const int offset ) const; 92 getFwdLUT()93 const Pel* getFwdLUT() const { return m_fwdLUT; } getInvLUT()94 const Pel* getInvLUT() const { return m_invLUT; } 95 96 bool getCTUFlag( const Slice& slice ) const; 97 98 int calculateChromaAdj(Pel avgLuma) const; 99 int getPWLIdxInv(int lumaVal) const; getSliceReshaperInfo()100 SliceReshapeInfo& getSliceReshaperInfo() { return m_sliceReshapeInfo; } 101 void copySliceReshaperInfo(SliceReshapeInfo& tInfo, SliceReshapeInfo& sInfo); 102 103 void constructReshaper(); 104 int calculateChromaAdjVpduNei(TransformUnit &tu, const Position pos); setVPDULoc(int x,int y)105 void setVPDULoc(int x, int y) { m_vpduX = x, m_vpduY = y; } isVPDUprocessed(int x,int y)106 bool isVPDUprocessed(int x, int y) { return ((x == m_vpduX) && (y == m_vpduY)); } setChromaScale(int chromaScale)107 void setChromaScale (int chromaScale) { m_chromaScale = chromaScale; } getChromaScale()108 int getChromaScale() { return m_chromaScale; } 109 };// END CLASS DEFINITION Reshape 110 111 } 112