[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 | |
---|
| 34 | |
---|
| 35 | |
---|
[5] | 36 | |
---|
[2] | 37 | // Include files |
---|
| 38 | #include "CommonDef.h" |
---|
| 39 | #include "TComYuv.h" |
---|
| 40 | #include "TComWedgelet.h" |
---|
| 41 | |
---|
| 42 | #include <stdlib.h> |
---|
| 43 | #include <memory.h> |
---|
| 44 | |
---|
[56] | 45 | using namespace std; |
---|
[2] | 46 | |
---|
[56] | 47 | |
---|
[2] | 48 | TComWedgelet::TComWedgelet( UInt uiWidth, UInt uiHeight ) : m_uhXs ( 0 ), |
---|
| 49 | m_uhYs ( 0 ), |
---|
| 50 | m_uhXe ( 0 ), |
---|
| 51 | m_uhYe ( 0 ), |
---|
| 52 | m_uhOri ( 0 ), |
---|
| 53 | m_eWedgeRes( FULL_PEL ) |
---|
[296] | 54 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 55 | , m_bIsCoarse( false ) |
---|
| 56 | #endif |
---|
[2] | 57 | { |
---|
| 58 | create( uiWidth, uiHeight ); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | TComWedgelet::TComWedgelet( const TComWedgelet &rcWedge ) : m_uhXs ( rcWedge.m_uhXs ), |
---|
| 62 | m_uhYs ( rcWedge.m_uhYs ), |
---|
| 63 | m_uhXe ( rcWedge.m_uhXe ), |
---|
| 64 | m_uhYe ( rcWedge.m_uhYe ), |
---|
| 65 | m_uhOri ( rcWedge.m_uhOri ), |
---|
| 66 | m_eWedgeRes( rcWedge.m_eWedgeRes ), |
---|
[296] | 67 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 68 | m_bIsCoarse( rcWedge.m_bIsCoarse ), |
---|
| 69 | m_uiAng ( rcWedge.m_uiAng ), |
---|
| 70 | #endif |
---|
[2] | 71 | m_uiWidth ( rcWedge.m_uiWidth ), |
---|
| 72 | m_uiHeight ( rcWedge.m_uiHeight ), |
---|
| 73 | m_pbPattern( (Bool*)xMalloc( Bool, (m_uiWidth * m_uiHeight) ) ) |
---|
| 74 | { |
---|
| 75 | ::memcpy( m_pbPattern, rcWedge.m_pbPattern, sizeof(Bool) * (m_uiWidth * m_uiHeight)); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | TComWedgelet::~TComWedgelet(void) |
---|
| 79 | { |
---|
| 80 | destroy(); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | Void TComWedgelet::create( UInt uiWidth, UInt uiHeight ) |
---|
| 84 | { |
---|
| 85 | assert( uiWidth > 0 && uiHeight > 0 ); |
---|
| 86 | |
---|
| 87 | m_uiWidth = uiWidth; |
---|
| 88 | m_uiHeight = uiHeight; |
---|
| 89 | |
---|
| 90 | m_pbPattern = (Bool*)xMalloc( Bool, (m_uiWidth * m_uiHeight) ); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | Void TComWedgelet::destroy() |
---|
| 94 | { |
---|
| 95 | if( m_pbPattern ) { xFree( m_pbPattern ); m_pbPattern = NULL; } |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | Void TComWedgelet::clear() |
---|
| 99 | { |
---|
| 100 | ::memset( m_pbPattern, 0, (m_uiWidth * m_uiHeight) * sizeof(Bool) ); |
---|
| 101 | } |
---|
| 102 | |
---|
[296] | 103 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 104 | Void TComWedgelet::findClosetAngle() |
---|
| 105 | { |
---|
| 106 | UInt uiAng=0,uiOptAng=0; |
---|
| 107 | UInt uiMinD=MAX_UINT; |
---|
| 108 | UInt uiTmpD=0; |
---|
| 109 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
| 110 | |
---|
| 111 | UChar uhXs = m_uhXs; |
---|
| 112 | UChar uhYs = m_uhYs; |
---|
| 113 | UChar uhXe = m_uhXe; |
---|
| 114 | UChar uhYe = m_uhYe; |
---|
| 115 | |
---|
| 116 | for(uiAng=2; uiAng<=34; uiAng++) |
---|
| 117 | { |
---|
| 118 | Int iSign = (uiAng<VER_IDX && uiAng>HOR_IDX ) ? -1 : 1; |
---|
| 119 | Int iVer = uiAng>17 ? 32 : angTable[(uiAng>10) ? (uiAng-10) : (10-uiAng)]; |
---|
| 120 | Int iHor = uiAng<19 ? 32 : angTable[(uiAng>26) ? (uiAng-26) : (26-uiAng)]; |
---|
| 121 | |
---|
| 122 | uiTmpD = abs(iVer*iSign*(uhXs-uhXe) - iHor*(uhYe-uhYs)); |
---|
| 123 | |
---|
| 124 | if( uiTmpD < uiMinD ) |
---|
| 125 | { |
---|
| 126 | uiMinD = uiTmpD; |
---|
| 127 | uiOptAng = uiAng; |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | m_uiAng = uiOptAng; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | Void TComWedgelet::setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse ) |
---|
| 134 | #else |
---|
[2] | 135 | Void TComWedgelet::setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes ) |
---|
[189] | 136 | #endif |
---|
[2] | 137 | { |
---|
| 138 | m_uhXs = uhXs; |
---|
| 139 | m_uhYs = uhYs; |
---|
| 140 | m_uhXe = uhXe; |
---|
| 141 | m_uhYe = uhYe; |
---|
| 142 | m_uhOri = uhOri; |
---|
| 143 | m_eWedgeRes = eWedgeRes; |
---|
[296] | 144 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 145 | m_bIsCoarse = bIsCoarse; |
---|
| 146 | #endif |
---|
[2] | 147 | |
---|
| 148 | xGenerateWedgePattern(); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | Bool TComWedgelet::checkNotPlain() |
---|
| 152 | { |
---|
| 153 | for( UInt k = 1; k < (m_uiWidth * m_uiHeight); k++ ) |
---|
| 154 | { |
---|
| 155 | if( m_pbPattern[0] != m_pbPattern[k] ) |
---|
| 156 | { |
---|
| 157 | return true; |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | return false; |
---|
| 161 | } |
---|
| 162 | |
---|
[56] | 163 | Bool TComWedgelet::checkIdentical( Bool* pbRefPattern ) |
---|
[2] | 164 | { |
---|
| 165 | for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ ) |
---|
| 166 | { |
---|
| 167 | if( m_pbPattern[k] != pbRefPattern[k] ) |
---|
| 168 | { |
---|
[56] | 169 | return false; |
---|
[2] | 170 | } |
---|
| 171 | } |
---|
[56] | 172 | return true; |
---|
[2] | 173 | } |
---|
| 174 | |
---|
[56] | 175 | Bool TComWedgelet::checkInvIdentical( Bool* pbRefPattern ) |
---|
[2] | 176 | { |
---|
| 177 | for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ ) |
---|
| 178 | { |
---|
| 179 | if( m_pbPattern[k] == pbRefPattern[k] ) |
---|
| 180 | { |
---|
[56] | 181 | return false; |
---|
[2] | 182 | } |
---|
| 183 | } |
---|
[56] | 184 | return true; |
---|
[2] | 185 | } |
---|
| 186 | |
---|
[5] | 187 | #if HHI_DMM_WEDGE_INTRA |
---|
[2] | 188 | Bool TComWedgelet::checkPredDirAbovePossible( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset ) |
---|
| 189 | { |
---|
| 190 | WedgeResolution eContDWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiPredDirBlockSize]]; |
---|
| 191 | UInt uiContDStartEndMax = 0; |
---|
| 192 | UInt uiContDStartEndOffset = 0; |
---|
| 193 | switch( eContDWedgeRes ) |
---|
| 194 | { |
---|
| 195 | case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; } |
---|
| 196 | case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; } |
---|
| 197 | case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; } |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | if( m_uhOri == 2 || m_uhOri == 3 || m_uhOri == 4 ) |
---|
| 201 | { |
---|
| 202 | UInt uiThisStartEndMax = 0; |
---|
| 203 | switch( m_eWedgeRes ) |
---|
| 204 | { |
---|
| 205 | case( DOUBLE_PEL ): { uiThisStartEndMax = (m_uiWidth>>1); break; } |
---|
| 206 | case( FULL_PEL ): { uiThisStartEndMax = m_uiWidth; break; } |
---|
| 207 | case( HALF_PEL ): { uiThisStartEndMax = (m_uiWidth<<1); break; } |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | UChar uhStartX = m_uhXs; |
---|
| 211 | UChar uhStartY = m_uhYs; |
---|
| 212 | UChar uhEndX = m_uhXe; |
---|
| 213 | UChar uhEndY = m_uhYe; |
---|
| 214 | |
---|
| 215 | if( 2 == m_uhOri ) |
---|
| 216 | { |
---|
| 217 | std::swap( uhStartX, uhEndX ); |
---|
| 218 | std::swap( uhStartY, uhEndY ); |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | UInt uiScaledEndX = (UInt)uhEndX; |
---|
| 222 | Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes; |
---|
| 223 | if( iDeltaRes > 0 ) { uiScaledEndX <<= iDeltaRes; } |
---|
| 224 | if( iDeltaRes < 0 ) { uiScaledEndX >>= -iDeltaRes; } |
---|
| 225 | |
---|
| 226 | if( ((UInt)uhEndY == (uiThisStartEndMax-1)) && ((uiScaledEndX-uiContDStartEndOffset) > 0 && (uiScaledEndX-uiContDStartEndOffset) < (uiContDStartEndMax-1)) ) |
---|
| 227 | { |
---|
| 228 | return true; |
---|
| 229 | } |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | return false; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | Bool TComWedgelet::checkPredDirLeftPossible( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset ) |
---|
| 236 | { |
---|
| 237 | WedgeResolution eContDWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiPredDirBlockSize]]; |
---|
| 238 | UInt uiContDStartEndMax = 0; |
---|
| 239 | UInt uiContDStartEndOffset = 0; |
---|
| 240 | switch( eContDWedgeRes ) |
---|
| 241 | { |
---|
| 242 | case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; } |
---|
| 243 | case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; } |
---|
| 244 | case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; } |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | if( m_uhOri == 1 || m_uhOri == 2 || m_uhOri == 5 ) |
---|
| 248 | { |
---|
| 249 | UInt uiThisStartEndMax = 0; |
---|
| 250 | switch( m_eWedgeRes ) |
---|
| 251 | { |
---|
| 252 | case( DOUBLE_PEL ): { uiThisStartEndMax = (m_uiHeight>>1); break; } |
---|
| 253 | case( FULL_PEL ): { uiThisStartEndMax = m_uiHeight; break; } |
---|
| 254 | case( HALF_PEL ): { uiThisStartEndMax = (m_uiHeight<<1); break; } |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | UChar uhStartX = m_uhXs; |
---|
| 258 | UChar uhStartY = m_uhYs; |
---|
| 259 | UChar uhEndX = m_uhXe; |
---|
| 260 | UChar uhEndY = m_uhYe; |
---|
| 261 | |
---|
| 262 | if( 1 == m_uhOri || 5 == m_uhOri ) |
---|
| 263 | { |
---|
| 264 | std::swap( uhStartX, uhEndX ); |
---|
| 265 | std::swap( uhStartY, uhEndY ); |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | UInt uiScaledEndY = (UInt)uhEndY; |
---|
| 269 | Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes; |
---|
| 270 | if( iDeltaRes > 0 ) { uiScaledEndY <<= iDeltaRes; } |
---|
| 271 | if( iDeltaRes < 0 ) { uiScaledEndY >>= -iDeltaRes; } |
---|
| 272 | |
---|
| 273 | if( ((UInt)uhEndX == (uiThisStartEndMax-1)) && ((uiScaledEndY-uiContDStartEndOffset) > 0 && (uiScaledEndY-uiContDStartEndOffset) < (uiContDStartEndMax-1)) ) |
---|
| 274 | { |
---|
| 275 | return true; |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | return false; |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | Void TComWedgelet::getPredDirStartEndAbove( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd ) |
---|
| 283 | { |
---|
| 284 | ruhXs = 0; |
---|
| 285 | ruhYs = 0; |
---|
| 286 | ruhXe = 0; |
---|
| 287 | ruhYe = 0; |
---|
| 288 | |
---|
| 289 | // get start/end of reference (=this) wedgelet |
---|
| 290 | UInt uiRefStartX = (UInt)getStartX(); |
---|
| 291 | UInt uiRefStartY = (UInt)getStartY(); |
---|
| 292 | UInt uiRefEndX = (UInt)getEndX(); |
---|
| 293 | UInt uiRefEndY = (UInt)getEndY(); |
---|
| 294 | |
---|
| 295 | WedgeResolution eContDWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiPredDirBlockSize]]; |
---|
| 296 | UInt uiContDStartEndMax = 0; |
---|
| 297 | UInt uiContDStartEndOffset = 0; |
---|
| 298 | switch( eContDWedgeRes ) |
---|
| 299 | { |
---|
| 300 | case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; } |
---|
| 301 | case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; } |
---|
| 302 | case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; } |
---|
| 303 | } |
---|
[56] | 304 | Int iContDMaxPos = (Int)uiContDStartEndMax - 1; |
---|
[2] | 305 | |
---|
| 306 | // swap if start/end if line orientation is not from top to bottom |
---|
| 307 | if( 2 == (UInt)getOri() ) |
---|
| 308 | { |
---|
| 309 | std::swap( uiRefStartX, uiRefEndX ); |
---|
| 310 | std::swap( uiRefStartY, uiRefEndY ); |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | // calc slopes |
---|
| 314 | Int iA_DeltaX = (Int)uiRefEndX - (Int)uiRefStartX; |
---|
| 315 | Int iA_DeltaY = (Int)uiRefEndY - (Int)uiRefStartY; |
---|
| 316 | |
---|
| 317 | // get aligned end x value of ref wedge |
---|
| 318 | UInt uiScaledRefEndX = uiRefEndX; |
---|
| 319 | Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes; |
---|
| 320 | if( iDeltaRes > 0 ) { uiScaledRefEndX <<= iDeltaRes; } |
---|
| 321 | if( iDeltaRes < 0 ) { uiScaledRefEndX >>= -iDeltaRes; } |
---|
| 322 | |
---|
| 323 | assert( uiScaledRefEndX >= uiContDStartEndOffset ); |
---|
| 324 | Int iAlignedRefEndX = (Int)uiScaledRefEndX - (Int)uiContDStartEndOffset; |
---|
| 325 | |
---|
| 326 | // special for straight vertical wedge |
---|
| 327 | if( iA_DeltaX == 0 ) |
---|
| 328 | { |
---|
| 329 | ruhXs = (UChar)iAlignedRefEndX; |
---|
| 330 | ruhYs = 0; |
---|
| 331 | |
---|
| 332 | Int iXe = iAlignedRefEndX + iDeltaEnd; |
---|
| 333 | if( iXe < 0 ) |
---|
| 334 | { |
---|
| 335 | ruhXe = 0; |
---|
[56] | 336 | ruhYe = (UChar)min( max( (iContDMaxPos + iXe), 0 ), iContDMaxPos ); |
---|
[2] | 337 | |
---|
| 338 | return; |
---|
| 339 | } |
---|
[56] | 340 | else if( iXe > iContDMaxPos ) |
---|
[2] | 341 | { |
---|
[56] | 342 | ruhXe = (UChar)iContDMaxPos; |
---|
| 343 | ruhYe = (UChar)min( max( (iContDMaxPos - (iXe - iContDMaxPos)), 0 ), iContDMaxPos ); |
---|
[2] | 344 | |
---|
| 345 | std::swap( ruhXs, ruhXe ); |
---|
| 346 | std::swap( ruhYs, ruhYe ); |
---|
| 347 | return; |
---|
| 348 | } |
---|
| 349 | else |
---|
| 350 | { |
---|
| 351 | ruhXe = (UChar)iXe; |
---|
[56] | 352 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 353 | |
---|
| 354 | return; |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | // special for straight horizontal short bottom line |
---|
| 359 | if( iA_DeltaY == 0 ) |
---|
| 360 | { |
---|
| 361 | switch( (UInt)getOri() ) |
---|
| 362 | { |
---|
| 363 | case( 2 ): |
---|
| 364 | { |
---|
| 365 | ruhXs = (UChar)(iAlignedRefEndX-1); |
---|
| 366 | ruhYs = 0; |
---|
| 367 | ruhXe = 0; |
---|
[56] | 368 | ruhYe = (UChar)min( max( iDeltaEnd, 0 ), iContDMaxPos ); |
---|
[2] | 369 | |
---|
| 370 | return; |
---|
| 371 | } |
---|
| 372 | case( 3 ): |
---|
| 373 | { |
---|
| 374 | ruhXs = (UChar)(iAlignedRefEndX+1); |
---|
| 375 | ruhYs = 0; |
---|
[56] | 376 | ruhXe = (UChar)iContDMaxPos; |
---|
| 377 | ruhYe = (UChar)min( max( -iDeltaEnd, 0 ), iContDMaxPos ); |
---|
[2] | 378 | |
---|
| 379 | std::swap( ruhXs, ruhXe ); |
---|
| 380 | std::swap( ruhYs, ruhYe ); |
---|
| 381 | return; |
---|
| 382 | } |
---|
| 383 | default: |
---|
| 384 | { |
---|
| 385 | assert( 0 ); |
---|
| 386 | return; |
---|
| 387 | } |
---|
| 388 | } |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | // set start point depending on slope |
---|
| 392 | if( abs( iA_DeltaX ) >= abs( iA_DeltaY ) ) { if( iA_DeltaX < 0 ) { ruhXs = (UChar)(iAlignedRefEndX-1); ruhYs = 0; } |
---|
| 393 | if( iA_DeltaX > 0 ) { ruhXs = (UChar)(iAlignedRefEndX+1); ruhYs = 0; } } |
---|
| 394 | else { ruhXs = (UChar)(iAlignedRefEndX); ruhYs = 0; } |
---|
| 395 | |
---|
| 396 | // calc end point and determine orientation |
---|
[56] | 397 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iContDMaxPos * ((Double)iA_DeltaX / (Double)iA_DeltaY) ); |
---|
[2] | 398 | |
---|
| 399 | if( iVirtualEndX < 0 ) |
---|
| 400 | { |
---|
| 401 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iA_DeltaY / (Double)iA_DeltaX) ) + iDeltaEnd; |
---|
| 402 | if( iYe < (Int)uiContDStartEndMax ) |
---|
| 403 | { |
---|
| 404 | ruhXe = 0; |
---|
[56] | 405 | ruhYe = (UChar)max( iYe, 0 ); |
---|
[2] | 406 | |
---|
| 407 | return; |
---|
| 408 | } |
---|
| 409 | else |
---|
| 410 | { |
---|
[56] | 411 | ruhXe = (UChar)min( (iYe - iContDMaxPos), iContDMaxPos ); |
---|
| 412 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 413 | |
---|
| 414 | return; |
---|
| 415 | } |
---|
| 416 | } |
---|
[56] | 417 | else if( iVirtualEndX > iContDMaxPos ) |
---|
[2] | 418 | { |
---|
[56] | 419 | Int iYe = roftoi( (Double)(iContDMaxPos - (Int)ruhXs) * ((Double)iA_DeltaY / (Double)iA_DeltaX) ) - iDeltaEnd; |
---|
[2] | 420 | if( iYe < (Int)uiContDStartEndMax ) |
---|
| 421 | { |
---|
[56] | 422 | ruhXe = (UChar)iContDMaxPos; |
---|
| 423 | ruhYe = (UChar)max( iYe, 0 ); |
---|
[2] | 424 | |
---|
| 425 | std::swap( ruhXs, ruhXe ); |
---|
| 426 | std::swap( ruhYs, ruhYe ); |
---|
| 427 | return; |
---|
| 428 | } |
---|
| 429 | else |
---|
| 430 | { |
---|
[56] | 431 | ruhXe = (UChar)max( (iContDMaxPos - (iYe - iContDMaxPos)), 0 ); |
---|
| 432 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 433 | |
---|
| 434 | return; |
---|
| 435 | } |
---|
| 436 | } |
---|
| 437 | else |
---|
| 438 | { |
---|
| 439 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 440 | if( iXe < 0 ) |
---|
| 441 | { |
---|
| 442 | ruhXe = 0; |
---|
[56] | 443 | ruhYe = (UChar)max( (iContDMaxPos + iXe), 0 ); |
---|
[2] | 444 | |
---|
| 445 | return; |
---|
| 446 | } |
---|
[56] | 447 | else if( iXe > iContDMaxPos ) |
---|
[2] | 448 | { |
---|
[56] | 449 | ruhXe = (UChar)iContDMaxPos; |
---|
| 450 | ruhYe = (UChar)max( (iContDMaxPos - (iXe - iContDMaxPos)), 0 ); |
---|
[2] | 451 | |
---|
| 452 | std::swap( ruhXs, ruhXe ); |
---|
| 453 | std::swap( ruhYs, ruhYe ); |
---|
| 454 | return; |
---|
| 455 | } |
---|
| 456 | else |
---|
| 457 | { |
---|
| 458 | ruhXe = (UChar)iXe; |
---|
[56] | 459 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 460 | |
---|
| 461 | return; |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | Void TComWedgelet::getPredDirStartEndLeft( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd ) |
---|
| 467 | { |
---|
| 468 | ruhXs = 0; |
---|
| 469 | ruhYs = 0; |
---|
| 470 | ruhXe = 0; |
---|
| 471 | ruhYe = 0; |
---|
| 472 | |
---|
| 473 | // get start/end of reference (=this) wedgelet |
---|
| 474 | UInt uiRefStartX = (UInt)getStartX(); |
---|
| 475 | UInt uiRefStartY = (UInt)getStartY(); |
---|
| 476 | UInt uiRefEndX = (UInt)getEndX(); |
---|
| 477 | UInt uiRefEndY = (UInt)getEndY(); |
---|
| 478 | |
---|
| 479 | WedgeResolution eContDWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiPredDirBlockSize]]; |
---|
| 480 | UInt uiContDStartEndMax = 0; |
---|
| 481 | UInt uiContDStartEndOffset = 0; |
---|
| 482 | switch( eContDWedgeRes ) |
---|
| 483 | { |
---|
| 484 | case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; } |
---|
| 485 | case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; } |
---|
| 486 | case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; } |
---|
| 487 | } |
---|
[56] | 488 | Int iContDMaxPos = (Int)uiContDStartEndMax - 1; |
---|
[2] | 489 | |
---|
| 490 | // swap if start/end if line orientation is not from left to right |
---|
| 491 | if( 1 == (UInt)getOri() || 5 == (UInt)getOri() ) |
---|
| 492 | { |
---|
| 493 | std::swap( uiRefStartX, uiRefEndX ); |
---|
| 494 | std::swap( uiRefStartY, uiRefEndY ); |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | Int iL_DeltaX = (Int)uiRefEndX - (Int)uiRefStartX; |
---|
| 498 | Int iL_DeltaY = (Int)uiRefEndY - (Int)uiRefStartY; |
---|
| 499 | |
---|
| 500 | UInt uiScaledRefEndY = uiRefEndY; |
---|
| 501 | Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes; |
---|
| 502 | if( iDeltaRes > 0 ) { uiScaledRefEndY <<= iDeltaRes; } |
---|
| 503 | if( iDeltaRes < 0 ) { uiScaledRefEndY >>= -iDeltaRes; } |
---|
| 504 | |
---|
| 505 | assert( uiScaledRefEndY >= uiContDStartEndOffset ); |
---|
| 506 | Int iAlignedRefEndY = (Int)uiScaledRefEndY - (Int)uiContDStartEndOffset; |
---|
| 507 | |
---|
| 508 | // special for straight horizontal wedge |
---|
| 509 | if( iL_DeltaY == 0 ) |
---|
| 510 | { |
---|
| 511 | ruhXs = 0; |
---|
| 512 | ruhYs = (UChar)iAlignedRefEndY; |
---|
| 513 | |
---|
| 514 | Int iYe = iAlignedRefEndY - iDeltaEnd; |
---|
| 515 | if( iYe < 0 ) |
---|
| 516 | { |
---|
[56] | 517 | ruhXe = (UChar)min( max( (iContDMaxPos + iYe), 0 ), iContDMaxPos ); |
---|
[2] | 518 | ruhYe = 0; |
---|
| 519 | |
---|
| 520 | std::swap( ruhXs, ruhXe ); |
---|
| 521 | std::swap( ruhYs, ruhYe ); |
---|
| 522 | return; |
---|
| 523 | } |
---|
[56] | 524 | else if( iYe > iContDMaxPos ) |
---|
[2] | 525 | { |
---|
[56] | 526 | ruhXe = (UChar)min( max( (iContDMaxPos - (iYe - iContDMaxPos)), 0 ), iContDMaxPos ); |
---|
| 527 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 528 | |
---|
| 529 | return; |
---|
| 530 | } |
---|
| 531 | else |
---|
| 532 | { |
---|
[56] | 533 | ruhXe = (UChar)iContDMaxPos; |
---|
[2] | 534 | ruhYe = (UChar)iYe; |
---|
| 535 | |
---|
| 536 | std::swap( ruhXs, ruhXe ); |
---|
| 537 | std::swap( ruhYs, ruhYe ); |
---|
| 538 | return; |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | // special for straight vertical short right line |
---|
| 543 | if( iL_DeltaX == 0 ) |
---|
| 544 | { |
---|
| 545 | switch( (UInt)getOri() ) |
---|
| 546 | { |
---|
| 547 | case( 1 ): |
---|
| 548 | { |
---|
| 549 | ruhXs = 0; |
---|
| 550 | ruhYs = (UChar)(iAlignedRefEndY+1); |
---|
[56] | 551 | ruhXe = (UChar)min( max( iDeltaEnd, 0 ), iContDMaxPos ); |
---|
| 552 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 553 | |
---|
| 554 | return; |
---|
| 555 | } |
---|
| 556 | case( 2 ): |
---|
| 557 | { |
---|
| 558 | ruhXs = 0; |
---|
| 559 | ruhYs = (UChar)(iAlignedRefEndY-1); |
---|
[56] | 560 | ruhXe = (UChar)min( max( -iDeltaEnd, 0 ), iContDMaxPos ); |
---|
[2] | 561 | ruhYe = 0; |
---|
| 562 | |
---|
| 563 | std::swap( ruhXs, ruhXe ); |
---|
| 564 | std::swap( ruhYs, ruhYe ); |
---|
| 565 | return; |
---|
| 566 | } |
---|
| 567 | default: |
---|
| 568 | { |
---|
| 569 | assert( 0 ); |
---|
| 570 | return; |
---|
| 571 | } |
---|
| 572 | } |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | // set start point depending on slope |
---|
| 576 | if( abs( iL_DeltaY ) >= abs( iL_DeltaX ) ) { if( iL_DeltaY < 0 ) { ruhYs = (UChar)(iAlignedRefEndY-1); ruhXs = 0; } |
---|
| 577 | if( iL_DeltaY > 0 ) { ruhYs = (UChar)(iAlignedRefEndY+1); ruhXs = 0; } } |
---|
| 578 | else { ruhYs = (UChar)(iAlignedRefEndY); ruhXs = 0; } |
---|
| 579 | |
---|
| 580 | // calc end point and determine orientation |
---|
[56] | 581 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iContDMaxPos * ((Double)iL_DeltaY / (Double)iL_DeltaX) ); |
---|
[2] | 582 | |
---|
| 583 | if( iVirtualEndY < 0 ) |
---|
| 584 | { |
---|
| 585 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iL_DeltaX / (Double)iL_DeltaY) ) - iDeltaEnd; |
---|
| 586 | if( iXe < (Int)uiContDStartEndMax ) |
---|
| 587 | { |
---|
[56] | 588 | ruhXe = (UChar)max( iXe, 0 ); |
---|
[2] | 589 | ruhYe = 0; |
---|
| 590 | |
---|
| 591 | std::swap( ruhXs, ruhXe ); |
---|
| 592 | std::swap( ruhYs, ruhYe ); |
---|
| 593 | return; |
---|
| 594 | } |
---|
| 595 | else |
---|
| 596 | { |
---|
[56] | 597 | ruhXe = (UChar)iContDMaxPos; |
---|
| 598 | ruhYe = (UChar)min( (iXe - iContDMaxPos), iContDMaxPos ); |
---|
[2] | 599 | |
---|
| 600 | std::swap( ruhXs, ruhXe ); |
---|
| 601 | std::swap( ruhYs, ruhYe ); |
---|
| 602 | return; |
---|
| 603 | } |
---|
| 604 | } |
---|
[56] | 605 | else if( iVirtualEndY > iContDMaxPos ) |
---|
[2] | 606 | { |
---|
[56] | 607 | Int iXe = roftoi( (Double)(iContDMaxPos - (Int)ruhYs ) * ((Double)iL_DeltaX / (Double)iL_DeltaY) ) + iDeltaEnd; |
---|
[2] | 608 | if( iXe < (Int)uiContDStartEndMax ) |
---|
| 609 | { |
---|
[56] | 610 | ruhXe = (UChar)max( iXe, 0 ); |
---|
| 611 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 612 | |
---|
| 613 | return; |
---|
| 614 | } |
---|
| 615 | else |
---|
| 616 | { |
---|
[56] | 617 | ruhXe = (UChar)iContDMaxPos; |
---|
| 618 | ruhYe = (UChar)max( (iContDMaxPos - (iXe - iContDMaxPos)), 0 ); |
---|
[2] | 619 | |
---|
| 620 | std::swap( ruhXs, ruhXe ); |
---|
| 621 | std::swap( ruhYs, ruhYe ); |
---|
| 622 | return; |
---|
| 623 | } |
---|
| 624 | } |
---|
| 625 | else |
---|
| 626 | { |
---|
| 627 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
| 628 | if( iYe < 0 ) |
---|
| 629 | { |
---|
[56] | 630 | ruhXe = (UChar)max( (iContDMaxPos + iYe), 0 ); |
---|
[2] | 631 | ruhYe = 0; |
---|
| 632 | |
---|
| 633 | std::swap( ruhXs, ruhXe ); |
---|
| 634 | std::swap( ruhYs, ruhYe ); |
---|
| 635 | return; |
---|
| 636 | } |
---|
[56] | 637 | else if( iYe > iContDMaxPos ) |
---|
[2] | 638 | { |
---|
[56] | 639 | ruhXe = (UChar)max( (iContDMaxPos - (iYe - iContDMaxPos)), 0 ); |
---|
| 640 | ruhYe = (UChar)iContDMaxPos; |
---|
[2] | 641 | |
---|
| 642 | return; |
---|
| 643 | } |
---|
| 644 | else |
---|
| 645 | { |
---|
[56] | 646 | ruhXe = (UChar)iContDMaxPos; |
---|
[2] | 647 | ruhYe = (UChar)iYe; |
---|
| 648 | |
---|
| 649 | std::swap( ruhXs, ruhXe ); |
---|
| 650 | std::swap( ruhYs, ruhYe ); |
---|
| 651 | return; |
---|
| 652 | } |
---|
| 653 | } |
---|
| 654 | } |
---|
| 655 | #endif |
---|
| 656 | |
---|
| 657 | Void TComWedgelet::xGenerateWedgePattern() |
---|
| 658 | { |
---|
| 659 | UInt uiTempBlockSize = 0; |
---|
| 660 | UChar uhXs = 0, uhYs = 0, uhXe = 0, uhYe = 0; |
---|
| 661 | switch( m_eWedgeRes ) |
---|
| 662 | { |
---|
| 663 | case( DOUBLE_PEL ): { uiTempBlockSize = m_uiWidth; uhXs = (m_uhXs<<1); uhYs = (m_uhYs<<1); uhXe = (m_uhXe<<1); uhYe = (m_uhYe<<1); } break; |
---|
| 664 | case( FULL_PEL ): { uiTempBlockSize = m_uiWidth; uhXs = m_uhXs; uhYs = m_uhYs; uhXe = m_uhXe; uhYe = m_uhYe; } break; |
---|
| 665 | case( HALF_PEL ): { uiTempBlockSize = (m_uiWidth<<1); uhXs = m_uhXs; uhYs = m_uhYs; uhXe = m_uhXe; uhYe = m_uhYe; } break; |
---|
| 666 | } |
---|
| 667 | |
---|
| 668 | if( m_eWedgeRes == DOUBLE_PEL) // fix for line-end problem with DOUBLE_PEL resolution |
---|
| 669 | { |
---|
| 670 | if( m_uhOri == 1 ) { uhXs = uiTempBlockSize-1; } |
---|
| 671 | if( m_uhOri == 2 ) { uhXe = uiTempBlockSize-1; uhYs = uiTempBlockSize-1; } |
---|
| 672 | if( m_uhOri == 3 ) { uhYe = uiTempBlockSize-1; } |
---|
| 673 | if( m_uhOri == 4 ) { uhYe = uiTempBlockSize-1; } |
---|
| 674 | if( m_uhOri == 5 ) { uhXs = uiTempBlockSize-1; } |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | Bool* pbTempPattern = new Bool[ (uiTempBlockSize * uiTempBlockSize) ]; |
---|
| 678 | ::memset( pbTempPattern, 0, (uiTempBlockSize * uiTempBlockSize) * sizeof(Bool) ); |
---|
| 679 | Int iTempStride = uiTempBlockSize; |
---|
| 680 | |
---|
| 681 | xDrawEdgeLine( uhXs, uhYs, uhXe, uhYe, pbTempPattern, iTempStride ); |
---|
| 682 | |
---|
| 683 | switch( m_uhOri ) |
---|
| 684 | { |
---|
| 685 | case( 0 ): { for( UInt iX = 0; iX < uhXs; iX++ ) { UInt iY = 0; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } } break; |
---|
| 686 | case( 1 ): { for( UInt iY = 0; iY < uhYs; iY++ ) { UInt iX = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX--; } } } break; |
---|
| 687 | case( 2 ): { for( UInt iX = uiTempBlockSize-1; iX > uhXs; iX-- ) { UInt iY = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY--; } } } break; |
---|
| 688 | case( 3 ): { for( UInt iY = uiTempBlockSize-1; iY > uhYs; iY-- ) { UInt iX = 0; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } } break; |
---|
[296] | 689 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 690 | case( 4 ): |
---|
| 691 | { |
---|
| 692 | if( (uhXs+uhXe) < uiTempBlockSize ) { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = 0; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } } |
---|
| 693 | else { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX--; } } } |
---|
| 694 | } |
---|
| 695 | break; |
---|
| 696 | case( 5 ): |
---|
| 697 | { |
---|
| 698 | if( (uhYs+uhYe) < uiTempBlockSize ) { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = 0; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } } |
---|
| 699 | else { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY--; } } } |
---|
| 700 | } |
---|
| 701 | #else |
---|
[56] | 702 | case( 4 ): { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = 0; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } } break; |
---|
| 703 | case( 5 ): { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = 0; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } } break; |
---|
[189] | 704 | #endif |
---|
[2] | 705 | } |
---|
| 706 | |
---|
| 707 | clear(); |
---|
| 708 | switch( m_eWedgeRes ) |
---|
| 709 | { |
---|
| 710 | case( DOUBLE_PEL ): { for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ ) { m_pbPattern[k] = pbTempPattern[k]; }; } break; |
---|
| 711 | case( FULL_PEL ): { for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ ) { m_pbPattern[k] = pbTempPattern[k]; }; } break; |
---|
| 712 | case( HALF_PEL ): // sub-sampling by factor 2 |
---|
| 713 | { |
---|
| 714 | Int iStride = getStride(); |
---|
| 715 | |
---|
| 716 | UInt uiOffX, uiOffY; |
---|
| 717 | switch( m_uhOri ) |
---|
| 718 | { |
---|
| 719 | case( 0 ): { uiOffX = 0; uiOffY = 0; } break; |
---|
| 720 | case( 1 ): { uiOffX = 1; uiOffY = 0; } break; |
---|
| 721 | case( 2 ): { uiOffX = 1; uiOffY = 1; } break; |
---|
| 722 | case( 3 ): { uiOffX = 0; uiOffY = 1; } break; |
---|
[296] | 723 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 724 | case( 4 ): |
---|
| 725 | { |
---|
| 726 | if( (uhXs+uhXe) < uiTempBlockSize ) { uiOffX = 0; uiOffY = 0; } |
---|
| 727 | else { uiOffX = 1; uiOffY = 0; } |
---|
| 728 | } |
---|
| 729 | break; |
---|
| 730 | case( 5 ): |
---|
| 731 | { |
---|
| 732 | if( (uhYs+uhYe) < uiTempBlockSize ) { uiOffX = 0; uiOffY = 0; } |
---|
| 733 | else { uiOffX = 0; uiOffY = 1; } |
---|
| 734 | } |
---|
| 735 | break; |
---|
| 736 | #else |
---|
[2] | 737 | case( 4 ): { uiOffX = 0; uiOffY = 0; } break; |
---|
| 738 | case( 5 ): { uiOffX = 0; uiOffY = 0; } break; |
---|
[189] | 739 | #endif |
---|
[2] | 740 | default: { uiOffX = 0; uiOffY = 0; } break; |
---|
| 741 | } |
---|
| 742 | |
---|
| 743 | for(Int iY = 0; iY < m_uiHeight; iY++) |
---|
| 744 | { |
---|
| 745 | for(Int iX = 0; iX < m_uiWidth; iX++) |
---|
| 746 | { |
---|
| 747 | m_pbPattern[(iY * iStride) + iX] = pbTempPattern[(((iY<<1)+uiOffY) * iTempStride) + ((iX<<1)+uiOffX)]; |
---|
| 748 | } |
---|
| 749 | } |
---|
| 750 | } |
---|
| 751 | break; |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | if( pbTempPattern ) |
---|
| 755 | { |
---|
| 756 | delete [] pbTempPattern; |
---|
| 757 | pbTempPattern = NULL; |
---|
| 758 | } |
---|
| 759 | } |
---|
| 760 | |
---|
| 761 | Void TComWedgelet::xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride ) |
---|
| 762 | { |
---|
| 763 | Int x0 = (Int)uhXs; |
---|
| 764 | Int y0 = (Int)uhYs; |
---|
| 765 | Int x1 = (Int)uhXe; |
---|
| 766 | Int y1 = (Int)uhYe; |
---|
| 767 | |
---|
| 768 | // direction independent Bresenham line |
---|
| 769 | bool steep = (abs(y1 - y0) > abs(x1 - x0)); |
---|
| 770 | if( steep ) |
---|
| 771 | { |
---|
| 772 | std::swap( x0, y0 ); |
---|
| 773 | std::swap( x1, y1 ); |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | bool backward = ( x0 > x1 ); |
---|
| 777 | if( backward ) |
---|
| 778 | { |
---|
| 779 | std::swap( x0, x1 ); |
---|
| 780 | std::swap( y0, y1 ); |
---|
| 781 | } |
---|
| 782 | |
---|
| 783 | Int deltax = x1 - x0; |
---|
| 784 | Int deltay = abs(y1 - y0); |
---|
[344] | 785 | #if FIX_WEDGE_NOFLOAT_D0036 |
---|
| 786 | Int error = 0; |
---|
| 787 | Int deltaerr = (deltay<<1); |
---|
| 788 | #else |
---|
[2] | 789 | double error = 0.0; |
---|
| 790 | double deltaerr = (double)deltay / (double)deltax; |
---|
[344] | 791 | #endif |
---|
[2] | 792 | |
---|
| 793 | Int ystep; |
---|
| 794 | Int y = y0; |
---|
| 795 | if( y0 < y1 ) ystep = 1; |
---|
| 796 | else ystep = -1; |
---|
| 797 | |
---|
| 798 | for( Int x = x0; x <= x1; x++ ) |
---|
| 799 | { |
---|
| 800 | if( steep ) { pbPattern[(x * iPatternStride) + y] = true; } |
---|
| 801 | else { pbPattern[(y * iPatternStride) + x] = true; } |
---|
| 802 | |
---|
| 803 | error += deltaerr; |
---|
[344] | 804 | #if FIX_WEDGE_NOFLOAT_D0036 |
---|
| 805 | if( error >= deltax ) |
---|
| 806 | #else |
---|
[2] | 807 | if( error >= 0.5) |
---|
[344] | 808 | #endif |
---|
[2] | 809 | { |
---|
| 810 | y += ystep; |
---|
[344] | 811 | #if FIX_WEDGE_NOFLOAT_D0036 |
---|
| 812 | error = error - (deltax<<1); |
---|
| 813 | #else |
---|
[2] | 814 | error = error - 1.0; |
---|
[344] | 815 | #endif |
---|
[2] | 816 | } |
---|
| 817 | } |
---|
| 818 | } |
---|
[56] | 819 | |
---|
[296] | 820 | #if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA |
---|
[189] | 821 | TComWedgeNode::TComWedgeNode() |
---|
| 822 | { |
---|
| 823 | m_uiPatternIdx = NO_IDX; |
---|
| 824 | for( UInt uiPos = 0; uiPos < NUM_WEDGE_REFINES; uiPos++ ) |
---|
| 825 | { |
---|
| 826 | m_uiRefineIdx[uiPos] = NO_IDX; |
---|
| 827 | } |
---|
| 828 | } |
---|
| 829 | |
---|
| 830 | UInt TComWedgeNode::getPatternIdx() |
---|
| 831 | { |
---|
| 832 | return m_uiPatternIdx; |
---|
| 833 | } |
---|
| 834 | UInt TComWedgeNode::getRefineIdx( UInt uiPos ) |
---|
| 835 | { |
---|
| 836 | assert( uiPos < NUM_WEDGE_REFINES ); |
---|
| 837 | return m_uiRefineIdx[uiPos]; |
---|
| 838 | } |
---|
| 839 | Void TComWedgeNode::setPatternIdx( UInt uiIdx ) |
---|
| 840 | { |
---|
| 841 | m_uiPatternIdx = uiIdx; |
---|
| 842 | } |
---|
| 843 | Void TComWedgeNode::setRefineIdx( UInt uiIdx, UInt uiPos ) |
---|
| 844 | { |
---|
| 845 | assert( uiPos < NUM_WEDGE_REFINES ); |
---|
| 846 | m_uiRefineIdx[uiPos] = uiIdx; |
---|
| 847 | } |
---|
| 848 | #endif |
---|
| 849 | |
---|
[56] | 850 | #if HHI_DMM_PRED_TEX |
---|
| 851 | TComWedgeDist::TComWedgeDist() |
---|
| 852 | { |
---|
| 853 | init(); |
---|
| 854 | } |
---|
| 855 | |
---|
| 856 | TComWedgeDist::~TComWedgeDist() |
---|
| 857 | { |
---|
| 858 | } |
---|
| 859 | |
---|
| 860 | Void TComWedgeDist::init() |
---|
| 861 | { |
---|
| 862 | m_afpDistortFunc[0] = TComWedgeDist::xGetSAD4; |
---|
| 863 | m_afpDistortFunc[1] = TComWedgeDist::xGetSAD8; |
---|
| 864 | m_afpDistortFunc[2] = TComWedgeDist::xGetSAD16; |
---|
| 865 | m_afpDistortFunc[3] = TComWedgeDist::xGetSAD32; |
---|
| 866 | |
---|
| 867 | m_afpDistortFunc[4] = TComWedgeDist::xGetSSE4; |
---|
| 868 | m_afpDistortFunc[5] = TComWedgeDist::xGetSSE8; |
---|
| 869 | m_afpDistortFunc[6] = TComWedgeDist::xGetSSE16; |
---|
| 870 | m_afpDistortFunc[7] = TComWedgeDist::xGetSSE32; |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | UInt TComWedgeDist::xGetSAD4( WedgeDistParam* pcDtParam ) |
---|
| 874 | { |
---|
| 875 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 876 | Pel* piCur = pcDtParam->pCur; |
---|
| 877 | Int iRows = pcDtParam->iRows; |
---|
| 878 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 879 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 880 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 881 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 882 | |
---|
| 883 | UInt uiSum = 0; |
---|
| 884 | |
---|
| 885 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 886 | { |
---|
| 887 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 888 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 889 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 890 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 891 | |
---|
| 892 | piOrg += iStrideOrg; |
---|
| 893 | piCur += iStrideCur; |
---|
| 894 | } |
---|
| 895 | |
---|
| 896 | uiSum <<= iSubShift; |
---|
| 897 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 898 | } |
---|
| 899 | |
---|
| 900 | UInt TComWedgeDist::xGetSAD8( WedgeDistParam* pcDtParam ) |
---|
| 901 | { |
---|
| 902 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 903 | Pel* piCur = pcDtParam->pCur; |
---|
| 904 | Int iRows = pcDtParam->iRows; |
---|
| 905 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 906 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 907 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 908 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 909 | |
---|
| 910 | UInt uiSum = 0; |
---|
| 911 | |
---|
| 912 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 913 | { |
---|
| 914 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 915 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 916 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 917 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 918 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 919 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 920 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 921 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 922 | |
---|
| 923 | piOrg += iStrideOrg; |
---|
| 924 | piCur += iStrideCur; |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | uiSum <<= iSubShift; |
---|
| 928 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 929 | } |
---|
| 930 | |
---|
| 931 | UInt TComWedgeDist::xGetSAD16( WedgeDistParam* pcDtParam ) |
---|
| 932 | { |
---|
| 933 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 934 | Pel* piCur = pcDtParam->pCur; |
---|
| 935 | Int iRows = pcDtParam->iRows; |
---|
| 936 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 937 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 938 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 939 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 940 | |
---|
| 941 | UInt uiSum = 0; |
---|
| 942 | |
---|
| 943 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 944 | { |
---|
| 945 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 946 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 947 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 948 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 949 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 950 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 951 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 952 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 953 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 954 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 955 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 956 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 957 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 958 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 959 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 960 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 961 | |
---|
| 962 | piOrg += iStrideOrg; |
---|
| 963 | piCur += iStrideCur; |
---|
| 964 | } |
---|
| 965 | |
---|
| 966 | uiSum <<= iSubShift; |
---|
| 967 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 968 | } |
---|
| 969 | |
---|
| 970 | UInt TComWedgeDist::xGetSAD32( WedgeDistParam* pcDtParam ) |
---|
| 971 | { |
---|
| 972 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 973 | Pel* piCur = pcDtParam->pCur; |
---|
| 974 | Int iRows = pcDtParam->iRows; |
---|
| 975 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 976 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 977 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 978 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 979 | |
---|
| 980 | UInt uiSum = 0; |
---|
| 981 | |
---|
| 982 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 983 | { |
---|
| 984 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 985 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 986 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 987 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 988 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 989 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 990 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 991 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 992 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 993 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 994 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 995 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 996 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 997 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 998 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 999 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 1000 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 1001 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 1002 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 1003 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 1004 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 1005 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 1006 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 1007 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 1008 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 1009 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 1010 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 1011 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 1012 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 1013 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 1014 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 1015 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 1016 | |
---|
| 1017 | piOrg += iStrideOrg; |
---|
| 1018 | piCur += iStrideCur; |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | uiSum <<= iSubShift; |
---|
| 1022 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 1023 | } |
---|
| 1024 | |
---|
| 1025 | UInt TComWedgeDist::xGetSSE4( WedgeDistParam* pcDtParam ) |
---|
| 1026 | { |
---|
| 1027 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1028 | Pel* piCur = pcDtParam->pCur; |
---|
| 1029 | Int iRows = pcDtParam->iRows; |
---|
| 1030 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1031 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1032 | |
---|
| 1033 | UInt uiSum = 0; |
---|
| 1034 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1035 | |
---|
| 1036 | Int iTemp; |
---|
| 1037 | |
---|
| 1038 | for( ; iRows != 0; iRows-- ) |
---|
| 1039 | { |
---|
| 1040 | |
---|
| 1041 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1042 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1043 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1044 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1045 | |
---|
| 1046 | piOrg += iStrideOrg; |
---|
| 1047 | piCur += iStrideCur; |
---|
| 1048 | } |
---|
| 1049 | |
---|
| 1050 | return ( uiSum ); |
---|
| 1051 | } |
---|
| 1052 | |
---|
| 1053 | UInt TComWedgeDist::xGetSSE8( WedgeDistParam* pcDtParam ) |
---|
| 1054 | { |
---|
| 1055 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1056 | Pel* piCur = pcDtParam->pCur; |
---|
| 1057 | Int iRows = pcDtParam->iRows; |
---|
| 1058 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1059 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1060 | |
---|
| 1061 | UInt uiSum = 0; |
---|
| 1062 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1063 | |
---|
| 1064 | Int iTemp; |
---|
| 1065 | |
---|
| 1066 | for( ; iRows != 0; iRows-- ) |
---|
| 1067 | { |
---|
| 1068 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1069 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1070 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1071 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1072 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1073 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1074 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1075 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1076 | |
---|
| 1077 | piOrg += iStrideOrg; |
---|
| 1078 | piCur += iStrideCur; |
---|
| 1079 | } |
---|
| 1080 | |
---|
| 1081 | return ( uiSum ); |
---|
| 1082 | } |
---|
| 1083 | |
---|
| 1084 | UInt TComWedgeDist::xGetSSE16( WedgeDistParam* pcDtParam ) |
---|
| 1085 | { |
---|
| 1086 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1087 | Pel* piCur = pcDtParam->pCur; |
---|
| 1088 | Int iRows = pcDtParam->iRows; |
---|
| 1089 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1090 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1091 | |
---|
| 1092 | UInt uiSum = 0; |
---|
| 1093 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1094 | |
---|
| 1095 | Int iTemp; |
---|
| 1096 | |
---|
| 1097 | for( ; iRows != 0; iRows-- ) |
---|
| 1098 | { |
---|
| 1099 | |
---|
| 1100 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1101 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1102 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1103 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1104 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1105 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1106 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1107 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1108 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1109 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1110 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1111 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1112 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1113 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1114 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1115 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1116 | |
---|
| 1117 | piOrg += iStrideOrg; |
---|
| 1118 | piCur += iStrideCur; |
---|
| 1119 | } |
---|
| 1120 | |
---|
| 1121 | return ( uiSum ); |
---|
| 1122 | } |
---|
| 1123 | |
---|
| 1124 | UInt TComWedgeDist::xGetSSE32( WedgeDistParam* pcDtParam ) |
---|
| 1125 | { |
---|
| 1126 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1127 | Pel* piCur = pcDtParam->pCur; |
---|
| 1128 | Int iRows = pcDtParam->iRows; |
---|
| 1129 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1130 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1131 | |
---|
| 1132 | UInt uiSum = 0; |
---|
| 1133 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1134 | Int iTemp; |
---|
| 1135 | |
---|
| 1136 | for( ; iRows != 0; iRows-- ) |
---|
| 1137 | { |
---|
| 1138 | |
---|
| 1139 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1140 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1141 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1142 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1143 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1144 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1145 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1146 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1147 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1148 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1149 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1150 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1151 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1152 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1153 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1154 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1155 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1156 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1157 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1158 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1159 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1160 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1161 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1162 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1163 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1164 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1165 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1166 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1167 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1168 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1169 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1170 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1171 | |
---|
| 1172 | piOrg += iStrideOrg; |
---|
| 1173 | piCur += iStrideCur; |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | return ( uiSum ); |
---|
| 1177 | } |
---|
| 1178 | |
---|
| 1179 | Void TComWedgeDist::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, WedgeDistParam& rcDistParam ) |
---|
| 1180 | { |
---|
| 1181 | // set Block Width / Height |
---|
| 1182 | rcDistParam.iCols = uiBlkWidth; |
---|
| 1183 | rcDistParam.iRows = uiBlkHeight; |
---|
| 1184 | rcDistParam.DistFunc = m_afpDistortFunc[eWDist + g_aucConvertToBit[ rcDistParam.iCols ] ]; |
---|
| 1185 | |
---|
| 1186 | // initialize |
---|
| 1187 | rcDistParam.iSubShift = 0; |
---|
| 1188 | } |
---|
| 1189 | |
---|
| 1190 | UInt TComWedgeDist::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist ) |
---|
| 1191 | { |
---|
| 1192 | WedgeDistParam cDtParam; |
---|
| 1193 | setDistParam( uiBlkWidth, uiBlkHeight, eWDist, cDtParam ); |
---|
| 1194 | cDtParam.pOrg = piOrg; |
---|
| 1195 | cDtParam.pCur = piCur; |
---|
| 1196 | cDtParam.iStrideOrg = iOrgStride; |
---|
| 1197 | cDtParam.iStrideCur = iCurStride; |
---|
| 1198 | cDtParam.iStep = 1; |
---|
| 1199 | |
---|
| 1200 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 1201 | } |
---|
| 1202 | #endif |
---|