[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 ) |
---|
[158] | 54 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 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 ), |
---|
[158] | 67 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 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 | |
---|
[158] | 103 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 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 ) |
---|
[158] | 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; |
---|
[158] | 144 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 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; |
---|
[158] | 689 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 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; |
---|
[158] | 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; |
---|
[158] | 723 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 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; |
---|
[158] | 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); |
---|
| 785 | double error = 0.0; |
---|
| 786 | double deltaerr = (double)deltay / (double)deltax; |
---|
| 787 | |
---|
| 788 | Int ystep; |
---|
| 789 | Int y = y0; |
---|
| 790 | if( y0 < y1 ) ystep = 1; |
---|
| 791 | else ystep = -1; |
---|
| 792 | |
---|
| 793 | for( Int x = x0; x <= x1; x++ ) |
---|
| 794 | { |
---|
| 795 | if( steep ) { pbPattern[(x * iPatternStride) + y] = true; } |
---|
| 796 | else { pbPattern[(y * iPatternStride) + x] = true; } |
---|
| 797 | |
---|
| 798 | error += deltaerr; |
---|
| 799 | if( error >= 0.5) |
---|
| 800 | { |
---|
| 801 | y += ystep; |
---|
| 802 | error = error - 1.0; |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | } |
---|
[56] | 806 | |
---|
[158] | 807 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 808 | TComWedgeNode::TComWedgeNode() |
---|
| 809 | { |
---|
| 810 | m_uiPatternIdx = NO_IDX; |
---|
| 811 | for( UInt uiPos = 0; uiPos < NUM_WEDGE_REFINES; uiPos++ ) |
---|
| 812 | { |
---|
| 813 | m_uiRefineIdx[uiPos] = NO_IDX; |
---|
| 814 | } |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | UInt TComWedgeNode::getPatternIdx() |
---|
| 818 | { |
---|
| 819 | return m_uiPatternIdx; |
---|
| 820 | } |
---|
| 821 | UInt TComWedgeNode::getRefineIdx( UInt uiPos ) |
---|
| 822 | { |
---|
| 823 | assert( uiPos < NUM_WEDGE_REFINES ); |
---|
| 824 | return m_uiRefineIdx[uiPos]; |
---|
| 825 | } |
---|
| 826 | Void TComWedgeNode::setPatternIdx( UInt uiIdx ) |
---|
| 827 | { |
---|
| 828 | m_uiPatternIdx = uiIdx; |
---|
| 829 | } |
---|
| 830 | Void TComWedgeNode::setRefineIdx( UInt uiIdx, UInt uiPos ) |
---|
| 831 | { |
---|
| 832 | assert( uiPos < NUM_WEDGE_REFINES ); |
---|
| 833 | m_uiRefineIdx[uiPos] = uiIdx; |
---|
| 834 | } |
---|
| 835 | #endif |
---|
| 836 | |
---|
[56] | 837 | #if HHI_DMM_PRED_TEX |
---|
| 838 | TComWedgeDist::TComWedgeDist() |
---|
| 839 | { |
---|
| 840 | init(); |
---|
| 841 | } |
---|
| 842 | |
---|
| 843 | TComWedgeDist::~TComWedgeDist() |
---|
| 844 | { |
---|
| 845 | } |
---|
| 846 | |
---|
| 847 | Void TComWedgeDist::init() |
---|
| 848 | { |
---|
| 849 | m_afpDistortFunc[0] = TComWedgeDist::xGetSAD4; |
---|
| 850 | m_afpDistortFunc[1] = TComWedgeDist::xGetSAD8; |
---|
| 851 | m_afpDistortFunc[2] = TComWedgeDist::xGetSAD16; |
---|
| 852 | m_afpDistortFunc[3] = TComWedgeDist::xGetSAD32; |
---|
| 853 | |
---|
| 854 | m_afpDistortFunc[4] = TComWedgeDist::xGetSSE4; |
---|
| 855 | m_afpDistortFunc[5] = TComWedgeDist::xGetSSE8; |
---|
| 856 | m_afpDistortFunc[6] = TComWedgeDist::xGetSSE16; |
---|
| 857 | m_afpDistortFunc[7] = TComWedgeDist::xGetSSE32; |
---|
| 858 | } |
---|
| 859 | |
---|
| 860 | UInt TComWedgeDist::xGetSAD4( WedgeDistParam* pcDtParam ) |
---|
| 861 | { |
---|
| 862 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 863 | Pel* piCur = pcDtParam->pCur; |
---|
| 864 | Int iRows = pcDtParam->iRows; |
---|
| 865 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 866 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 867 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 868 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 869 | |
---|
| 870 | UInt uiSum = 0; |
---|
| 871 | |
---|
| 872 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 873 | { |
---|
| 874 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 875 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 876 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 877 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 878 | |
---|
| 879 | piOrg += iStrideOrg; |
---|
| 880 | piCur += iStrideCur; |
---|
| 881 | } |
---|
| 882 | |
---|
| 883 | uiSum <<= iSubShift; |
---|
| 884 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 885 | } |
---|
| 886 | |
---|
| 887 | UInt TComWedgeDist::xGetSAD8( WedgeDistParam* pcDtParam ) |
---|
| 888 | { |
---|
| 889 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 890 | Pel* piCur = pcDtParam->pCur; |
---|
| 891 | Int iRows = pcDtParam->iRows; |
---|
| 892 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 893 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 894 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 895 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 896 | |
---|
| 897 | UInt uiSum = 0; |
---|
| 898 | |
---|
| 899 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 900 | { |
---|
| 901 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 902 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 903 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 904 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 905 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 906 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 907 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 908 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 909 | |
---|
| 910 | piOrg += iStrideOrg; |
---|
| 911 | piCur += iStrideCur; |
---|
| 912 | } |
---|
| 913 | |
---|
| 914 | uiSum <<= iSubShift; |
---|
| 915 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 916 | } |
---|
| 917 | |
---|
| 918 | UInt TComWedgeDist::xGetSAD16( WedgeDistParam* pcDtParam ) |
---|
| 919 | { |
---|
| 920 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 921 | Pel* piCur = pcDtParam->pCur; |
---|
| 922 | Int iRows = pcDtParam->iRows; |
---|
| 923 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 924 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 925 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 926 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 927 | |
---|
| 928 | UInt uiSum = 0; |
---|
| 929 | |
---|
| 930 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 931 | { |
---|
| 932 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 933 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 934 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 935 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 936 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 937 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 938 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 939 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 940 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 941 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 942 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 943 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 944 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 945 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 946 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 947 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 948 | |
---|
| 949 | piOrg += iStrideOrg; |
---|
| 950 | piCur += iStrideCur; |
---|
| 951 | } |
---|
| 952 | |
---|
| 953 | uiSum <<= iSubShift; |
---|
| 954 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | UInt TComWedgeDist::xGetSAD32( WedgeDistParam* pcDtParam ) |
---|
| 958 | { |
---|
| 959 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 960 | Pel* piCur = pcDtParam->pCur; |
---|
| 961 | Int iRows = pcDtParam->iRows; |
---|
| 962 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 963 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 964 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 965 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 966 | |
---|
| 967 | UInt uiSum = 0; |
---|
| 968 | |
---|
| 969 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 970 | { |
---|
| 971 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 972 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 973 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 974 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 975 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 976 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 977 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 978 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 979 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 980 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 981 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 982 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 983 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 984 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 985 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 986 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 987 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 988 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 989 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 990 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 991 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 992 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 993 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 994 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 995 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 996 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 997 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 998 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 999 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 1000 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 1001 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 1002 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 1003 | |
---|
| 1004 | piOrg += iStrideOrg; |
---|
| 1005 | piCur += iStrideCur; |
---|
| 1006 | } |
---|
| 1007 | |
---|
| 1008 | uiSum <<= iSubShift; |
---|
| 1009 | return ( uiSum >> g_uiBitIncrement ); |
---|
| 1010 | } |
---|
| 1011 | |
---|
| 1012 | UInt TComWedgeDist::xGetSSE4( WedgeDistParam* pcDtParam ) |
---|
| 1013 | { |
---|
| 1014 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1015 | Pel* piCur = pcDtParam->pCur; |
---|
| 1016 | Int iRows = pcDtParam->iRows; |
---|
| 1017 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1018 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1019 | |
---|
| 1020 | UInt uiSum = 0; |
---|
| 1021 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1022 | |
---|
| 1023 | Int iTemp; |
---|
| 1024 | |
---|
| 1025 | for( ; iRows != 0; iRows-- ) |
---|
| 1026 | { |
---|
| 1027 | |
---|
| 1028 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1029 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1030 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1031 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1032 | |
---|
| 1033 | piOrg += iStrideOrg; |
---|
| 1034 | piCur += iStrideCur; |
---|
| 1035 | } |
---|
| 1036 | |
---|
| 1037 | return ( uiSum ); |
---|
| 1038 | } |
---|
| 1039 | |
---|
| 1040 | UInt TComWedgeDist::xGetSSE8( WedgeDistParam* pcDtParam ) |
---|
| 1041 | { |
---|
| 1042 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1043 | Pel* piCur = pcDtParam->pCur; |
---|
| 1044 | Int iRows = pcDtParam->iRows; |
---|
| 1045 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1046 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1047 | |
---|
| 1048 | UInt uiSum = 0; |
---|
| 1049 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1050 | |
---|
| 1051 | Int iTemp; |
---|
| 1052 | |
---|
| 1053 | for( ; iRows != 0; iRows-- ) |
---|
| 1054 | { |
---|
| 1055 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1056 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1057 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1058 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1059 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1060 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1061 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1062 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1063 | |
---|
| 1064 | piOrg += iStrideOrg; |
---|
| 1065 | piCur += iStrideCur; |
---|
| 1066 | } |
---|
| 1067 | |
---|
| 1068 | return ( uiSum ); |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | UInt TComWedgeDist::xGetSSE16( WedgeDistParam* pcDtParam ) |
---|
| 1072 | { |
---|
| 1073 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1074 | Pel* piCur = pcDtParam->pCur; |
---|
| 1075 | Int iRows = pcDtParam->iRows; |
---|
| 1076 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1077 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1078 | |
---|
| 1079 | UInt uiSum = 0; |
---|
| 1080 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1081 | |
---|
| 1082 | Int iTemp; |
---|
| 1083 | |
---|
| 1084 | for( ; iRows != 0; iRows-- ) |
---|
| 1085 | { |
---|
| 1086 | |
---|
| 1087 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1088 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1089 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1090 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1091 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1092 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1093 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1094 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1095 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1096 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1097 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1098 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1099 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1100 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1101 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1102 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1103 | |
---|
| 1104 | piOrg += iStrideOrg; |
---|
| 1105 | piCur += iStrideCur; |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | return ( uiSum ); |
---|
| 1109 | } |
---|
| 1110 | |
---|
| 1111 | UInt TComWedgeDist::xGetSSE32( WedgeDistParam* pcDtParam ) |
---|
| 1112 | { |
---|
| 1113 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1114 | Pel* piCur = pcDtParam->pCur; |
---|
| 1115 | Int iRows = pcDtParam->iRows; |
---|
| 1116 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1117 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1118 | |
---|
| 1119 | UInt uiSum = 0; |
---|
| 1120 | UInt uiShift = g_uiBitIncrement<<1; |
---|
| 1121 | Int iTemp; |
---|
| 1122 | |
---|
| 1123 | for( ; iRows != 0; iRows-- ) |
---|
| 1124 | { |
---|
| 1125 | |
---|
| 1126 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1127 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1128 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1129 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1130 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1131 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1132 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1133 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1134 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1135 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1136 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1137 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1138 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1139 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1140 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1141 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1142 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1143 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1144 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1145 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1146 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1147 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1148 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1149 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1150 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1151 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1152 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1153 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1154 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1155 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1156 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1157 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1158 | |
---|
| 1159 | piOrg += iStrideOrg; |
---|
| 1160 | piCur += iStrideCur; |
---|
| 1161 | } |
---|
| 1162 | |
---|
| 1163 | return ( uiSum ); |
---|
| 1164 | } |
---|
| 1165 | |
---|
| 1166 | Void TComWedgeDist::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, WedgeDistParam& rcDistParam ) |
---|
| 1167 | { |
---|
| 1168 | // set Block Width / Height |
---|
| 1169 | rcDistParam.iCols = uiBlkWidth; |
---|
| 1170 | rcDistParam.iRows = uiBlkHeight; |
---|
| 1171 | rcDistParam.DistFunc = m_afpDistortFunc[eWDist + g_aucConvertToBit[ rcDistParam.iCols ] ]; |
---|
| 1172 | |
---|
| 1173 | // initialize |
---|
| 1174 | rcDistParam.iSubShift = 0; |
---|
| 1175 | } |
---|
| 1176 | |
---|
| 1177 | UInt TComWedgeDist::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist ) |
---|
| 1178 | { |
---|
| 1179 | WedgeDistParam cDtParam; |
---|
| 1180 | setDistParam( uiBlkWidth, uiBlkHeight, eWDist, cDtParam ); |
---|
| 1181 | cDtParam.pOrg = piOrg; |
---|
| 1182 | cDtParam.pCur = piCur; |
---|
| 1183 | cDtParam.iStrideOrg = iOrgStride; |
---|
| 1184 | cDtParam.iStrideCur = iCurStride; |
---|
| 1185 | cDtParam.iStep = 1; |
---|
| 1186 | |
---|
| 1187 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 1188 | } |
---|
| 1189 | #endif |
---|