[x265-commits] [x265] port TComLoopFilter Functions into /common/deblock

Gopu Govindaswamy gopu at multicorewareinc.com
Thu Jul 24 19:07:43 CEST 2014


details:   http://hg.videolan.org/x265/rev/6c7a31f1b029
branches:  
changeset: 7536:6c7a31f1b029
user:      Gopu Govindaswamy <gopu at multicorewareinc.com>
date:      Thu Jul 24 14:41:25 2014 +0530
description:
port TComLoopFilter Functions into /common/deblock

1. Rename TComLoopFilter to Deblock
2. Remove hungarian notation function names and variables
3. Remove unused or empty functions
Subject: [x265] rc: add cli options for multi-pass rate control

details:   http://hg.videolan.org/x265/rev/5955c949ef8c
branches:  
changeset: 7537:5955c949ef8c
user:      Aarthi Thirumalai
date:      Thu Jul 24 21:45:58 2014 +0530
description:
rc: add cli options for multi-pass rate control

diffstat:

 source/Lib/TLibCommon/TComLoopFilter.cpp |  792 -------------------------------
 source/Lib/TLibCommon/TComLoopFilter.h   |  133 -----
 source/common/CMakeLists.txt             |    6 +-
 source/common/deblock.cpp                |  672 ++++++++++++++++++++++++++
 source/common/deblock.h                  |   76 ++
 source/common/loopfilter.cpp             |    1 +
 source/common/param.cpp                  |    7 +
 source/encoder/framefilter.cpp           |   14 +-
 source/encoder/framefilter.h             |    4 +-
 source/x265.cpp                          |    7 +
 10 files changed, 772 insertions(+), 940 deletions(-)

diffs (truncated from 1845 to 300 lines):

diff -r 47407360120a -r 5955c949ef8c source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Wed Jul 23 23:57:59 2014 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,792 +0,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
- * 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.
- *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * 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     TComLoopFilter.cpp
-    \brief    deblocking filter
-*/
-
-#include "common.h"
-#include "TComLoopFilter.h"
-#include "slice.h"
-#include "mv.h"
-
-using namespace x265;
-
-//! \ingroup TLibCommon
-//! \{
-
-// ====================================================================================================================
-// Constants
-// ====================================================================================================================
-#define DEFAULT_INTRA_TC_OFFSET 2 ///< Default intra TC offset
-
-// ====================================================================================================================
-// Tables
-// ====================================================================================================================
-
-const uint8_t TComLoopFilter::sm_tcTable[54] =
-{
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24
-};
-
-const uint8_t TComLoopFilter::sm_betaTable[52] =
-{
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64
-};
-
-// ====================================================================================================================
-// Constructor / destructor / create / destroy
-// ====================================================================================================================
-
-TComLoopFilter::TComLoopFilter()
-    : m_numPartitions(0)
-{
-}
-
-TComLoopFilter::~TComLoopFilter()
-{}
-
-void TComLoopFilter::create(uint32_t maxCuDepth)
-{
-    destroy();
-    m_numPartitions = 1 << (maxCuDepth << 1);
-}
-
-void TComLoopFilter::destroy()
-{
-}
-
-void TComLoopFilter::loopFilterCU(TComDataCU* cu, int dir, bool edgeFilter[], uint8_t blockingStrength[])
-{
-    ::memset(blockingStrength, 0, sizeof(uint8_t) * m_numPartitions);
-    ::memset(edgeFilter, 0, sizeof(bool) * m_numPartitions);
-
-    // CU-based deblocking
-    xDeblockCU(cu, 0, 0, dir, edgeFilter, blockingStrength);
-}
-
-// ====================================================================================================================
-// Protected member functions
-// ====================================================================================================================
-
-/**
- - Deblocking filter process in CU-based (the same function as conventional's)
- .
- \param Edge          the direction of the edge in block boundary (horizonta/vertical), which is added newly
-*/
-void TComLoopFilter::xDeblockCU(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, const int dir, bool edgeFilter[], uint8_t blockingStrength[])
-{
-    if (cu->m_pic == 0 || cu->getPartitionSize(absZOrderIdx) == SIZE_NONE)
-    {
-        return;
-    }
-    Frame* pic = cu->m_pic;
-    uint32_t curNumParts = pic->getNumPartInCU() >> (depth << 1);
-    uint32_t qNumParts   = curNumParts >> 2;
-
-    if (cu->getDepth(absZOrderIdx) > depth)
-    {
-        for (uint32_t partIdx = 0; partIdx < 4; partIdx++, absZOrderIdx += qNumParts)
-        {
-            uint32_t lpelx = cu->getCUPelX() + g_rasterToPelX[g_zscanToRaster[absZOrderIdx]];
-            uint32_t tpely = cu->getCUPelY() + g_rasterToPelY[g_zscanToRaster[absZOrderIdx]];
-            if ((lpelx < cu->m_slice->m_sps->picWidthInLumaSamples) && (tpely < cu->m_slice->m_sps->picHeightInLumaSamples))
-            {
-                xDeblockCU(cu, absZOrderIdx, depth + 1, dir, edgeFilter, blockingStrength);
-            }
-        }
-
-        return;
-    }
-
-    ///< status structure
-    LFCUParam lfcuParam;
-    xSetLoopfilterParam(cu, absZOrderIdx, &lfcuParam);
-
-    xSetEdgefilterTU(cu, absZOrderIdx, absZOrderIdx, depth, dir, edgeFilter, blockingStrength);
-    xSetEdgefilterPU(cu, absZOrderIdx, dir, &lfcuParam, edgeFilter, blockingStrength);
-
-    for (uint32_t partIdx = absZOrderIdx; partIdx < absZOrderIdx + curNumParts; partIdx++)
-    {
-        uint32_t bsCheck;
-        if (g_log2UnitSize == 2)
-        {
-            bsCheck = (dir == EDGE_VER && (partIdx & 1) == 0) || (dir == EDGE_HOR && (partIdx & 2) == 0);
-        }
-        else
-        {
-            bsCheck = 1;
-        }
-
-        if (edgeFilter[partIdx] && bsCheck)
-        {
-            xGetBoundaryStrengthSingle(cu, dir, partIdx, blockingStrength);
-        }
-    }
-
-    uint32_t log2UnitSize = g_log2UnitSize;
-    uint32_t partIdxIncr = (DEBLOCK_SMALLEST_BLOCK >> log2UnitSize) ? (DEBLOCK_SMALLEST_BLOCK >> log2UnitSize) : 1;
-
-    uint32_t sizeInPU = pic->getNumPartInCUSize() >> (depth);
-    uint32_t shiftFactor = (dir == EDGE_VER) ? cu->getHorzChromaShift() : cu->getVertChromaShift();
-    const bool bAlwaysDoChroma = (cu->getChromaFormat() == CHROMA_444 || (1 << log2UnitSize) > DEBLOCK_SMALLEST_BLOCK);
-    for (uint32_t e = 0; e < sizeInPU; e += partIdxIncr)
-    {
-        xEdgeFilterLuma(cu, absZOrderIdx, depth, dir, e, blockingStrength);
-        if (bAlwaysDoChroma || (e % ((DEBLOCK_SMALLEST_BLOCK << shiftFactor) >> log2UnitSize)) == 0)
-        {
-            xEdgeFilterChroma(cu, absZOrderIdx, depth, dir, e, blockingStrength);
-        }
-    }
-}
-
-void TComLoopFilter::xSetEdgefilterMultiple(TComDataCU* cu, uint32_t scanIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, bool edgeFilter[], uint8_t blockingStrength[], uint32_t widthInBaseUnits)
-{
-    if (widthInBaseUnits == 0)
-    {
-        widthInBaseUnits  = cu->m_pic->getNumPartInCUSize() >> depth;
-    }
-    const uint32_t numElem = widthInBaseUnits;
-    X265_CHECK(numElem > 0, "numElem edge filter check\n");
-    for (uint32_t i = 0; i < numElem; i++)
-    {
-        const uint32_t bsidx = xCalcBsIdx(cu, scanIdx, dir, edgeIdx, i);
-        edgeFilter[bsidx] = bValue;
-        if (edgeIdx == 0)
-        {
-            blockingStrength[bsidx] = bValue;
-        }
-    }
-}
-
-void TComLoopFilter::xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth, int dir, bool edgeFilter[], uint8_t blockingStrength[])
-{
-    if (cu->getTransformIdx(absZOrderIdx) + cu->getDepth(absZOrderIdx) > depth)
-    {
-        const uint32_t curNumParts = cu->m_pic->getNumPartInCU() >> (depth << 1);
-        const uint32_t qNumParts   = curNumParts >> 2;
-        for (uint32_t partIdx = 0; partIdx < 4; partIdx++, absZOrderIdx += qNumParts)
-        {
-            uint32_t nsAddr = absZOrderIdx;
-            xSetEdgefilterTU(cu, nsAddr, absZOrderIdx, depth + 1, dir, edgeFilter, blockingStrength);
-        }
-
-        return;
-    }
-
-    uint32_t widthInBaseUnits  = 1 << (cu->getLog2CUSize(absZOrderIdx) - cu->getTransformIdx(absZOrderIdx) - g_log2UnitSize);
-
-    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, dir, 0, true, edgeFilter, blockingStrength, widthInBaseUnits);
-}
-
-void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx, int dir, LFCUParam *lfcuParam, bool edgeFilter[], uint8_t blockingStrength[])
-{
-    const uint32_t depth = cu->getDepth(absZOrderIdx);
-    const uint32_t widthInBaseUnits  = cu->m_pic->getNumPartInCUSize() >> depth;
-    const uint32_t hWidthInBaseUnits  = widthInBaseUnits  >> 1;
-    const uint32_t qWidthInBaseUnits  = widthInBaseUnits  >> 2;
-
-    xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, 0, (dir == EDGE_VER ? lfcuParam->bLeftEdge : lfcuParam->bTopEdge), edgeFilter, blockingStrength);
-
-    int mode = cu->getPartitionSize(absZOrderIdx);
-    switch (mode)
-    {
-    case SIZE_2Nx2N:
-    {
-        break;
-    }
-    case SIZE_2NxN:
-    case SIZE_Nx2N:
-    {
-        const int realDir = (mode == SIZE_2NxN ? EDGE_HOR : EDGE_VER);
-
-        if (realDir == dir)
-            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter, blockingStrength);
-        break;
-    }
-    case SIZE_NxN:
-    {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter, blockingStrength);
-        break;
-    }
-    case SIZE_2NxnU:
-    case SIZE_nLx2N:
-    {
-        const int realDir = (mode == SIZE_2NxnU ? EDGE_HOR : EDGE_VER);
-
-        if (realDir == dir)
-            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, qWidthInBaseUnits, true, edgeFilter, blockingStrength);
-        break;
-    }
-    case SIZE_2NxnD:
-    case SIZE_nRx2N:
-    {
-        const int realDir = (mode == SIZE_2NxnD ? EDGE_HOR : EDGE_VER);
-
-        if (realDir == dir)
-            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, widthInBaseUnits - qWidthInBaseUnits, true, edgeFilter, blockingStrength);
-        break;
-    }
-    default:
-    {
-        break;
-    }
-    }
-}
-
-void TComLoopFilter::xSetLoopfilterParam(TComDataCU* cu, uint32_t absZOrderIdx, LFCUParam *lfcuParam)
-{
-    uint32_t x = cu->getCUPelX() + g_rasterToPelX[g_zscanToRaster[absZOrderIdx]];
-    uint32_t y = cu->getCUPelY() + g_rasterToPelY[g_zscanToRaster[absZOrderIdx]];
-
-    TComDataCU* tempCU;
-    uint32_t    tempPartIdx;
-
-    if (x == 0)
-    {
-        lfcuParam->bLeftEdge = false;
-    }
-    else
-    {
-        tempCU = cu->getPULeft(tempPartIdx, absZOrderIdx);
-        if (tempCU)
-        {
-            lfcuParam->bLeftEdge = true;
-        }
-        else
-        {
-            lfcuParam->bLeftEdge = false;
-        }
-    }
-
-    if (y == 0)
-    {
-        lfcuParam->bTopEdge = false;
-    }
-    else


More information about the x265-commits mailing list