[2] | 1 | |
---|
| 2 | |
---|
| 3 | // Include files |
---|
| 4 | #include "TComMVDRefData.h" |
---|
| 5 | #include "TComPicYuv.h" |
---|
| 6 | #include <math.h> |
---|
| 7 | #include <vector> |
---|
| 8 | #include <iostream> |
---|
| 9 | #include <fstream> |
---|
| 10 | |
---|
| 11 | Void TComMVDRefData::setPicYuvBaseView( InterViewReference eView, Bool bDepth, TComPicYuv* pcOrgView, TComPicYuv* pcRecView ) |
---|
| 12 | { |
---|
| 13 | if ( bDepth ) |
---|
| 14 | { |
---|
| 15 | m_apcDepthRec[eView] = pcRecView; |
---|
| 16 | m_apcDepthOrg[eView] = pcOrgView; |
---|
| 17 | } |
---|
| 18 | else |
---|
| 19 | { |
---|
| 20 | m_apcVideoRec[eView] = pcRecView; |
---|
| 21 | m_apcVideoOrg[eView] = pcOrgView; |
---|
| 22 | } |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | Void TComMVDRefData::setShiftLUTsBaseView( InterViewReference eView, Double** adInLut, Int** aiInLut ) |
---|
| 26 | { |
---|
| 27 | m_aiBaseViewShiftLUT[eView] = aiInLut; |
---|
| 28 | m_adBaseViewShiftLUT[eView] = adInLut; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | TComMVDRefData::TComMVDRefData() |
---|
| 32 | { |
---|
| 33 | //GT VSO |
---|
| 34 | m_adERViewShiftLUT = 0; |
---|
| 35 | m_aiERViewShiftLUT = 0; |
---|
| 36 | m_apcExternalReferenceViews.resize(0); |
---|
| 37 | //GT VSO end |
---|
| 38 | |
---|
| 39 | for (UInt uiView = 0; uiView < 3; uiView++) |
---|
| 40 | { |
---|
| 41 | m_apcVideoOrg[uiView] = NULL; |
---|
| 42 | m_apcDepthOrg[uiView] = NULL; |
---|
| 43 | m_apcVideoRec[uiView] = NULL; |
---|
| 44 | m_apcDepthRec[uiView] = NULL; |
---|
| 45 | |
---|
| 46 | //GT VSO |
---|
| 47 | m_adBaseViewShiftLUT [uiView] = NULL; |
---|
| 48 | m_aiBaseViewShiftLUT [uiView] = NULL; |
---|
| 49 | //GT VSO end |
---|
| 50 | }; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | //GT VSO |
---|
| 54 | Void TComMVDRefData::getRefPicYuvAndLUT( TComPicYuv**& rpacDistRefPicList, Int***& rppaiShiftLut ) |
---|
| 55 | { |
---|
| 56 | //GT |
---|
| 57 | |
---|
| 58 | UInt uiNextEntry = 0; |
---|
| 59 | for ( UInt uiViewIdx = 0; uiViewIdx < m_aiExtViewRefInd.size(); uiViewIdx++ ) |
---|
| 60 | { |
---|
| 61 | rppaiShiftLut[uiNextEntry] = m_aiERViewShiftLUT [ m_aiExtViewRefLUTInd[uiViewIdx] ]; |
---|
| 62 | rpacDistRefPicList[uiNextEntry] = m_apcExternalReferenceViews[ m_aiExtViewRefInd [uiViewIdx] ]; |
---|
| 63 | uiNextEntry++; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | for ( UInt uiViewIdx = 0; uiViewIdx < m_aiBaseViewRefInd.size(); uiViewIdx++ ) |
---|
| 67 | { |
---|
| 68 | rppaiShiftLut[uiNextEntry] = m_aiBaseViewShiftLUT[ m_aiBaseViewRefInd[uiViewIdx] + 1 ]; |
---|
| 69 | rpacDistRefPicList[uiNextEntry] = getPicYuvRecVideo( (InterViewReference) (m_aiBaseViewRefInd[uiViewIdx] + 1) ) ? getPicYuvRecVideo( (InterViewReference) (m_aiBaseViewRefInd[uiViewIdx] + 1) ) : getPicYuvOrgVideo( (InterViewReference) (m_aiBaseViewRefInd[uiViewIdx] + 1) ); |
---|
| 70 | uiNextEntry++; |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | Void TComMVDRefData::getRefPicYuvAndLUTMode1( TComPicYuv**& rpacDistRefPicList, Int***& rppaiShiftLut ) |
---|
| 75 | { |
---|
| 76 | rppaiShiftLut[0] = m_aiBaseViewShiftLUT[ PREVVIEW ]; |
---|
| 77 | rppaiShiftLut[1] = NULL; |
---|
| 78 | rppaiShiftLut[2] = m_aiBaseViewShiftLUT[ NEXTVIEW ]; |
---|
| 79 | |
---|
| 80 | //GT: Only orginals of this view needed for Mode 1; |
---|
| 81 | rpacDistRefPicList[0] = NULL; |
---|
| 82 | rpacDistRefPicList[1] = NULL; |
---|
| 83 | rpacDistRefPicList[2] = NULL; |
---|
| 84 | } |
---|
| 85 | //GT VSO end |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | //Void TComMVDRefData::render( TComPicYuv* pOut ) |
---|
| 91 | ////Void TComMVDRefData::render( TComPicYuv* pIn, TComPicYuv* pOut, TComPicYuv* pDepth, Long** aalLUT ) |
---|
| 92 | //{ |
---|
| 93 | // |
---|
| 94 | // std::cout << "InRender" << std::endl; |
---|
| 95 | // |
---|
| 96 | // TComPicYuv* pIn = getPicYuvOrgVideo(CURRVIEW); |
---|
| 97 | // // TComPicYuv* pOut = getRecVideo(CURRVIEW); |
---|
| 98 | // TComPicYuv* pDepth = getPicYuvOrgDepth(CURRVIEW); |
---|
| 99 | // |
---|
| 100 | // Int** aaiLUT = getShiftLUTIERView(0); |
---|
| 101 | // |
---|
| 102 | // Int iHeight = (Int) pIn->getHeight(); |
---|
| 103 | // Int iWidth = (Int) pIn->getWidth(); |
---|
| 104 | // |
---|
| 105 | // Pel* piSourceLumaData = pIn ->getLumaAddr(); |
---|
| 106 | // Pel* piTargetLumaData = pOut ->getLumaAddr(); |
---|
| 107 | // Pel* piDepthData = pDepth->getLumaAddr(); |
---|
| 108 | // |
---|
| 109 | // Int iSourceLumaStride = pIn ->getStride(); |
---|
| 110 | // Int iTargetLumaStride = pOut ->getStride(); |
---|
| 111 | // Int iDepthStride = pDepth->getStride(); |
---|
| 112 | // |
---|
| 113 | // |
---|
| 114 | // for (Int iY = 0; iY < iHeight; iY++) |
---|
| 115 | // { |
---|
| 116 | // for (Int iX = 0; iX < iWidth; iX++) |
---|
| 117 | // { |
---|
| 118 | // piTargetLumaData[iX] = 0; |
---|
| 119 | // } |
---|
| 120 | // piTargetLumaData += iTargetLumaStride; |
---|
| 121 | // } |
---|
| 122 | // |
---|
| 123 | // piTargetLumaData = pOut ->getLumaAddr(); |
---|
| 124 | // |
---|
| 125 | // Int iNewPos; |
---|
| 126 | // for (Int iY = 0; iY < iHeight; iY++) |
---|
| 127 | // { |
---|
| 128 | // for (Int iX = 0; iX < iWidth; iX++) |
---|
| 129 | // { |
---|
| 130 | // iNewPos = iX - aaiLUT[0][(piDepthData[iX] >> g_uiBitIncrement)]; |
---|
| 131 | // iNewPos = (iNewPos < 0 ) ? 0 : iNewPos; |
---|
| 132 | // iNewPos = (iNewPos >= iWidth) ? iWidth - 1 : iNewPos; |
---|
| 133 | // |
---|
| 134 | // piTargetLumaData[iNewPos] = piSourceLumaData[iX]; |
---|
| 135 | // } |
---|
| 136 | // piSourceLumaData += iSourceLumaStride; |
---|
| 137 | // piTargetLumaData += iTargetLumaStride; |
---|
| 138 | // piDepthData += iDepthStride; |
---|
| 139 | // } |
---|
| 140 | //} |
---|
| 141 | // |
---|
| 142 | // |
---|
| 143 | // |
---|
| 144 | // |
---|
| 145 | //TComRendererModel::TComRendererModel() |
---|
| 146 | //{ |
---|
| 147 | // m_pcInputSamples = NULL; |
---|
| 148 | // m_pcOutputSamples = NULL; |
---|
| 149 | // m_ppiShiftLUT = NULL; |
---|
| 150 | //} |
---|
| 151 | // |
---|
| 152 | //TComRendererModel::~TComRendererModel() |
---|
| 153 | //{ |
---|
| 154 | // if ( m_pcOutputSamples ) |
---|
| 155 | // delete[] m_pcOutputSamples; |
---|
| 156 | // |
---|
| 157 | // if ( m_pcInputSamples ) |
---|
| 158 | // delete[] m_pcInputSamples; |
---|
| 159 | // |
---|
| 160 | //} |
---|
| 161 | // |
---|
| 162 | //Void TComRendererModel::createModel( TComPicYuv* pcYuvDepth, TComPicYuv* pcYuvVideo, TComPicYuv* pcYuvRef, Int** ppiShiftLUT ) |
---|
| 163 | //{ |
---|
| 164 | // createModel(pcYuvDepth->getLumaAddr(), pcYuvDepth->getStride(), pcYuvVideo->getLumaAddr(), pcYuvVideo->getStride(), pcYuvVideo->getCbAddr(), pcYuvVideo->getCrAddr(), pcYuvVideo->getCStride(), pcYuvVideo->getWidth(), pcYuvVideo->getHeight(), ppiShiftLUT ); |
---|
| 165 | //} |
---|
| 166 | // |
---|
| 167 | //Void TComRendererModel::createModel( TComPicYuv* pcYuvDepth, TComPicYuv* pcYuvVideo, Int** ppiShiftLUT ) |
---|
| 168 | //{ |
---|
| 169 | // |
---|
| 170 | //} |
---|
| 171 | // |
---|
| 172 | //Void TComRendererModel::createModel( Pel* pcPelDisp, Int iStrideDisp, Pel* pcPelY, Int iStrideY, Pel* pcPelU, Pel* pcPelV, Int iStrideC, Int iWidth, Int iHeight, Int** ppiShiftLUT ) |
---|
| 173 | //{ |
---|
| 174 | // |
---|
| 175 | //} |
---|
| 176 | // |
---|
| 177 | //Void TComRendererModel::xCreateRenderedView( Pel* pcPelDisp, Int iDispStride, Pel* pcPelY, Int iLStride, Pel* pcPelU, Pel* pcPelV, Int iCStride, Int iWidth, Int iHeight, Int** ppiShiftLUT,Bool bSAD ) |
---|
| 178 | //{ |
---|
| 179 | // m_ppiShiftLUT = ppiShiftLUT; |
---|
| 180 | // m_iWidth = iWidth; |
---|
| 181 | // m_iHeight = iHeight; |
---|
| 182 | // m_iStride = iWidth; |
---|
| 183 | // |
---|
| 184 | // m_pcOutputSamples = new RendererOutputSample[ iWidth * iHeight]; |
---|
| 185 | // m_pcInputSamples = new RendererInputSample [ iWidth * iHeight]; |
---|
| 186 | // |
---|
| 187 | // RendererInputSample* pcInputSamples = m_pcInputSamples ; |
---|
| 188 | // RendererOutputSample* pcOutputSamples = m_pcOutputSamples ; |
---|
| 189 | // |
---|
| 190 | // for ( Int iRow = 0; iRow < iHeight; iRow++ ) |
---|
| 191 | // { |
---|
| 192 | // for ( Int iCol = 0; iCol < iWidth; iCol++ ) |
---|
| 193 | // { |
---|
| 194 | // pcInputSamples[iCol].m_uiPosX = iCol; |
---|
| 195 | // pcInputSamples[iCol].m_uiY = pcPelY[ iCol ]; |
---|
| 196 | // pcInputSamples[iCol].m_uiU = pcPelU[ iCol >> 1 ]; |
---|
| 197 | // pcInputSamples[iCol].m_uiV = pcPelV[ iCol >> 1 ]; |
---|
| 198 | // pcOutputSamples[iCol].m_iErr = 0; |
---|
| 199 | // |
---|
| 200 | // pcInputSamples[iCol].m_iPosShifted = iCol + m_ppiShiftLUT[0][ pcPelDisp[ iCol ] ]; |
---|
| 201 | // pcInputSamples[iCol].m_uiDisp = pcPelDisp[ iCol ]; |
---|
| 202 | // |
---|
| 203 | // } |
---|
| 204 | // |
---|
| 205 | // pcInputSamples += m_iStride; |
---|
| 206 | // pcOutputSamples += m_iStride; |
---|
| 207 | // pcPelY += iLStride; |
---|
| 208 | // pcPelDisp += iDispStride; |
---|
| 209 | // |
---|
| 210 | // if ( iRow & 1 ) |
---|
| 211 | // { |
---|
| 212 | // pcPelU += iCStride; |
---|
| 213 | // pcPelV += iCStride; |
---|
| 214 | // } |
---|
| 215 | // |
---|
| 216 | // } |
---|
| 217 | // |
---|
| 218 | // m_lErr = 0; |
---|
| 219 | // Long lDump; |
---|
| 220 | // changeModel(0,0,m_iWidth, m_iHeight, pcPelDisp, iDispStride, lDump, bSAD); |
---|
| 221 | //} |
---|
| 222 | // |
---|
| 223 | //Void TComRendererModel::changeModel( Int iPosX, Int iPosY, Int iWidth, Int iHeight, Pel* pcPelDisp, Int iDispStride, Long& rlErr, Bool bSAD ) |
---|
| 224 | //{ |
---|
| 225 | // RendererInputSample* pcInputSamples = m_pcInputSamples ; |
---|
| 226 | // RendererOutputSample* pcOutputSamples = m_pcOutputSamples ; |
---|
| 227 | // |
---|
| 228 | // Int iMinChangedPosition = 0; |
---|
| 229 | // Int iMaxChangedPosition = m_iWidth - 1; |
---|
| 230 | // |
---|
| 231 | // rlErr = 0; |
---|
| 232 | // |
---|
| 233 | // for ( Int iRow = iPosX; iRow < iHeight; iRow++ ) |
---|
| 234 | // { |
---|
| 235 | // // Add and Remove samples (Update Model) |
---|
| 236 | // for ( Int iCol = iPosY; iCol < iWidth; iCol++ ) |
---|
| 237 | // { |
---|
| 238 | // // Remove from old position |
---|
| 239 | // Int iOldPosShifted = pcInputSamples[iCol].m_iPosShifted; |
---|
| 240 | // |
---|
| 241 | // iMinChangedPosition = Min( iOldPosShifted, iMinChangedPosition ); |
---|
| 242 | // iMaxChangedPosition = Max( iOldPosShifted, iMaxChangedPosition ); |
---|
| 243 | // |
---|
| 244 | // pcOutputSamples[ iOldPosShifted ].removeInputSample( &(pcInputSamples[iCol]) ); |
---|
| 245 | // |
---|
| 246 | // // Add to new position |
---|
| 247 | // Int iShift = m_ppiShiftLUT[0][ pcPelDisp[ iCol ] ]; |
---|
| 248 | // |
---|
| 249 | // Int iPosShifted = iPosX + iShift; |
---|
| 250 | // |
---|
| 251 | // iPosShifted = Min(Max(iPosShifted, 0), m_iWidth - 1); |
---|
| 252 | // iMinChangedPosition = Min(iPosShifted, iMinChangedPosition); |
---|
| 253 | // iMaxChangedPosition = Max(iPosShifted, iMaxChangedPosition); |
---|
| 254 | // |
---|
| 255 | // pcInputSamples[iCol].m_uiDisp = pcPelDisp[ iCol ]; |
---|
| 256 | // pcInputSamples[iCol].m_iPosShifted = iPosShifted; |
---|
| 257 | // |
---|
| 258 | // pcOutputSamples[ iPosShifted ].addInputSample( &(pcInputSamples[iCol]) ); |
---|
| 259 | // } |
---|
| 260 | // |
---|
| 261 | // // ReRender |
---|
| 262 | // |
---|
| 263 | // // Get Top Plane |
---|
| 264 | // Int iMaxInd = -1; |
---|
| 265 | // |
---|
| 266 | // if ( pcOutputSamples[iMinChangedPosition].m_pcTopSample ) |
---|
| 267 | // { |
---|
| 268 | // iMaxInd = pcOutputSamples[iMinChangedPosition].m_pcTopSample->m_uiPosX; |
---|
| 269 | // } |
---|
| 270 | // |
---|
| 271 | // if ( iMinChangedPosition > 0 && pcOutputSamples[iMinChangedPosition].m_pcTopSample ) |
---|
| 272 | // { |
---|
| 273 | // iMaxInd = Max( iMaxInd, pcOutputSamples[iMinChangedPosition-1].m_pcTopSample->m_uiPosX ); |
---|
| 274 | // } |
---|
| 275 | // |
---|
| 276 | // for ( Int iCol = iMinChangedPosition; iCol <= iMaxChangedPosition; iCol++ ) |
---|
| 277 | // { |
---|
| 278 | // if ( pcOutputSamples[iCol].m_pcTopSample == NULL ) |
---|
| 279 | // { |
---|
| 280 | // if ( pcOutputSamples[iCol+1].m_pcTopSample == NULL ) |
---|
| 281 | // { |
---|
| 282 | // // Hole Filling |
---|
| 283 | // Int iFillStartCol = iCol; |
---|
| 284 | // iCol++; |
---|
| 285 | // |
---|
| 286 | // while( ( pcOutputSamples[iCol].m_pcTopSample == NULL ) && (iMinChangedPosition < iMaxChangedPosition) ) iCol++; |
---|
| 287 | // |
---|
| 288 | // for ( int iFillCol = iFillStartCol; iFillCol < iCol; iFillCol++ ) |
---|
| 289 | // { |
---|
| 290 | // pcOutputSamples[iFillCol].assignValues( pcOutputSamples[iCol], rlErr, bSAD ); |
---|
| 291 | // } |
---|
| 292 | // |
---|
| 293 | // if ( iMaxInd == -1 ) |
---|
| 294 | // { |
---|
| 295 | // iMaxInd = pcOutputSamples[iCol].m_pcTopSample->m_uiPosX; |
---|
| 296 | // } |
---|
| 297 | // } |
---|
| 298 | // else |
---|
| 299 | // { |
---|
| 300 | // // Fill Gap here |
---|
| 301 | // pcOutputSamples[iCol].assignValues( pcOutputSamples[iCol-1], rlErr, bSAD ); |
---|
| 302 | // |
---|
| 303 | // }; |
---|
| 304 | // } |
---|
| 305 | // else |
---|
| 306 | // { |
---|
| 307 | // if ( pcOutputSamples[iCol].m_pcTopSample->m_uiPosX > iMaxInd) |
---|
| 308 | // { |
---|
| 309 | // iMaxInd = pcOutputSamples[iCol].m_pcTopSample->m_uiPosX; |
---|
| 310 | // |
---|
| 311 | // //assign this Sample |
---|
| 312 | // pcOutputSamples[iCol].assignValues( pcOutputSamples[iCol], rlErr, bSAD ); |
---|
| 313 | // } |
---|
| 314 | // else |
---|
| 315 | // { |
---|
| 316 | // //assign last sample |
---|
| 317 | // pcOutputSamples[iCol].assignValues( pcOutputSamples[iCol-1], rlErr, bSAD ); |
---|
| 318 | // } |
---|
| 319 | // } |
---|
| 320 | // } |
---|
| 321 | // |
---|
| 322 | // pcInputSamples += m_iStride; |
---|
| 323 | // pcPelDisp += iDispStride; |
---|
| 324 | // |
---|
| 325 | // } |
---|
| 326 | //} |
---|
| 327 | // |
---|
| 328 | //Void RendererOutputSample::assignValues( RendererOutputSample& rpcOutputSample, Long& rlErr, Bool bSAD ) |
---|
| 329 | //{ |
---|
| 330 | // m_uiY = rpcOutputSample.m_uiYRef; |
---|
| 331 | // m_uiU = rpcOutputSample.m_uiURef; |
---|
| 332 | // m_uiV = rpcOutputSample.m_uiVRef; |
---|
| 333 | // |
---|
| 334 | // rlErr -= m_iErr; |
---|
| 335 | // |
---|
| 336 | // int iErr = m_uiY - m_uiYRef; |
---|
| 337 | // |
---|
| 338 | // if (bSAD) |
---|
| 339 | // { |
---|
| 340 | // rlErr += abs(iErr); |
---|
| 341 | // } |
---|
| 342 | // else |
---|
| 343 | // { |
---|
| 344 | // rlErr += iErr * iErr; |
---|
| 345 | // } |
---|
| 346 | //} |
---|
| 347 | // |
---|
| 348 | //Void RendererOutputSample::addInputSample( RendererInputSample* pcInputSample ) |
---|
| 349 | //{ |
---|
| 350 | // if ( m_acInputSamples.size() == 0 ) |
---|
| 351 | // { |
---|
| 352 | // m_acInputSamples.push_back( pcInputSample ); |
---|
| 353 | // m_pcTopSample = pcInputSample; |
---|
| 354 | // pcInputSample->cIter = m_acInputSamples.begin(); |
---|
| 355 | // } |
---|
| 356 | // else |
---|
| 357 | // { |
---|
| 358 | // std::vector <RendererInputSample*>::iterator cIter; |
---|
| 359 | // |
---|
| 360 | // for ( cIter = m_acInputSamples.begin( ) ; cIter != m_acInputSamples.end( ) ; cIter++ ) |
---|
| 361 | // { |
---|
| 362 | // if ( (*cIter)->m_uiPosX <= pcInputSample->m_uiPosX ) break; |
---|
| 363 | // } |
---|
| 364 | // |
---|
| 365 | // m_acInputSamples.insert( cIter, 1, pcInputSample ); |
---|
| 366 | // |
---|
| 367 | // pcInputSample->cIter = cIter; |
---|
| 368 | // |
---|
| 369 | // if ( cIter == m_acInputSamples.begin() ) |
---|
| 370 | // { |
---|
| 371 | // m_pcTopSample = pcInputSample; |
---|
| 372 | // } |
---|
| 373 | // } |
---|
| 374 | //} |
---|
| 375 | // |
---|
| 376 | //RendererOutputSample::RendererOutputSample() |
---|
| 377 | //{ |
---|
| 378 | // m_pcTopSample = 0; |
---|
| 379 | //} |
---|
| 380 | // |
---|
| 381 | //Void RendererOutputSample::removeInputSample( RendererInputSample* pcInputSample ) |
---|
| 382 | //{ |
---|
| 383 | // m_acInputSamples.erase( pcInputSample->cIter ); |
---|
| 384 | //} |
---|
| 385 | // |
---|