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