| 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 | */ |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | #include "TRenImage.h" |
|---|
| 36 | #include "TRenFilter.h" |
|---|
| 37 | #include "TRenSingleModel.h" |
|---|
| 38 | |
|---|
| 39 | ////////////// TRENSINGLE MODEL /////////////// |
|---|
| 40 | TRenSingleModel::TRenSingleModel() |
|---|
| 41 | : m_iDistShift ( g_uiBitIncrement << 1 ) |
|---|
| 42 | { |
|---|
| 43 | m_iWidth = -1; |
|---|
| 44 | m_iHeight = -1; |
|---|
| 45 | m_iStride = -1; |
|---|
| 46 | m_iMode = -1; |
|---|
| 47 | m_iPad = PICYUV_PAD; |
|---|
| 48 | m_iGapTolerance = -1; |
|---|
| 49 | m_bUseOrgRef = false; |
|---|
| 50 | |
|---|
| 51 | m_pcPicYuvRef = NULL; |
|---|
| 52 | m_aapiRefVideoPel[0] = NULL; |
|---|
| 53 | m_aapiRefVideoPel[1] = NULL; |
|---|
| 54 | m_aapiRefVideoPel[2] = NULL; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | m_aiRefVideoStrides[0] = -1; |
|---|
| 58 | m_aiRefVideoStrides[1] = -1; |
|---|
| 59 | m_aiRefVideoStrides[2] = -1; |
|---|
| 60 | |
|---|
| 61 | for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++) |
|---|
| 62 | { |
|---|
| 63 | // LUT |
|---|
| 64 | m_appiShiftLut[uiViewNum] = NULL; |
|---|
| 65 | m_ppiCurLUT = NULL; |
|---|
| 66 | m_piInvZLUTLeft = NULL; |
|---|
| 67 | m_piInvZLUTRight = NULL; |
|---|
| 68 | |
|---|
| 69 | // Cur Data |
|---|
| 70 | m_apiBaseDepthPel [uiViewNum] = NULL; |
|---|
| 71 | m_aiBaseDepthStrides [uiViewNum] = -1; |
|---|
| 72 | |
|---|
| 73 | // State Data |
|---|
| 74 | m_apbOccluded [uiViewNum] = NULL; |
|---|
| 75 | m_apiFilled [uiViewNum] = NULL; |
|---|
| 76 | |
|---|
| 77 | // Cur Data |
|---|
| 78 | m_aapiBaseVideoPel [uiViewNum] = NULL; |
|---|
| 79 | m_aaiBaseVideoStrides [uiViewNum] = NULL; |
|---|
| 80 | }; |
|---|
| 81 | |
|---|
| 82 | m_piError = NULL; |
|---|
| 83 | |
|---|
| 84 | for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++) |
|---|
| 85 | { |
|---|
| 86 | m_apiSynthDepthPel[uiViewNum] = NULL; |
|---|
| 87 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
|---|
| 88 | { |
|---|
| 89 | // Rendered Data |
|---|
| 90 | m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] = NULL; |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | TRenSingleModel::~TRenSingleModel() |
|---|
| 96 | { |
|---|
| 97 | if ( m_apbOccluded[0] ) delete[] m_apbOccluded[0]; |
|---|
| 98 | if ( m_apbOccluded[1] ) delete[] m_apbOccluded[1]; |
|---|
| 99 | |
|---|
| 100 | if ( m_apiFilled [0] ) delete[] m_apiFilled [0]; |
|---|
| 101 | if ( m_apiFilled [1] ) delete[] m_apiFilled [1]; |
|---|
| 102 | |
|---|
| 103 | if ( m_piError ) delete[] m_piError ; |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++) |
|---|
| 107 | { |
|---|
| 108 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
|---|
| 109 | { |
|---|
| 110 | if ( m_aapiSynthVideoPel[uiViewNum] && m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] ) delete[] m_aapiSynthVideoPel[uiViewNum][uiPlaneNum]; |
|---|
| 111 | } |
|---|
| 112 | if ( m_apiSynthDepthPel[uiViewNum] ) delete[] m_apiSynthDepthPel[uiViewNum]; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | delete[] (m_aapiRefVideoPel[0] - m_iPad * m_aiRefVideoStrides[0] - m_iPad ); |
|---|
| 116 | delete[] (m_aapiRefVideoPel[1] - m_iPad * m_aiRefVideoStrides[1] - m_iPad ); |
|---|
| 117 | delete[] (m_aapiRefVideoPel[2] - m_iPad * m_aiRefVideoStrides[2] - m_iPad ); |
|---|
| 118 | |
|---|
| 119 | if ( m_piInvZLUTLeft ) delete[] m_piInvZLUTLeft; |
|---|
| 120 | if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight; |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | Void |
|---|
| 124 | TRenSingleModel::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode ) |
|---|
| 125 | { |
|---|
| 126 | m_iBlendMode = iBlendMode; |
|---|
| 127 | m_iMode = iMode; |
|---|
| 128 | m_iWidth = iWidth; |
|---|
| 129 | m_iHeight = iHeight; |
|---|
| 130 | m_iStride = iWidth; |
|---|
| 131 | |
|---|
| 132 | m_iSampledWidth = m_iWidth << iShiftPrec; |
|---|
| 133 | m_iSampledStride = m_iStride << iShiftPrec; |
|---|
| 134 | |
|---|
| 135 | m_iShiftPrec = iShiftPrec; |
|---|
| 136 | m_aaiSubPelShiftL = aaaiSubPelShiftTable[0]; |
|---|
| 137 | m_aaiSubPelShiftR = aaaiSubPelShiftTable[1]; |
|---|
| 138 | |
|---|
| 139 | if (m_iMode == 2) |
|---|
| 140 | { |
|---|
| 141 | m_piInvZLUTLeft = new Int[257]; |
|---|
| 142 | m_piInvZLUTRight = new Int[257]; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | m_iGapTolerance = ( 2 << iShiftPrec ); |
|---|
| 146 | m_iHoleMargin = iHoleMargin; |
|---|
| 147 | |
|---|
| 148 | m_bUseOrgRef = bUseOrgRef; |
|---|
| 149 | |
|---|
| 150 | m_aiRefVideoStrides[0] = m_iStride + (m_iPad << 1); |
|---|
| 151 | m_aiRefVideoStrides[1] = m_iStride + (m_iPad << 1); |
|---|
| 152 | m_aiRefVideoStrides[2] = m_iStride + (m_iPad << 1); |
|---|
| 153 | |
|---|
| 154 | m_aapiRefVideoPel [0] = new Pel[ m_aiRefVideoStrides[0] * (m_iHeight + (m_iPad << 1))]; |
|---|
| 155 | m_aapiRefVideoPel [1] = new Pel[ m_aiRefVideoStrides[1] * (m_iHeight + (m_iPad << 1))]; |
|---|
| 156 | m_aapiRefVideoPel [2] = new Pel[ m_aiRefVideoStrides[2] * (m_iHeight + (m_iPad << 1))]; |
|---|
| 157 | |
|---|
| 158 | m_aapiRefVideoPel [0] += m_aiRefVideoStrides[0] * m_iPad + m_iPad; |
|---|
| 159 | m_aapiRefVideoPel [1] += m_aiRefVideoStrides[1] * m_iPad + m_iPad; |
|---|
| 160 | m_aapiRefVideoPel [2] += m_aiRefVideoStrides[2] * m_iPad + m_iPad; |
|---|
| 161 | |
|---|
| 162 | m_piError = new Int [m_iStride*m_iHeight]; |
|---|
| 163 | |
|---|
| 164 | // Create Buffers |
|---|
| 165 | if ( (m_iMode == 0) || (m_iMode == 2 ) ) |
|---|
| 166 | { |
|---|
| 167 | m_apbOccluded [0] = new Bool[m_iStride*m_iHeight]; |
|---|
| 168 | m_apiFilled [0] = new Pel [m_iStride*m_iHeight]; |
|---|
| 169 | |
|---|
| 170 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
|---|
| 171 | { |
|---|
| 172 | m_aapiSynthVideoPel[0][uiPlaneNum] = new Pel[m_iStride*m_iHeight]; |
|---|
| 173 | } |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | if ( (m_iMode == 1) || (m_iMode == 2 ) ) |
|---|
| 177 | { |
|---|
| 178 | m_apbOccluded [1] = new Bool[m_iStride*m_iHeight]; |
|---|
| 179 | m_apiFilled [1] = new Pel [m_iStride*m_iHeight]; |
|---|
| 180 | |
|---|
| 181 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
|---|
| 182 | { |
|---|
| 183 | m_aapiSynthVideoPel[1][uiPlaneNum] = new Pel[m_iStride*m_iHeight]; |
|---|
| 184 | } |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | if ( m_iMode == 2 ) |
|---|
| 188 | { |
|---|
| 189 | m_apiSynthDepthPel[0] = new Pel[m_iStride*m_iHeight]; |
|---|
| 190 | m_apiSynthDepthPel[1] = new Pel[m_iStride*m_iHeight]; |
|---|
| 191 | m_apiSynthDepthPel[2] = new Pel[m_iStride*m_iHeight]; |
|---|
| 192 | |
|---|
| 193 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
|---|
| 194 | { |
|---|
| 195 | m_aapiSynthVideoPel[2][uiPlaneNum] = new Pel[m_iStride*m_iHeight]; |
|---|
| 196 | } |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | Void |
|---|
| 201 | TRenSingleModel::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) |
|---|
| 202 | { |
|---|
| 203 | AOF(( iViewPos == 0) || (iViewPos == 1) ); |
|---|
| 204 | m_aapiBaseVideoPel [iViewPos] = apiCurVideoPel; |
|---|
| 205 | m_aaiBaseVideoStrides [iViewPos] = aiCurVideoStride; |
|---|
| 206 | m_apiBaseDepthPel [iViewPos] = piCurDepthPel; |
|---|
| 207 | m_aiBaseDepthStrides [iViewPos] = iCurDepthStride; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | Void |
|---|
| 211 | TRenSingleModel::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bKeepReference ) |
|---|
| 212 | { |
|---|
| 213 | AOT( !m_bUseOrgRef && pcOrgVideo ); |
|---|
| 214 | AOT( (ppiShiftLutLeft == NULL) && (m_iMode == 0 || m_iMode == 2) ); |
|---|
| 215 | AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) ); |
|---|
| 216 | #if HHI_FIX |
|---|
| 217 | #else |
|---|
| 218 | AOT( pcOrgVideo != NULL && bKeepReference ); |
|---|
| 219 | #endif |
|---|
| 220 | |
|---|
| 221 | m_appiShiftLut[0] = ppiShiftLutLeft; |
|---|
| 222 | m_appiShiftLut[1] = ppiShiftLutRight; |
|---|
| 223 | |
|---|
| 224 | // Copy Reference |
|---|
| 225 | m_pcPicYuvRef = pcOrgVideo; |
|---|
| 226 | |
|---|
| 227 | #if HHI_FIX |
|---|
| 228 | if ( pcOrgVideo && !bKeepReference ) |
|---|
| 229 | #else |
|---|
| 230 | if ( pcOrgVideo ) |
|---|
| 231 | #endif |
|---|
| 232 | { |
|---|
| 233 | TRenFilter::copy( pcOrgVideo->getLumaAddr(), pcOrgVideo->getStride() , m_iWidth, m_iHeight, m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]); |
|---|
| 234 | TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr() , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]); |
|---|
| 235 | TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr() , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]); |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | // Initial Rendering |
|---|
| 239 | xSetInts( m_piError , m_iStride, m_iWidth, m_iHeight, 0 ); |
|---|
| 240 | |
|---|
| 241 | switch ( m_iMode ) |
|---|
| 242 | { |
|---|
| 243 | case 0: |
|---|
| 244 | xInitView( VIEWPOS_LEFT ); |
|---|
| 245 | xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true ); |
|---|
| 246 | break; |
|---|
| 247 | case 1: |
|---|
| 248 | xInitView( VIEWPOS_RIGHT ); |
|---|
| 249 | xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true ); |
|---|
| 250 | break; |
|---|
| 251 | case 2: |
|---|
| 252 | TRenFilter::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight ); |
|---|
| 253 | xInitView( VIEWPOS_LEFT ); |
|---|
| 254 | xInitView( VIEWPOS_RIGHT ); |
|---|
| 255 | xInitView( VIEWPOS_MERGED ); |
|---|
| 256 | xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true ); |
|---|
| 257 | xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true ); |
|---|
| 258 | break; |
|---|
| 259 | default: |
|---|
| 260 | AOT(true); |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | // Get Rendered View as Reference |
|---|
| 264 | if ( !pcOrgVideo && !bKeepReference ) |
|---|
| 265 | { |
|---|
| 266 | xSetInts ( m_piError , m_iStride, m_iWidth, m_iHeight, 0 ); |
|---|
| 267 | TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][0], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]); |
|---|
| 268 | TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][1], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]); |
|---|
| 269 | TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][2], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]); |
|---|
| 270 | } |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | RMDist |
|---|
| 274 | TRenSingleModel::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
|---|
| 275 | { |
|---|
| 276 | RMDist iSSE = 0; |
|---|
| 277 | switch (iViewPos ) |
|---|
| 278 | { |
|---|
| 279 | case 0: |
|---|
| 280 | iSSE = xRenderL( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, false ); |
|---|
| 281 | break; |
|---|
| 282 | case 1: |
|---|
| 283 | iSSE = xRenderR( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, false ); |
|---|
| 284 | break; |
|---|
| 285 | default: |
|---|
| 286 | assert(0); |
|---|
| 287 | } |
|---|
| 288 | return iSSE; |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | Void |
|---|
| 292 | TRenSingleModel::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
|---|
| 293 | { |
|---|
| 294 | switch (iViewPos ) |
|---|
| 295 | { |
|---|
| 296 | case 0: |
|---|
| 297 | xRenderL( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, true ); |
|---|
| 298 | break; |
|---|
| 299 | case 1: |
|---|
| 300 | xRenderR( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, true ); |
|---|
| 301 | break; |
|---|
| 302 | default: |
|---|
| 303 | assert(0); |
|---|
| 304 | } |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | Void |
|---|
| 309 | TRenSingleModel::getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride ) |
|---|
| 310 | { |
|---|
| 311 | rppiRenVideoPel = m_aapiSynthVideoPel[iViewPos]; |
|---|
| 312 | rpiRenDepthPel = m_apiSynthDepthPel [iViewPos]; |
|---|
| 313 | riStride = m_iStride; |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | Void |
|---|
| 318 | TRenSingleModel::getRefView( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides ) |
|---|
| 319 | { |
|---|
| 320 | rpcPicYuvRefView = m_pcPicYuvRef; |
|---|
| 321 | rppiRefVideoPel = m_aapiRefVideoPel; |
|---|
| 322 | raiStrides = m_aiRefVideoStrides; |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | RMDist |
|---|
| 327 | TRenSingleModel::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
|---|
| 328 | { |
|---|
| 329 | AOF(false); |
|---|
| 330 | return 0; |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | Void |
|---|
| 334 | TRenSingleModel::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
|---|
| 335 | { |
|---|
| 336 | AOF(false); |
|---|
| 337 | } |
|---|
| 338 | |
|---|
| 339 | |
|---|
| 340 | |
|---|
| 341 | __inline Void |
|---|
| 342 | TRenSingleModel::xSetViewRow( Int iPosY ) |
|---|
| 343 | { |
|---|
| 344 | m_aapiBaseVideoPelRow [m_iCurViewPos][0] = m_aapiBaseVideoPel [m_iCurViewPos] [0] + m_aaiBaseVideoStrides [ m_iCurViewPos ][0] * iPosY; |
|---|
| 345 | m_aapiBaseVideoPelRow [m_iCurViewPos][1] = m_aapiBaseVideoPel [m_iCurViewPos] [1] + m_aaiBaseVideoStrides [ m_iCurViewPos ][1] * iPosY; |
|---|
| 346 | m_aapiBaseVideoPelRow [m_iCurViewPos][2] = m_aapiBaseVideoPel [m_iCurViewPos] [2] + m_aaiBaseVideoStrides [ m_iCurViewPos ][2] * iPosY; |
|---|
| 347 | |
|---|
| 348 | m_apiBaseDepthPelRow [m_iCurViewPos] = m_apiBaseDepthPel [m_iCurViewPos] + m_aiBaseDepthStrides [ m_iCurViewPos] * iPosY; |
|---|
| 349 | m_apbOccludedRow [m_iCurViewPos] = m_apbOccluded [m_iCurViewPos] + m_iStride * iPosY; |
|---|
| 350 | m_apiFilledRow [m_iCurViewPos] = m_apiFilled [m_iCurViewPos] + m_iStride * iPosY; |
|---|
| 351 | m_apiErrorRow = m_piError + m_iStride * iPosY; |
|---|
| 352 | |
|---|
| 353 | m_aapiSynthVideoPelRow [m_iCurViewPos][0] = m_aapiSynthVideoPel [m_iCurViewPos] [0] + m_iStride * iPosY; |
|---|
| 354 | m_aapiSynthVideoPelRow [m_iCurViewPos][1] = m_aapiSynthVideoPel [m_iCurViewPos] [1] + m_iStride * iPosY; |
|---|
| 355 | m_aapiSynthVideoPelRow [m_iCurViewPos][2] = m_aapiSynthVideoPel [m_iCurViewPos] [2] + m_iStride * iPosY; |
|---|
| 356 | |
|---|
| 357 | m_aapiRefVideoPelRow [0] = m_aapiRefVideoPel [0] + m_aiRefVideoStrides [0] * iPosY; |
|---|
| 358 | m_aapiRefVideoPelRow [1] = m_aapiRefVideoPel [1] + m_aiRefVideoStrides [1] * iPosY; |
|---|
| 359 | m_aapiRefVideoPelRow [2] = m_aapiRefVideoPel [2] + m_aiRefVideoStrides [2] * iPosY; |
|---|
| 360 | |
|---|
| 361 | if (m_iMode == 2) |
|---|
| 362 | { |
|---|
| 363 | m_apiSynthDepthPelRow [m_iCurViewPos ] = m_apiSynthDepthPel [m_iCurViewPos] + m_iStride * iPosY; |
|---|
| 364 | m_aapiSynthVideoPelRow[m_iOtherViewPos][0] = m_aapiSynthVideoPel [m_iOtherViewPos][0] + m_iStride * iPosY; |
|---|
| 365 | m_aapiSynthVideoPelRow[m_iOtherViewPos][1] = m_aapiSynthVideoPel [m_iOtherViewPos][1] + m_iStride * iPosY; |
|---|
| 366 | m_aapiSynthVideoPelRow[m_iOtherViewPos][2] = m_aapiSynthVideoPel [m_iOtherViewPos][2] + m_iStride * iPosY; |
|---|
| 367 | |
|---|
| 368 | m_apiFilledRow [m_iOtherViewPos] = m_apiFilled [m_iOtherViewPos] + m_iStride * iPosY; |
|---|
| 369 | m_apiSynthDepthPelRow [m_iOtherViewPos] = m_apiSynthDepthPel [m_iOtherViewPos] + m_iStride * iPosY; |
|---|
| 370 | |
|---|
| 371 | m_aapiSynthVideoPelRow[2 ][0] = m_aapiSynthVideoPel[2] [0] + m_iStride * iPosY; |
|---|
| 372 | m_aapiSynthVideoPelRow[2 ][1] = m_aapiSynthVideoPel[2] [1] + m_iStride * iPosY; |
|---|
| 373 | m_aapiSynthVideoPelRow[2 ][2] = m_aapiSynthVideoPel[2] [2] + m_iStride * iPosY; |
|---|
| 374 | } |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | __inline Void |
|---|
| 378 | TRenSingleModel::xIncViewRow( ) |
|---|
| 379 | { |
|---|
| 380 | m_aapiBaseVideoPelRow [m_iCurViewPos][0] += m_aaiBaseVideoStrides [ m_iCurViewPos ][0]; |
|---|
| 381 | m_aapiBaseVideoPelRow [m_iCurViewPos][1] += m_aaiBaseVideoStrides [ m_iCurViewPos ][1]; |
|---|
| 382 | m_aapiBaseVideoPelRow [m_iCurViewPos][2] += m_aaiBaseVideoStrides [ m_iCurViewPos ][2]; |
|---|
| 383 | |
|---|
| 384 | m_apiBaseDepthPelRow [m_iCurViewPos] += m_aiBaseDepthStrides [ m_iCurViewPos] ; |
|---|
| 385 | m_apbOccludedRow [m_iCurViewPos] += m_iStride ; |
|---|
| 386 | m_apiFilledRow [m_iCurViewPos] += m_iStride ; |
|---|
| 387 | m_apiErrorRow += m_iStride ; |
|---|
| 388 | |
|---|
| 389 | m_aapiSynthVideoPelRow [m_iCurViewPos][0] += m_iStride ; |
|---|
| 390 | m_aapiSynthVideoPelRow [m_iCurViewPos][1] += m_iStride ; |
|---|
| 391 | m_aapiSynthVideoPelRow [m_iCurViewPos][2] += m_iStride ; |
|---|
| 392 | |
|---|
| 393 | m_aapiRefVideoPelRow [0] += m_aiRefVideoStrides [0]; |
|---|
| 394 | m_aapiRefVideoPelRow [1] += m_aiRefVideoStrides [1]; |
|---|
| 395 | m_aapiRefVideoPelRow [2] += m_aiRefVideoStrides [2]; |
|---|
| 396 | |
|---|
| 397 | if (m_iMode == 2) |
|---|
| 398 | { |
|---|
| 399 | m_apiSynthDepthPelRow [m_iCurViewPos ] += m_iStride ; // This is correct! |
|---|
| 400 | |
|---|
| 401 | m_aapiSynthVideoPelRow[m_iOtherViewPos][0] += m_iStride ; |
|---|
| 402 | m_aapiSynthVideoPelRow[m_iOtherViewPos][1] += m_iStride ; |
|---|
| 403 | m_aapiSynthVideoPelRow[m_iOtherViewPos][2] += m_iStride ; |
|---|
| 404 | |
|---|
| 405 | m_apiFilledRow [m_iOtherViewPos] += m_iStride ; |
|---|
| 406 | m_apiSynthDepthPelRow [m_iOtherViewPos] += m_iStride ; |
|---|
| 407 | |
|---|
| 408 | m_aapiSynthVideoPelRow[2 ][0] += m_iStride ; |
|---|
| 409 | m_aapiSynthVideoPelRow[2 ][1] += m_iStride ; |
|---|
| 410 | m_aapiSynthVideoPelRow[2 ][2] += m_iStride ; |
|---|
| 411 | } |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | __inline RMDist |
|---|
| 415 | TRenSingleModel::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd ) |
|---|
| 416 | { |
|---|
| 417 | m_bSet = bAdd; |
|---|
| 418 | m_iCurViewPos = 0; |
|---|
| 419 | m_iOtherViewPos = 1; |
|---|
| 420 | |
|---|
| 421 | m_piNewDepthData = piNewData; |
|---|
| 422 | m_iNewDataWidth = iWidth; |
|---|
| 423 | m_iStartChangePosX = iStartPosX; |
|---|
| 424 | |
|---|
| 425 | if ((iWidth == 0) || (iHeight == 0)) |
|---|
| 426 | return 0; |
|---|
| 427 | |
|---|
| 428 | //TODO: Specialize to left and right; setData and getDist |
|---|
| 429 | |
|---|
| 430 | // Get Data |
|---|
| 431 | m_ppiCurLUT = m_appiShiftLut [m_iCurViewPos]; |
|---|
| 432 | |
|---|
| 433 | xSetViewRow ( iStartPosY); |
|---|
| 434 | |
|---|
| 435 | // Init Start |
|---|
| 436 | RMDist iError = 0; |
|---|
| 437 | Int iStartChangePos; |
|---|
| 438 | |
|---|
| 439 | iStartChangePos = m_iStartChangePosX; |
|---|
| 440 | |
|---|
| 441 | for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ ) |
|---|
| 442 | { |
|---|
| 443 | m_bInOcclusion = false; |
|---|
| 444 | |
|---|
| 445 | Int iLastSPos; |
|---|
| 446 | Int iEndChangePos = m_iStartChangePosX + iWidth - 1; |
|---|
| 447 | Int iPosXinNewData = iWidth - 1; |
|---|
| 448 | Int iMinChangedSPos = m_iSampledWidth; |
|---|
| 449 | |
|---|
| 450 | if ( iEndChangePos == ( m_iWidth -1 )) // Special processing for rightmost depth sample |
|---|
| 451 | { |
|---|
| 452 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
|---|
| 453 | Int iCurSPos = xShiftNewData(iEndChangePos, iPosXinNewData); |
|---|
| 454 | m_iLastOccludedSPos = iCurSPos + 1; |
|---|
| 455 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
|---|
| 456 | xExtrapolateMarginL ( iCurSPos, iEndChangePos, iError ); |
|---|
| 457 | iMinChangedSPos = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]); |
|---|
| 458 | iLastSPos = iCurSPos; |
|---|
| 459 | m_iLastDepth = m_iCurDepth; |
|---|
| 460 | iPosXinNewData--; |
|---|
| 461 | iEndChangePos--; |
|---|
| 462 | } |
|---|
| 463 | else |
|---|
| 464 | { |
|---|
| 465 | iLastSPos = xShift(iEndChangePos+1); |
|---|
| 466 | m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos+1]; |
|---|
| 467 | xInitRenderPartL( iEndChangePos, iLastSPos ); |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | //// RENDER NEW DATA |
|---|
| 471 | Int iCurPosX; |
|---|
| 472 | for ( iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- ) |
|---|
| 473 | { |
|---|
| 474 | // Get minimal changed sample position |
|---|
| 475 | iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]); |
|---|
| 476 | Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData); |
|---|
| 477 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
|---|
| 478 | xRenderRangeL(iCurSPos, iLastSPos, iCurPosX, iError ); |
|---|
| 479 | iLastSPos = iCurSPos; |
|---|
| 480 | m_iLastDepth = m_iCurDepth; |
|---|
| 481 | iPosXinNewData--; |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | //// RE-RENDER DATA LEFT TO NEW DATA |
|---|
| 485 | while ( iCurPosX >= 0 ) |
|---|
| 486 | { |
|---|
| 487 | Int iCurSPos = xShift(iCurPosX); |
|---|
| 488 | m_iCurDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX]; |
|---|
| 489 | xRenderRangeL( iCurSPos, iLastSPos, iCurPosX, iError ); |
|---|
| 490 | |
|---|
| 491 | if ( iCurSPos < iMinChangedSPos ) |
|---|
| 492 | { |
|---|
| 493 | break; |
|---|
| 494 | } |
|---|
| 495 | |
|---|
| 496 | iCurPosX--; |
|---|
| 497 | iLastSPos = iCurSPos; |
|---|
| 498 | m_iLastDepth = m_iCurDepth; |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | xIncViewRow(); |
|---|
| 502 | m_piNewDepthData += iStride; |
|---|
| 503 | } |
|---|
| 504 | return iError; |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | __inline RMDist |
|---|
| 509 | TRenSingleModel::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd ) |
|---|
| 510 | { |
|---|
| 511 | m_bSet = bAdd; |
|---|
| 512 | m_iCurViewPos = 1; |
|---|
| 513 | m_iOtherViewPos = 0; |
|---|
| 514 | |
|---|
| 515 | m_piNewDepthData = piNewData; |
|---|
| 516 | m_iNewDataWidth = iWidth; |
|---|
| 517 | m_iStartChangePosX = iStartPosX; |
|---|
| 518 | |
|---|
| 519 | if ((iWidth == 0) || (iHeight == 0)) |
|---|
| 520 | return 0; |
|---|
| 521 | |
|---|
| 522 | // Get Data |
|---|
| 523 | m_ppiCurLUT = m_appiShiftLut [m_iCurViewPos]; |
|---|
| 524 | |
|---|
| 525 | xSetViewRow ( iStartPosY); |
|---|
| 526 | |
|---|
| 527 | // Init Start |
|---|
| 528 | RMDist iError = 0; |
|---|
| 529 | Int iEndChangePos; |
|---|
| 530 | |
|---|
| 531 | iEndChangePos = m_iStartChangePosX + iWidth - 1; |
|---|
| 532 | |
|---|
| 533 | |
|---|
| 534 | for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ ) |
|---|
| 535 | { |
|---|
| 536 | m_bInOcclusion = false; |
|---|
| 537 | |
|---|
| 538 | Int iLastSPos; |
|---|
| 539 | Int iStartChangePos = m_iStartChangePosX; |
|---|
| 540 | Int iPosXinNewData = 0; |
|---|
| 541 | Int iMaxChangedSPos = -1; |
|---|
| 542 | |
|---|
| 543 | if ( iStartChangePos == 0 ) // Special processing for leftmost depth sample |
|---|
| 544 | { |
|---|
| 545 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
|---|
| 546 | Int iCurSPos = xShiftNewData(iStartChangePos, iPosXinNewData); |
|---|
| 547 | m_iLastOccludedSPos = iCurSPos - 1; |
|---|
| 548 | m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos ); |
|---|
| 549 | xExtrapolateMarginR ( iCurSPos, iStartChangePos, iError ); |
|---|
| 550 | iMaxChangedSPos = max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]); |
|---|
| 551 | iLastSPos = iCurSPos; |
|---|
| 552 | m_iLastDepth = m_iCurDepth; |
|---|
| 553 | iPosXinNewData++; |
|---|
| 554 | iStartChangePos++; |
|---|
| 555 | } |
|---|
| 556 | else |
|---|
| 557 | { |
|---|
| 558 | iLastSPos = xShift(iStartChangePos-1); |
|---|
| 559 | m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos-1]; |
|---|
| 560 | xInitRenderPartR( iStartChangePos, iLastSPos ); |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | //// RENDER NEW DATA |
|---|
| 564 | Int iCurPosX; |
|---|
| 565 | for ( iCurPosX = iStartChangePos; iCurPosX <= iEndChangePos; iCurPosX++ ) |
|---|
| 566 | { |
|---|
| 567 | // Get minimal changed sample position |
|---|
| 568 | iMaxChangedSPos = max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]); |
|---|
| 569 | Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData); |
|---|
| 570 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
|---|
| 571 | xRenderRangeR(iCurSPos, iLastSPos, iCurPosX, iError ); |
|---|
| 572 | iLastSPos = iCurSPos; |
|---|
| 573 | m_iLastDepth = m_iCurDepth; |
|---|
| 574 | iPosXinNewData++; |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | //// RE-RENDER DATA LEFT TO NEW DATA |
|---|
| 578 | while ( iCurPosX < m_iWidth ) |
|---|
| 579 | { |
|---|
| 580 | Int iCurSPos = xShift(iCurPosX); |
|---|
| 581 | m_iCurDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX]; |
|---|
| 582 | xRenderRangeR( iCurSPos, iLastSPos, iCurPosX, iError ); |
|---|
| 583 | |
|---|
| 584 | if ( iCurSPos > iMaxChangedSPos ) |
|---|
| 585 | { |
|---|
| 586 | break; |
|---|
| 587 | } |
|---|
| 588 | iCurPosX++; |
|---|
| 589 | iLastSPos = iCurSPos; |
|---|
| 590 | m_iLastDepth = m_iCurDepth; |
|---|
| 591 | } |
|---|
| 592 | xIncViewRow(); |
|---|
| 593 | m_piNewDepthData += iStride; |
|---|
| 594 | } |
|---|
| 595 | return iError; |
|---|
| 596 | } |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | __inline Void |
|---|
| 600 | TRenSingleModel::xInitRenderPartL( Int iEndChangePos, Int iLastSPos ) |
|---|
| 601 | { |
|---|
| 602 | // GET MINIMAL OCCLUDED SAMPLE POSITION |
|---|
| 603 | Int iCurPosX = iEndChangePos; |
|---|
| 604 | |
|---|
| 605 | if ( ( iCurPosX + 1 < m_iWidth ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) ) |
|---|
| 606 | { |
|---|
| 607 | iCurPosX++; |
|---|
| 608 | while ( (iCurPosX + 1 < m_iWidth) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) ) |
|---|
| 609 | iCurPosX++; |
|---|
| 610 | |
|---|
| 611 | if ( iCurPosX + 1 < m_iWidth ) |
|---|
| 612 | { |
|---|
| 613 | iCurPosX++; |
|---|
| 614 | m_iLastOccludedSPos = xShift(iCurPosX); |
|---|
| 615 | } |
|---|
| 616 | else |
|---|
| 617 | { |
|---|
| 618 | m_iLastOccludedSPos = xShift(iCurPosX) + 1; |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | m_iLastOccludedSPosFP = xRoundL( m_iLastOccludedSPos ); |
|---|
| 622 | } |
|---|
| 623 | else |
|---|
| 624 | { |
|---|
| 625 | m_iLastOccludedSPos = iLastSPos+1; |
|---|
| 626 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | m_bInOcclusion = iLastSPos >= m_iLastOccludedSPos; |
|---|
| 630 | }; |
|---|
| 631 | |
|---|
| 632 | __inline Void |
|---|
| 633 | TRenSingleModel::xInitRenderPartR( Int iStartChangePos, Int iLastSPos ) |
|---|
| 634 | { |
|---|
| 635 | // GET MINIMAL OCCLUDED SAMPLE POSITION |
|---|
| 636 | Int iCurPosX = iStartChangePos; |
|---|
| 637 | |
|---|
| 638 | if ( ( iCurPosX - 1 > -1 ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] ) ) |
|---|
| 639 | { |
|---|
| 640 | iCurPosX--; |
|---|
| 641 | while ( (iCurPosX - 1 > -1 ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] ) ) |
|---|
| 642 | iCurPosX--; |
|---|
| 643 | |
|---|
| 644 | if ( iCurPosX - 1 > -1 ) |
|---|
| 645 | { |
|---|
| 646 | iCurPosX--; |
|---|
| 647 | m_iLastOccludedSPos = xShift(iCurPosX); |
|---|
| 648 | } |
|---|
| 649 | else |
|---|
| 650 | { |
|---|
| 651 | m_iLastOccludedSPos = xShift(iCurPosX) - 1; |
|---|
| 652 | } |
|---|
| 653 | m_iLastOccludedSPosFP = xRoundR( m_iLastOccludedSPos ); |
|---|
| 654 | } |
|---|
| 655 | else |
|---|
| 656 | { |
|---|
| 657 | m_iLastOccludedSPos = iLastSPos-1; |
|---|
| 658 | m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos ); |
|---|
| 659 | } |
|---|
| 660 | |
|---|
| 661 | m_bInOcclusion = iLastSPos <= m_iLastOccludedSPos; |
|---|
| 662 | }; |
|---|
| 663 | |
|---|
| 664 | |
|---|
| 665 | __inline Void |
|---|
| 666 | TRenSingleModel::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
|---|
| 667 | { |
|---|
| 668 | assert( iCurSPos <= iLastSPos ); |
|---|
| 669 | //assert( iRightSPos < m_iWidth ); |
|---|
| 670 | |
|---|
| 671 | Int iDeltaSPos = iLastSPos - iCurSPos; |
|---|
| 672 | if ( iDeltaSPos > m_iGapTolerance ) |
|---|
| 673 | { |
|---|
| 674 | xFillHoleL( iCurSPos, iLastSPos, iCurPos, riError ); |
|---|
| 675 | } |
|---|
| 676 | else |
|---|
| 677 | { |
|---|
| 678 | if (iLastSPos < 0 ) |
|---|
| 679 | return; |
|---|
| 680 | |
|---|
| 681 | AOT( iDeltaSPos > m_iGapTolerance ); |
|---|
| 682 | |
|---|
| 683 | m_iThisDepth = m_iCurDepth; |
|---|
| 684 | for (Int iFillSPos = max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ ) |
|---|
| 685 | { |
|---|
| 686 | Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iCurSPos; |
|---|
| 687 | |
|---|
| 688 | AOT( iDeltaCurSPos > iDeltaSPos ); |
|---|
| 689 | AOT( iDeltaCurSPos < 0 ); |
|---|
| 690 | AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead); |
|---|
| 691 | |
|---|
| 692 | Int iSourcePos = (iCurPos << m_iShiftPrec) + m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos]; // GT: = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos; |
|---|
| 693 | xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError ); |
|---|
| 694 | } |
|---|
| 695 | }; |
|---|
| 696 | } |
|---|
| 697 | |
|---|
| 698 | __inline Void |
|---|
| 699 | TRenSingleModel::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
|---|
| 700 | { |
|---|
| 701 | assert( iCurSPos >= iLastSPos ); |
|---|
| 702 | //assert( iRightSPos < m_iWidth ); |
|---|
| 703 | |
|---|
| 704 | Int iDeltaSPos = iCurSPos - iLastSPos; |
|---|
| 705 | if ( iDeltaSPos > m_iGapTolerance ) |
|---|
| 706 | { |
|---|
| 707 | xFillHoleR( iCurSPos, iLastSPos, iCurPos, riError ); |
|---|
| 708 | } |
|---|
| 709 | else |
|---|
| 710 | { |
|---|
| 711 | if (iLastSPos > m_iSampledWidth - 1 ) |
|---|
| 712 | return; |
|---|
| 713 | |
|---|
| 714 | m_iThisDepth = m_iCurDepth; |
|---|
| 715 | AOT( iDeltaSPos > m_iGapTolerance ); |
|---|
| 716 | for (Int iFillSPos = max(m_iLastOccludedSPosFP+1, xRangeLeftR(iLastSPos) ); iFillSPos <= min(xRangeRightR( iCurSPos ) ,m_iWidth -1); iFillSPos++ ) |
|---|
| 717 | { |
|---|
| 718 | Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iLastSPos; |
|---|
| 719 | |
|---|
| 720 | AOT( iDeltaCurSPos > iDeltaSPos ); |
|---|
| 721 | AOT( iDeltaCurSPos < 0 ); |
|---|
| 722 | AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead); |
|---|
| 723 | |
|---|
| 724 | Int iSourcePos = (iCurPos << m_iShiftPrec) + m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos]; // GT: = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos; |
|---|
| 725 | |
|---|
| 726 | xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError ); |
|---|
| 727 | } |
|---|
| 728 | }; |
|---|
| 729 | } |
|---|
| 730 | |
|---|
| 731 | |
|---|
| 732 | |
|---|
| 733 | __inline Void |
|---|
| 734 | TRenSingleModel::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
|---|
| 735 | { |
|---|
| 736 | if ( !m_bInOcclusion ) |
|---|
| 737 | { |
|---|
| 738 | if ( iCurSPos >= iLastSPos ) |
|---|
| 739 | { |
|---|
| 740 | m_iLastOccludedSPos = iLastSPos; |
|---|
| 741 | |
|---|
| 742 | Int iRightSPosFP = xRoundL( iLastSPos ); |
|---|
| 743 | if ( ( iRightSPosFP == xRangeRightL(iLastSPos)) && (iRightSPosFP >= 0) ) |
|---|
| 744 | { |
|---|
| 745 | m_iThisDepth = m_iLastDepth; |
|---|
| 746 | xSetShiftedPel( (iCurPos+1) << m_iShiftPrec, iRightSPosFP, REN_IS_FILLED, riError ); |
|---|
| 747 | } |
|---|
| 748 | m_iLastOccludedSPosFP = iRightSPosFP; |
|---|
| 749 | |
|---|
| 750 | m_bInOcclusion = true; |
|---|
| 751 | |
|---|
| 752 | if ( m_bSet ) |
|---|
| 753 | { |
|---|
| 754 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
|---|
| 755 | } |
|---|
| 756 | } |
|---|
| 757 | else |
|---|
| 758 | { |
|---|
| 759 | if ( m_bSet ) |
|---|
| 760 | { |
|---|
| 761 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
|---|
| 762 | } |
|---|
| 763 | |
|---|
| 764 | xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError ); |
|---|
| 765 | } |
|---|
| 766 | } |
|---|
| 767 | else |
|---|
| 768 | { |
|---|
| 769 | if ( iCurSPos < m_iLastOccludedSPos ) |
|---|
| 770 | { |
|---|
| 771 | m_bInOcclusion = false; |
|---|
| 772 | if ( m_bSet ) |
|---|
| 773 | { |
|---|
| 774 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
|---|
| 775 | } |
|---|
| 776 | |
|---|
| 777 | xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError ); |
|---|
| 778 | } |
|---|
| 779 | else |
|---|
| 780 | { |
|---|
| 781 | if ( m_bSet ) |
|---|
| 782 | { |
|---|
| 783 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
|---|
| 784 | } |
|---|
| 785 | } |
|---|
| 786 | } |
|---|
| 787 | } |
|---|
| 788 | |
|---|
| 789 | __inline Void |
|---|
| 790 | TRenSingleModel::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
|---|
| 791 | { |
|---|
| 792 | // Find out if current sample is occluded |
|---|
| 793 | if ( !m_bInOcclusion ) |
|---|
| 794 | { |
|---|
| 795 | if ( iCurSPos <= iLastSPos ) |
|---|
| 796 | { |
|---|
| 797 | m_iLastOccludedSPos = iLastSPos; |
|---|
| 798 | |
|---|
| 799 | Int iLeftSPosFP = xRoundR( iLastSPos ); |
|---|
| 800 | if ( ( iLeftSPosFP == xRangeLeftR(iLastSPos)) && (iLeftSPosFP <= m_iWidth - 1) ) |
|---|
| 801 | { |
|---|
| 802 | m_iThisDepth = m_iLastDepth; |
|---|
| 803 | xSetShiftedPel( (iCurPos-1) << m_iShiftPrec, iLeftSPosFP, REN_IS_FILLED, riError ); |
|---|
| 804 | } |
|---|
| 805 | m_iLastOccludedSPosFP = iLeftSPosFP; |
|---|
| 806 | |
|---|
| 807 | m_bInOcclusion = true; |
|---|
| 808 | |
|---|
| 809 | if ( m_bSet ) |
|---|
| 810 | { |
|---|
| 811 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
|---|
| 812 | } |
|---|
| 813 | } |
|---|
| 814 | else |
|---|
| 815 | { |
|---|
| 816 | if ( m_bSet ) |
|---|
| 817 | { |
|---|
| 818 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
|---|
| 819 | } |
|---|
| 820 | |
|---|
| 821 | xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError ); |
|---|
| 822 | } |
|---|
| 823 | } |
|---|
| 824 | else |
|---|
| 825 | { |
|---|
| 826 | if ( iCurSPos > m_iLastOccludedSPos ) |
|---|
| 827 | { |
|---|
| 828 | m_bInOcclusion = false; |
|---|
| 829 | if ( m_bSet ) |
|---|
| 830 | { |
|---|
| 831 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
|---|
| 832 | } |
|---|
| 833 | |
|---|
| 834 | xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError ); |
|---|
| 835 | } |
|---|
| 836 | else |
|---|
| 837 | { |
|---|
| 838 | if ( m_bSet ) |
|---|
| 839 | { |
|---|
| 840 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
|---|
| 841 | } |
|---|
| 842 | } |
|---|
| 843 | } |
|---|
| 844 | } |
|---|
| 845 | |
|---|
| 846 | __inline Void |
|---|
| 847 | TRenSingleModel::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
|---|
| 848 | { |
|---|
| 849 | if (iLastSPos < 0) |
|---|
| 850 | return; |
|---|
| 851 | |
|---|
| 852 | Int iStartFillSPos = iCurSPos; |
|---|
| 853 | Int iStartFillPos = iCurPos; |
|---|
| 854 | Int iLastPos = iCurPos + 1; |
|---|
| 855 | |
|---|
| 856 | Int iStartFillSPosFP = xRangeLeftL(iStartFillSPos); |
|---|
| 857 | |
|---|
| 858 | if (iStartFillSPosFP == xRoundL(iStartFillSPos)) |
|---|
| 859 | { |
|---|
| 860 | if ((iStartFillSPosFP >= 0) && (iStartFillSPosFP < m_iLastOccludedSPosFP) ) |
|---|
| 861 | { |
|---|
| 862 | m_iThisDepth = m_iCurDepth; |
|---|
| 863 | xSetShiftedPel ( iStartFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError ); |
|---|
| 864 | } |
|---|
| 865 | } |
|---|
| 866 | else |
|---|
| 867 | { |
|---|
| 868 | iStartFillSPosFP--; |
|---|
| 869 | } |
|---|
| 870 | |
|---|
| 871 | m_iThisDepth = m_iLastDepth; |
|---|
| 872 | for (Int iFillSPos = max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ ) |
|---|
| 873 | { |
|---|
| 874 | xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
|---|
| 875 | } |
|---|
| 876 | } |
|---|
| 877 | |
|---|
| 878 | __inline Void |
|---|
| 879 | TRenSingleModel::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
|---|
| 880 | { |
|---|
| 881 | if (iLastSPos < 0) |
|---|
| 882 | return; |
|---|
| 883 | |
|---|
| 884 | Int iStartFillSPos = iCurSPos; |
|---|
| 885 | Int iEndFillPos = iCurPos; |
|---|
| 886 | Int iLastPos = iCurPos - 1; |
|---|
| 887 | |
|---|
| 888 | Int iStartFillSPosFP = xRangeRightR(iStartFillSPos); |
|---|
| 889 | |
|---|
| 890 | if (iStartFillSPosFP == xRoundR(iStartFillSPos)) |
|---|
| 891 | { |
|---|
| 892 | if ((iStartFillSPosFP < m_iWidth) && (iStartFillSPosFP > m_iLastOccludedSPosFP) ) |
|---|
| 893 | { |
|---|
| 894 | m_iThisDepth = m_iCurDepth; |
|---|
| 895 | xSetShiftedPel( iEndFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError ); |
|---|
| 896 | } |
|---|
| 897 | } |
|---|
| 898 | else |
|---|
| 899 | { |
|---|
| 900 | iStartFillSPosFP++; |
|---|
| 901 | } |
|---|
| 902 | |
|---|
| 903 | m_iThisDepth = m_iLastDepth; |
|---|
| 904 | for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ ) |
|---|
| 905 | { |
|---|
| 906 | xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
|---|
| 907 | } |
|---|
| 908 | } |
|---|
| 909 | |
|---|
| 910 | __inline Void |
|---|
| 911 | TRenSingleModel::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError ) |
|---|
| 912 | { |
|---|
| 913 | // if (iLeftSPos < 0 ) |
|---|
| 914 | // return; |
|---|
| 915 | |
|---|
| 916 | Int iSPosFullPel = max(0,xRangeLeftL(iCurSPos)); |
|---|
| 917 | |
|---|
| 918 | m_iThisDepth = m_iCurDepth; |
|---|
| 919 | if (iSPosFullPel < m_iWidth) |
|---|
| 920 | { |
|---|
| 921 | xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError ); |
|---|
| 922 | } |
|---|
| 923 | |
|---|
| 924 | for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ ) |
|---|
| 925 | { |
|---|
| 926 | xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
|---|
| 927 | } |
|---|
| 928 | } |
|---|
| 929 | |
|---|
| 930 | __inline Void |
|---|
| 931 | TRenSingleModel::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError ) |
|---|
| 932 | { |
|---|
| 933 | // if (iLeftSPos < 0 ) |
|---|
| 934 | // return; |
|---|
| 935 | |
|---|
| 936 | Int iSPosFullPel = Min(m_iWidth-1,xRangeRightR(iCurSPos)); |
|---|
| 937 | |
|---|
| 938 | m_iThisDepth = m_iCurDepth; |
|---|
| 939 | if (iSPosFullPel > -1) |
|---|
| 940 | { |
|---|
| 941 | xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError ); |
|---|
| 942 | } |
|---|
| 943 | |
|---|
| 944 | for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- ) |
|---|
| 945 | { |
|---|
| 946 | xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
|---|
| 947 | } |
|---|
| 948 | } |
|---|
| 949 | |
|---|
| 950 | |
|---|
| 951 | __inline Int |
|---|
| 952 | TRenSingleModel::xShiftNewData( Int iPosX, Int iPosInNewData ) |
|---|
| 953 | { |
|---|
| 954 | AOT( iPosInNewData < 0 ); |
|---|
| 955 | AOF( iPosInNewData < m_iNewDataWidth ); |
|---|
| 956 | |
|---|
| 957 | return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_piNewDepthData[iPosInNewData] )]; |
|---|
| 958 | } |
|---|
| 959 | |
|---|
| 960 | __inline Int |
|---|
| 961 | TRenSingleModel::xShift( Int iPosX ) |
|---|
| 962 | { |
|---|
| 963 | AOT( iPosX < 0); |
|---|
| 964 | AOF( iPosX < m_iWidth); |
|---|
| 965 | return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )]; |
|---|
| 966 | } |
|---|
| 967 | |
|---|
| 968 | |
|---|
| 969 | __inline Int |
|---|
| 970 | TRenSingleModel::xShift( Int iPos, Int iPosInNewData ) |
|---|
| 971 | { |
|---|
| 972 | if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) ) |
|---|
| 973 | { |
|---|
| 974 | return xShiftNewData(iPos ,iPosInNewData ); |
|---|
| 975 | } |
|---|
| 976 | else |
|---|
| 977 | { |
|---|
| 978 | return xShift(iPos); |
|---|
| 979 | } |
|---|
| 980 | } |
|---|
| 981 | |
|---|
| 982 | __inline Int |
|---|
| 983 | TRenSingleModel::xRangeLeftL( Int iPos ) |
|---|
| 984 | { |
|---|
| 985 | return ( iPos + (1 << m_iShiftPrec) - 1) >> m_iShiftPrec; |
|---|
| 986 | } |
|---|
| 987 | |
|---|
| 988 | |
|---|
| 989 | __inline Int |
|---|
| 990 | TRenSingleModel::xRangeLeftR( Int iPos ) |
|---|
| 991 | { |
|---|
| 992 | |
|---|
| 993 | return xRangeRightR( iPos ) + 1; |
|---|
| 994 | } |
|---|
| 995 | |
|---|
| 996 | |
|---|
| 997 | __inline Int |
|---|
| 998 | TRenSingleModel::xRangeRightL( Int iPos ) |
|---|
| 999 | { |
|---|
| 1000 | return xRangeLeftL(iPos) - 1; |
|---|
| 1001 | } |
|---|
| 1002 | |
|---|
| 1003 | __inline Int |
|---|
| 1004 | TRenSingleModel::xRangeRightR( Int iPos ) |
|---|
| 1005 | { |
|---|
| 1006 | return iPos >> m_iShiftPrec; |
|---|
| 1007 | } |
|---|
| 1008 | |
|---|
| 1009 | |
|---|
| 1010 | __inline Int |
|---|
| 1011 | TRenSingleModel::xRoundL( Int iPos ) |
|---|
| 1012 | { |
|---|
| 1013 | return (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec; |
|---|
| 1014 | } |
|---|
| 1015 | |
|---|
| 1016 | __inline Int |
|---|
| 1017 | TRenSingleModel::xRoundR( Int iPos ) |
|---|
| 1018 | { |
|---|
| 1019 | return (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1); |
|---|
| 1020 | } |
|---|
| 1021 | |
|---|
| 1022 | |
|---|
| 1023 | Void |
|---|
| 1024 | TRenSingleModel::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal ) |
|---|
| 1025 | { |
|---|
| 1026 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
|---|
| 1027 | { |
|---|
| 1028 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
|---|
| 1029 | { |
|---|
| 1030 | piPelSource[iXPos] = iVal; |
|---|
| 1031 | } |
|---|
| 1032 | piPelSource += iSourceStride; |
|---|
| 1033 | } |
|---|
| 1034 | } |
|---|
| 1035 | |
|---|
| 1036 | Void |
|---|
| 1037 | TRenSingleModel::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal ) |
|---|
| 1038 | { |
|---|
| 1039 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
|---|
| 1040 | { |
|---|
| 1041 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
|---|
| 1042 | { |
|---|
| 1043 | piPelSource[iXPos] = iVal; |
|---|
| 1044 | } |
|---|
| 1045 | piPelSource += iSourceStride; |
|---|
| 1046 | } |
|---|
| 1047 | } |
|---|
| 1048 | |
|---|
| 1049 | |
|---|
| 1050 | Void |
|---|
| 1051 | TRenSingleModel::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal ) |
|---|
| 1052 | { |
|---|
| 1053 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
|---|
| 1054 | { |
|---|
| 1055 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
|---|
| 1056 | { |
|---|
| 1057 | pbPelSource[iXPos] = bVal; |
|---|
| 1058 | } |
|---|
| 1059 | pbPelSource += iSourceStride; |
|---|
| 1060 | } |
|---|
| 1061 | } |
|---|
| 1062 | |
|---|
| 1063 | Void |
|---|
| 1064 | TRenSingleModel::xInitView( Int iViewPos ) |
|---|
| 1065 | { |
|---|
| 1066 | AOT( iViewPos == VIEWPOS_MERGED && ( m_iMode == 0 || m_iMode == 1 ) ); |
|---|
| 1067 | |
|---|
| 1068 | xSetPels( m_aapiSynthVideoPel[iViewPos][0], m_iStride, m_iWidth, m_iHeight, 0 ); |
|---|
| 1069 | xSetPels( m_aapiSynthVideoPel[iViewPos][1], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement ); |
|---|
| 1070 | xSetPels( m_aapiSynthVideoPel[iViewPos][2], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement ); |
|---|
| 1071 | |
|---|
| 1072 | if ( iViewPos != VIEWPOS_MERGED) |
|---|
| 1073 | { |
|---|
| 1074 | xSetBools( m_apbOccluded [iViewPos], m_iStride, m_iWidth, m_iHeight, false ); |
|---|
| 1075 | xSetPels ( m_apiFilled [iViewPos], m_iStride, m_iWidth, m_iHeight, REN_IS_HOLE); |
|---|
| 1076 | if ( m_iMode == 2 ) |
|---|
| 1077 | { |
|---|
| 1078 | xSetPels( m_apiSynthDepthPel [iViewPos], m_iStride, m_iWidth, m_iHeight, 0); |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | } |
|---|
| 1082 | |
|---|
| 1083 | __inline Void |
|---|
| 1084 | TRenSingleModel::xSetShiftedPel(Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError ) |
|---|
| 1085 | { |
|---|
| 1086 | AOT( iSourcePos < 0 ); |
|---|
| 1087 | AOT( iSourcePos >= m_iSampledWidth ); |
|---|
| 1088 | |
|---|
| 1089 | AOT( iTargetSPos < 0 ); |
|---|
| 1090 | AOT( iTargetSPos >= m_iWidth ); |
|---|
| 1091 | // AOT( m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE); |
|---|
| 1092 | |
|---|
| 1093 | if ( m_iMode == 2) |
|---|
| 1094 | { |
|---|
| 1095 | xSetShiftedPelBlend(iSourcePos, iTargetSPos, iFilled, riError ); |
|---|
| 1096 | return; |
|---|
| 1097 | } |
|---|
| 1098 | |
|---|
| 1099 | if ( m_bSet ) |
|---|
| 1100 | { |
|---|
| 1101 | m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos]; |
|---|
| 1102 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1103 | m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos]; |
|---|
| 1104 | m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos]; |
|---|
| 1105 | #endif |
|---|
| 1106 | m_apiFilledRow [m_iCurViewPos] [iTargetSPos] = iFilled; |
|---|
| 1107 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos]; |
|---|
| 1108 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1109 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos]; |
|---|
| 1110 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos]; |
|---|
| 1111 | m_apiErrorRow [iTargetSPos] = xGetDist( iDiffY, iDiffU, iDiffV); |
|---|
| 1112 | #else |
|---|
| 1113 | m_apiErrorRow [iTargetSPos] = xGetDist(iDiffY); |
|---|
| 1114 | #endif |
|---|
| 1115 | } |
|---|
| 1116 | else |
|---|
| 1117 | { |
|---|
| 1118 | Int iSDOld = m_apiErrorRow [iTargetSPos]; |
|---|
| 1119 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][0][iSourcePos]; |
|---|
| 1120 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1121 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][1][iSourcePos]; |
|---|
| 1122 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][2][iSourcePos]; |
|---|
| 1123 | riError += ( xGetDist(iDiffY,iDiffU,iDiffV) - iSDOld ); |
|---|
| 1124 | #else |
|---|
| 1125 | riError += ( xGetDist( iDiffY ) - iSDOld ); |
|---|
| 1126 | #endif |
|---|
| 1127 | } |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | __inline Void |
|---|
| 1131 | TRenSingleModel::xSetShiftedPelBlend( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError ) |
|---|
| 1132 | { |
|---|
| 1133 | AOT( iSourcePos < 0 ); |
|---|
| 1134 | AOT( iSourcePos >= m_iSampledWidth ); |
|---|
| 1135 | |
|---|
| 1136 | AOT( iTargetSPos < 0 ); |
|---|
| 1137 | AOT( iTargetSPos >= m_iWidth ); |
|---|
| 1138 | // AOT( m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE); |
|---|
| 1139 | |
|---|
| 1140 | Pel piBlendedValueY; |
|---|
| 1141 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1142 | Pel piBlendedValueU; |
|---|
| 1143 | Pel piBlendedValueV; |
|---|
| 1144 | #endif |
|---|
| 1145 | |
|---|
| 1146 | |
|---|
| 1147 | if (m_iCurViewPos == 0) |
|---|
| 1148 | { |
|---|
| 1149 | xGetBlendedValue ( |
|---|
| 1150 | m_aapiBaseVideoPelRow [0][0][iSourcePos ] , |
|---|
| 1151 | m_aapiSynthVideoPelRow [1][0][iTargetSPos] , |
|---|
| 1152 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1153 | m_aapiBaseVideoPelRow [0][1][iSourcePos ] , |
|---|
| 1154 | m_aapiSynthVideoPelRow [1][1][iTargetSPos] , |
|---|
| 1155 | m_aapiBaseVideoPelRow [0][2][iSourcePos ] , |
|---|
| 1156 | m_aapiSynthVideoPelRow [1][2][iTargetSPos] , |
|---|
| 1157 | #endif |
|---|
| 1158 | m_piInvZLUTLeft [RemoveBitIncrement(m_iThisDepth) ], |
|---|
| 1159 | m_piInvZLUTRight[RemoveBitIncrement(m_apiSynthDepthPelRow[1] [iTargetSPos])], |
|---|
| 1160 | iFilled, |
|---|
| 1161 | m_apiFilledRow [1] [iTargetSPos] , |
|---|
| 1162 | piBlendedValueY |
|---|
| 1163 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1164 | , piBlendedValueU, |
|---|
| 1165 | piBlendedValueV |
|---|
| 1166 | #endif |
|---|
| 1167 | ); |
|---|
| 1168 | } |
|---|
| 1169 | else |
|---|
| 1170 | { |
|---|
| 1171 | xGetBlendedValue ( |
|---|
| 1172 | m_aapiSynthVideoPelRow [0][0][iTargetSPos], |
|---|
| 1173 | m_aapiBaseVideoPelRow [1][0][iSourcePos ], |
|---|
| 1174 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1175 | m_aapiSynthVideoPelRow [0][1][iTargetSPos], |
|---|
| 1176 | m_aapiBaseVideoPelRow [1][1][iSourcePos ], |
|---|
| 1177 | m_aapiSynthVideoPelRow [0][2][iTargetSPos], |
|---|
| 1178 | m_aapiBaseVideoPelRow [1][2][iSourcePos ], |
|---|
| 1179 | #endif |
|---|
| 1180 | m_piInvZLUTLeft [RemoveBitIncrement(m_apiSynthDepthPelRow[0] [iTargetSPos])], |
|---|
| 1181 | m_piInvZLUTRight[RemoveBitIncrement(m_iThisDepth) ], |
|---|
| 1182 | m_apiFilledRow [0] [iTargetSPos], |
|---|
| 1183 | iFilled , |
|---|
| 1184 | piBlendedValueY |
|---|
| 1185 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1186 | , piBlendedValueU, |
|---|
| 1187 | piBlendedValueV |
|---|
| 1188 | #endif |
|---|
| 1189 | ); |
|---|
| 1190 | } |
|---|
| 1191 | |
|---|
| 1192 | if ( m_bSet ) |
|---|
| 1193 | { |
|---|
| 1194 | m_apiSynthDepthPelRow [m_iCurViewPos] [iTargetSPos] = m_iThisDepth; |
|---|
| 1195 | m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos]; |
|---|
| 1196 | m_aapiSynthVideoPelRow[2 ][0][iTargetSPos] = piBlendedValueY; |
|---|
| 1197 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1198 | m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos]; |
|---|
| 1199 | m_aapiSynthVideoPelRow[2 ][1][iTargetSPos] = piBlendedValueU; |
|---|
| 1200 | m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos]; |
|---|
| 1201 | m_aapiSynthVideoPelRow[2 ][2][iTargetSPos] = piBlendedValueV; |
|---|
| 1202 | #endif |
|---|
| 1203 | m_apiFilledRow [m_iCurViewPos] [iTargetSPos] = iFilled; |
|---|
| 1204 | |
|---|
| 1205 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - piBlendedValueY; |
|---|
| 1206 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1207 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - piBlendedValueU; |
|---|
| 1208 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - piBlendedValueV; |
|---|
| 1209 | m_apiErrorRow [iTargetSPos] = xGetDist(iDiffY, iDiffU, iDiffV ); |
|---|
| 1210 | #else |
|---|
| 1211 | m_apiErrorRow [iTargetSPos] = xGetDist(iDiffY); |
|---|
| 1212 | #endif |
|---|
| 1213 | } |
|---|
| 1214 | else |
|---|
| 1215 | { |
|---|
| 1216 | Int iSDOld = m_apiErrorRow [iTargetSPos]; |
|---|
| 1217 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - piBlendedValueY; |
|---|
| 1218 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1219 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - piBlendedValueU; |
|---|
| 1220 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - piBlendedValueV; |
|---|
| 1221 | riError += ( xGetDist( iDiffY, iDiffU, iDiffV ) - iSDOld ); |
|---|
| 1222 | #else |
|---|
| 1223 | riError += ( xGetDist( iDiffY )- iSDOld ); |
|---|
| 1224 | #endif |
|---|
| 1225 | } |
|---|
| 1226 | } |
|---|
| 1227 | |
|---|
| 1228 | |
|---|
| 1229 | __inline Int |
|---|
| 1230 | TRenSingleModel::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV ) |
|---|
| 1231 | { |
|---|
| 1232 | return ( ((iDiffY * iDiffY) >> m_iDistShift) |
|---|
| 1233 | + ((( ((iDiffU * iDiffU) >> m_iDistShift) |
|---|
| 1234 | +((iDiffV * iDiffV) >> m_iDistShift) |
|---|
| 1235 | ) |
|---|
| 1236 | ) >> 2 |
|---|
| 1237 | ) |
|---|
| 1238 | ); |
|---|
| 1239 | } |
|---|
| 1240 | |
|---|
| 1241 | __inline Int |
|---|
| 1242 | TRenSingleModel::xGetDist( Int iDiffY ) |
|---|
| 1243 | { |
|---|
| 1244 | return ((iDiffY * iDiffY) >> m_iDistShift); |
|---|
| 1245 | } |
|---|
| 1246 | |
|---|
| 1247 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1248 | __inline Void |
|---|
| 1249 | TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV ) |
|---|
| 1250 | #else |
|---|
| 1251 | Void |
|---|
| 1252 | TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
|---|
| 1253 | #endif |
|---|
| 1254 | { |
|---|
| 1255 | if (m_iBlendMode != 0 ) |
|---|
| 1256 | { |
|---|
| 1257 | if (m_iBlendMode == 1 ) |
|---|
| 1258 | { |
|---|
| 1259 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1260 | xGetBlendedValueBM1( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV ); |
|---|
| 1261 | #else |
|---|
| 1262 | xGetBlendedValueBM1( iYL, iYR, iDepthL, iDepthR, iFilledL, iFilledR, riY ); |
|---|
| 1263 | #endif |
|---|
| 1264 | } |
|---|
| 1265 | else |
|---|
| 1266 | { |
|---|
| 1267 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1268 | xGetBlendedValueBM2( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV ); |
|---|
| 1269 | #else |
|---|
| 1270 | xGetBlendedValueBM2( iYL, iYR, iDepthL, iDepthR, iFilledL, iFilledR, riY ); |
|---|
| 1271 | #endif |
|---|
| 1272 | } |
|---|
| 1273 | return; |
|---|
| 1274 | } |
|---|
| 1275 | |
|---|
| 1276 | if ( (iFilledL != REN_IS_HOLE ) && ( iFilledR != REN_IS_HOLE) ) |
|---|
| 1277 | { |
|---|
| 1278 | Int iDepthDifference = iDepthR - iDepthL; |
|---|
| 1279 | |
|---|
| 1280 | if ( abs ( iDepthDifference ) <= m_iBlendZThres ) |
|---|
| 1281 | { |
|---|
| 1282 | if ((iFilledL == REN_IS_FILLED) && ( iFilledR != REN_IS_FILLED)) |
|---|
| 1283 | { |
|---|
| 1284 | riY = xBlend( iYL, iYR, iFilledR >> 1 ); |
|---|
| 1285 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1286 | riU = xBlend( iUL, iUR, iFilledR >> 1 ); |
|---|
| 1287 | riV = xBlend( iVL, iVR, iFilledR >> 1 ); |
|---|
| 1288 | #endif |
|---|
| 1289 | |
|---|
| 1290 | } |
|---|
| 1291 | else if ((iFilledL != REN_IS_FILLED) && ( iFilledR == REN_IS_FILLED)) |
|---|
| 1292 | { |
|---|
| 1293 | riY = xBlend( iYR, iYL, (iFilledL >> 1) ); |
|---|
| 1294 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1295 | riU = xBlend( iUR, iUL, (iFilledL >> 1) ); |
|---|
| 1296 | riV = xBlend( iVR, iVL, (iFilledL >> 1) ); |
|---|
| 1297 | #endif |
|---|
| 1298 | } |
|---|
| 1299 | else |
|---|
| 1300 | { |
|---|
| 1301 | #if HHI_FIX |
|---|
| 1302 | riY = xBlend( iYL, iYR, m_iBlendDistWeight ); |
|---|
| 1303 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1304 | riU = xBlend( iUL, iUR, m_iBlendDistWeight ); |
|---|
| 1305 | riV = xBlend( iVL, iVR, m_iBlendDistWeight ); |
|---|
| 1306 | #endif |
|---|
| 1307 | #else |
|---|
| 1308 | riY = xBlend( iYR, iYL, m_iBlendDistWeight ); |
|---|
| 1309 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1310 | riU = xBlend( iUR, iUL, m_iBlendDistWeight ); |
|---|
| 1311 | riV = xBlend( iVR, iVL, m_iBlendDistWeight ); |
|---|
| 1312 | #endif |
|---|
| 1313 | #endif |
|---|
| 1314 | } |
|---|
| 1315 | } |
|---|
| 1316 | else if ( iDepthDifference < 0 ) |
|---|
| 1317 | { |
|---|
| 1318 | riY = iYL; |
|---|
| 1319 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1320 | riU = iUL; |
|---|
| 1321 | riV = iVL; |
|---|
| 1322 | #endif |
|---|
| 1323 | } |
|---|
| 1324 | else |
|---|
| 1325 | { |
|---|
| 1326 | riY = iYR; |
|---|
| 1327 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1328 | riU = iUR; |
|---|
| 1329 | riV = iVR; |
|---|
| 1330 | #endif |
|---|
| 1331 | } |
|---|
| 1332 | } |
|---|
| 1333 | else if ( (iFilledL == REN_IS_HOLE) && (iFilledR == REN_IS_HOLE)) |
|---|
| 1334 | { |
|---|
| 1335 | if ( iDepthR < iDepthL ) |
|---|
| 1336 | { |
|---|
| 1337 | riY = iYR; |
|---|
| 1338 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1339 | riU = iUR; |
|---|
| 1340 | riV = iVR; |
|---|
| 1341 | #endif |
|---|
| 1342 | } |
|---|
| 1343 | else |
|---|
| 1344 | { |
|---|
| 1345 | riY = iYL; |
|---|
| 1346 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1347 | riU = iUL; |
|---|
| 1348 | riV = iVL; |
|---|
| 1349 | #endif |
|---|
| 1350 | } |
|---|
| 1351 | } |
|---|
| 1352 | else |
|---|
| 1353 | { |
|---|
| 1354 | if (iFilledR == REN_IS_HOLE) |
|---|
| 1355 | { |
|---|
| 1356 | riY = iYL; |
|---|
| 1357 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1358 | riU = iUL; |
|---|
| 1359 | riV = iVL; |
|---|
| 1360 | #endif |
|---|
| 1361 | } |
|---|
| 1362 | else |
|---|
| 1363 | { |
|---|
| 1364 | riY = iYR; |
|---|
| 1365 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1366 | riU = iUR; |
|---|
| 1367 | riV = iVR; |
|---|
| 1368 | #endif |
|---|
| 1369 | } |
|---|
| 1370 | } |
|---|
| 1371 | |
|---|
| 1372 | } |
|---|
| 1373 | |
|---|
| 1374 | __inline Void |
|---|
| 1375 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1376 | TRenSingleModel::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV ) |
|---|
| 1377 | #else |
|---|
| 1378 | TRenSingleModel::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
|---|
| 1379 | #endif |
|---|
| 1380 | { |
|---|
| 1381 | if ( iFilledL == REN_IS_FILLED || iFilledR == REN_IS_HOLE ) |
|---|
| 1382 | { |
|---|
| 1383 | riY = iYL; |
|---|
| 1384 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1385 | riU = iUL; |
|---|
| 1386 | riV = iVL; |
|---|
| 1387 | #endif |
|---|
| 1388 | } |
|---|
| 1389 | else if ( iFilledL == REN_IS_HOLE ) |
|---|
| 1390 | { |
|---|
| 1391 | riY = iYR; |
|---|
| 1392 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1393 | riU = iUR; |
|---|
| 1394 | riV = iVR; |
|---|
| 1395 | #endif |
|---|
| 1396 | } |
|---|
| 1397 | else |
|---|
| 1398 | { |
|---|
| 1399 | riY = xBlend( iYR, iYL, iFilledL ); |
|---|
| 1400 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1401 | riU = xBlend( iUR, iUL, iFilledL ); |
|---|
| 1402 | riV = xBlend( iVR, iUL, iFilledL ); |
|---|
| 1403 | #endif |
|---|
| 1404 | } |
|---|
| 1405 | } |
|---|
| 1406 | |
|---|
| 1407 | __inline Void |
|---|
| 1408 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1409 | TRenSingleModel::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV ) |
|---|
| 1410 | #else |
|---|
| 1411 | TRenSingleModel::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
|---|
| 1412 | #endif |
|---|
| 1413 | { |
|---|
| 1414 | if ( iFilledR == REN_IS_FILLED || iFilledL == REN_IS_HOLE ) |
|---|
| 1415 | { |
|---|
| 1416 | riY = iYR; |
|---|
| 1417 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1418 | riU = iUR; |
|---|
| 1419 | riV = iVR; |
|---|
| 1420 | #endif |
|---|
| 1421 | } |
|---|
| 1422 | else if ( iFilledR == REN_IS_HOLE ) |
|---|
| 1423 | { |
|---|
| 1424 | riY = iYL; |
|---|
| 1425 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1426 | riU = iUL; |
|---|
| 1427 | riV = iVL; |
|---|
| 1428 | #endif |
|---|
| 1429 | } |
|---|
| 1430 | else |
|---|
| 1431 | { |
|---|
| 1432 | riY = xBlend( iYL, iYR, iFilledR ); |
|---|
| 1433 | #if HHI_VSO_COLOR_PLANES |
|---|
| 1434 | riU = xBlend( iUL, iUR, iFilledR ); |
|---|
| 1435 | riV = xBlend( iVL, iUR, iFilledR ); |
|---|
| 1436 | #endif |
|---|
| 1437 | } |
|---|
| 1438 | } |
|---|
| 1439 | |
|---|
| 1440 | __inline Pel |
|---|
| 1441 | TRenSingleModel::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 ) |
|---|
| 1442 | { |
|---|
| 1443 | return pVal1 + (Pel) ( ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
|---|
| 1444 | } |
|---|