Changeset 1360 in 3DVCSoftware for branches/HTM-15.2-dev/source/Lib/TLibEncoder
- Timestamp:
- 28 Oct 2015, 17:46:00 (9 years ago)
- Location:
- branches/HTM-15.2-dev/source/Lib/TLibEncoder
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-15.2-dev/source/Lib/TLibEncoder/AnnexBwrite.h
r1313 r1360 60 60 UInt size = 0; /* size of annexB unit in bytes */ 61 61 62 static const Char start_code_prefix[] = {0,0,0,1};62 static const UChar start_code_prefix[] = {0,0,0,1}; 63 63 if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_VPS || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_PPS) 64 64 { … … 71 71 * 7.4.1.2.3. 72 72 */ 73 out.write( start_code_prefix, 4);73 out.write(reinterpret_cast<const TChar*>(start_code_prefix), 4); 74 74 size += 4; 75 75 } 76 76 else 77 77 { 78 out.write( start_code_prefix+1, 3);78 out.write(reinterpret_cast<const TChar*>(start_code_prefix+1), 3); 79 79 size += 3; 80 80 } -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/NALwrite.cpp
r1313 r1360 45 45 //! \{ 46 46 47 static const Char emulation_prevention_three_byte[] = {3};47 static const UChar emulation_prevention_three_byte[] = {3}; 48 48 49 49 Void writeNalUnitHeader(ostream& out, OutputNALUnit& nalu) // nal_unit_header() … … 60 60 bsNALUHeader.write(nalu.m_temporalId+1, 3); // nuh_temporal_id_plus1 61 61 62 out.write( bsNALUHeader.getByteStream(), bsNALUHeader.getByteStreamLength());62 out.write(reinterpret_cast<const TChar*>(bsNALUHeader.getByteStream()), bsNALUHeader.getByteStreamLength()); 63 63 } 64 64 /** … … 124 124 outputBuffer[outputAmount++]=emulation_prevention_three_byte[0]; 125 125 } 126 out.write( (Char*)&(*outputBuffer.begin()), outputAmount);126 out.write(reinterpret_cast<const TChar*>(&(*outputBuffer.begin())), outputAmount); 127 127 } 128 128 -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/SEIEncoder.cpp
r1356 r1360 294 294 assert (pcPic!=NULL); 295 295 296 if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1) 297 { 298 decodedPictureHashSEI->method = SEIDecodedPictureHash::MD5; 296 decodedPictureHashSEI->method = m_pcCfg->getDecodedPictureHashSEIType(); 297 switch (m_pcCfg->getDecodedPictureHashSEIType()) 298 { 299 case HASHTYPE_MD5: 300 { 299 301 UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); 300 302 rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); 301 303 } 302 else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 2)303 {304 decodedPictureHashSEI->method = SEIDecodedPictureHash::CRC;304 break; 305 case HASHTYPE_CRC: 306 { 305 307 UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); 306 308 rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); 307 309 } 308 else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 3) 309 { 310 decodedPictureHashSEI->method = SEIDecodedPictureHash::CHECKSUM; 310 break; 311 case HASHTYPE_CHECKSUM: 312 default: 313 { 311 314 UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); 312 315 rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); 316 } 317 break; 313 318 } 314 319 } … … 397 402 } 398 403 } 399 400 Void SEIEncoder::initSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex) 401 { 402 assert (m_isInitialized); 403 assert (seiChromaSamplingFilterHint!=NULL); 404 405 seiChromaSamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex; 406 seiChromaSamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex; 407 seiChromaSamplingFilterHint->m_verFilteringProcessFlag = 1; 408 seiChromaSamplingFilterHint->m_targetFormatIdc = 3; 409 seiChromaSamplingFilterHint->m_perfectReconstructionFlag = false; 410 if(seiChromaSamplingFilterHint->m_verChromaFilterIdc == 1) 411 { 412 seiChromaSamplingFilterHint->m_numVerticalFilters = 1; 413 seiChromaSamplingFilterHint->m_verTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int)); 414 seiChromaSamplingFilterHint->m_verFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int*)); 415 for(Int i = 0; i < seiChromaSamplingFilterHint->m_numVerticalFilters; i ++) 416 { 417 seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] = 0; 418 seiChromaSamplingFilterHint->m_verFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] * sizeof(Int)); 419 for(Int j = 0; j < seiChromaSamplingFilterHint->m_verTapLengthMinus1[i]; j ++) 420 { 421 seiChromaSamplingFilterHint->m_verFilterCoeff[i][j] = 0; 422 } 423 } 404 template <typename T> 405 static Void readTokenValue(T &returnedValue, /// value returned 406 Bool &failed, /// used and updated 407 std::istream &is, /// stream to read token from 408 const TChar *pToken) /// token string 409 { 410 returnedValue=T(); 411 if (failed) 412 { 413 return; 414 } 415 416 Int c; 417 // Ignore any whitespace 418 while ((c=is.get())!=EOF && isspace(c)); 419 // test for comment mark 420 while (c=='#') 421 { 422 // Ignore to the end of the line 423 while ((c=is.get())!=EOF && (c!=10 && c!=13)); 424 // Ignore any white space at the start of the next line 425 while ((c=is.get())!=EOF && isspace(c)); 426 } 427 // test first character of token 428 failed=(c!=pToken[0]); 429 // test remaining characters of token 430 Int pos; 431 for(pos=1;!failed && pToken[pos]!=0 && is.get()==pToken[pos]; pos++); 432 failed|=(pToken[pos]!=0); 433 // Ignore any whitespace before the ':' 434 while (!failed && (c=is.get())!=EOF && isspace(c)); 435 failed|=(c!=':'); 436 // Now read the value associated with the token: 437 if (!failed) 438 { 439 is >> returnedValue; 440 failed=!is.good(); 441 if (!failed) 442 { 443 c=is.get(); 444 failed=(c!=EOF && !isspace(c)); 445 } 446 } 447 if (failed) 448 { 449 std::cerr << "Unable to read token '" << pToken << "'\n"; 450 } 451 } 452 453 template <typename T> 454 static Void readTokenValueAndValidate(T &returnedValue, /// value returned 455 Bool &failed, /// used and updated 456 std::istream &is, /// stream to read token from 457 const TChar *pToken, /// token string 458 const T &minInclusive, /// minimum value allowed, inclusive 459 const T &maxInclusive) /// maximum value allowed, inclusive 460 { 461 readTokenValue(returnedValue, failed, is, pToken); 462 if (!failed) 463 { 464 if (returnedValue<minInclusive || returnedValue>maxInclusive) 465 { 466 failed=true; 467 std::cerr << "Value for token " << pToken << " must be in the range " << minInclusive << " to " << maxInclusive << " (inclusive); value read: " << returnedValue << std::endl; 468 } 469 } 470 } 471 472 // Bool version does not have maximum and minimum values. 473 static Void readTokenValueAndValidate(Bool &returnedValue, /// value returned 474 Bool &failed, /// used and updated 475 std::istream &is, /// stream to read token from 476 const TChar *pToken) /// token string 477 { 478 readTokenValue(returnedValue, failed, is, pToken); 479 } 480 481 Bool SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo* seiColourRemappingInfo, Int currPOC) // returns true on success, false on failure. 482 { 483 assert (m_isInitialized); 484 assert (seiColourRemappingInfo!=NULL); 485 486 // reading external Colour Remapping Information SEI message parameters from file 487 if( !m_pcCfg->getColourRemapInfoSEIFileRoot().empty()) 488 { 489 Bool failed=false; 490 491 // building the CRI file name with poc num in prefix "_poc.txt" 492 std::string colourRemapSEIFileWithPoc(m_pcCfg->getColourRemapInfoSEIFileRoot()); 493 { 494 std::stringstream suffix; 495 suffix << "_" << currPOC << ".txt"; 496 colourRemapSEIFileWithPoc+=suffix.str(); 497 } 498 499 std::ifstream fic(colourRemapSEIFileWithPoc.c_str()); 500 if (!fic.good() || !fic.is_open()) 501 { 502 std::cerr << "No Colour Remapping Information SEI parameters file " << colourRemapSEIFileWithPoc << " for POC " << currPOC << std::endl; 503 return false; 504 } 505 506 // TODO: identify and remove duplication with decoder parsing through abstraction. 507 508 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapId, failed, fic, "colour_remap_id", UInt(0), UInt(0x7fffffff) ); 509 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCancelFlag, failed, fic, "colour_remap_cancel_flag" ); 510 if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) 511 { 512 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPersistenceFlag, failed, fic, "colour_remap_persistence_flag" ); 513 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag, failed, fic, "colour_remap_video_signal_info_present_flag"); 514 if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) 515 { 516 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapFullRangeFlag, failed, fic, "colour_remap_full_range_flag" ); 517 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPrimaries, failed, fic, "colour_remap_primaries", Int(0), Int(255) ); 518 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapTransferFunction, failed, fic, "colour_remap_transfer_function", Int(0), Int(255) ); 519 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixCoefficients, failed, fic, "colour_remap_matrix_coefficients", Int(0), Int(255) ); 520 } 521 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapInputBitDepth, failed, fic, "colour_remap_input_bit_depth", Int(8), Int(16) ); 522 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapBitDepth, failed, fic, "colour_remap_bit_depth", Int(8), Int(16) ); 523 524 const Int maximumInputValue = (1 << (((seiColourRemappingInfo->m_colourRemapInputBitDepth + 7) >> 3) << 3)) - 1; 525 const Int maximumRemappedValue = (1 << (((seiColourRemappingInfo->m_colourRemapBitDepth + 7) >> 3) << 3)) - 1; 526 527 for( Int c=0 ; c<3 ; c++ ) 528 { 529 readTokenValueAndValidate(seiColourRemappingInfo->m_preLutNumValMinus1[c], failed, fic, "pre_lut_num_val_minus1[c]", Int(0), Int(32) ); 530 if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) 531 { 532 seiColourRemappingInfo->m_preLut[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); 533 for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++ ) 534 { 535 readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].codedValue, failed, fic, "pre_lut_coded_value[c][i]", Int(0), maximumInputValue ); 536 readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].targetValue, failed, fic, "pre_lut_target_value[c][i]", Int(0), maximumRemappedValue ); 537 } 538 } 539 } 540 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixPresentFlag, failed, fic, "colour_remap_matrix_present_flag" ); 541 if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) 542 { 543 readTokenValueAndValidate(seiColourRemappingInfo->m_log2MatrixDenom, failed, fic, "log2_matrix_denom", Int(0), Int(15) ); 544 for( Int c=0 ; c<3 ; c++ ) 545 { 546 for( Int i=0 ; i<3 ; i++ ) 547 { 548 readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCoeffs[c][i], failed, fic, "colour_remap_coeffs[c][i]", -32768, 32767 ); 549 } 550 } 551 } 552 for( Int c=0 ; c<3 ; c++ ) 553 { 554 readTokenValueAndValidate(seiColourRemappingInfo->m_postLutNumValMinus1[c], failed, fic, "post_lut_num_val_minus1[c]", Int(0), Int(32) ); 555 if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) 556 { 557 seiColourRemappingInfo->m_postLut[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); 558 for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++ ) 559 { 560 readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].codedValue, failed, fic, "post_lut_coded_value[c][i]", Int(0), maximumRemappedValue ); 561 readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].targetValue, failed, fic, "post_lut_target_value[c][i]", Int(0), maximumRemappedValue ); 562 } 563 } 564 } 565 } 566 567 if( failed ) 568 { 569 std::cerr << "Error while reading Colour Remapping Information SEI parameters file '" << colourRemapSEIFileWithPoc << "'" << std::endl; 570 exit(EXIT_FAILURE); 571 } 572 } 573 return true; 574 } 575 576 577 Void SEIEncoder::initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex) 578 { 579 assert (m_isInitialized); 580 assert (seiChromaResamplingFilterHint!=NULL); 581 582 seiChromaResamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex; 583 seiChromaResamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex; 584 seiChromaResamplingFilterHint->m_verFilteringFieldProcessingFlag = 1; 585 seiChromaResamplingFilterHint->m_targetFormatIdc = 3; 586 seiChromaResamplingFilterHint->m_perfectReconstructionFlag = false; 587 588 // this creates some example filter values, if explicit filter definition is selected 589 if (seiChromaResamplingFilterHint->m_verChromaFilterIdc == 1) 590 { 591 const Int numVerticalFilters = 3; 592 const Int verTapLengthMinus1[] = {5,3,3}; 593 594 seiChromaResamplingFilterHint->m_verFilterCoeff.resize(numVerticalFilters); 595 for(Int i = 0; i < numVerticalFilters; i ++) 596 { 597 seiChromaResamplingFilterHint->m_verFilterCoeff[i].resize(verTapLengthMinus1[i]+1); 598 } 599 // Note: C++11 -> seiChromaResamplingFilterHint->m_verFilterCoeff[0] = {-3,13,31,23,3,-3}; 600 seiChromaResamplingFilterHint->m_verFilterCoeff[0][0] = -3; 601 seiChromaResamplingFilterHint->m_verFilterCoeff[0][1] = 13; 602 seiChromaResamplingFilterHint->m_verFilterCoeff[0][2] = 31; 603 seiChromaResamplingFilterHint->m_verFilterCoeff[0][3] = 23; 604 seiChromaResamplingFilterHint->m_verFilterCoeff[0][4] = 3; 605 seiChromaResamplingFilterHint->m_verFilterCoeff[0][5] = -3; 606 607 seiChromaResamplingFilterHint->m_verFilterCoeff[1][0] = -1; 608 seiChromaResamplingFilterHint->m_verFilterCoeff[1][1] = 25; 609 seiChromaResamplingFilterHint->m_verFilterCoeff[1][2] = 247; 610 seiChromaResamplingFilterHint->m_verFilterCoeff[1][3] = -15; 611 612 seiChromaResamplingFilterHint->m_verFilterCoeff[2][0] = -20; 613 seiChromaResamplingFilterHint->m_verFilterCoeff[2][1] = 186; 614 seiChromaResamplingFilterHint->m_verFilterCoeff[2][2] = 100; 615 seiChromaResamplingFilterHint->m_verFilterCoeff[2][3] = -10; 424 616 } 425 617 else 426 618 { 427 seiChromaSamplingFilterHint->m_numVerticalFilters = 0; 428 seiChromaSamplingFilterHint->m_verTapLengthMinus1 = NULL; 429 seiChromaSamplingFilterHint->m_verFilterCoeff = NULL; 430 } 431 if(seiChromaSamplingFilterHint->m_horChromaFilterIdc == 1) 432 { 433 seiChromaSamplingFilterHint->m_numHorizontalFilters = 1; 434 seiChromaSamplingFilterHint->m_horTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int)); 435 seiChromaSamplingFilterHint->m_horFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int*)); 436 for(Int i = 0; i < seiChromaSamplingFilterHint->m_numHorizontalFilters; i ++) 437 { 438 seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] = 0; 439 seiChromaSamplingFilterHint->m_horFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] * sizeof(Int)); 440 for(Int j = 0; j < seiChromaSamplingFilterHint->m_horTapLengthMinus1[i]; j ++) 441 { 442 seiChromaSamplingFilterHint->m_horFilterCoeff[i][j] = 0; 443 } 444 } 619 seiChromaResamplingFilterHint->m_verFilterCoeff.resize(0); 620 } 621 622 if (seiChromaResamplingFilterHint->m_horChromaFilterIdc == 1) 623 { 624 Int const numHorizontalFilters = 1; 625 const Int horTapLengthMinus1[] = {3}; 626 627 seiChromaResamplingFilterHint->m_horFilterCoeff.resize(numHorizontalFilters); 628 for(Int i = 0; i < numHorizontalFilters; i ++) 629 { 630 seiChromaResamplingFilterHint->m_horFilterCoeff[i].resize(horTapLengthMinus1[i]+1); 631 } 632 seiChromaResamplingFilterHint->m_horFilterCoeff[0][0] = 1; 633 seiChromaResamplingFilterHint->m_horFilterCoeff[0][1] = 6; 634 seiChromaResamplingFilterHint->m_horFilterCoeff[0][2] = 1; 445 635 } 446 636 else 447 637 { 448 seiChromaSamplingFilterHint->m_numHorizontalFilters = 0; 449 seiChromaSamplingFilterHint->m_horTapLengthMinus1 = NULL; 450 seiChromaSamplingFilterHint->m_horFilterCoeff = NULL; 638 seiChromaResamplingFilterHint->m_horFilterCoeff.resize(0); 451 639 } 452 640 } -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/SEIEncoder.h
r1356 r1360 79 79 Void initSEITempMotionConstrainedTileSets (SEITempMotionConstrainedTileSets *sei, const TComPPS *pps); 80 80 Void initSEIKneeFunctionInfo(SEIKneeFunctionInfo *sei); 81 Void initSEIChroma SamplingFilterHint(SEIChromaSamplingFilterHint *sei, Int iHorFilterIndex, Int iVerFilterIndex);81 Void initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *sei, Int iHorFilterIndex, Int iVerFilterIndex); 82 82 Void initSEITimeCode(SEITimeCode *sei); 83 Bool initSEIColourRemappingInfo(SEIColourRemappingInfo *sei, Int currPOC); // returns true on success, false on failure. 83 84 84 85 // trailing SEIs -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/SEIwrite.cpp
r1356 r1360 106 106 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); 107 107 break; 108 case SEI::CHROMA_ SAMPLING_FILTER_HINT:109 xWriteSEIChroma SamplingFilterHint(*static_cast<const SEIChromaSamplingFilterHint*>(&sei)/*, sps*/);108 case SEI::CHROMA_RESAMPLING_FILTER_HINT: 109 xWriteSEIChromaResamplingFilterHint(*static_cast<const SEIChromaResamplingFilterHint*>(&sei)); 110 110 break; 111 111 case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: … … 117 117 case SEI::KNEE_FUNCTION_INFO: 118 118 xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei)); 119 break; 120 case SEI::COLOUR_REMAPPING_INFO: 121 xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei)); 119 122 break; 120 123 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: … … 189 192 190 193 default: 191 assert(!" Unhandled SEI message");194 assert(!"Trying to write unhandled SEI message"); 192 195 break; 193 196 } … … 277 280 Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei) 278 281 { 279 const Char *traceString="\0";282 const TChar *traceString="\0"; 280 283 switch (sei.method) 281 284 { 282 case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break;283 case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break;284 case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break;285 case HASHTYPE_MD5: traceString="picture_md5"; break; 286 case HASHTYPE_CRC: traceString="picture_crc"; break; 287 case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break; 285 288 default: assert(false); break; 286 289 } … … 726 729 } 727 730 728 Void SEIWriter::xWriteSEIChroma SamplingFilterHint(const SEIChromaSamplingFilterHint &sei/*, TComSPS* sps*/)731 Void SEIWriter::xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint &sei) 729 732 { 730 733 WRITE_CODE(sei.m_verChromaFilterIdc, 8, "ver_chroma_filter_idc"); 731 734 WRITE_CODE(sei.m_horChromaFilterIdc, 8, "hor_chroma_filter_idc"); 732 WRITE_FLAG(sei.m_verFiltering ProcessFlag, "ver_filtering_process_flag");735 WRITE_FLAG(sei.m_verFilteringFieldProcessingFlag, "ver_filtering_field_processing_flag"); 733 736 if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) 734 737 { 735 writeUserDefinedCoefficients(sei); 736 } 737 } 738 739 // write hardcoded chroma filter coefficients in the SEI messages 740 Void SEIWriter::writeUserDefinedCoefficients(const SEIChromaSamplingFilterHint &sei) 741 { 742 Int const iNumVerticalFilters = 3; 743 Int verticalTapLength_minus1[iNumVerticalFilters] = {5,3,3}; 744 Int* userVerticalCoefficients[iNumVerticalFilters]; 745 for(Int i = 0; i < iNumVerticalFilters; i ++) 746 { 747 userVerticalCoefficients[i] = (Int*)malloc( (verticalTapLength_minus1[i]+1) * sizeof(Int)); 748 } 749 userVerticalCoefficients[0][0] = -3; 750 userVerticalCoefficients[0][1] = 13; 751 userVerticalCoefficients[0][2] = 31; 752 userVerticalCoefficients[0][3] = 23; 753 userVerticalCoefficients[0][4] = 3; 754 userVerticalCoefficients[0][5] = -3; 755 756 userVerticalCoefficients[1][0] = -1; 757 userVerticalCoefficients[1][1] = 25; 758 userVerticalCoefficients[1][2] = 247; 759 userVerticalCoefficients[1][3] = -15; 760 761 userVerticalCoefficients[2][0] = -20; 762 userVerticalCoefficients[2][1] = 186; 763 userVerticalCoefficients[2][2] = 100; 764 userVerticalCoefficients[2][3] = -10; 765 766 Int const iNumHorizontalFilters = 1; 767 Int horizontalTapLength_minus1[iNumHorizontalFilters] = {3}; 768 Int* userHorizontalCoefficients[iNumHorizontalFilters]; 769 for(Int i = 0; i < iNumHorizontalFilters; i ++) 770 { 771 userHorizontalCoefficients[i] = (Int*)malloc( (horizontalTapLength_minus1[i]+1) * sizeof(Int)); 772 } 773 userHorizontalCoefficients[0][0] = 1; 774 userHorizontalCoefficients[0][1] = 6; 775 userHorizontalCoefficients[0][2] = 1; 776 777 WRITE_UVLC(3, "target_format_idc"); 778 if(sei.m_verChromaFilterIdc == 1) 779 { 780 WRITE_UVLC(iNumVerticalFilters, "num_vertical_filters"); 781 if(iNumVerticalFilters > 0) 782 { 783 for(Int i = 0; i < iNumVerticalFilters; i ++) 784 { 785 WRITE_UVLC(verticalTapLength_minus1[i], "ver_tap_length_minus_1"); 786 for(Int j = 0; j < verticalTapLength_minus1[i]; j ++) 787 { 788 WRITE_SVLC(userVerticalCoefficients[i][j], "ver_filter_coeff"); 789 } 790 } 791 } 792 } 793 if(sei.m_horChromaFilterIdc == 1) 794 { 795 WRITE_UVLC(iNumHorizontalFilters, "num_horizontal_filters"); 796 if(iNumHorizontalFilters > 0) 797 { 798 for(Int i = 0; i < iNumHorizontalFilters; i ++) 799 { 800 WRITE_UVLC(horizontalTapLength_minus1[i], "hor_tap_length_minus_1"); 801 for(Int j = 0; j < horizontalTapLength_minus1[i]; j ++) 802 { 803 WRITE_SVLC(userHorizontalCoefficients[i][j], "hor_filter_coeff"); 804 } 805 } 806 } 807 } 808 } 809 738 WRITE_UVLC(sei.m_targetFormatIdc, "target_format_idc"); 739 if(sei.m_verChromaFilterIdc == 1) 740 { 741 const Int numVerticalFilter = (Int)sei.m_verFilterCoeff.size(); 742 WRITE_UVLC(numVerticalFilter, "num_vertical_filters"); 743 if(numVerticalFilter > 0) 744 { 745 for(Int i = 0; i < numVerticalFilter; i ++) 746 { 747 const Int verTapLengthMinus1 = (Int) sei.m_verFilterCoeff[i].size() - 1; 748 WRITE_UVLC(verTapLengthMinus1, "ver_tap_length_minus_1"); 749 for(Int j = 0; j < (verTapLengthMinus1 + 1); j ++) 750 { 751 WRITE_SVLC(sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); 752 } 753 } 754 } 755 } 756 if(sei.m_horChromaFilterIdc == 1) 757 { 758 const Int numHorizontalFilter = (Int) sei.m_horFilterCoeff.size(); 759 WRITE_UVLC(numHorizontalFilter, "num_horizontal_filters"); 760 if(numHorizontalFilter > 0) 761 { 762 for(Int i = 0; i < numHorizontalFilter; i ++) 763 { 764 const Int horTapLengthMinus1 = (Int) sei.m_horFilterCoeff[i].size() - 1; 765 WRITE_UVLC(horTapLengthMinus1, "hor_tap_length_minus_1"); 766 for(Int j = 0; j < (horTapLengthMinus1 + 1); j ++) 767 { 768 WRITE_SVLC(sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); 769 } 770 } 771 } 772 } 773 } 774 } 810 775 #if NH_MV 811 776 #if !NH_MV_SEI … … 849 814 } 850 815 816 Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei) 817 { 818 WRITE_UVLC( sei.m_colourRemapId, "colour_remap_id" ); 819 WRITE_FLAG( sei.m_colourRemapCancelFlag, "colour_remap_cancel_flag" ); 820 if( !sei.m_colourRemapCancelFlag ) 821 { 822 WRITE_FLAG( sei.m_colourRemapPersistenceFlag, "colour_remap_persistence_flag" ); 823 WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag, "colour_remap_video_signal_info_present_flag" ); 824 if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) 825 { 826 WRITE_FLAG( sei.m_colourRemapFullRangeFlag, "colour_remap_full_range_flag" ); 827 WRITE_CODE( sei.m_colourRemapPrimaries, 8, "colour_remap_primaries" ); 828 WRITE_CODE( sei.m_colourRemapTransferFunction, 8, "colour_remap_transfer_function" ); 829 WRITE_CODE( sei.m_colourRemapMatrixCoefficients, 8, "colour_remap_matrix_coefficients" ); 830 } 831 WRITE_CODE( sei.m_colourRemapInputBitDepth, 8, "colour_remap_input_bit_depth" ); 832 WRITE_CODE( sei.m_colourRemapBitDepth, 8, "colour_remap_bit_depth" ); 833 for( Int c=0 ; c<3 ; c++ ) 834 { 835 WRITE_CODE( sei.m_preLutNumValMinus1[c], 8, "pre_lut_num_val_minus1[c]" ); 836 if( sei.m_preLutNumValMinus1[c]>0 ) 837 { 838 for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 839 { 840 WRITE_CODE( sei.m_preLut[c][i].codedValue, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" ); 841 WRITE_CODE( sei.m_preLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" ); 842 } 843 } 844 } 845 WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag, "colour_remap_matrix_present_flag" ); 846 if( sei.m_colourRemapMatrixPresentFlag ) 847 { 848 WRITE_CODE( sei.m_log2MatrixDenom, 4, "log2_matrix_denom" ); 849 for( Int c=0 ; c<3 ; c++ ) 850 { 851 for( Int i=0 ; i<3 ; i++ ) 852 { 853 WRITE_SVLC( sei.m_colourRemapCoeffs[c][i], "colour_remap_coeffs[c][i]" ); 854 } 855 } 856 } 857 858 for( Int c=0 ; c<3 ; c++ ) 859 { 860 WRITE_CODE( sei.m_postLutNumValMinus1[c], 8, "m_postLutNumValMinus1[c]" ); 861 if( sei.m_postLutNumValMinus1[c]>0 ) 862 { 863 for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 864 { 865 WRITE_CODE( sei.m_postLut[c][i].codedValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" ); 866 WRITE_CODE( sei.m_postLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" ); 867 } 868 } 869 } 870 } 871 } 851 872 852 873 Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei) … … 863 884 WRITE_CODE( sei.values.whitePoint[0], 16, "white_point_x" ); 864 885 WRITE_CODE( sei.values.whitePoint[1], 16, "white_point_y" ); 865 886 866 887 WRITE_CODE( sei.values.maxLuminance, 32, "max_display_mastering_luminance" ); 867 888 WRITE_CODE( sei.values.minLuminance, 32, "min_display_mastering_luminance" ); … … 881 902 } 882 903 904 883 905 #if NH_MV_LAYERS_NOT_PRESENT_SEI 884 906 Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei) … … 892 914 #endif 893 915 894 895 916 #if NH_MV 896 917 Void SEIWriter::xWriteSEIInterLayerConstrainedTileSets( const SEIInterLayerConstrainedTileSets& sei) 897 918 { … … 927 948 } 928 949 }; 950 #endif 929 951 930 952 #if NH_MV_SEI_TBD … … 1067 1089 } 1068 1090 }; 1091 1069 1092 1070 1093 Void SEIWriter::xWriteSEITemporalMvPredictionConstraints( const SEITemporalMvPredictionConstraints& sei) -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/SEIwrite.h
r1356 r1360 53 53 54 54 protected: 55 Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, const TComSPS *sps);56 55 Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei); 57 56 Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei); … … 60 59 Void xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps); 61 60 Void xWriteSEIPictureTiming(const SEIPictureTiming& sei, const TComSPS *sps); 62 TComSPS *m_pSPS;63 61 Void xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei); 64 62 Void xWriteSEIFramePacking(const SEIFramePacking& sei); … … 78 76 Void xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei); 79 77 Void xWriteSEITimeCode(const SEITimeCode& sei); 80 Void xWriteSEIChromaSamplingFilterHint(const SEIChromaSamplingFilterHint& sei/*, TComSPS *sps*/); 81 Void writeUserDefinedCoefficients(const SEIChromaSamplingFilterHint& sei); 78 Void xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint& sei); 82 79 Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei); 80 Void xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei); 83 81 Void xWriteSEIMasteringDisplayColourVolume( const SEIMasteringDisplayColourVolume& sei); 84 82 … … 110 108 Void xWriteSEIAlternativeDepthInfo ( const SEIAlternativeDepthInfo& sei); 111 109 #endif 110 Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, const TComSPS *sps); 112 111 Void xWriteByteAlign(); 113 112 }; -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/SyntaxElementWriter.cpp
r1356 r1360 44 44 #if ENC_DEC_TRACE 45 45 46 Void SyntaxElementWriter::xWriteCodeTr (UInt value, UInt length, const Char *pSymbolName)46 Void SyntaxElementWriter::xWriteCodeTr (UInt value, UInt length, const TChar *pSymbolName) 47 47 { 48 48 xWriteCode (value,length); … … 70 70 } 71 71 72 Void SyntaxElementWriter::xWriteUvlcTr (UInt value, const Char *pSymbolName)72 Void SyntaxElementWriter::xWriteUvlcTr (UInt value, const TChar *pSymbolName) 73 73 { 74 74 xWriteUvlc (value); … … 89 89 } 90 90 91 Void SyntaxElementWriter::xWriteSvlcTr (Int value, const Char *pSymbolName)91 Void SyntaxElementWriter::xWriteSvlcTr (Int value, const TChar *pSymbolName) 92 92 { 93 93 xWriteSvlc(value); … … 108 108 } 109 109 110 Void SyntaxElementWriter::xWriteFlagTr(UInt value, const Char *pSymbolName)110 Void SyntaxElementWriter::xWriteFlagTr(UInt value, const TChar *pSymbolName) 111 111 { 112 112 xWriteFlag(value); … … 127 127 } 128 128 129 #if H_MV_ENC_DEC_TRAC 129 130 Void SyntaxElementWriter::xWriteStringTr( UChar* value, UInt length, const Char *pSymbolName) 130 131 { … … 136 137 } 137 138 } 138 139 #endif 139 140 #endif 140 141 … … 176 177 } 177 178 179 #if H_MV_ENC_DEC_TRAC 178 180 Void SyntaxElementWriter::xWriteString( UChar* sCode, UInt uiLength) 179 181 { … … 185 187 m_pcBitIf->write( 0, 8 ); //zero-termination byte 186 188 } 187 189 #endif 188 190 Void SyntaxElementWriter::xWriteRbspTrailingBits() 189 191 { -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/SyntaxElementWriter.h
r1356 r1360 56 56 #define WRITE_SVLC( value, name) xWriteSvlcTr ( value, name ) 57 57 #define WRITE_FLAG( value, name) xWriteFlagTr ( value, name ) 58 #if NH_MV 58 59 #define WRITE_STRING( value, length, name) xWriteStringTr( value, length, name ) 60 #endif 59 61 60 62 #else … … 64 66 #define WRITE_SVLC( value, name) xWriteSvlc ( value ) 65 67 #define WRITE_FLAG( value, name) xWriteFlag ( value ) 68 #if NH_MV 66 69 #define WRITE_STRING( value, length, name) xWriteString( value, length ) 67 70 #endif 68 71 #endif 69 72 … … 84 87 Void xWriteSvlc ( Int iCode ); 85 88 Void xWriteFlag ( UInt uiCode ); 89 #if NH_MV 86 90 Void xWriteString ( UChar* sCode, UInt uiLength); 91 #endif 87 92 #if ENC_DEC_TRACE 88 Void xWriteCodeTr ( UInt value, UInt length, const Char *pSymbolName); 89 Void xWriteUvlcTr ( UInt value, const Char *pSymbolName); 90 Void xWriteSvlcTr ( Int value, const Char *pSymbolName); 91 Void xWriteFlagTr ( UInt value, const Char *pSymbolName); 93 Void xWriteCodeTr ( UInt value, UInt length, const TChar *pSymbolName); 94 Void xWriteUvlcTr ( UInt value, const TChar *pSymbolName); 95 Void xWriteSvlcTr ( Int value, const TChar *pSymbolName); 96 Void xWriteFlagTr ( UInt value, const TChar *pSymbolName); 97 #if NH_MV 92 98 Void xWriteStringTr ( UChar* value, UInt length, const Char *pSymbolName); 99 #endif 93 100 #endif 94 101 Void xWriteRbspTrailingBits(); -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncAnalyze.h
r1313 r1360 137 137 138 138 139 Void printOut ( Char cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths )139 Void printOut ( TChar cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths ) 140 140 { 141 141 Double dFps = m_dFrmRate; //--CFG_KDY -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
r1321 r1360 246 246 if (g_debugCounter >= debugCabacBinTargetLine) 247 247 { 248 Char breakPointThis;248 UChar breakPointThis; 249 249 breakPointThis = 7; 250 250 } -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp
r1321 r1360 97 97 if (g_debugCounter >= debugEncoderSearchBinTargetLine) 98 98 { 99 Char breakPointThis;99 UChar breakPointThis; 100 100 breakPointThis = 7; 101 101 } -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r1321 r1360 69 69 fprintf( g_hTrace, "=========== Slice ===========\n"); 70 70 } 71 #endif 72 #endif 71 72 Void xTraceAccessUnitDelimiter () 73 { 74 fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n"); 75 } 76 77 #endif 78 #endif 79 80 Void AUDWriter::codeAUD(TComBitIf& bs, const Int pictureType) 81 { 82 #if ENC_DEC_TRACE 83 xTraceAccessUnitDelimiter(); 84 #endif 85 86 assert (pictureType < 3); 87 setBitstream(&bs); 88 WRITE_CODE(pictureType, 3, "pic_type"); 89 xWriteRbspTrailingBits(); 90 } 91 73 92 // ==================================================================================================================== 74 93 // Constructor / destructor / create / destroy … … 266 285 { 267 286 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 268 static const char *syntaxStrings[]={ "pps_range_extension_flag",287 static const TChar *syntaxStrings[]={ "pps_range_extension_flag", 269 288 "pps_multilayer_extension_flag", 270 289 "pps_extension_6bits[0]", … … 748 767 WRITE_UVLC( pcSPS->getSpsMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]" ); 749 768 #else 750 WRITE_UVLC( pcSPS->getMaxLatencyIncrease (i),"sps_max_latency_increase_plus1[i]" );769 WRITE_UVLC( pcSPS->getMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]" ); 751 770 #endif 752 771 if (!subLayerOrderingInfoPresentFlag) … … 858 877 { 859 878 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 860 static const char *syntaxStrings[]={ "sps_range_extension_flag",879 static const TChar *syntaxStrings[]={ "sps_range_extension_flag", 861 880 "sps_multilayer_extension_flag", 862 881 "sps_extension_6bits[0]", -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncCavlc.h
r1321 r1360 58 58 // ==================================================================================================================== 59 59 60 class AUDWriter : public SyntaxElementWriter 61 { 62 public: 63 AUDWriter() {}; 64 virtual ~AUDWriter() {}; 65 66 Void codeAUD(TComBitIf& bs, const Int pictureType); 67 }; 68 60 69 /// CAVLC encoder class 61 70 class TEncCavlc : public SyntaxElementWriter, public TEncEntropyIf -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncCfg.h
r1356 r1360 65 65 Bool m_refPic; 66 66 Int m_numRefPicsActive; 67 Char m_sliceType;67 SChar m_sliceType; 68 68 Int m_numRefPics; 69 69 Int m_referencePics[MAX_NUM_REF_PICS]; … … 137 137 Int m_framesToBeEncoded; 138 138 Double m_adLambdaModifier[ MAX_TLAYER ]; 139 std::vector<Double> m_adIntraLambdaModifier; 140 Double m_dIntraQpFactor; ///< Intra Q Factor. If negative, use a default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) )) 139 141 140 142 Bool m_printMSEBasedSequencePSNR; … … 174 176 Int m_aiPad[2]; 175 177 178 Bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units 176 179 177 180 Int m_iMaxRefPicNum; ///< this is used to mimic the sliding mechanism used by the decoder … … 206 209 //====== Motion search ======== 207 210 Bool m_bDisableIntraPUsInInterSlices; 208 Int m_iFastSearch; // 0:Full search 1:Diamond 2:PMVFAST211 MESearchMethod m_motionEstimationSearchMethod; 209 212 Int m_iSearchRange; // 0:Full frame 210 213 Int m_bipredSearchRange; 211 214 Bool m_bClipForBiPredMeEnabled; 212 215 Bool m_bFastMEAssumingSmootherMVEnabled; 216 Int m_minSearchWindow; 217 Bool m_bRestrictMESampling; 213 218 214 219 #if NH_MV … … 243 248 #endif 244 249 UInt m_rdPenalty; 245 Bool m_bUseFastEnc;250 FastInterSearchMode m_fastInterSearchMode; 246 251 Bool m_bUseEarlyCU; 247 252 Bool m_useFastDecisionForMerge; … … 289 294 std::vector<Int> m_tileRowHeight; 290 295 291 Int m_iWaveFrontSynchro;292 293 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message294 Intm_bufferingPeriodSEIEnabled;295 Intm_pictureTimingSEIEnabled;296 Intm_recoveryPointSEIEnabled;296 Bool m_entropyCodingSyncEnabledFlag; 297 298 HashType m_decodedPictureHashSEIType; 299 Bool m_bufferingPeriodSEIEnabled; 300 Bool m_pictureTimingSEIEnabled; 301 Bool m_recoveryPointSEIEnabled; 297 302 Bool m_toneMappingInfoSEIEnabled; 298 303 Int m_toneMapId; … … 322 327 Int* m_codedPivotValue; 323 328 Int* m_targetPivotValue; 324 Intm_framePackingSEIEnabled;329 Bool m_framePackingSEIEnabled; 325 330 Int m_framePackingSEIType; 326 331 Int m_framePackingSEIId; 327 332 Int m_framePackingSEIQuincunx; 328 333 Int m_framePackingSEIInterpretation; 329 Intm_segmentedRectFramePackingSEIEnabled;334 Bool m_segmentedRectFramePackingSEIEnabled; 330 335 Bool m_segmentedRectFramePackingSEICancel; 331 336 Int m_segmentedRectFramePackingSEIType; 332 337 Bool m_segmentedRectFramePackingSEIPersistence; 333 338 Int m_displayOrientationSEIAngle; 334 Intm_temporalLevel0IndexSEIEnabled;335 Intm_gradualDecodingRefreshInfoEnabled;339 Bool m_temporalLevel0IndexSEIEnabled; 340 Bool m_gradualDecodingRefreshInfoEnabled; 336 341 Int m_noDisplaySEITLayer; 337 Intm_decodingUnitInfoSEIEnabled;338 Intm_SOPDescriptionSEIEnabled;339 Intm_scalableNestingSEIEnabled;342 Bool m_decodingUnitInfoSEIEnabled; 343 Bool m_SOPDescriptionSEIEnabled; 344 Bool m_scalableNestingSEIEnabled; 340 345 Bool m_tmctsSEIEnabled; 341 346 Bool m_timeCodeSEIEnabled; … … 353 358 Int* m_kneeSEIInputKneePoint; 354 359 Int* m_kneeSEIOutputKneePoint; 360 std::string m_colourRemapSEIFileRoot; ///< SEI Colour Remapping File (initialized from external file) 355 361 TComSEIMasteringDisplay m_masteringDisplay; 356 362 #if NH_MV_SEI … … 360 366 Bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) 361 367 Bool m_useWeightedBiPred; //< Use of Bi-directional Weighting Prediction (B_SLICE) 368 WeightedPredictionMethod m_weightedPredictionMethod; 362 369 UInt m_log2ParallelMergeLevelMinus2; ///< Parallel merge estimation region 363 370 UInt m_maxNumMergeCand; ///< Maximum number of merge candidates 364 371 ScalingListMode m_useScalingListId; ///< Using quantization matrix i.e. 0=off, 1=default, 2=file. 365 Char* m_scalingListFile;///< quantization matrix file name372 std::string m_scalingListFileName; ///< quantization matrix file name 366 373 Int m_TMVPModeId; 367 374 Bool m_signHideFlag; … … 373 380 Int m_RCInitialQP; 374 381 Bool m_RCForceIntraQP; 382 #if U0132_TARGET_BITS_SATURATION 383 Bool m_RCCpbSaturationEnabled; 384 UInt m_RCCpbSize; 385 Double m_RCInitialCpbFullness; 386 #endif 375 387 376 388 #if KWU_RC_MADPRED_E0227 … … 398 410 Bool m_vuiParametersPresentFlag; ///< enable generation of VUI parameters 399 411 Bool m_aspectRatioInfoPresentFlag; ///< Signals whether aspect_ratio_idc is present 400 Bool m_chroma SamplingFilterHintEnabled;///< Signals whether chroma sampling filter hint data is present401 Int m_chroma SamplingHorFilterIdc;///< Specifies the Index of filter to use402 Int m_chroma SamplingVerFilterIdc;///< Specifies the Index of filter to use412 Bool m_chromaResamplingFilterHintEnabled; ///< Signals whether chroma sampling filter hint data is present 413 Int m_chromaResamplingHorFilterIdc; ///< Specifies the Index of filter to use 414 Int m_chromaResamplingVerFilterIdc; ///< Specifies the Index of filter to use 403 415 Int m_aspectRatioIdc; ///< aspect_ratio_idc 404 416 Int m_sarWidth; ///< horizontal size of the sample aspect ratio … … 606 618 //====== Motion search ======== 607 619 Void setDisableIntraPUsInInterSlices ( Bool b ) { m_bDisableIntraPUsInInterSlices = b; } 608 Void set FastSearch ( Int i ) { m_iFastSearch = i; }620 Void setMotionEstimationSearchMethod ( MESearchMethod e ) { m_motionEstimationSearchMethod = e; } 609 621 Void setSearchRange ( Int i ) { m_iSearchRange = i; } 610 622 Void setBipredSearchRange ( Int i ) { m_bipredSearchRange = i; } 611 623 Void setClipForBiPredMeEnabled ( Bool b ) { m_bClipForBiPredMeEnabled = b; } 612 624 Void setFastMEAssumingSmootherMVEnabled ( Bool b ) { m_bFastMEAssumingSmootherMVEnabled = b; } 625 Void setMinSearchWindow ( Int i ) { m_minSearchWindow = i; } 626 Void setRestrictMESampling ( Bool b ) { m_bRestrictMESampling = b; } 627 613 628 #if NH_MV 614 629 Void setUseDisparitySearchRangeRestriction ( Bool b ) { m_bUseDisparitySearchRangeRestriction = b; } … … 649 664 Int getSourceHeight () { return m_iSourceHeight; } 650 665 Int getFramesToBeEncoded () { return m_framesToBeEncoded; } 666 667 //====== Lambda Modifiers ======== 651 668 Void setLambdaModifier ( UInt uiIndex, Double dValue ) { m_adLambdaModifier[ uiIndex ] = dValue; } 652 669 Double getLambdaModifier ( UInt uiIndex ) const { return m_adLambdaModifier[ uiIndex ]; } 670 Void setIntraLambdaModifier ( const std::vector<Double> &dValue ) { m_adIntraLambdaModifier = dValue; } 671 const std::vector<Double>& getIntraLambdaModifier() const { return m_adIntraLambdaModifier; } 672 Void setIntraQpFactor ( Double dValue ) { m_dIntraQpFactor = dValue; } 673 Double getIntraQpFactor () const { return m_dIntraQpFactor; } 653 674 654 675 //==== Coding Structure ======== … … 662 683 Int getPad ( Int i ) { assert (i < 2 ); return m_aiPad[i]; } 663 684 685 Bool getAccessUnitDelimiter() const { return m_AccessUnitDelimiter; } 686 Void setAccessUnitDelimiter(Bool val){ m_AccessUnitDelimiter = val; } 687 664 688 //======== Transform ============= 665 689 UInt getQuadtreeTULog2MaxSize () const { return m_uiQuadtreeTULog2MaxSize; } … … 677 701 //==== Motion search ======== 678 702 Bool getDisableIntraPUsInInterSlices () const { return m_bDisableIntraPUsInInterSlices; } 679 Int getFastSearch () const { return m_iFastSearch; }703 MESearchMethod getMotionEstimationSearchMethod ( ) const { return m_motionEstimationSearchMethod; } 680 704 Int getSearchRange () const { return m_iSearchRange; } 681 705 Bool getClipForBiPredMeEnabled () const { return m_bClipForBiPredMeEnabled; } 682 706 Bool getFastMEAssumingSmootherMVEnabled ( ) const { return m_bFastMEAssumingSmootherMVEnabled; } 707 Int getMinSearchWindow () const { return m_minSearchWindow; } 708 Bool getRestrictMESampling () const { return m_bRestrictMESampling; } 709 683 710 #if NH_MV 684 711 Bool getUseDisparitySearchRangeRestriction () { return m_bUseDisparitySearchRangeRestriction; } … … 701 728 Void setUseSelectiveRDOQ ( Bool b ) { m_useSelectiveRDOQ = b; } 702 729 #endif 703 Void setRDpenalty ( UInt b ) { m_rdPenalty = b; }704 Void set UseFastEnc ( Bool b ) { m_bUseFastEnc = b; }730 Void setRDpenalty ( UInt u ) { m_rdPenalty = u; } 731 Void setFastInterSearchMode ( FastInterSearchMode m ) { m_fastInterSearchMode = m; } 705 732 Void setUseEarlyCU ( Bool b ) { m_bUseEarlyCU = b; } 706 733 Void setUseFastDecisionForMerge ( Bool b ) { m_useFastDecisionForMerge = b; } … … 729 756 #endif 730 757 Int getRDpenalty () { return m_rdPenalty; } 731 Bool getUseFastEnc () { return m_bUseFastEnc;}758 FastInterSearchMode getFastInterSearchMode() const{ return m_fastInterSearchMode; } 732 759 Bool getUseEarlyCU () { return m_bUseEarlyCU; } 733 760 Bool getUseFastDecisionForMerge () { return m_useFastDecisionForMerge; } … … 812 839 UInt getRowHeight ( UInt rowIdx ) { return m_tileRowHeight[rowIdx]; } 813 840 Void xCheckGSParameters(); 814 Void set WaveFrontSynchro(Int iWaveFrontSynchro) { m_iWaveFrontSynchro = iWaveFrontSynchro; }815 Int getWaveFrontsynchro() { return m_iWaveFrontSynchro; }816 Void setDecodedPictureHashSEI Enabled(Int b) { m_decodedPictureHashSEIEnabled = b; }817 Int getDecodedPictureHashSEIEnabled() { return m_decodedPictureHashSEIEnabled; }818 Void setBufferingPeriodSEIEnabled( Int b){ m_bufferingPeriodSEIEnabled = b; }819 Int getBufferingPeriodSEIEnabled(){ return m_bufferingPeriodSEIEnabled; }820 Void setPictureTimingSEIEnabled( Int b){ m_pictureTimingSEIEnabled = b; }821 Int getPictureTimingSEIEnabled(){ return m_pictureTimingSEIEnabled; }822 Void setRecoveryPointSEIEnabled( Int b){ m_recoveryPointSEIEnabled = b; }823 Int getRecoveryPointSEIEnabled(){ return m_recoveryPointSEIEnabled; }841 Void setEntropyCodingSyncEnabledFlag(Bool b) { m_entropyCodingSyncEnabledFlag = b; } 842 Bool getEntropyCodingSyncEnabledFlag() const { return m_entropyCodingSyncEnabledFlag; } 843 Void setDecodedPictureHashSEIType(HashType m) { m_decodedPictureHashSEIType = m; } 844 HashType getDecodedPictureHashSEIType() const { return m_decodedPictureHashSEIType; } 845 Void setBufferingPeriodSEIEnabled(Bool b) { m_bufferingPeriodSEIEnabled = b; } 846 Bool getBufferingPeriodSEIEnabled() const { return m_bufferingPeriodSEIEnabled; } 847 Void setPictureTimingSEIEnabled(Bool b) { m_pictureTimingSEIEnabled = b; } 848 Bool getPictureTimingSEIEnabled() const { return m_pictureTimingSEIEnabled; } 849 Void setRecoveryPointSEIEnabled(Bool b) { m_recoveryPointSEIEnabled = b; } 850 Bool getRecoveryPointSEIEnabled() const { return m_recoveryPointSEIEnabled; } 824 851 Void setToneMappingInfoSEIEnabled(Bool b) { m_toneMappingInfoSEIEnabled = b; } 825 852 Bool getToneMappingInfoSEIEnabled() { return m_toneMappingInfoSEIEnabled; } … … 876 903 Void setTMISEIExtendedWhiteLevelLumaCodeValue(Int b) { m_extendedWhiteLevelLumaCodeValue =b; } 877 904 Int getTMISEIExtendedWhiteLevelLumaCodeValue() { return m_extendedWhiteLevelLumaCodeValue; } 878 Void setFramePackingArrangementSEIEnabled( Int b){ m_framePackingSEIEnabled = b; }879 Int getFramePackingArrangementSEIEnabled(){ return m_framePackingSEIEnabled; }905 Void setFramePackingArrangementSEIEnabled(Bool b) { m_framePackingSEIEnabled = b; } 906 Bool getFramePackingArrangementSEIEnabled() const { return m_framePackingSEIEnabled; } 880 907 Void setFramePackingArrangementSEIType(Int b) { m_framePackingSEIType = b; } 881 908 Int getFramePackingArrangementSEIType() { return m_framePackingSEIType; } … … 886 913 Void setFramePackingArrangementSEIInterpretation(Int b) { m_framePackingSEIInterpretation = b; } 887 914 Int getFramePackingArrangementSEIInterpretation() { return m_framePackingSEIInterpretation; } 888 Void setSegmentedRectFramePackingArrangementSEIEnabled( Int b){ m_segmentedRectFramePackingSEIEnabled = b; }889 Int getSegmentedRectFramePackingArrangementSEIEnabled(){ return m_segmentedRectFramePackingSEIEnabled; }915 Void setSegmentedRectFramePackingArrangementSEIEnabled(Bool b) { m_segmentedRectFramePackingSEIEnabled = b; } 916 Bool getSegmentedRectFramePackingArrangementSEIEnabled() const { return m_segmentedRectFramePackingSEIEnabled; } 890 917 Void setSegmentedRectFramePackingArrangementSEICancel(Int b) { m_segmentedRectFramePackingSEICancel = b; } 891 918 Int getSegmentedRectFramePackingArrangementSEICancel() { return m_segmentedRectFramePackingSEICancel; } … … 896 923 Void setDisplayOrientationSEIAngle(Int b) { m_displayOrientationSEIAngle = b; } 897 924 Int getDisplayOrientationSEIAngle() { return m_displayOrientationSEIAngle; } 898 Void setTemporalLevel0IndexSEIEnabled( Int b){ m_temporalLevel0IndexSEIEnabled = b; }899 Int getTemporalLevel0IndexSEIEnabled(){ return m_temporalLevel0IndexSEIEnabled; }900 Void setGradualDecodingRefreshInfoEnabled( Int b){ m_gradualDecodingRefreshInfoEnabled = b; }901 Int getGradualDecodingRefreshInfoEnabled(){ return m_gradualDecodingRefreshInfoEnabled; }925 Void setTemporalLevel0IndexSEIEnabled(Bool b) { m_temporalLevel0IndexSEIEnabled = b; } 926 Bool getTemporalLevel0IndexSEIEnabled() const { return m_temporalLevel0IndexSEIEnabled; } 927 Void setGradualDecodingRefreshInfoEnabled(Bool b) { m_gradualDecodingRefreshInfoEnabled = b; } 928 Bool getGradualDecodingRefreshInfoEnabled() const { return m_gradualDecodingRefreshInfoEnabled; } 902 929 Void setNoDisplaySEITLayer(Int b) { m_noDisplaySEITLayer = b; } 903 930 Int getNoDisplaySEITLayer() { return m_noDisplaySEITLayer; } 904 Void setDecodingUnitInfoSEIEnabled( Int b){ m_decodingUnitInfoSEIEnabled = b; }905 Int getDecodingUnitInfoSEIEnabled(){ return m_decodingUnitInfoSEIEnabled; }906 Void setSOPDescriptionSEIEnabled( Int b){ m_SOPDescriptionSEIEnabled = b; }907 Int getSOPDescriptionSEIEnabled(){ return m_SOPDescriptionSEIEnabled; }908 Void setScalableNestingSEIEnabled( Int b){ m_scalableNestingSEIEnabled = b; }909 Int getScalableNestingSEIEnabled(){ return m_scalableNestingSEIEnabled; }931 Void setDecodingUnitInfoSEIEnabled(Bool b) { m_decodingUnitInfoSEIEnabled = b; } 932 Bool getDecodingUnitInfoSEIEnabled() const { return m_decodingUnitInfoSEIEnabled; } 933 Void setSOPDescriptionSEIEnabled(Bool b) { m_SOPDescriptionSEIEnabled = b; } 934 Bool getSOPDescriptionSEIEnabled() const { return m_SOPDescriptionSEIEnabled; } 935 Void setScalableNestingSEIEnabled(Bool b) { m_scalableNestingSEIEnabled = b; } 936 Bool getScalableNestingSEIEnabled() const { return m_scalableNestingSEIEnabled; } 910 937 Void setTMCTSSEIEnabled(Bool b) { m_tmctsSEIEnabled = b; } 911 938 Bool getTMCTSSEIEnabled() { return m_tmctsSEIEnabled; } … … 939 966 Void setKneeSEIOutputKneePoint(Int *p) { m_kneeSEIOutputKneePoint = p; } 940 967 Int* getKneeSEIOutputKneePoint() { return m_kneeSEIOutputKneePoint; } 968 Void setColourRemapInfoSEIFileRoot( const std::string &s ) { m_colourRemapSEIFileRoot = s; } 969 const std::string &getColourRemapInfoSEIFileRoot() const { return m_colourRemapSEIFileRoot; } 970 941 971 Void setMasteringDisplaySEI(const TComSEIMasteringDisplay &src) { m_masteringDisplay = src; } 942 972 const TComSEIMasteringDisplay &getMasteringDisplaySEI() const { return m_masteringDisplay; } … … 984 1014 Void setUseScalingListId ( ScalingListMode u ) { m_useScalingListId = u; } 985 1015 ScalingListMode getUseScalingListId () { return m_useScalingListId; } 986 Void setScalingListFile ( Char* pch ) { m_scalingListFile = pch;}987 Char* getScalingListFile () { return m_scalingListFile;}1016 Void setScalingListFileName ( const std::string &s ) { m_scalingListFileName = s; } 1017 const std::string& getScalingListFileName () const { return m_scalingListFileName; } 988 1018 Void setTMVPModeId ( Int u ) { m_TMVPModeId = u; } 989 1019 Int getTMVPModeId () { return m_TMVPModeId; } 1020 WeightedPredictionMethod getWeightedPredictionMethod() const { return m_weightedPredictionMethod; } 1021 Void setWeightedPredictionMethod( WeightedPredictionMethod m ) { m_weightedPredictionMethod = m; } 990 1022 Void setSignHideFlag( Bool signHideFlag ) { m_signHideFlag = signHideFlag; } 991 1023 Bool getSignHideFlag() { return m_signHideFlag; } … … 1004 1036 Bool getForceIntraQP () { return m_RCForceIntraQP; } 1005 1037 Void setForceIntraQP ( Bool b ) { m_RCForceIntraQP = b; } 1038 1039 #if U0132_TARGET_BITS_SATURATION 1040 Bool getCpbSaturationEnabled() { return m_RCCpbSaturationEnabled;} 1041 Void setCpbSaturationEnabled( Bool b ) { m_RCCpbSaturationEnabled = b; } 1042 UInt getCpbSize () { return m_RCCpbSize;} 1043 Void setCpbSize ( UInt ui ) { m_RCCpbSize = ui; } 1044 Double getInitialCpbFullness () { return m_RCInitialCpbFullness; } 1045 Void setInitialCpbFullness (Double f) { m_RCInitialCpbFullness = f; } 1046 #endif 1006 1047 1007 1048 #if KWU_RC_MADPRED_E0227 … … 1132 1173 Bool getLowerBitRateConstraintFlag() const { return m_lowerBitRateConstraintFlag; } 1133 1174 Void setLowerBitRateConstraintFlag(Bool b) { m_lowerBitRateConstraintFlag=b; } 1134 Bool getChromaSamplingFilterHintEnabled() { return m_chromaSamplingFilterHintEnabled;}1135 Void setChromaSamplingFilterHintEnabled(Bool i) { m_chromaSamplingFilterHintEnabled = i;}1136 Int getChromaSamplingHorFilterIdc() { return m_chromaSamplingHorFilterIdc;}1137 Void setChromaSamplingHorFilterIdc(Int i) { m_chromaSamplingHorFilterIdc = i;}1138 Int getChromaSamplingVerFilterIdc() { return m_chromaSamplingVerFilterIdc;}1139 Void setChromaSamplingVerFilterIdc(Int i) { m_chromaSamplingVerFilterIdc = i;}1175 Bool getChromaResamplingFilterHintEnabled() { return m_chromaResamplingFilterHintEnabled;} 1176 Void setChromaResamplingFilterHintEnabled(Bool i) { m_chromaResamplingFilterHintEnabled = i;} 1177 Int getChromaResamplingHorFilterIdc() { return m_chromaResamplingHorFilterIdc;} 1178 Void setChromaResamplingHorFilterIdc(Int i) { m_chromaResamplingHorFilterIdc = i;} 1179 Int getChromaResamplingVerFilterIdc() { return m_chromaResamplingVerFilterIdc;} 1180 Void setChromaResamplingVerFilterIdc(Int i) { m_chromaResamplingVerFilterIdc = i;} 1140 1181 1141 1182 Void setSummaryOutFilename(const std::string &s) { m_summaryOutFilename = s; } -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncCu.cpp
r1321 r1360 2216 2216 *earlyDetectionSkipMode = true; 2217 2217 } 2218 else if(m_pcEncCfg->get FastSearch() !=SELECTIVE)2218 else if(m_pcEncCfg->getMotionEstimationSearchMethod() != MESEARCH_SELECTIVE) 2219 2219 { 2220 2220 Int absoulte_MV=0; -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1356 r1360 219 219 } 220 220 221 Void TEncGOP::xWriteAccessUnitDelimiter (AccessUnit &accessUnit, TComSlice *slice) 222 { 223 AUDWriter audWriter; 224 OutputNALUnit nalu(NAL_UNIT_ACCESS_UNIT_DELIMITER); 225 226 Int picType = slice->isIntra() ? 0 : (slice->isInterP() ? 1 : 2); 227 228 audWriter.codeAUD(nalu.m_Bitstream, picType); 229 accessUnit.push_front(new NALUnitEBSP(nalu)); 230 } 231 221 232 // write SEI list into one NAL unit and add it to the Access unit at auPos 222 233 Void TEncGOP::xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps) … … 485 496 } 486 497 498 if(m_pcCfg->getChromaResamplingFilterHintEnabled()) 499 { 500 SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint = new SEIChromaResamplingFilterHint; 501 m_seiEncoder.initSEIChromaResamplingFilterHint(seiChromaResamplingFilterHint, m_pcCfg->getChromaResamplingHorFilterIdc(), m_pcCfg->getChromaResamplingVerFilterIdc()); 502 seiMessages.push_back(seiChromaResamplingFilterHint); 503 } 504 505 487 506 #if NH_MV 488 507 #if !NH_MV_SEI … … 545 564 } 546 565 547 if(slice->getSPS()->getVuiParametersPresentFlag() && m_pcCfg->getChromaSamplingFilterHintEnabled() && ( slice->getSliceType() == I_SLICE ))548 {549 SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint = new SEIChromaSamplingFilterHint;550 m_seiEncoder.initSEIChromaSamplingFilterHint(seiChromaSamplingFilterHint, m_pcCfg->getChromaSamplingHorFilterIdc(), m_pcCfg->getChromaSamplingVerFilterIdc());551 seiMessages.push_back(seiChromaSamplingFilterHint);552 }553 554 566 if( m_pcEncTop->getNoDisplaySEITLayer() && ( slice->getTLayer() >= m_pcEncTop->getNoDisplaySEITLayer() ) ) 555 567 { … … 557 569 seiNoDisplay->m_noDisplay = true; 558 570 seiMessages.push_back(seiNoDisplay); 571 } 572 573 // insert one Colour Remapping Info SEI for the picture (if the file exists) 574 if (!m_pcCfg->getColourRemapInfoSEIFileRoot().empty()) 575 { 576 SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo(); 577 const Bool success = m_seiEncoder.initSEIColourRemappingInfo(seiColourRemappingInfo, slice->getPOC() ); 578 579 if(success) 580 { 581 seiMessages.push_back(seiColourRemappingInfo); 582 } 583 else 584 { 585 delete seiColourRemappingInfo; 586 } 559 587 } 560 588 } … … 577 605 Void TEncGOP::xCreatePictureTimingSEI (Int IRAPGOPid, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, TComSlice *slice, Bool isField, std::deque<DUData> &duData) 578 606 { 579 Int picSptDpbOutputDuDelay = 0;580 607 #if !NH_MV 581 608 SEIPictureTiming *pictureTimingSEI = new SEIPictureTiming(); … … 590 617 ( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) ) 591 618 { 592 #if NH_MV 593 // Preliminary fix to avoid memory leak. 619 Int picSptDpbOutputDuDelay = 0; 594 620 SEIPictureTiming *pictureTimingSEI = new SEIPictureTiming(); 595 #endif596 621 597 622 // DU parameters … … 712 737 } 713 738 } 739 740 if( !m_pcCfg->getPictureTimingSEIEnabled() && pictureTimingSEI ) 741 { 742 delete pictureTimingSEI; 743 } 714 744 } 715 745 } … … 745 775 746 776 // The last DU may have a trailing SEI 747 if (m_pcCfg->getDecodedPictureHashSEI Enabled())777 if (m_pcCfg->getDecodedPictureHashSEIType()!=HASHTYPE_NONE) 748 778 { 749 779 duData.back().accumBitsDU += ( 20 << 3 ); // probably around 20 bytes - should be further adjusted, e.g. by type … … 867 897 if (cabacZeroWordPaddingEnabled) 868 898 { 869 std::vector< Char> zeroBytesPadding(numberOfAdditionalCabacZeroBytes,Char(0));899 std::vector<UChar> zeroBytesPadding(numberOfAdditionalCabacZeroBytes, UChar(0)); 870 900 for(std::size_t i=0; i<numberOfAdditionalCabacZeroWords; i++) 871 901 { 872 902 zeroBytesPadding[i*3+2]=3; // 00 00 03 873 903 } 874 nalUnitData.write( &(zeroBytesPadding[0]), numberOfAdditionalCabacZeroBytes);904 nalUnitData.write(reinterpret_cast<const TChar*>(&(zeroBytesPadding[0])), numberOfAdditionalCabacZeroBytes); 875 905 printf("Adding %d bytes of padding\n", UInt(numberOfAdditionalCabacZeroWords*3)); 876 906 } … … 1058 1088 { 1059 1089 return 1; 1090 } 1091 } 1092 1093 1094 static Void 1095 printHash(const HashType hashType, const std::string &digestStr) 1096 { 1097 const TChar *decodedPictureHashModeName; 1098 switch (hashType) 1099 { 1100 case HASHTYPE_MD5: 1101 decodedPictureHashModeName = "MD5"; 1102 break; 1103 case HASHTYPE_CRC: 1104 decodedPictureHashModeName = "CRC"; 1105 break; 1106 case HASHTYPE_CHECKSUM: 1107 decodedPictureHashModeName = "Checksum"; 1108 break; 1109 default: 1110 decodedPictureHashModeName = NULL; 1111 break; 1112 } 1113 if (decodedPictureHashModeName != NULL) 1114 { 1115 if (digestStr.empty()) 1116 { 1117 printf(" [%s:%s]", decodedPictureHashModeName, "?"); 1118 } 1119 else 1120 { 1121 printf(" [%s:%s]", decodedPictureHashModeName, digestStr.c_str()); 1122 } 1060 1123 } 1061 1124 } … … 1606 1669 #endif 1607 1670 1608 /////////////////////////////////////////////////////////////////////////////////////////////////// Compress a slice 1609 // Slice compression 1610 if (m_pcCfg->getUseASR()) 1671 if (m_pcCfg->getUseASR() && pcSlice->getSliceType()!=I_SLICE) 1611 1672 { 1612 1673 m_pcSliceEncoder->setSearchRange(pcSlice); … … 1654 1715 } 1655 1716 m_pcRateCtrl->initRCPic( frameLevel ); 1717 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits(); 1656 1718 1657 1719 #if KWU_RC_MADPRED_E0227 … … 1662 1724 #endif 1663 1725 1664 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits(); 1726 #if U0132_TARGET_BITS_SATURATION 1727 if (m_pcRateCtrl->getCpbSaturationEnabled() && frameLevel != 0) 1728 { 1729 Int estimatedCpbFullness = m_pcRateCtrl->getCpbState() + m_pcRateCtrl->getBufferingRate(); 1730 1731 // prevent overflow 1732 if (estimatedCpbFullness - estimatedBits > (Int)(m_pcRateCtrl->getCpbSize()*0.9f)) 1733 { 1734 estimatedBits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.9f); 1735 } 1736 1737 estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate(); 1738 // prevent underflow 1739 if (estimatedCpbFullness - estimatedBits < (Int)(m_pcRateCtrl->getCpbSize()*0.1f)) 1740 { 1741 estimatedBits = max(200, estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.1f)); 1742 } 1743 1744 m_pcRateCtrl->getRCPic()->setTargetBits(estimatedBits); 1745 } 1746 #endif 1665 1747 1666 1748 Int sliceQP = m_pcCfg->getInitialQP(); … … 1683 1765 Int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits(); 1684 1766 bits = m_pcRateCtrl->getRCPic()->getRefineBitsForIntra( bits ); 1767 1768 #if U0132_TARGET_BITS_SATURATION 1769 if (m_pcRateCtrl->getCpbSaturationEnabled() ) 1770 { 1771 Int estimatedCpbFullness = m_pcRateCtrl->getCpbState() + m_pcRateCtrl->getBufferingRate(); 1772 1773 // prevent overflow 1774 if (estimatedCpbFullness - bits > (Int)(m_pcRateCtrl->getCpbSize()*0.9f)) 1775 { 1776 bits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.9f); 1777 } 1778 1779 estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate(); 1780 // prevent underflow 1781 if (estimatedCpbFullness - bits < (Int)(m_pcRateCtrl->getCpbSize()*0.1f)) 1782 { 1783 bits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.1f); 1784 } 1785 } 1786 #endif 1787 1685 1788 if ( bits < 200 ) 1686 1789 { … … 1835 1938 m_bSeqFirst = false; 1836 1939 } 1940 if (m_pcCfg->getAccessUnitDelimiter()) 1941 { 1942 xWriteAccessUnitDelimiter(accessUnit, pcSlice); 1943 } 1837 1944 1838 1945 // reset presence of BP SEI indication … … 2002 2109 2003 2110 std::string digestStr; 2004 if (m_pcCfg->getDecodedPictureHashSEI Enabled())2111 if (m_pcCfg->getDecodedPictureHashSEIType()!=HASHTYPE_NONE) 2005 2112 { 2006 2113 SEIDecodedPictureHash *decodedPictureHashSei = new SEIDecodedPictureHash(); … … 2014 2121 xCalculateAddPSNRs( isField, isTff, iGOPid, pcPic, accessUnit, rcListPic, dEncTime, snr_conversion, printFrameMSE ); 2015 2122 2016 if (!digestStr.empty()) 2017 { 2018 if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1) 2019 { 2020 printf(" [MD5:%s]", digestStr.c_str()); 2021 } 2022 else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 2) 2023 { 2024 printf(" [CRC:%s]", digestStr.c_str()); 2025 } 2026 else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 3) 2027 { 2028 printf(" [Checksum:%s]", digestStr.c_str()); 2029 } 2030 } 2123 printHash(m_pcCfg->getDecodedPictureHashSEIType(), digestStr); 2031 2124 2032 2125 if ( m_pcCfg->getUseRateCtrl() ) … … 2051 2144 m_pcRateCtrl->getRCGOP()->updateAfterPicture( estimatedBits ); 2052 2145 } 2146 #if U0132_TARGET_BITS_SATURATION 2147 if (m_pcRateCtrl->getCpbSaturationEnabled()) 2148 { 2149 m_pcRateCtrl->updateCpbState(actualTotalBits); 2150 printf(" [CPB %6d bits]", m_pcRateCtrl->getCpbState()); 2151 } 2152 #endif 2053 2153 } 2054 2154 … … 2352 2452 if (conversion!=IPCOLOURSPACE_UNCHANGED) 2353 2453 { 2354 cscd.create (pcPicD->getWidth(COMPONENT_Y), pcPicD->getHeight(COMPONENT_Y), pcPicD->getChromaFormat(), pcPicD->getWidth(COMPONENT_Y), pcPicD->getHeight(COMPONENT_Y), 0, false);2454 cscd.createWithoutCUInfo(pcPicD->getWidth(COMPONENT_Y), pcPicD->getHeight(COMPONENT_Y), pcPicD->getChromaFormat() ); 2355 2455 TVideoIOYuv::ColourSpaceConvert(*pcPicD, cscd, conversion, false); 2356 2456 } … … 2452 2552 } 2453 2553 2454 Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');2554 TChar c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); 2455 2555 if (!pcSlice->isReferenced()) 2456 2556 { … … 2506 2606 printf(" [ET %5.0f ]", dEncTime ); 2507 2607 2608 // printf(" [WP %d]", pcSlice->getUseWeightedPrediction()); 2609 2508 2610 for (Int iRefList = 0; iRefList < 2; iRefList++) 2509 2611 { … … 2555 2657 { 2556 2658 TComPicYuv &reconField=*(apcPicRecFields[fieldNum]); 2557 cscd[fieldNum].create (reconField.getWidth(COMPONENT_Y), reconField.getHeight(COMPONENT_Y), reconField.getChromaFormat(), reconField.getWidth(COMPONENT_Y), reconField.getHeight(COMPONENT_Y), 0, false);2659 cscd[fieldNum].createWithoutCUInfo(reconField.getWidth(COMPONENT_Y), reconField.getHeight(COMPONENT_Y), reconField.getChromaFormat() ); 2558 2660 TVideoIOYuv::ColourSpaceConvert(reconField, cscd[fieldNum], conversion, false); 2559 2661 apcPicRecFields[fieldNum]=cscd+fieldNum; -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncGOP.h
r1313 r1360 220 220 Double xCalculateRVM(); 221 221 222 Void xWriteAccessUnitDelimiter (AccessUnit &accessUnit, TComSlice *slice); 223 222 224 Void xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps); 223 225 Void xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice); -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncPreanalyzer.cpp
r1313 r1360 87 87 UInt64 uiSum[4] = {0, 0, 0, 0}; 88 88 UInt64 uiSumSq[4] = {0, 0, 0, 0}; 89 UInt uiNumPixInAQPart = 0;90 89 UInt by = 0; 91 90 for ( ; by < uiCurrAQPartHeight>>1; by++ ) 92 91 { 93 92 UInt bx = 0; 94 for ( ; bx < uiCurrAQPartWidth>>1; bx++ , uiNumPixInAQPart++)93 for ( ; bx < uiCurrAQPartWidth>>1; bx++ ) 95 94 { 96 95 uiSum [0] += pBlkY[bx]; 97 96 uiSumSq[0] += pBlkY[bx] * pBlkY[bx]; 98 97 } 99 for ( ; bx < uiCurrAQPartWidth; bx++ , uiNumPixInAQPart++)98 for ( ; bx < uiCurrAQPartWidth; bx++ ) 100 99 { 101 100 uiSum [1] += pBlkY[bx]; … … 107 106 { 108 107 UInt bx = 0; 109 for ( ; bx < uiCurrAQPartWidth>>1; bx++ , uiNumPixInAQPart++)108 for ( ; bx < uiCurrAQPartWidth>>1; bx++ ) 110 109 { 111 110 uiSum [2] += pBlkY[bx]; 112 111 uiSumSq[2] += pBlkY[bx] * pBlkY[bx]; 113 112 } 114 for ( ; bx < uiCurrAQPartWidth; bx++ , uiNumPixInAQPart++)113 for ( ; bx < uiCurrAQPartWidth; bx++ ) 115 114 { 116 115 uiSum [3] += pBlkY[bx]; … … 120 119 } 121 120 121 assert ((uiCurrAQPartWidth&1)==0); 122 assert ((uiCurrAQPartHeight&1)==0); 123 const UInt pixelWidthOfQuadrants = uiCurrAQPartWidth >>1; 124 const UInt pixelHeightOfQuadrants = uiCurrAQPartHeight>>1; 125 const UInt numPixInAQPart = pixelWidthOfQuadrants * pixelHeightOfQuadrants; 126 122 127 Double dMinVar = DBL_MAX; 128 if (numPixInAQPart!=0) 129 { 123 130 for ( Int i=0; i<4; i++) 124 131 { 125 const Double dAverage = Double(uiSum[i]) / uiNumPixInAQPart;126 const Double dVariance = Double(uiSumSq[i]) / uiNumPixInAQPart - dAverage * dAverage;132 const Double dAverage = Double(uiSum[i]) / numPixInAQPart; 133 const Double dVariance = Double(uiSumSq[i]) / numPixInAQPart - dAverage * dAverage; 127 134 dMinVar = min(dMinVar, dVariance); 135 } 136 } 137 else 138 { 139 dMinVar = 0.0; 128 140 } 129 141 const Double dActivity = 1.0 + dMinVar; -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r1313 r1360 1639 1639 m_encRCSeq->initLCUPara(); 1640 1640 } 1641 #if U0132_TARGET_BITS_SATURATION 1642 m_CpbSaturationEnabled = false; 1643 m_cpbSize = targetBitrate; 1644 m_cpbState = (UInt)(m_cpbSize*0.5f); 1645 m_bufferingRate = (Int)(targetBitrate / frameRate); 1646 #endif 1641 1647 1642 1648 #if KWU_RC_MADPRED_E0227 … … 1664 1670 } 1665 1671 1672 #if U0132_TARGET_BITS_SATURATION 1673 Int TEncRateCtrl::updateCpbState(Int actualBits) 1674 { 1675 Int cpbState = 1; 1676 1677 m_cpbState -= actualBits; 1678 if (m_cpbState < 0) 1679 { 1680 cpbState = -1; 1681 } 1682 1683 m_cpbState += m_bufferingRate; 1684 if (m_cpbState > m_cpbSize) 1685 { 1686 cpbState = 0; 1687 } 1688 1689 return cpbState; 1690 } 1691 1692 Void TEncRateCtrl::initHrdParam(const TComHRD* pcHrd, Int iFrameRate, Double fInitialCpbFullness) 1693 { 1694 m_CpbSaturationEnabled = true; 1695 m_cpbSize = (pcHrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (4 + pcHrd->getCpbSizeScale()); 1696 m_cpbState = (UInt)(m_cpbSize*fInitialCpbFullness); 1697 m_bufferingRate = (UInt)(((pcHrd->getBitRateValueMinus1(0, 0, 0) + 1) << (6 + pcHrd->getBitRateScale())) / iFrameRate); 1698 printf("\nHRD - [Initial CPB state %6d] [CPB Size %6d] [Buffering Rate %6d]\n", m_cpbState, m_cpbSize, m_bufferingRate); 1699 } 1700 #endif 1701 1666 1702 Void TEncRateCtrl::destroyRCGOP() 1667 1703 { -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncRateCtrl.h
r1313 r1360 285 285 TRCLCU& getLCU( Int LCUIdx ) { return m_LCUs[LCUIdx]; } 286 286 Int getPicActualHeaderBits() { return m_picActualHeaderBits; } 287 #if U0132_TARGET_BITS_SATURATION 288 Void setBitLeft(Int bits) { m_bitsLeft = bits; } 289 #endif 287 290 Void setTargetBits( Int bits ) { m_targetBits = bits; m_bitsLeft = bits;} 288 291 Void setTotalIntraCost(Double cost) { m_totalCostIntra = cost; } … … 369 372 Void setLayerID(Int layerid) { m_LayerID = layerid; } 370 373 #endif 374 #if U0132_TARGET_BITS_SATURATION 375 Bool getCpbSaturationEnabled() { return m_CpbSaturationEnabled; } 376 UInt getCpbState() { return m_cpbState; } 377 UInt getCpbSize() { return m_cpbSize; } 378 UInt getBufferingRate() { return m_bufferingRate; } 379 Int updateCpbState(Int actualBits); 380 Void initHrdParam(const TComHRD* pcHrd, Int iFrameRate, Double fInitialCpbFullness); 381 #endif 382 371 383 private: 372 384 TEncRCSeq* m_encRCSeq; … … 375 387 list<TEncRCPic*> m_listRCPictures; 376 388 Int m_RCQP; 389 #if U0132_TARGET_BITS_SATURATION 390 Bool m_CpbSaturationEnabled; // Enable target bits saturation to avoid CPB overflow and underflow 391 Int m_cpbState; // CPB State 392 UInt m_cpbSize; // CPB size 393 UInt m_bufferingRate; // Buffering rate 394 #endif 395 377 396 #if KWU_RC_MADPRED_E0227 378 397 Int m_LayerID; -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r1321 r1360 908 908 m_signLineBuf1 = NULL; 909 909 } 910 m_signLineBuf1 = new Char[m_lineBufWidth+1];910 m_signLineBuf1 = new SChar[m_lineBufWidth+1]; 911 911 912 912 if (m_signLineBuf2) … … 915 915 m_signLineBuf2 = NULL; 916 916 } 917 m_signLineBuf2 = new Char[m_lineBufWidth+1];917 m_signLineBuf2 = new SChar[m_lineBufWidth+1]; 918 918 } 919 919 920 920 Int x,y, startX, startY, endX, endY, edgeType, firstLineStartX, firstLineEndX; 921 Char signLeft, signRight, signDown;921 SChar signLeft, signRight, signDown; 922 922 Int64 *diff, *count; 923 923 Pel *srcLine, *orgLine; … … 949 949 for (y=0; y<endY; y++) 950 950 { 951 signLeft = ( Char)sgn(srcLine[startX] - srcLine[startX-1]);951 signLeft = (SChar)sgn(srcLine[startX] - srcLine[startX-1]); 952 952 for (x=startX; x<endX; x++) 953 953 { 954 signRight = ( Char)sgn(srcLine[x] - srcLine[x+1]);954 signRight = (SChar)sgn(srcLine[x] - srcLine[x+1]); 955 955 edgeType = signRight + signLeft; 956 956 signLeft = -signRight; … … 971 971 for(y=0; y<skipLinesB[typeIdx]; y++) 972 972 { 973 signLeft = ( Char)sgn(srcLine[startX] - srcLine[startX-1]);973 signLeft = (SChar)sgn(srcLine[startX] - srcLine[startX-1]); 974 974 for (x=startX; x<endX; x++) 975 975 { 976 signRight = ( Char)sgn(srcLine[x] - srcLine[x+1]);976 signRight = (SChar)sgn(srcLine[x] - srcLine[x+1]); 977 977 edgeType = signRight + signLeft; 978 978 signLeft = -signRight; … … 992 992 diff +=2; 993 993 count+=2; 994 Char *signUpLine = m_signLineBuf1;994 SChar *signUpLine = m_signLineBuf1; 995 995 996 996 startX = (!isCalculatePreDeblockSamples) ? 0 … … 1011 1011 for (x=startX; x<endX; x++) 1012 1012 { 1013 signUpLine[x] = ( Char)sgn(srcLine[x] - srcLineAbove[x]);1013 signUpLine[x] = (SChar)sgn(srcLine[x] - srcLineAbove[x]); 1014 1014 } 1015 1015 … … 1021 1021 for (x=startX; x<endX; x++) 1022 1022 { 1023 signDown = ( Char)sgn(srcLine[x] - srcLineBelow[x]);1023 signDown = (SChar)sgn(srcLine[x] - srcLineBelow[x]); 1024 1024 edgeType = signDown + signUpLine[x]; 1025 1025 signUpLine[x]= -signDown; … … 1061 1061 diff +=2; 1062 1062 count+=2; 1063 Char *signUpLine, *signDownLine, *signTmpLine;1063 SChar *signUpLine, *signDownLine, *signTmpLine; 1064 1064 1065 1065 signUpLine = m_signLineBuf1; … … 1079 1079 for (x=startX; x<endX+1; x++) 1080 1080 { 1081 signUpLine[x] = ( Char)sgn(srcLineBelow[x] - srcLine[x-1]);1081 signUpLine[x] = (SChar)sgn(srcLineBelow[x] - srcLine[x-1]); 1082 1082 } 1083 1083 … … 1103 1103 for (x=startX; x<endX; x++) 1104 1104 { 1105 signDown = ( Char)sgn(srcLine[x] - srcLineBelow[x+1]);1105 signDown = (SChar)sgn(srcLine[x] - srcLineBelow[x+1]); 1106 1106 edgeType = signDown + signUpLine[x]; 1107 1107 diff [edgeType] += (orgLine[x] - srcLine[x]); … … 1110 1110 signDownLine[x+1] = -signDown; 1111 1111 } 1112 signDownLine[startX] = ( Char)sgn(srcLineBelow[startX] - srcLine[startX-1]);1112 signDownLine[startX] = (SChar)sgn(srcLineBelow[startX] - srcLine[startX-1]); 1113 1113 1114 1114 signTmpLine = signUpLine; … … 1148 1148 diff +=2; 1149 1149 count+=2; 1150 Char *signUpLine = m_signLineBuf1+1;1150 SChar *signUpLine = m_signLineBuf1+1; 1151 1151 1152 1152 startX = (!isCalculatePreDeblockSamples) ? (isLeftAvail ? 0 : 1) … … 1162 1162 for (x=startX-1; x<endX; x++) 1163 1163 { 1164 signUpLine[x] = ( Char)sgn(srcLineBelow[x] - srcLine[x+1]);1164 signUpLine[x] = (SChar)sgn(srcLineBelow[x] - srcLine[x+1]); 1165 1165 } 1166 1166 … … 1191 1191 for(x=startX; x<endX; x++) 1192 1192 { 1193 signDown = ( Char)sgn(srcLine[x] - srcLineBelow[x-1]);1193 signDown = (SChar)sgn(srcLine[x] - srcLineBelow[x-1]); 1194 1194 edgeType = signDown + signUpLine[x]; 1195 1195 … … 1199 1199 signUpLine[x-1] = -signDown; 1200 1200 } 1201 signUpLine[endX-1] = ( Char)sgn(srcLineBelow[endX-1] - srcLine[endX]);1201 signUpLine[endX-1] = (SChar)sgn(srcLineBelow[endX-1] - srcLine[endX]); 1202 1202 srcLine += srcStride; 1203 1203 orgLine += orgStride; -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncSearch.cpp
r1321 r1360 74 74 }; 75 75 76 static const UInt s_auiDFilter[9] =77 {78 0, 1, 0,79 2, 3, 2,80 0, 1, 081 };82 83 76 static Void offsetSubTUCBFs(TComTU &rTu, const ComponentID compID) 84 77 { … … 120 113 , m_iSearchRange (0) 121 114 , m_bipredSearchRange (0) 122 , m_iFastSearch (0)123 115 , m_pppcRDSbacCoder (NULL) 124 116 , m_pcRDGoOnSbacCoder (NULL) 125 117 , m_pTempPel (NULL) 126 , m_puiDFilter (NULL)127 118 , m_isInitialized (false) 128 119 { … … 130 121 { 131 122 m_ppcQTTempCoeff[ch] = NULL; 132 m_pcQTTempCoeff[ch] = NULL;133 123 #if ADAPTIVE_QP_SELECTION 134 124 m_ppcQTTempArlCoeff[ch] = NULL; 135 m_pcQTTempArlCoeff[ch] = NULL;136 125 #endif 137 126 m_puhQTTempCbf[ch] = NULL; … … 181 170 } 182 171 delete[] m_ppcQTTempCoeff[ch]; 183 delete[] m_pcQTTempCoeff[ch];184 172 delete[] m_puhQTTempCbf[ch]; 185 173 #if ADAPTIVE_QP_SELECTION 186 174 delete[] m_ppcQTTempArlCoeff[ch]; 187 delete[] m_pcQTTempArlCoeff[ch];188 175 #endif 189 176 } … … 229 216 Int iSearchRange, 230 217 Int bipredSearchRange, 231 Int iFastSearch,218 MESearchMethod motionEstimationSearchMethod, 232 219 const UInt maxCUWidth, 233 220 const UInt maxCUHeight, … … 244 231 m_iSearchRange = iSearchRange; 245 232 m_bipredSearchRange = bipredSearchRange; 246 m_ iFastSearch = iFastSearch;233 m_motionEstimationSearchMethod = motionEstimationSearchMethod; 247 234 m_pcEntropyCoder = pcEntropyCoder; 248 235 m_pcRdCost = pcRdCost; … … 258 245 } 259 246 } 260 261 m_puiDFilter = s_auiDFilter + 4;262 247 263 248 // initialize motion cost … … 289 274 const UInt csy=::getComponentScaleY(ComponentID(ch), cform); 290 275 m_ppcQTTempCoeff[ch] = new TCoeff* [uiNumLayersToAllocate]; 291 m_pcQTTempCoeff[ch] = new TCoeff [(maxCUWidth*maxCUHeight)>>(csx+csy) ];292 276 #if ADAPTIVE_QP_SELECTION 293 277 m_ppcQTTempArlCoeff[ch] = new TCoeff*[uiNumLayersToAllocate]; 294 m_pcQTTempArlCoeff[ch] = new TCoeff [(maxCUWidth*maxCUHeight)>>(csx+csy) ];295 278 #endif 296 279 m_puhQTTempCbf[ch] = new UChar [uiNumPartitions]; … … 304 287 } 305 288 306 m_phQTTempCrossComponentPredictionAlpha[ch] = new Char [uiNumPartitions];289 m_phQTTempCrossComponentPredictionAlpha[ch] = new SChar [uiNumPartitions]; 307 290 m_pSharedPredTransformSkip[ch] = new Pel [MAX_CU_SIZE*MAX_CU_SIZE]; 308 291 m_pcQTTempTUCoeff[ch] = new TCoeff[MAX_CU_SIZE*MAX_CU_SIZE]; … … 323 306 } 324 307 325 #define TZ_SEARCH_CONFIGURATION \ 326 const Int iRaster = 5; /* TZ soll von aussen ?ergeben werden */ \ 327 const Bool bTestOtherPredictedMV = 0; \ 328 const Bool bTestZeroVector = 1; \ 329 const Bool bTestZeroVectorStart = 0; \ 330 const Bool bTestZeroVectorStop = 0; \ 331 const Bool bFirstSearchDiamond = 1; /* 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch */ \ 332 const Bool bFirstSearchStop = m_pcEncCfg->getFastMEAssumingSmootherMVEnabled(); \ 333 const UInt uiFirstSearchRounds = 3; /* first search stop X rounds after best match (must be >=1) */ \ 334 const Bool bEnableRasterSearch = 1; \ 335 const Bool bAlwaysRasterSearch = 0; /* ===== 1: BETTER but factor 2 slower ===== */ \ 336 const Bool bRasterRefinementEnable = 0; /* enable either raster refinement or star refinement */ \ 337 const Bool bRasterRefinementDiamond = 0; /* 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch */ \ 338 const Bool bStarRefinementEnable = 1; /* enable either star refinement or raster refinement */ \ 339 const Bool bStarRefinementDiamond = 1; /* 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch */ \ 340 const Bool bStarRefinementStop = 0; \ 341 const UInt uiStarRefinementRounds = 2; /* star refinement stop X rounds after best match (must be >=1) */ \ 342 343 344 #define SEL_SEARCH_CONFIGURATION \ 345 const Bool bTestOtherPredictedMV = 1; \ 346 const Bool bTestZeroVector = 1; \ 347 const Bool bEnableRasterSearch = 1; \ 348 const Bool bAlwaysRasterSearch = 0; /* ===== 1: BETTER but factor 15x slower ===== */ \ 349 const Bool bStarRefinementEnable = 1; /* enable either star refinement or raster refinement */ \ 350 const Bool bStarRefinementDiamond = 1; /* 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch */ \ 351 const Bool bStarRefinementStop = 0; \ 352 const UInt uiStarRefinementRounds = 2; /* star refinement stop X rounds after best match (must be >=1) */ \ 353 const UInt uiSearchRange = m_iSearchRange; \ 354 const Int uiSearchRangeInitial = m_iSearchRange >> 2; \ 355 const Int uiSearchStep = 4; \ 356 const Int iMVDistThresh = 8; \ 357 358 359 360 __inline Void TEncSearch::xTZSearchHelp( TComPattern* pcPatternKey, IntTZSearchStruct& rcStruct, const Int iSearchX, const Int iSearchY, const UChar ucPointNr, const UInt uiDistance ) 308 309 310 311 __inline Void TEncSearch::xTZSearchHelp( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const Int iSearchX, const Int iSearchY, const UChar ucPointNr, const UInt uiDistance ) 361 312 { 362 313 Distortion uiSad = 0; 363 314 364 Pel* piRefSrch; 365 366 piRefSrch = rcStruct.piRefY + iSearchY * rcStruct.iYStride + iSearchX; 315 const Pel* const piRefSrch = rcStruct.piRefY + iSearchY * rcStruct.iYStride + iSearchX; 316 367 317 #if NH_3D_IC 368 318 m_cDistParam.bUseIC = pcPatternKey->getICFlag(); … … 374 324 m_pcRdCost->setDistParam( pcPatternKey, piRefSrch, rcStruct.iYStride, m_cDistParam ); 375 325 376 if(m_pcEncCfg->getFastSearch() != SELECTIVE)377 {378 // fast encoder decision: use subsampled SAD when rows > 8 for integer ME379 if ( m_pcEncCfg->getUseFastEnc() )380 {381 if ( m_cDistParam.iRows > 8 )382 {383 m_cDistParam.iSubShift = 1;384 }385 }386 }387 388 326 setDistParamComp(COMPONENT_Y); 389 327 390 328 // distortion 391 329 m_cDistParam.bitDepth = pcPatternKey->getBitDepthY(); 392 if(m_pcEncCfg->getFastSearch() == SELECTIVE) 330 m_cDistParam.m_maximumDistortionForEarlyExit = rcStruct.uiBestSad; 331 332 if((m_pcEncCfg->getRestrictMESampling() == false) && m_pcEncCfg->getMotionEstimationSearchMethod() == MESEARCH_SELECTIVE) 393 333 { 394 334 Int isubShift = 0; 395 335 // motion cost 396 Distortion uiBitCost = m_pcRdCost->getCost( iSearchX, iSearchY ); 397 336 Distortion uiBitCost = m_pcRdCost->getCostOfVectorWithPredictor( iSearchX, iSearchY ); 337 338 // Skip search if bit cost is already larger than best SAD 339 if (uiBitCost < rcStruct.uiBestSad) 340 { 398 341 if ( m_cDistParam.iRows > 32 ) 399 342 { … … 443 386 rcStruct.uiBestRound = 0; 444 387 rcStruct.ucPointNr = ucPointNr; 388 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 389 } 445 390 } 446 391 } … … 449 394 else 450 395 { 396 // fast encoder decision: use subsampled SAD when rows > 8 for integer ME 397 if ( m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE1 || m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE3 ) 398 { 399 if ( m_cDistParam.iRows > 8 ) 400 { 401 m_cDistParam.iSubShift = 1; 402 } 403 } 404 451 405 uiSad = m_cDistParam.DistFunc( &m_cDistParam ); 452 406 407 // only add motion cost if uiSad is smaller than best. Otherwise pointless 408 // to add motion cost. 409 if( uiSad < rcStruct.uiBestSad ) 410 { 453 411 // motion cost 454 uiSad += m_pcRdCost->getCost( iSearchX, iSearchY );412 uiSad += m_pcRdCost->getCostOfVectorWithPredictor( iSearchX, iSearchY ); 455 413 456 414 if( uiSad < rcStruct.uiBestSad ) … … 462 420 rcStruct.uiBestRound = 0; 463 421 rcStruct.ucPointNr = ucPointNr; 422 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 423 } 464 424 } 465 425 } … … 469 429 470 430 471 __inline Void TEncSearch::xTZ2PointSearch( TComPattern* pcPatternKey, IntTZSearchStruct& rcStruct, TComMv* pcMvSrchRngLT, TComMv*pcMvSrchRngRB )431 __inline Void TEncSearch::xTZ2PointSearch( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB ) 472 432 { 473 433 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); … … 602 562 603 563 604 __inline Void TEncSearch::xTZ8PointSquareSearch( TComPattern* pcPatternKey, IntTZSearchStruct& rcStruct, TComMv* pcMvSrchRngLT, TComMv*pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist )564 __inline Void TEncSearch::xTZ8PointSquareSearch( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist ) 605 565 { 606 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor();607 Int iSrchRngHorRight = pcMvSrchRngRB->getHor();608 Int iSrchRngVerTop = pcMvSrchRngLT->getVer();609 Int iSrchRngVerBottom = pcMvSrchRngRB->getVer();566 const Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); 567 const Int iSrchRngHorRight = pcMvSrchRngRB->getHor(); 568 const Int iSrchRngVerTop = pcMvSrchRngLT->getVer(); 569 const Int iSrchRngVerBottom = pcMvSrchRngRB->getVer(); 610 570 611 571 // 8 point search, // 1 2 3 … … 660 620 661 621 662 __inline Void TEncSearch::xTZ8PointDiamondSearch( TComPattern* pcPatternKey, IntTZSearchStruct& rcStruct, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist ) 622 __inline Void TEncSearch::xTZ8PointDiamondSearch( const TComPattern*const pcPatternKey, 623 IntTZSearchStruct& rcStruct, 624 const TComMv*const pcMvSrchRngLT, 625 const TComMv*const pcMvSrchRngRB, 626 const Int iStartX, 627 const Int iStartY, 628 const Int iDist, 629 const Bool bCheckCornersAtDist1 ) 663 630 { 664 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor();665 Int iSrchRngHorRight = pcMvSrchRngRB->getHor();666 Int iSrchRngVerTop = pcMvSrchRngLT->getVer();667 Int iSrchRngVerBottom = pcMvSrchRngRB->getVer();631 const Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); 632 const Int iSrchRngHorRight = pcMvSrchRngRB->getHor(); 633 const Int iSrchRngVerTop = pcMvSrchRngLT->getVer(); 634 const Int iSrchRngVerBottom = pcMvSrchRngRB->getVer(); 668 635 669 636 // 8 point search, // 1 2 3 … … 677 644 rcStruct.uiBestRound += 1; 678 645 679 if ( iDist == 1 ) // iDist == 1646 if ( iDist == 1 ) 680 647 { 681 648 if ( iTop >= iSrchRngVerTop ) // check top 682 649 { 650 if (bCheckCornersAtDist1) 651 { 652 if ( iLeft >= iSrchRngHorLeft) // check top-left 653 { 654 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iTop, 1, iDist ); 655 } 656 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist ); 657 if ( iRight <= iSrchRngHorRight ) // check middle right 658 { 659 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iTop, 3, iDist ); 660 } 661 } 662 else 663 { 683 664 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iTop, 2, iDist ); 684 665 } 666 } 685 667 if ( iLeft >= iSrchRngHorLeft ) // check middle left 686 668 { … … 693 675 if ( iBottom <= iSrchRngVerBottom ) // check bottom 694 676 { 677 if (bCheckCornersAtDist1) 678 { 679 if ( iLeft >= iSrchRngHorLeft) // check top-left 680 { 681 xTZSearchHelp( pcPatternKey, rcStruct, iLeft, iBottom, 6, iDist ); 682 } 683 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist ); 684 if ( iRight <= iSrchRngHorRight ) // check middle right 685 { 686 xTZSearchHelp( pcPatternKey, rcStruct, iRight, iBottom, 8, iDist ); 687 } 688 } 689 else 690 { 695 691 xTZSearchHelp( pcPatternKey, rcStruct, iStartX, iBottom, 7, iDist ); 696 692 } 697 693 } 698 else // if (iDist != 1) 694 } 695 else 699 696 { 700 697 if ( iDist <= 8 ) … … 770 767 for ( Int index = 1; index < 4; index++ ) 771 768 { 772 Int iPosYT = iTop + ((iDist>>2) * index);773 Int iPosYB = iBottom - ((iDist>>2) * index);774 Int iPosXL = iStartX - ((iDist>>2) * index);775 Int iPosXR = iStartX + ((iDist>>2) * index);769 const Int iPosYT = iTop + ((iDist>>2) * index); 770 const Int iPosYB = iBottom - ((iDist>>2) * index); 771 const Int iPosXL = iStartX - ((iDist>>2) * index); 772 const Int iPosXR = iStartX + ((iDist>>2) * index); 776 773 xTZSearchHelp( pcPatternKey, rcStruct, iPosXL, iPosYT, 0, iDist ); 777 774 xTZSearchHelp( pcPatternKey, rcStruct, iPosXR, iPosYT, 0, iDist ); … … 800 797 for ( Int index = 1; index < 4; index++ ) 801 798 { 802 Int iPosYT = iTop + ((iDist>>2) * index);803 Int iPosYB = iBottom - ((iDist>>2) * index);804 Int iPosXL = iStartX - ((iDist>>2) * index);805 Int iPosXR = iStartX + ((iDist>>2) * index);799 const Int iPosYT = iTop + ((iDist>>2) * index); 800 const Int iPosYB = iBottom - ((iDist>>2) * index); 801 const Int iPosXL = iStartX - ((iDist>>2) * index); 802 const Int iPosXR = iStartX + ((iDist>>2) * index); 806 803 807 804 if ( iPosYT >= iSrchRngVerTop ) // check top … … 833 830 } 834 831 835 836 837 838 839 //<--840 841 832 Distortion TEncSearch::xPatternRefinement( TComPattern* pcPatternKey, 842 833 TComMv baseRefMv, … … 886 877 m_cDistParam.bitDepth = pcPatternKey->getBitDepthY(); 887 878 uiDist = m_cDistParam.DistFunc( &m_cDistParam ); 888 uiDist += m_pcRdCost->getCost ( cMvTest.getHor(), cMvTest.getVer() );879 uiDist += m_pcRdCost->getCostOfVectorWithPredictor( cMvTest.getHor(), cMvTest.getVer() ); 889 880 890 881 if ( uiDist < uiDistBest ) … … 892 883 uiDistBest = uiDist; 893 884 uiDirecBest = i; 885 m_cDistParam.m_maximumDistortionForEarlyExit = uiDist; 894 886 } 895 887 } … … 2410 2402 } 2411 2403 2412 Char2404 SChar 2413 2405 TEncSearch::xCalcCrossComponentPredictionAlpha( TComTU &rTu, 2414 2406 const ComponentID compID, … … 2427 2419 const Int diffBitDepth = pCU->getSlice()->getSPS()->getDifferentialLumaChromaBitDepth(); 2428 2420 2429 Char alpha = 0;2421 SChar alpha = 0; 2430 2422 Int SSxy = 0; 2431 2423 Int SSxx = 0; … … 2447 2439 { 2448 2440 Double dAlpha = SSxy / Double( SSxx ); 2449 alpha = Char(Clip3<Int>(-16, 16, (Int)(dAlpha * 16)));2450 2451 static const Char alphaQuant[17] = {0, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8};2441 alpha = SChar(Clip3<Int>(-16, 16, (Int)(dAlpha * 16))); 2442 2443 static const SChar alphaQuant[17] = {0, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8}; 2452 2444 2453 2445 alpha = (alpha < 0) ? -alphaQuant[Int(-alpha)] : alphaQuant[Int(alpha)]; … … 2540 2532 Double singleCostTmp = 0; 2541 2533 UInt singleCbfCTmp = 0; 2542 CharbestCrossCPredictionAlpha = 0;2534 SChar bestCrossCPredictionAlpha = 0; 2543 2535 Int bestTransformSkipMode = 0; 2544 2536 … … 3689 3681 ::memcpy( m_puhQTTempCbf[compID], pcCU->getCbf( compID )+uiPartOffset, uiQPartNum * sizeof( UChar ) ); 3690 3682 ::memcpy( m_puhQTTempTransformSkipFlag[compID], pcCU->getTransformSkip( compID )+uiPartOffset, uiQPartNum * sizeof( UChar ) ); 3691 ::memcpy( m_phQTTempCrossComponentPredictionAlpha[compID], pcCU->getCrossComponentPredictionAlpha(compID)+uiPartOffset, uiQPartNum * sizeof( Char ) );3683 ::memcpy( m_phQTTempCrossComponentPredictionAlpha[compID], pcCU->getCrossComponentPredictionAlpha(compID)+uiPartOffset, uiQPartNum * sizeof( SChar ) ); 3692 3684 } 3693 3685 } … … 3702 3694 ::memcpy( pcCU->getCbf( compID )+uiPartOffset, m_puhQTTempCbf[compID], uiQPartNum * sizeof( UChar ) ); 3703 3695 ::memcpy( pcCU->getTransformSkip( compID )+uiPartOffset, m_puhQTTempTransformSkipFlag[compID], uiQPartNum * sizeof( UChar ) ); 3704 ::memcpy( pcCU->getCrossComponentPredictionAlpha(compID)+uiPartOffset, m_phQTTempCrossComponentPredictionAlpha[compID], uiQPartNum * sizeof( Char ) );3696 ::memcpy( pcCU->getCrossComponentPredictionAlpha(compID)+uiPartOffset, m_phQTTempCrossComponentPredictionAlpha[compID], uiQPartNum * sizeof( SChar ) ); 3705 3697 } 3706 3698 } … … 3812 3804 { 3813 3805 UInt uiDepth = pcCU->getDepth(0); 3814 const UIntuiDistortion = 0;3806 const Distortion uiDistortion = 0; 3815 3807 UInt uiBits; 3816 3808 … … 4325 4317 /*correct the bit-rate part of the current ref*/ 4326 4318 m_pcRdCost->setPredictor ( cMvPred[iRefList][iRefIdxTemp] ); 4327 uiBitsTemp += m_pcRdCost->getBits ( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );4319 uiBitsTemp += m_pcRdCost->getBitsOfVectorWithPredictor( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() ); 4328 4320 /*calculate the correct cost*/ 4329 4321 uiCostTemp += m_pcRdCost->getCost( uiBitsTemp ); … … 4374 4366 } 4375 4367 4376 // Bi- directional prediction4368 // Bi-predictive Motion estimation 4377 4369 if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) ) 4378 4370 { … … 4429 4421 4430 4422 // fast encoder setting: only one iteration 4431 if ( m_pcEncCfg->get UseFastEnc() || pcCU->getSlice()->getMvdL1ZeroFlag())4423 if ( m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE1 || m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE2 || pcCU->getSlice()->getMvdL1ZeroFlag() ) 4432 4424 { 4433 4425 iNumIter = 1; … … 4438 4430 Int iRefList = iIter % 2; 4439 4431 4440 if ( m_pcEncCfg->get UseFastEnc())4432 if ( m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE1 || m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE2 ) 4441 4433 { 4442 4434 if( uiCost[0] <= uiCost[1] ) … … 4629 4621 TComMvField cMEMvField[2]; 4630 4622 4631 m_pcRdCost-> getMotionCost( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) );4623 m_pcRdCost->selectMotionLambda( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) ); 4632 4624 4633 4625 #if AMP_MRG … … 4652 4644 // save ME result. 4653 4645 uiMEInterDir = pcCU->getInterDir( uiPartAddr ); 4654 pcCU->getMvField( pcCU, uiPartAddr, REF_PIC_LIST_0, cMEMvField[0] );4655 pcCU->getMvField( pcCU, uiPartAddr, REF_PIC_LIST_1, cMEMvField[1] );4646 TComDataCU::getMvField( pcCU, uiPartAddr, REF_PIC_LIST_0, cMEMvField[0] ); 4647 TComDataCU::getMvField( pcCU, uiPartAddr, REF_PIC_LIST_1, cMEMvField[1] ); 4656 4648 4657 4649 // find Merge result … … 5040 5032 } 5041 5033 5042 m_pcRdCost-> getMotionCost( true, 0, pcCU->getCUTransquantBypass(0) );5034 m_pcRdCost->selectMotionLambda( true, 0, pcCU->getCUTransquantBypass(0) ); 5043 5035 m_pcRdCost->setCostScale ( 0 ); 5044 5036 … … 5046 5038 5047 5039 m_pcRdCost->setPredictor( rcMvPred ); 5048 Int iOrgMvBits = m_pcRdCost->getBits (cMv.getHor(), cMv.getVer());5040 Int iOrgMvBits = m_pcRdCost->getBitsOfVectorWithPredictor(cMv.getHor(), cMv.getVer()); 5049 5041 iOrgMvBits += m_auiMVPIdxCost[riMVPIdx][AMVP_MAX_NUM_CANDS]; 5050 5042 Int iBestMvBits = iOrgMvBits; … … 5059 5051 m_pcRdCost->setPredictor( pcAMVPInfo->m_acMvCand[iMVPIdx] ); 5060 5052 5061 Int iMvBits = m_pcRdCost->getBits (cMv.getHor(), cMv.getVer());5053 Int iMvBits = m_pcRdCost->getBitsOfVectorWithPredictor(cMv.getHor(), cMv.getVer()); 5062 5054 iMvBits += m_auiMVPIdxCost[iMVPIdx][AMVP_MAX_NUM_CANDS]; 5063 5055 … … 5134 5126 5135 5127 uiCost = m_pcRdCost->getDistPart( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), pcTemplateCand->getAddr(COMPONENT_Y, uiPartAddr), pcTemplateCand->getStride(COMPONENT_Y), pcOrgYuv->getAddr(COMPONENT_Y, uiPartAddr), pcOrgYuv->getStride(COMPONENT_Y), iSizeX, iSizeY, COMPONENT_Y, DF_SAD ); 5136 uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, false,DF_SAD );5128 uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, DF_SAD ); 5137 5129 return uiCost; 5138 5130 } … … 5176 5168 #endif 5177 5169 5178 if ( bBi ) 5170 if ( bBi ) // Bipredictive ME 5179 5171 { 5180 5172 TComYuv* pcYuvOther = &m_acYuvPred[1-(Int)eRefPicList]; … … 5187 5179 fWeight = 0.5; 5188 5180 } 5181 m_cDistParam.bIsBiPred = bBi; 5189 5182 5190 5183 // Search key pattern initialization … … 5212 5205 } 5213 5206 5214 m_pcRdCost-> getMotionCost( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) );5207 m_pcRdCost->selectMotionLambda( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) ); 5215 5208 5216 5209 m_pcRdCost->setPredictor ( *pcMvPred ); … … 5231 5224 setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList ); 5232 5225 // Do integer search 5233 if ( !m_iFastSearch|| bBi )5226 if ( (m_motionEstimationSearchMethod==MESEARCH_FULL) || bBi ) 5234 5227 { 5235 5228 xPatternSearch ( pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); … … 5250 5243 } 5251 5244 5252 m_pcRdCost-> getMotionCost( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) );5245 m_pcRdCost->selectMotionLambda( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) ); 5253 5246 #if NH_3D_INTEGER_MV_DEPTH 5254 5247 if( ! pcCU->getSlice()->getIsDepth() ) … … 5268 5261 #endif 5269 5262 5270 UInt uiMvBits = m_pcRdCost->getBits ( rcMv.getHor(), rcMv.getVer() );5263 UInt uiMvBits = m_pcRdCost->getBitsOfVectorWithPredictor( rcMv.getHor(), rcMv.getVer() ); 5271 5264 #if NH_3D_INTEGER_MV_DEPTH 5272 5265 if( pcCU->getSlice()->getIsDepth() ) … … 5285 5278 5286 5279 5287 Void TEncSearch::xSetSearchRange ( TComDataCU* pcCU, TComMv& cMvPred, Int iSrchRng, TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB ) 5280 Void TEncSearch::xSetSearchRange ( const TComDataCU* const pcCU, const TComMv& cMvPred, const Int iSrchRng, 5281 TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB ) 5288 5282 { 5289 5283 Int iMvShift = 2; … … 5317 5311 pcCU->clipMv ( rcMvSrchRngRB ); 5318 5312 5313 #if ME_ENABLE_ROUNDING_OF_MVS 5314 rcMvSrchRngLT.divideByPowerOf2(iMvShift); 5315 rcMvSrchRngRB.divideByPowerOf2(iMvShift); 5316 #else 5319 5317 rcMvSrchRngLT >>= iMvShift; 5320 5318 rcMvSrchRngRB >>= iMvShift; 5319 #endif 5321 5320 } 5322 5321 5323 5322 5324 5325 5326 Void TEncSearch::xPatternSearch( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, TComMv& rcMv, Distortion& ruiSAD ) 5323 Void TEncSearch::xPatternSearch( const TComPattern* const pcPatternKey, 5324 const Pel* piRefY, 5325 const Int iRefStride, 5326 const TComMv* const pcMvSrchRngLT, 5327 const TComMv* const pcMvSrchRngRB, 5328 TComMv& rcMv, 5329 Distortion& ruiSAD ) 5327 5330 { 5328 5331 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); … … 5336 5339 Int iBestY = 0; 5337 5340 5338 Pel* piRefSrch;5339 5340 5341 //-- jclee for using the SAD function pointer 5341 5342 m_pcRdCost->setDistParam( pcPatternKey, piRefY, iRefStride, m_cDistParam ); 5342 5343 5343 5344 // fast encoder decision: use subsampled SAD for integer ME 5344 if ( m_pcEncCfg->get UseFastEnc())5345 if ( m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE1 || m_pcEncCfg->getFastInterSearchMode()==FASTINTERSEARCH_MODE3 ) 5345 5346 { 5346 5347 if ( m_cDistParam.iRows > 8 ) … … 5356 5357 { 5357 5358 // find min. distortion position 5358 piRefSrch = piRefY + x; 5359 m_cDistParam.pCur = piRefSrch; 5359 m_cDistParam.pCur = piRefY + x; 5360 5360 5361 5361 setDistParamComp(COMPONENT_Y); … … 5373 5373 5374 5374 // motion cost 5375 uiSad += m_pcRdCost->getCost ( x, y );5375 uiSad += m_pcRdCost->getCostOfVectorWithPredictor( x, y ); 5376 5376 5377 5377 if ( uiSad < uiSadBest ) … … 5380 5380 iBestX = x; 5381 5381 iBestY = y; 5382 m_cDistParam.m_maximumDistortionForEarlyExit = uiSad; 5382 5383 } 5383 5384 } … … 5387 5388 rcMv.set( iBestX, iBestY ); 5388 5389 5389 ruiSAD = uiSadBest - m_pcRdCost->getCost ( iBestX, iBestY );5390 ruiSAD = uiSadBest - m_pcRdCost->getCostOfVectorWithPredictor( iBestX, iBestY ); 5390 5391 return; 5391 5392 } … … 5393 5394 5394 5395 5395 Void TEncSearch::xPatternSearchFast( TComDataCU*pcCU,5396 TComPattern*pcPatternKey,5397 Pel*piRefY,5398 IntiRefStride,5399 TComMv*pcMvSrchRngLT,5400 TComMv*pcMvSrchRngRB,5396 Void TEncSearch::xPatternSearchFast( const TComDataCU* const pcCU, 5397 const TComPattern* const pcPatternKey, 5398 const Pel* const piRefY, 5399 const Int iRefStride, 5400 const TComMv* const pcMvSrchRngLT, 5401 const TComMv* const pcMvSrchRngRB, 5401 5402 TComMv &rcMv, 5402 5403 Distortion &ruiSAD, 5403 const TComMv* pIntegerMv2Nx2NPred )5404 const TComMv* const pIntegerMv2Nx2NPred ) 5404 5405 { 5405 5406 assert (MD_LEFT < NUM_MV_PREDICTORS); … … 5410 5411 pcCU->getMvPredAboveRight ( m_acMvPredictors[MD_ABOVE_RIGHT] ); 5411 5412 5412 switch ( m_ iFastSearch)5413 { 5414 case 1:5415 xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred );5413 switch ( m_motionEstimationSearchMethod ) 5414 { 5415 case MESEARCH_DIAMOND: 5416 xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred, false ); 5416 5417 break; 5417 5418 5418 case 2:5419 case MESEARCH_SELECTIVE: 5419 5420 xTZSearchSelective( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred ); 5420 5421 break; 5422 5423 case MESEARCH_DIAMOND_ENHANCED: 5424 xTZSearch( pcCU, pcPatternKey, piRefY, iRefStride, pcMvSrchRngLT, pcMvSrchRngRB, rcMv, ruiSAD, pIntegerMv2Nx2NPred, true ); 5425 break; 5426 5427 case MESEARCH_FULL: // shouldn't get here. 5421 5428 default: 5422 5429 break; … … 5427 5434 5428 5435 5429 Void TEncSearch::xTZSearch( TComDataCU*pcCU,5430 TComPattern*pcPatternKey,5431 Pel*piRefY,5432 IntiRefStride,5433 TComMv*pcMvSrchRngLT,5434 TComMv*pcMvSrchRngRB,5436 Void TEncSearch::xTZSearch( const TComDataCU* const pcCU, 5437 const TComPattern* const pcPatternKey, 5438 const Pel* const piRefY, 5439 const Int iRefStride, 5440 const TComMv* const pcMvSrchRngLT, 5441 const TComMv* const pcMvSrchRngRB, 5435 5442 TComMv &rcMv, 5436 5443 Distortion &ruiSAD, 5437 const TComMv* pIntegerMv2Nx2NPred ) 5444 const TComMv* const pIntegerMv2Nx2NPred, 5445 const Bool bExtendedSettings) 5438 5446 { 5439 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); 5440 Int iSrchRngHorRight = pcMvSrchRngRB->getHor(); 5441 Int iSrchRngVerTop = pcMvSrchRngLT->getVer(); 5442 Int iSrchRngVerBottom = pcMvSrchRngRB->getVer(); 5443 5444 TZ_SEARCH_CONFIGURATION 5447 const Bool bUseAdaptiveRaster = bExtendedSettings; 5448 const Int iRaster = 5; 5449 const Bool bTestOtherPredictedMV = bExtendedSettings; 5450 const Bool bTestZeroVector = true; 5451 const Bool bTestZeroVectorStart = bExtendedSettings; 5452 const Bool bTestZeroVectorStop = false; 5453 const Bool bFirstSearchDiamond = true; // 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch 5454 const Bool bFirstCornersForDiamondDist1 = bExtendedSettings; 5455 const Bool bFirstSearchStop = m_pcEncCfg->getFastMEAssumingSmootherMVEnabled(); 5456 const UInt uiFirstSearchRounds = 3; // first search stop X rounds after best match (must be >=1) 5457 const Bool bEnableRasterSearch = true; 5458 const Bool bAlwaysRasterSearch = bExtendedSettings; // true: BETTER but factor 2 slower 5459 const Bool bRasterRefinementEnable = false; // enable either raster refinement or star refinement 5460 const Bool bRasterRefinementDiamond = false; // 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch 5461 const Bool bRasterRefinementCornersForDiamondDist1 = bExtendedSettings; 5462 const Bool bStarRefinementEnable = true; // enable either star refinement or raster refinement 5463 const Bool bStarRefinementDiamond = true; // 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch 5464 const Bool bStarRefinementCornersForDiamondDist1 = bExtendedSettings; 5465 const Bool bStarRefinementStop = false; 5466 const UInt uiStarRefinementRounds = 2; // star refinement stop X rounds after best match (must be >=1) 5467 const Bool bNewZeroNeighbourhoodTest = bExtendedSettings; 5445 5468 5446 5469 UInt uiSearchRange = m_iSearchRange; … … 5449 5472 if( ! pcCU->getSlice()->getIsDepth() ) 5450 5473 #endif 5474 #if ME_ENABLE_ROUNDING_OF_MVS 5475 rcMv.divideByPowerOf2(2); 5476 #else 5451 5477 rcMv >>= 2; 5478 #endif 5479 5452 5480 // init TZSearchStruct 5453 5481 IntTZSearchStruct cStruct; … … 5470 5498 { 5471 5499 #endif 5472 cMv >>= 2; 5500 #if ME_ENABLE_ROUNDING_OF_MVS 5501 cMv.divideByPowerOf2(2); 5502 #else 5503 cMv >>= 2; 5504 #endif 5505 5473 5506 #if NH_3D_INTEGER_MV_DEPTH 5474 5507 } 5475 5508 #endif 5476 5509 if (cMv != rcMv && (cMv.getHor() != cStruct.iBestX && cMv.getVer() != cStruct.iBestY)) 5510 { 5511 // only test cMV if not obviously previously tested. 5477 5512 xTZSearchHelp( pcPatternKey, cStruct, cMv.getHor(), cMv.getVer(), 0, 0 ); 5478 5513 } 5514 } 5479 5515 } 5480 5516 … … 5482 5518 if ( bTestZeroVector ) 5483 5519 { 5520 if ((rcMv.getHor() != 0 || rcMv.getVer() != 0) && 5521 (0 != cStruct.iBestX || 0 != cStruct.iBestY)) 5522 { 5523 // only test 0-vector if not obviously previously tested. 5484 5524 xTZSearchHelp( pcPatternKey, cStruct, 0, 0, 0, 0 ); 5485 5525 } 5526 } 5527 5528 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); 5529 Int iSrchRngHorRight = pcMvSrchRngRB->getHor(); 5530 Int iSrchRngVerTop = pcMvSrchRngLT->getVer(); 5531 Int iSrchRngVerBottom = pcMvSrchRngRB->getVer(); 5486 5532 5487 5533 if (pIntegerMv2Nx2NPred != 0) … … 5490 5536 integerMv2Nx2NPred <<= 2; 5491 5537 pcCU->clipMv( integerMv2Nx2NPred ); 5538 #if ME_ENABLE_ROUNDING_OF_MVS 5539 integerMv2Nx2NPred.divideByPowerOf2(2); 5540 #else 5492 5541 integerMv2Nx2NPred >>= 2; 5542 #endif 5543 if ((rcMv != integerMv2Nx2NPred) && 5544 (integerMv2Nx2NPred.getHor() != cStruct.iBestX || integerMv2Nx2NPred.getVer() != cStruct.iBestY)) 5545 { 5546 // only test integerMv2Nx2NPred if not obviously previously tested. 5493 5547 xTZSearchHelp(pcPatternKey, cStruct, integerMv2Nx2NPred.getHor(), integerMv2Nx2NPred.getVer(), 0, 0); 5548 } 5494 5549 5495 5550 // reset search range … … 5511 5566 Int iStartY = cStruct.iBestY; 5512 5567 5513 // first search 5568 const Bool bBestCandidateZero = (cStruct.iBestX == 0) && (cStruct.iBestY == 0); 5569 5570 // first search around best position up to now. 5571 // The following works as a "subsampled/log" window search around the best candidate 5514 5572 for ( iDist = 1; iDist <= (Int)uiSearchRange; iDist*=2 ) 5515 5573 { 5516 5574 if ( bFirstSearchDiamond == 1 ) 5517 5575 { 5518 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );5576 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bFirstCornersForDiamondDist1 ); 5519 5577 } 5520 5578 else … … 5529 5587 } 5530 5588 5589 if (!bNewZeroNeighbourhoodTest) 5590 { 5531 5591 // test whether zero Mv is a better start point than Median predictor 5532 5592 if ( bTestZeroVectorStart && ((cStruct.iBestX != 0) || (cStruct.iBestY != 0)) ) … … 5538 5598 for ( iDist = 1; iDist <= (Int)uiSearchRange; iDist*=2 ) 5539 5599 { 5540 xTZ8PointDiamondSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, 0, 0, iDist);5600 xTZ8PointDiamondSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, 0, 0, iDist, false ); 5541 5601 if ( bTestZeroVectorStop && (cStruct.uiBestRound > 0) ) // stop criterion 5602 { 5603 break; 5604 } 5605 } 5606 } 5607 } 5608 } 5609 else 5610 { 5611 // Test also zero neighbourhood but with half the range 5612 // It was reported that the original (above) search scheme using bTestZeroVectorStart did not 5613 // make sense since one would have already checked the zero candidate earlier 5614 // and thus the conditions for that test would have not been satisfied 5615 if (bTestZeroVectorStart == true && bBestCandidateZero != true) 5616 { 5617 for ( iDist = 1; iDist <= ((Int)uiSearchRange >> 1); iDist*=2 ) 5618 { 5619 xTZ8PointDiamondSearch( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, 0, 0, iDist, false ); 5620 if ( bTestZeroVectorStop && (cStruct.uiBestRound > 2) ) // stop criterion 5542 5621 { 5543 5622 break; … … 5555 5634 5556 5635 // raster search if distance is too big 5636 if (bUseAdaptiveRaster) 5637 { 5638 int iWindowSize = iRaster; 5639 Int iSrchRngRasterLeft = iSrchRngHorLeft; 5640 Int iSrchRngRasterRight = iSrchRngHorRight; 5641 Int iSrchRngRasterTop = iSrchRngVerTop; 5642 Int iSrchRngRasterBottom = iSrchRngVerBottom; 5643 5644 if (!(bEnableRasterSearch && ( ((Int)(cStruct.uiBestDistance) > iRaster)))) 5645 { 5646 iWindowSize ++; 5647 iSrchRngRasterLeft /= 2; 5648 iSrchRngRasterRight /= 2; 5649 iSrchRngRasterTop /= 2; 5650 iSrchRngRasterBottom /= 2; 5651 } 5652 cStruct.uiBestDistance = iWindowSize; 5653 for ( iStartY = iSrchRngRasterTop; iStartY <= iSrchRngRasterBottom; iStartY += iWindowSize ) 5654 { 5655 for ( iStartX = iSrchRngRasterLeft; iStartX <= iSrchRngRasterRight; iStartX += iWindowSize ) 5656 { 5657 xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, iWindowSize ); 5658 } 5659 } 5660 } 5661 else 5662 { 5557 5663 if ( bEnableRasterSearch && ( ((Int)(cStruct.uiBestDistance) > iRaster) || bAlwaysRasterSearch ) ) 5558 5664 { … … 5565 5671 } 5566 5672 } 5673 } 5567 5674 } 5568 5675 … … 5579 5686 if ( bRasterRefinementDiamond == 1 ) 5580 5687 { 5581 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );5688 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bRasterRefinementCornersForDiamondDist1 ); 5582 5689 } 5583 5690 else … … 5599 5706 } 5600 5707 5601 // star trefinement5708 // star refinement 5602 5709 if ( bStarRefinementEnable && cStruct.uiBestDistance > 0 ) 5603 5710 { … … 5612 5719 if ( bStarRefinementDiamond == 1 ) 5613 5720 { 5614 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );5721 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, bStarRefinementCornersForDiamondDist1 ); 5615 5722 } 5616 5723 else … … 5638 5745 // write out best match 5639 5746 rcMv.set( cStruct.iBestX, cStruct.iBestY ); 5640 ruiSAD = cStruct.uiBestSad - m_pcRdCost->getCost ( cStruct.iBestX, cStruct.iBestY );5747 ruiSAD = cStruct.uiBestSad - m_pcRdCost->getCostOfVectorWithPredictor( cStruct.iBestX, cStruct.iBestY ); 5641 5748 } 5642 5749 5643 5750 5644 Void TEncSearch::xTZSearchSelective( TComDataCU*pcCU,5645 TComPattern*pcPatternKey,5646 Pel*piRefY,5647 IntiRefStride,5648 TComMv*pcMvSrchRngLT,5649 TComMv*pcMvSrchRngRB,5751 Void TEncSearch::xTZSearchSelective( const TComDataCU* const pcCU, 5752 const TComPattern* const pcPatternKey, 5753 const Pel* const piRefY, 5754 const Int iRefStride, 5755 const TComMv* const pcMvSrchRngLT, 5756 const TComMv* const pcMvSrchRngRB, 5650 5757 TComMv &rcMv, 5651 5758 Distortion &ruiSAD, 5652 const TComMv* pIntegerMv2Nx2NPred )5759 const TComMv* const pIntegerMv2Nx2NPred ) 5653 5760 { 5654 SEL_SEARCH_CONFIGURATION 5761 const Bool bTestOtherPredictedMV = true; 5762 const Bool bTestZeroVector = true; 5763 const Bool bEnableRasterSearch = true; 5764 const Bool bAlwaysRasterSearch = false; // 1: BETTER but factor 15x slower 5765 const Bool bStarRefinementEnable = true; // enable either star refinement or raster refinement 5766 const Bool bStarRefinementDiamond = true; // 1 = xTZ8PointDiamondSearch 0 = xTZ8PointSquareSearch 5767 const Bool bStarRefinementStop = false; 5768 const UInt uiStarRefinementRounds = 2; // star refinement stop X rounds after best match (must be >=1) 5769 const UInt uiSearchRange = m_iSearchRange; 5770 const Int uiSearchRangeInitial = m_iSearchRange >> 2; 5771 const Int uiSearchStep = 4; 5772 const Int iMVDistThresh = 8; 5655 5773 5656 5774 Int iSrchRngHorLeft = pcMvSrchRngLT->getHor(); … … 5669 5787 5670 5788 pcCU->clipMv( rcMv ); 5789 #if ME_ENABLE_ROUNDING_OF_MVS 5790 rcMv.divideByPowerOf2(2); 5791 #else 5671 5792 rcMv >>= 2; 5793 #endif 5672 5794 // init TZSearchStruct 5673 5795 IntTZSearchStruct cStruct; … … 5689 5811 TComMv cMv = m_acMvPredictors[index]; 5690 5812 pcCU->clipMv( cMv ); 5813 #if ME_ENABLE_ROUNDING_OF_MVS 5814 cMv.divideByPowerOf2(2); 5815 #else 5691 5816 cMv >>= 2; 5817 #endif 5692 5818 xTZSearchHelp( pcPatternKey, cStruct, cMv.getHor(), cMv.getVer(), 0, 0 ); 5693 5819 } … … 5705 5831 integerMv2Nx2NPred <<= 2; 5706 5832 pcCU->clipMv( integerMv2Nx2NPred ); 5833 #if ME_ENABLE_ROUNDING_OF_MVS 5834 integerMv2Nx2NPred.divideByPowerOf2(2); 5835 #else 5707 5836 integerMv2Nx2NPred >>= 2; 5837 #endif 5708 5838 xTZSearchHelp(pcPatternKey, cStruct, integerMv2Nx2NPred.getHor(), integerMv2Nx2NPred.getVer(), 0, 0); 5709 5839 … … 5734 5864 { 5735 5865 xTZSearchHelp( pcPatternKey, cStruct, iStartX, iStartY, 0, 0 ); 5736 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 1 );5737 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 2 );5866 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 1, false ); 5867 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, 2, false ); 5738 5868 } 5739 5869 } … … 5766 5896 if ( bStarRefinementDiamond == 1 ) 5767 5897 { 5768 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist );5898 xTZ8PointDiamondSearch ( pcPatternKey, cStruct, pcMvSrchRngLT, pcMvSrchRngRB, iStartX, iStartY, iDist, false ); 5769 5899 } 5770 5900 else … … 5792 5922 // write out best match 5793 5923 rcMv.set( cStruct.iBestX, cStruct.iBestY ); 5794 ruiSAD = cStruct.uiBestSad - m_pcRdCost->getCost ( cStruct.iBestX, cStruct.iBestY );5924 ruiSAD = cStruct.uiBestSad - m_pcRdCost->getCostOfVectorWithPredictor( cStruct.iBestX, cStruct.iBestY ); 5795 5925 5796 5926 } … … 6027 6157 const ComponentID component = ComponentID(comp); 6028 6158 ::memset( pcCU->getCbf( component ) , 0, uiQPartNum * sizeof(UChar) ); 6029 ::memset( pcCU->getCrossComponentPredictionAlpha(component), 0, ( uiQPartNum * sizeof( Char) ) );6159 ::memset( pcCU->getCrossComponentPredictionAlpha(component), 0, ( uiQPartNum * sizeof(SChar) ) ); 6030 6160 } 6031 6161 static const UInt useTS[MAX_NUM_COMPONENT]={0,0,0}; … … 6315 6445 // Stores the best explicit RDPCM mode for a TU encoded without split 6316 6446 UInt bestExplicitRdpcmModeUnSplit[MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{3,3}, {3,3}, {3,3}}; 6317 CharbestCrossCPredictionAlpha [MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{0,0},{0,0},{0,0}};6447 SChar bestCrossCPredictionAlpha [MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/] = {{0,0},{0,0},{0,0}}; 6318 6448 6319 6449 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); … … 6386 6516 && (pcCU->getCbf(subTUAbsPartIdx, COMPONENT_Y, uiTrMode) != 0); 6387 6517 6388 Char preCalcAlpha = 0;6518 SChar preCalcAlpha = 0; 6389 6519 const Pel *pLumaResi = m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( COMPONENT_Y, rTu.getRect( COMPONENT_Y ).x0, rTu.getRect( COMPONENT_Y ).y0 ); 6390 6520 -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncSearch.h
r1321 r1360 68 68 private: 69 69 TCoeff** m_ppcQTTempCoeff[MAX_NUM_COMPONENT /* 0->Y, 1->Cb, 2->Cr*/]; 70 TCoeff* m_pcQTTempCoeff[MAX_NUM_COMPONENT];71 70 #if ADAPTIVE_QP_SELECTION 72 71 TCoeff** m_ppcQTTempArlCoeff[MAX_NUM_COMPONENT]; 73 TCoeff* m_pcQTTempArlCoeff[MAX_NUM_COMPONENT];74 72 #endif 75 73 UChar* m_puhQTTempTrIdx; … … 79 77 TComYuv m_tmpYuvPred; // To be used in xGetInterPredictionError() to avoid constant memory allocation/deallocation 80 78 81 Char*m_phQTTempCrossComponentPredictionAlpha[MAX_NUM_COMPONENT];79 SChar* m_phQTTempCrossComponentPredictionAlpha[MAX_NUM_COMPONENT]; 82 80 Pel* m_pSharedPredTransformSkip[MAX_NUM_COMPONENT]; 83 81 TCoeff* m_pcQTTempTUCoeff[MAX_NUM_COMPONENT]; … … 100 98 Int m_iSearchRange; 101 99 Int m_bipredSearchRange; // Search range for bi-prediction 102 Int m_iFastSearch;100 MESearchMethod m_motionEstimationSearchMethod; 103 101 #if NH_MV 104 102 Bool m_vertRestriction; 105 103 #endif 106 104 Int m_aaiAdaptSR[MAX_NUM_REF_LIST_ADAPT_SR][MAX_IDX_ADAPT_SR]; 107 TComMv m_cSrchRngLT;108 TComMv m_cSrchRngRB;109 105 TComMv m_acMvPredictors[NUM_MV_PREDICTORS]; // Left, Above, AboveRight. enum MVP_DIR first NUM_MV_PREDICTORS entries are suitable for accessing. 110 106 … … 116 112 // Misc. 117 113 Pel* m_pTempPel; 118 const UInt* m_puiDFilter;119 114 120 115 #if NH_3D_VSO // M17 … … 136 131 Int iSearchRange, 137 132 Int bipredSearchRange, 138 Int iFastSearch,133 MESearchMethod motionEstimationSearchMethod, 139 134 const UInt maxCUWidth, 140 135 const UInt maxCUHeight, … … 157 152 typedef struct 158 153 { 159 Pel*piRefY;154 const Pel* piRefY; 160 155 Int iYStride; 161 156 Int iBestX; … … 168 163 169 164 // sub-functions for ME 170 __inline Void xTZSearchHelp ( TComPattern*pcPatternKey, IntTZSearchStruct& rcStruct, const Int iSearchX, const Int iSearchY, const UChar ucPointNr, const UInt uiDistance );171 __inline Void xTZ2PointSearch ( TComPattern* pcPatternKey, IntTZSearchStruct& rcStrukt, TComMv* pcMvSrchRngLT, TComMv*pcMvSrchRngRB );172 __inline Void xTZ8PointSquareSearch ( TComPattern* pcPatternKey, IntTZSearchStruct& rcStrukt, TComMv* pcMvSrchRngLT, TComMv*pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist );173 __inline Void xTZ8PointDiamondSearch( TComPattern* pcPatternKey, IntTZSearchStruct& rcStrukt, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist);165 __inline Void xTZSearchHelp ( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const Int iSearchX, const Int iSearchY, const UChar ucPointNr, const UInt uiDistance ); 166 __inline Void xTZ2PointSearch ( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB ); 167 __inline Void xTZ8PointSquareSearch ( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist ); 168 __inline Void xTZ8PointDiamondSearch( const TComPattern* const pcPatternKey, IntTZSearchStruct& rcStruct, const TComMv* const pcMvSrchRngLT, const TComMv* const pcMvSrchRngRB, const Int iStartX, const Int iStartY, const Int iDist, const Bool bCheckCornersAtDist1 ); 174 169 175 170 Void xGetInterPredictionError( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, Distortion& ruiSAD, Bool Hadamard ); … … 322 317 const Int strideBest ); 323 318 324 Char xCalcCrossComponentPredictionAlpha( TComTU &rTu,319 SChar xCalcCrossComponentPredictionAlpha ( TComTU &rTu, 325 320 const ComponentID compID, 326 321 const Pel* piResiL, … … 446 441 Bool bBi = false ); 447 442 448 Void xTZSearch ( TComDataCU*pcCU,449 TComPattern*pcPatternKey,450 Pel*piRefY,451 IntiRefStride,452 TComMv*pcMvSrchRngLT,453 TComMv*pcMvSrchRngRB,443 Void xTZSearch ( const TComDataCU* const pcCU, 444 const TComPattern* const pcPatternKey, 445 const Pel* const piRefY, 446 const Int iRefStride, 447 const TComMv* const pcMvSrchRngLT, 448 const TComMv* const pcMvSrchRngRB, 454 449 TComMv& rcMv, 455 450 Distortion& ruiSAD, 456 const TComMv *pIntegerMv2Nx2NPred 451 const TComMv* const pIntegerMv2Nx2NPred, 452 const Bool bExtendedSettings 457 453 ); 458 454 459 Void xTZSearchSelective ( TComDataCU*pcCU,460 TComPattern*pcPatternKey,461 Pel*piRefY,462 IntiRefStride,463 TComMv*pcMvSrchRngLT,464 TComMv*pcMvSrchRngRB,455 Void xTZSearchSelective ( const TComDataCU* const pcCU, 456 const TComPattern* const pcPatternKey, 457 const Pel* const piRefY, 458 const Int iRefStride, 459 const TComMv* const pcMvSrchRngLT, 460 const TComMv* const pcMvSrchRngRB, 465 461 TComMv& rcMv, 466 462 Distortion& ruiSAD, 467 const TComMv *pIntegerMv2Nx2NPred463 const TComMv* const pIntegerMv2Nx2NPred 468 464 ); 469 465 470 Void xSetSearchRange ( TComDataCU*pcCU,471 TComMv& cMvPred,472 Int iSrchRng,466 Void xSetSearchRange ( const TComDataCU* const pcCU, 467 const TComMv& cMvPred, 468 const Int iSrchRng, 473 469 TComMv& rcMvSrchRngLT, 474 470 TComMv& rcMvSrchRngRB ); 475 471 476 Void xPatternSearchFast ( TComDataCU*pcCU,477 TComPattern*pcPatternKey,478 Pel*piRefY,479 IntiRefStride,480 TComMv*pcMvSrchRngLT,481 TComMv*pcMvSrchRngRB,472 Void xPatternSearchFast ( const TComDataCU* const pcCU, 473 const TComPattern* const pcPatternKey, 474 const Pel* const piRefY, 475 const Int iRefStride, 476 const TComMv* const pcMvSrchRngLT, 477 const TComMv* const pcMvSrchRngRB, 482 478 TComMv& rcMv, 483 479 Distortion& ruiSAD, 484 const TComMv* pIntegerMv2Nx2NPred480 const TComMv* const pIntegerMv2Nx2NPred 485 481 ); 486 482 487 Void xPatternSearch ( TComPattern*pcPatternKey,488 Pel*piRefY,489 IntiRefStride,490 TComMv*pcMvSrchRngLT,491 TComMv*pcMvSrchRngRB,483 Void xPatternSearch ( const TComPattern* const pcPatternKey, 484 const Pel* piRefY, 485 const Int iRefStride, 486 const TComMv* const pcMvSrchRngLT, 487 const TComMv* const pcMvSrchRngRB, 492 488 TComMv& rcMv, 493 489 Distortion& ruiSAD ); -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r1313 r1360 203 203 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, Int layerId, bool isField ) 204 204 #else 205 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iGOPid, TComSlice*& rpcSlice,Bool isField )205 Void TEncSlice::initEncSlice( TComPic* pcPic, const Int pocLast, const Int pocCurr, const Int iGOPid, TComSlice*& rpcSlice, const Bool isField ) 206 206 #endif 207 207 { … … 397 397 #endif 398 398 { 399 dQPFactor=0.57*dLambda_scale; 399 if (m_pcCfg->getIntraQpFactor()>=0.0 && m_pcCfg->getGOPEntry(iGOPid).m_sliceType != I_SLICE) 400 { 401 dQPFactor=m_pcCfg->getIntraQpFactor(); 402 } 403 else 404 { 405 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 406 407 dQPFactor=0.57*dLambda_scale; 408 } 400 409 } 401 410 dLambda = dQPFactor*pow( 2.0, qp_temp/3.0 ); … … 428 437 iQP = m_piRdPicQp [0]; 429 438 430 if( rpcSlice->getSliceType( ) != I_SLICE ) 431 { 439 432 440 #if NH_MV 433 dLambda *= m_pcCfg->getLambdaModifier( m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_temporalId ); 434 #else 435 dLambda *= m_pcCfg->getLambdaModifier( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); 436 #endif 437 } 438 441 const Int temporalId=m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_temporalId; 442 #else 443 const Int temporalId=m_pcCfg->getGOPEntry(iGOPid).m_temporalId; 444 #endif 445 const std::vector<Double> &intraLambdaModifiers=m_pcCfg->getIntraLambdaModifier(); 446 447 Double lambdaModifier; 448 if( rpcSlice->getSliceType( ) != I_SLICE || intraLambdaModifiers.empty()) 449 { 450 lambdaModifier = m_pcCfg->getLambdaModifier( temporalId ); 451 } 452 else 453 { 454 lambdaModifier = intraLambdaModifiers[ (temporalId < intraLambdaModifiers.size()) ? temporalId : (intraLambdaModifiers.size()-1) ]; 455 } 456 457 dLambda *= lambdaModifier; 439 458 setUpLambda(rpcSlice, dLambda, iQP); 440 459 … … 547 566 rpcSlice->setDepth ( depth ); 548 567 549 #if NH_MV 550 pcPic->setTLayer( m_pcCfg->getGOPEntry( (eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid ).m_temporalId ); 551 #else 552 pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); 553 #endif 568 pcPic->setTLayer( temporalId ); 554 569 if(eSliceType==I_SLICE) 555 570 { … … 589 604 // ==================================================================================================================== 590 605 606 //! set adaptive search range based on poc difference 591 607 Void TEncSlice::setSearchRange( TComSlice* pcSlice ) 592 608 { … … 598 614 Int iNumPredDir = pcSlice->isInterP() ? 1 : 2; 599 615 600 for (Int iDir = 0; iDir <= iNumPredDir; iDir++) 601 { 602 //RefPicList e = (RefPicList)iDir; 616 for (Int iDir = 0; iDir < iNumPredDir; iDir++) 617 { 603 618 RefPicList e = ( iDir ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 604 619 for (Int iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(e); iRefIdx++) 605 620 { 606 621 iRefPOC = pcSlice->getRefPic(e, iRefIdx)->getPOC(); 607 Int iNewSR = Clip3(8, iMaxSR, (iMaxSR*ADAPT_SR_SCALE*abs(iCurrPOC - iRefPOC)+iOffset)/iGOPSize);608 m_pcPredSearch->setAdaptiveSearchRange(iDir, iRefIdx, iNewSR);622 Int newSearchRange = Clip3(m_pcCfg->getMinSearchWindow(), iMaxSR, (iMaxSR*ADAPT_SR_SCALE*abs(iCurrPOC - iRefPOC)+iOffset)/iGOPSize); 623 m_pcPredSearch->setAdaptiveSearchRange(iDir, iRefIdx, newSearchRange); 609 624 } 610 625 } … … 696 711 697 712 // compute RD cost and choose the best 698 Double dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits, uiPicDist, true, DF_SSE_FRAME); // NOTE: Is the 'true' parameter really necessary? 713 #if NH_3D 714 Double dPicRdCost = m_pcRdCost->calcRdCost( (Double)m_uiPicTotalBits, uiPicDist, DF_SSE_FRAME); 715 #else 716 Double dPicRdCost = m_pcRdCost->calcRdCost( (Double)m_uiPicTotalBits, (Double)uiPicDist, DF_SSE_FRAME); 717 #endif 699 718 #if H_3D 700 719 // Above calculation need to be fixed for VSO, including frameLambda value. … … 805 824 } 806 825 807 xEstimateWPParamSlice( pcSlice );826 xEstimateWPParamSlice( pcSlice, m_pcCfg->getWeightedPredictionMethod() ); 808 827 pcSlice->initWpScaling(pcSlice->getSPS()); 809 828 … … 849 868 { 850 869 // This will only occur if dependent slice-segments (m_entropyCodingSyncContextState=true) are being used. 851 if( pCurrentTile->getTileWidthInCtus() >= 2 || !m_pcCfg->get WaveFrontsynchro() )870 if( pCurrentTile->getTileWidthInCtus() >= 2 || !m_pcCfg->getEntropyCodingSyncEnabledFlag() ) 852 871 { 853 872 m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( &m_lastSliceSegmentEndContextState ); … … 892 911 m_pppcRDSbacCoder[0][CI_CURR_BEST]->resetEntropy(pcSlice); 893 912 } 894 else if ( ctuXPosInCtus == tileXPosInCtus && m_pcCfg->get WaveFrontsynchro())913 else if ( ctuXPosInCtus == tileXPosInCtus && m_pcCfg->getEntropyCodingSyncEnabledFlag()) 895 914 { 896 915 // reset and then update contexts to the state at the end of the top-right CTU (if within current slice and tile). … … 1031 1050 1032 1051 // Store probabilities of second CTU in line into buffer - used only if wavefront-parallel-processing is enabled. 1033 if ( ctuXPosInCtus == tileXPosInCtus+1 && m_pcCfg->get WaveFrontsynchro())1052 if ( ctuXPosInCtus == tileXPosInCtus+1 && m_pcCfg->getEntropyCodingSyncEnabledFlag()) 1034 1053 { 1035 1054 m_entropyCodingSyncContextState.loadContexts(m_pppcRDSbacCoder[0][CI_CURR_BEST]); -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncSlice.h
r1313 r1360 120 120 Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, Int layerId, bool isField ); 121 121 #else 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr,123 Int iGOPid, TComSlice*& rpcSlice,Bool isField );122 Void initEncSlice ( TComPic* pcPic, const Int pocLast, const Int pocCurr, 123 const Int iGOPid, TComSlice*& rpcSlice, const Bool isField ); 124 124 #endif 125 125 Void resetQP ( TComPic* pic, Int sliceQP, Double lambda ); -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/TEncTop.cpp
r1321 r1360 44 44 #endif 45 45 #if NH_MV 46 #include "../../App/TAppEncoder/TAppEncTop.h"46 //#include "../../App/TAppEncoder/TAppEncTop.h" 47 47 #endif 48 48 … … 216 216 xInitVPS(); 217 217 218 #if U0132_TARGET_BITS_SATURATION 219 if (m_RCCpbSaturationEnabled) 220 { 221 m_cRateCtrl.initHrdParam(m_cSPS.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); 222 } 223 #endif 218 224 m_cRdCost.setCostMode(m_costMode); 219 225 … … 264 270 265 271 // initialize encoder search class 266 m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_ iFastSearch, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );272 m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_motionEstimationSearchMethod, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); 267 273 268 274 m_iMaxRefPicNum = 0; … … 299 305 { 300 306 m_cSPS.getScalingList().setDefaultScalingList (); 301 if(m_cSPS.getScalingList().xParseScalingList(getScalingListFile ()))307 if(m_cSPS.getScalingList().xParseScalingList(getScalingListFileName())) 302 308 { 303 309 Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string … … 842 848 m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0); 843 849 } 850 851 #if U0132_TARGET_BITS_SATURATION 852 if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() ) 853 #else 844 854 if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) 855 #endif 845 856 { 846 857 xInitHrdParameters(); … … 866 877 m_cSPS.setSpsRangeExtensionsFlag( m_cSPS.getSpsRangeExtension().settingsDifferFromDefaults() ); 867 878 #endif 868 869 } 870 879 } 880 #if U0132_TARGET_BITS_SATURATION 881 // calculate scale value of bitrate and initial delay 882 Int calcScale(Int x) 883 { 884 UInt iMask = 0xffffffff; 885 Int ScaleValue = 32; 886 887 while ((x&iMask) != 0) 888 { 889 ScaleValue--; 890 iMask = (iMask >> 1); 891 } 892 893 return ScaleValue; 894 } 895 #endif 871 896 Void TEncTop::xInitHrdParameters() 872 897 { … … 874 899 Int bitRate = getTargetBitrate(); 875 900 Bool isRandomAccess = getIntraPeriod() > 0; 876 901 # if U0132_TARGET_BITS_SATURATION 902 Int cpbSize = getCpbSize(); 903 904 if( !getVuiParametersPresentFlag() && !getCpbSaturationEnabled() ) 905 #else 877 906 if( !getVuiParametersPresentFlag() ) 907 #endif 878 908 { 879 909 return; … … 925 955 } 926 956 957 #if U0132_TARGET_BITS_SATURATION 958 if (calcScale(bitRate) <= 6) 959 { 960 hrd->setBitRateScale(0); 961 } 962 else 963 { 964 hrd->setBitRateScale(calcScale(bitRate) - 6); 965 } 966 967 if (calcScale(cpbSize) <= 4) 968 { 969 hrd->setCpbSizeScale(0); 970 } 971 else 972 { 973 hrd->setCpbSizeScale(calcScale(cpbSize) - 4); 974 } 975 #else 927 976 hrd->setBitRateScale( 4 ); // in units of 2^( 6 + 4 ) = 1,024 bps 928 977 hrd->setCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit 978 #endif 979 929 980 hrd->setDuCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit 930 981 … … 958 1009 bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down 959 1010 // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) 1011 #if U0132_TARGET_BITS_SATURATION 1012 cpbSizeValue = cpbSize / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size 1013 #else 960 1014 cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size 1015 #endif 1016 961 1017 962 1018 // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know … … 1066 1122 m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); 1067 1123 1068 m_cPPS.setEntropyCodingSyncEnabledFlag( m_ iWaveFrontSynchro > 0);1124 m_cPPS.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag ); 1069 1125 m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); 1070 1126 m_cPPS.setUseWP( m_useWeightedPred ); -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp
r1313 r1360 41 41 #include "../TLibCommon/TComPicYuv.h" 42 42 #include "WeightPredAnalysis.h" 43 44 #define ABS(a) ((a) < 0 ? - (a) : (a)) 45 #define DTHRESH (0.99) 43 #include <limits> 44 45 static const Double WEIGHT_PRED_SAD_RELATIVE_TO_NON_WEIGHT_PRED_SAD=0.99; // NOTE: U0040 used 0.95 46 47 //! calculate SAD values for both WP version and non-WP version. 48 static 49 Int64 xCalcSADvalueWP(const Int bitDepth, 50 const Pel *pOrgPel, 51 const Pel *pRefPel, 52 const Int width, 53 const Int height, 54 const Int orgStride, 55 const Int refStride, 56 const Int log2Denom, 57 const Int weight, 58 const Int offset, 59 const Bool useHighPrecision); 60 61 //! calculate SAD values for both WP version and non-WP version. 62 static 63 Int64 xCalcSADvalueWPOptionalClip(const Int bitDepth, 64 const Pel *pOrgPel, 65 const Pel *pRefPel, 66 const Int width, 67 const Int height, 68 const Int orgStride, 69 const Int refStride, 70 const Int log2Denom, 71 const Int weight, 72 const Int offset, 73 const Bool useHighPrecision, 74 const Bool clipped); 75 76 // ----------------------------------------------------------------------------- 77 // Helper functions 78 79 80 //! calculate Histogram for array of pixels 81 static 82 Void xCalcHistogram(const Pel *pPel, 83 std::vector<Int> &histogram, 84 const Int width, 85 const Int height, 86 const Int stride, 87 const Int maxPel) 88 { 89 histogram.clear(); 90 histogram.resize(maxPel); 91 for( Int y = 0; y < height; y++ ) 92 { 93 for( Int x = 0; x < width; x++ ) 94 { 95 const Pel v=pPel[x]; 96 histogram[v<0?0:(v>=maxPel)?maxPel-1:v]++; 97 } 98 pPel += stride; 99 } 100 } 101 102 static 103 Distortion xCalcHistDistortion (const std::vector<Int> &histogram0, 104 const std::vector<Int> &histogram1) 105 { 106 Distortion distortion = 0; 107 assert(histogram0.size()==histogram1.size()); 108 const Int numElements=Int(histogram0.size()); 109 110 // Scan histograms to compute histogram distortion 111 for (Int i = 0; i <= numElements; i++) 112 { 113 distortion += (Distortion)(abs(histogram0[i] - histogram1[i])); 114 } 115 116 return distortion; 117 } 118 119 static 120 void xScaleHistogram(const std::vector<Int> &histogramInput, 121 std::vector<Int> &histogramOutput, // cannot be the same as the input 122 const Int bitDepth, 123 const Int log2Denom, 124 const Int weight, 125 const Int offset, 126 const Bool bHighPrecision) 127 { 128 assert(&histogramInput != &histogramOutput); 129 const Int numElements=Int(histogramInput.size()); 130 histogramOutput.clear(); 131 histogramOutput.resize(numElements); 132 133 const Int64 iRealLog2Denom = bHighPrecision ? 0 : (bitDepth - 8); 134 const Int64 iRealOffset = ((Int64)offset)<<iRealLog2Denom; 135 136 const Int divOffset = log2Denom == 0 ? 0 : 1 << (log2Denom - 1); 137 // Scan histogram and apply illumination parameters appropriately 138 // Then compute updated histogram. 139 // Note that this technique only works with single list weights/offsets. 140 141 for (Int i = 0; i < numElements; i++) 142 { 143 const Int j = Clip3(0, numElements - 1, (Int)(((weight * i + divOffset) >> log2Denom) + iRealOffset)); 144 histogramOutput[j] += histogramInput[i]; 145 } 146 } 147 148 static 149 Distortion xSearchHistogram(const std::vector<Int> &histogramSource, 150 const std::vector<Int> &histogramRef, 151 std::vector<Int> &outputHistogram, 152 const Int bitDepth, 153 const Int log2Denom, 154 Int &weightToUpdate, 155 Int &offsetToUpdate, 156 const Bool bHighPrecision, 157 const ComponentID compID) 158 { 159 const Int initialWeight = weightToUpdate; 160 const Int initialOffset = offsetToUpdate; 161 const Int weightRange = 10; 162 const Int offsetRange = 10; 163 const Int maxOffset = 1 << ((bHighPrecision == true) ? (bitDepth - 1) : 7); 164 const Int range = bHighPrecision ? (1<<bitDepth) / 2 : 128; 165 const Int defaultWeight = (1<<log2Denom); 166 const Int minSearchWeight = std::max<Int>(initialWeight - weightRange, defaultWeight - range); 167 const Int maxSearchWeight = std::min<Int>(initialWeight + weightRange+1, defaultWeight + range); 168 169 Distortion minDistortion = std::numeric_limits<Distortion>::max(); 170 Int bestWeight = initialWeight; 171 Int bestOffset = initialOffset; 172 173 for (Int searchWeight = minSearchWeight; searchWeight < maxSearchWeight; searchWeight++) 174 { 175 if (compID == COMPONENT_Y) 176 { 177 for (Int searchOffset = std::max<Int>(initialOffset - offsetRange, -maxOffset); 178 searchOffset <= initialOffset + offsetRange && searchOffset<=(maxOffset-1); 179 searchOffset++) 180 { 181 xScaleHistogram(histogramRef, outputHistogram, bitDepth, log2Denom, searchWeight, searchOffset, bHighPrecision); 182 const Distortion distortion = xCalcHistDistortion(histogramSource, outputHistogram); 183 184 if (distortion < minDistortion) 185 { 186 minDistortion = distortion; 187 bestWeight = searchWeight; 188 bestOffset = searchOffset; 189 } 190 } 191 } 192 else 193 { 194 const Int pred = ( maxOffset - ( ( maxOffset*searchWeight)>>(log2Denom) ) ); 195 196 for (Int searchOffset = initialOffset - offsetRange; searchOffset <= initialOffset + offsetRange; searchOffset++) 197 { 198 const Int deltaOffset = Clip3( -4*maxOffset, 4*maxOffset-1, (searchOffset - pred) ); // signed 10bit (if !bHighPrecision) 199 const Int clippedOffset = Clip3( -1*maxOffset, 1*maxOffset-1, (deltaOffset + pred) ); // signed 8bit (if !bHighPrecision) 200 xScaleHistogram(histogramRef, outputHistogram, bitDepth, log2Denom, searchWeight, clippedOffset, bHighPrecision); 201 const Distortion distortion = xCalcHistDistortion(histogramSource, outputHistogram); 202 203 if (distortion < minDistortion) 204 { 205 minDistortion = distortion; 206 bestWeight = searchWeight; 207 bestOffset = clippedOffset; 208 } 209 } 210 } 211 } 212 213 weightToUpdate = bestWeight; 214 offsetToUpdate = bestOffset; 215 216 // regenerate best histogram 217 xScaleHistogram(histogramRef, outputHistogram, bitDepth, log2Denom, bestWeight, bestOffset, bHighPrecision); 218 219 return minDistortion; 220 } 221 222 223 // ----------------------------------------------------------------------------- 224 // Member functions 46 225 47 226 WeightPredAnalysis::WeightPredAnalysis() … … 49 228 for ( UInt lst =0 ; lst<NUM_REF_PIC_LIST_01 ; lst++ ) 50 229 { 51 for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )230 for ( Int refIdx=0 ; refIdx<MAX_NUM_REF ; refIdx++ ) 52 231 { 53 232 for ( Int comp=0 ; comp<MAX_NUM_COMPONENT ;comp++ ) 54 233 { 55 WPScalingParam *pwp = &(m_wp[lst][ iRefIdx][comp]);234 WPScalingParam *pwp = &(m_wp[lst][refIdx][comp]); 56 235 pwp->bPresentFlag = false; 57 236 pwp->uiLog2WeightDenom = 0; … … 78 257 // calculate DC/AC value for channel 79 258 80 const Int iStride = pPic->getStride(compID);81 const Int iWidth = pPic->getWidth(compID);82 const Int iHeight = pPic->getHeight(compID);83 84 const Int iSample = iWidth*iHeight;85 86 Int64 iOrgDC = 0;259 const Int stride = pPic->getStride(compID); 260 const Int width = pPic->getWidth(compID); 261 const Int height = pPic->getHeight(compID); 262 263 const Int sample = width*height; 264 265 Int64 orgDC = 0; 87 266 { 88 267 const Pel *pPel = pPic->getAddr(compID); 89 268 90 for(Int y = 0; y < iHeight; y++, pPel+=iStride )91 { 92 for(Int x = 0; x < iWidth; x++ )93 { 94 iOrgDC += (Int)( pPel[x] );95 } 96 } 97 } 98 99 const Int64 iOrgNormDC = ((iOrgDC+(iSample>>1)) / iSample);100 101 Int64 iOrgAC = 0;269 for(Int y = 0; y < height; y++, pPel+=stride ) 270 { 271 for(Int x = 0; x < width; x++ ) 272 { 273 orgDC += (Int)( pPel[x] ); 274 } 275 } 276 } 277 278 const Int64 orgNormDC = ((orgDC+(sample>>1)) / sample); 279 280 Int64 orgAC = 0; 102 281 { 103 282 const Pel *pPel = pPic->getAddr(compID); 104 283 105 for(Int y = 0; y < iHeight; y++, pPel += iStride )106 { 107 for(Int x = 0; x < iWidth; x++ )108 { 109 iOrgAC += abs( (Int)pPel[x] - (Int)iOrgNormDC );284 for(Int y = 0; y < height; y++, pPel += stride ) 285 { 286 for(Int x = 0; x < width; x++ ) 287 { 288 orgAC += abs( (Int)pPel[x] - (Int)orgNormDC ); 110 289 } 111 290 } … … 113 292 114 293 const Int fixedBitShift = (slice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag())?RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION:0; 115 weightACDCParam[compID].iDC = ((( iOrgDC<<fixedBitShift)+(iSample>>1)) / iSample);116 weightACDCParam[compID].iAC = iOrgAC;294 weightACDCParam[compID].iDC = (((orgDC<<fixedBitShift)+(sample>>1)) / sample); 295 weightACDCParam[compID].iAC = orgAC; 117 296 } 118 297 … … 126 305 const TComPicYuv *pPic = slice->getPic()->getPicYuvOrg(); 127 306 128 Int iPresentCnt = 0;307 Int presentCnt = 0; 129 308 for ( UInt lst=0 ; lst<NUM_REF_PIC_LIST_01 ; lst++ ) 130 309 { 131 for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )310 for ( Int refIdx=0 ; refIdx<MAX_NUM_REF ; refIdx++ ) 132 311 { 133 312 for(Int componentIndex = 0; componentIndex < pPic->getNumberValidComponents(); componentIndex++) 134 313 { 135 WPScalingParam *pwp = &(m_wp[lst][ iRefIdx][componentIndex]);136 iPresentCnt += (Int)pwp->bPresentFlag;137 } 138 } 139 } 140 141 if( iPresentCnt==0)314 WPScalingParam *pwp = &(m_wp[lst][refIdx][componentIndex]); 315 presentCnt += (Int)pwp->bPresentFlag; 316 } 317 } 318 } 319 320 if(presentCnt==0) 142 321 { 143 322 slice->setTestWeightPred(false); … … 146 325 for ( UInt lst=0 ; lst<NUM_REF_PIC_LIST_01 ; lst++ ) 147 326 { 148 for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )327 for ( Int refIdx=0 ; refIdx<MAX_NUM_REF ; refIdx++ ) 149 328 { 150 329 for(Int componentIndex = 0; componentIndex < pPic->getNumberValidComponents(); componentIndex++) 151 330 { 152 WPScalingParam *pwp = &(m_wp[lst][ iRefIdx][componentIndex]);331 WPScalingParam *pwp = &(m_wp[lst][refIdx][componentIndex]); 153 332 154 333 pwp->bPresentFlag = false; … … 163 342 else 164 343 { 165 slice->setTestWeightPred (slice->getPPS()->getUseWP());344 slice->setTestWeightPred (slice->getPPS()->getUseWP()); 166 345 slice->setTestWeightBiPred(slice->getPPS()->getWPBiPred()); 167 346 } … … 170 349 171 350 //! estimate wp tables for explicit wp 172 Void WeightPredAnalysis::xEstimateWPParamSlice(TComSlice *const slice )351 Void WeightPredAnalysis::xEstimateWPParamSlice(TComSlice *const slice, const WeightedPredictionMethod method) 173 352 { 174 353 Int iDenom = 6; … … 191 370 // selecting whether WP is used, or not (fast search) 192 371 // NOTE: This is not operating on a slice, but the entire picture. 193 xSelectWP(slice, iDenom); 372 switch (method) 373 { 374 case WP_PER_PICTURE_WITH_SIMPLE_DC_COMBINED_COMPONENT: 375 xSelectWP(slice, iDenom); 376 break; 377 case WP_PER_PICTURE_WITH_SIMPLE_DC_PER_COMPONENT: 378 xSelectWPHistExtClip(slice, iDenom, false, false, false); 379 break; 380 case WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT: 381 xSelectWPHistExtClip(slice, iDenom, false, false, true); 382 break; 383 case WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING: 384 xSelectWPHistExtClip(slice, iDenom, false, true, true); 385 break; 386 case WP_PER_PICTURE_WITH_HISTOGRAM_AND_PER_COMPONENT_AND_CLIPPING_AND_EXTENSION: 387 xSelectWPHistExtClip(slice, iDenom, true, true, true); 388 break; 389 default: 390 assert(0); 391 exit(1); 392 } 194 393 195 394 slice->setWpScaling( m_wp ); … … 251 450 // Weighting factor limitation 252 451 const Int defaultWeight = (1<<log2Denom); 253 const Int deltaWeight = ( defaultWeight - weight);452 const Int deltaWeight = (weight - defaultWeight); 254 453 255 454 if(deltaWeight >= range || deltaWeight < -range) … … 269 468 270 469 470 /** select whether weighted pred enables or not. 471 * \param TComSlice *slice 472 * \param log2Denom 473 * \returns Bool 474 */ 475 Bool WeightPredAnalysis::xSelectWPHistExtClip(TComSlice *const slice, const Int log2Denom, const Bool bDoEnhancement, const Bool bClipInitialSADWP, const Bool bUseHistogram) 476 { 477 const TComPicYuv *const pPic = slice->getPic()->getPicYuvOrg(); 478 const Int defaultWeight = 1<<log2Denom; 479 const Int numPredDir = slice->isInterP() ? 1 : 2; 480 const Bool useHighPrecision = slice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag(); 481 482 assert (numPredDir <= Int(NUM_REF_PIC_LIST_01)); 483 484 for ( Int refList = 0; refList < numPredDir; refList++ ) 485 { 486 const RefPicList eRefPicList = ( refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 487 488 for ( Int refIdxTemp = 0; refIdxTemp < slice->getNumRefIdx(eRefPicList); refIdxTemp++ ) 489 { 490 Bool useChromaWeight = false; 491 492 for(Int comp=0; comp<pPic->getNumberValidComponents(); comp++) 493 { 494 const ComponentID compID = ComponentID(comp); 495 const Pel *pOrg = pPic->getAddr(compID); 496 const Pel *pRef = slice->getRefPic(eRefPicList, refIdxTemp)->getPicYuvRec()->getAddr(compID); 497 const Int orgStride = pPic->getStride(compID); 498 const Int refStride = slice->getRefPic(eRefPicList, refIdxTemp)->getPicYuvRec()->getStride(compID); 499 const Int width = pPic->getWidth(compID); 500 const Int height = pPic->getHeight(compID); 501 const Int bitDepth = slice->getSPS()->getBitDepth(toChannelType(compID)); 502 WPScalingParam &wp = m_wp[refList][refIdxTemp][compID]; 503 Int weight = wp.iWeight; 504 Int offset = wp.iOffset; 505 Int weightDef = defaultWeight; 506 Int offsetDef = 0; 507 508 // calculate SAD costs with/without wp for luma 509 const Int64 SADnoWP = xCalcSADvalueWPOptionalClip(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, defaultWeight, 0, useHighPrecision, bClipInitialSADWP); 510 if (SADnoWP > 0) 511 { 512 const Int64 SADWP = xCalcSADvalueWPOptionalClip(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weight, offset, useHighPrecision, bClipInitialSADWP); 513 const Double dRatioSAD = (Double)SADWP / (Double)SADnoWP; 514 Double dRatioSr0SAD = std::numeric_limits<Double>::max(); 515 Double dRatioSrSAD = std::numeric_limits<Double>::max(); 516 517 if (bUseHistogram) 518 { 519 std::vector<Int> histogramOrg;// = pPic->getHistogram(compID); 520 std::vector<Int> histogramRef;// = slice->getRefPic(eRefPicList, refIdxTemp)->getPicYuvRec()->getHistogram(compID); 521 std::vector<Int> searchedHistogram; 522 523 // Compute histograms 524 xCalcHistogram(pOrg, histogramOrg, width, height, orgStride, 1 << bitDepth); 525 xCalcHistogram(pRef, histogramRef, width, height, refStride, 1 << bitDepth); 526 527 // Do a histogram search around DC WP parameters; resulting distortion and 'searchedHistogram' is discarded 528 xSearchHistogram(histogramOrg, histogramRef, searchedHistogram, bitDepth, log2Denom, weight, offset, useHighPrecision, compID); 529 // calculate updated WP SAD 530 const Int64 SADSrWP = xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weight, offset, useHighPrecision); 531 dRatioSrSAD = (Double)SADSrWP / (Double)SADnoWP; 532 533 if (bDoEnhancement) 534 { 535 // Do the same around the default ones; resulting distortion and 'searchedHistogram' is discarded 536 xSearchHistogram(histogramOrg, histogramRef, searchedHistogram, bitDepth, log2Denom, weightDef, offsetDef, useHighPrecision, compID); 537 // calculate updated WP SAD 538 const Int64 SADSr0WP = xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weightDef, offsetDef, useHighPrecision); 539 dRatioSr0SAD = (Double)SADSr0WP / (Double)SADnoWP; 540 } 541 } 542 543 if(min(dRatioSr0SAD, min(dRatioSAD, dRatioSrSAD)) >= WEIGHT_PRED_SAD_RELATIVE_TO_NON_WEIGHT_PRED_SAD) 544 { 545 wp.bPresentFlag = false; 546 wp.iOffset = 0; 547 wp.iWeight = defaultWeight; 548 wp.uiLog2WeightDenom = log2Denom; 549 } 550 else 551 { 552 if (compID != COMPONENT_Y) 553 { 554 useChromaWeight = true; 555 } 556 557 if (dRatioSr0SAD < dRatioSrSAD && dRatioSr0SAD < dRatioSAD) 558 { 559 wp.bPresentFlag = true; 560 wp.iOffset = offsetDef; 561 wp.iWeight = weightDef; 562 wp.uiLog2WeightDenom = log2Denom; 563 } 564 else if (dRatioSrSAD < dRatioSAD) 565 { 566 wp.bPresentFlag = true; 567 wp.iOffset = offset; 568 wp.iWeight = weight; 569 wp.uiLog2WeightDenom = log2Denom; 570 } 571 } 572 } 573 else // (SADnoWP <= 0) 574 { 575 wp.bPresentFlag = false; 576 wp.iOffset = 0; 577 wp.iWeight = defaultWeight; 578 wp.uiLog2WeightDenom = log2Denom; 579 } 580 } 581 582 for(Int comp=1; comp<pPic->getNumberValidComponents(); comp++) 583 { 584 m_wp[refList][refIdxTemp][comp].bPresentFlag = useChromaWeight; 585 } 586 } 587 } 588 589 return true; 590 } 591 271 592 //! select whether weighted pred enables or not. 272 593 Bool WeightPredAnalysis::xSelectWP(TComSlice *const slice, const Int log2Denom) 273 594 { 274 595 TComPicYuv *const pPic = slice->getPic()->getPicYuvOrg(); 275 const Int iDefaultWeight = ((Int)1<<log2Denom);276 const Int iNumPredDir= slice->isInterP() ? 1 : 2;596 const Int defaultWeight = 1<<log2Denom; 597 const Int numPredDir = slice->isInterP() ? 1 : 2; 277 598 const Bool useHighPrecisionPredictionWeighting = slice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag(); 278 599 279 assert ( iNumPredDir <= Int(NUM_REF_PIC_LIST_01));280 281 for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )282 { 283 const RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );284 285 for ( Int iRefIdxTemp = 0; iRefIdxTemp < slice->getNumRefIdx(eRefPicList); iRefIdxTemp++ )286 { 287 Int64 iSADWP = 0, iSADnoWP = 0;600 assert (numPredDir <= Int(NUM_REF_PIC_LIST_01)); 601 602 for ( Int refList = 0; refList < numPredDir; refList++ ) 603 { 604 const RefPicList eRefPicList = ( refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 605 606 for ( Int refIdxTemp = 0; refIdxTemp < slice->getNumRefIdx(eRefPicList); refIdxTemp++ ) 607 { 608 Int64 SADWP = 0, SADnoWP = 0; 288 609 289 610 for(Int comp=0; comp<pPic->getNumberValidComponents(); comp++) … … 291 612 const ComponentID compID = ComponentID(comp); 292 613 Pel *pOrg = pPic->getAddr(compID); 293 Pel *pRef = slice->getRefPic(eRefPicList, iRefIdxTemp)->getPicYuvRec()->getAddr(compID);294 const Int iOrgStride = pPic->getStride(compID);295 const Int iRefStride = slice->getRefPic(eRefPicList, iRefIdxTemp)->getPicYuvRec()->getStride(compID);296 const Int iWidth = pPic->getWidth(compID);297 const Int iHeight = pPic->getHeight(compID);614 Pel *pRef = slice->getRefPic(eRefPicList, refIdxTemp)->getPicYuvRec()->getAddr(compID); 615 const Int orgStride = pPic->getStride(compID); 616 const Int refStride = slice->getRefPic(eRefPicList, refIdxTemp)->getPicYuvRec()->getStride(compID); 617 const Int width = pPic->getWidth(compID); 618 const Int height = pPic->getHeight(compID); 298 619 const Int bitDepth = slice->getSPS()->getBitDepth(toChannelType(compID)); 299 620 300 621 // calculate SAD costs with/without wp for luma 301 iSADWP += xCalcSADvalueWP(bitDepth, pOrg, pRef, iWidth, iHeight, iOrgStride, iRefStride, log2Denom, m_wp[iRefList][iRefIdxTemp][compID].iWeight, m_wp[iRefList][iRefIdxTemp][compID].iOffset, useHighPrecisionPredictionWeighting);302 iSADnoWP += xCalcSADvalueWP(bitDepth, pOrg, pRef, iWidth, iHeight, iOrgStride, iRefStride, log2Denom, iDefaultWeight, 0, useHighPrecisionPredictionWeighting);303 } 304 305 const Double dRatio = ((Double)iSADWP / (Double)iSADnoWP);306 if(dRatio >= (Double)DTHRESH)622 SADWP += xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, m_wp[refList][refIdxTemp][compID].iWeight, m_wp[refList][refIdxTemp][compID].iOffset, useHighPrecisionPredictionWeighting); 623 SADnoWP += xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, defaultWeight, 0, useHighPrecisionPredictionWeighting); 624 } 625 626 const Double dRatio = SADnoWP > 0 ? (((Double)SADWP / (Double)SADnoWP)) : std::numeric_limits<Double>::max(); 627 if(dRatio >= WEIGHT_PRED_SAD_RELATIVE_TO_NON_WEIGHT_PRED_SAD) 307 628 { 308 629 for(Int comp=0; comp<pPic->getNumberValidComponents(); comp++) 309 630 { 310 m_wp[iRefList][iRefIdxTemp][comp].bPresentFlag = false; 311 m_wp[iRefList][iRefIdxTemp][comp].iOffset = 0; 312 m_wp[iRefList][iRefIdxTemp][comp].iWeight = iDefaultWeight; 313 m_wp[iRefList][iRefIdxTemp][comp].uiLog2WeightDenom = log2Denom; 631 WPScalingParam &wp=m_wp[refList][refIdxTemp][comp]; 632 wp.bPresentFlag = false; 633 wp.iOffset = 0; 634 wp.iWeight = defaultWeight; 635 wp.uiLog2WeightDenom = log2Denom; 314 636 } 315 637 } … … 320 642 } 321 643 322 323 //! calculate SAD values for both WP version and non-WP version. 324 Int64 WeightPredAnalysis::xCalcSADvalueWP(const Int bitDepth, 325 const Pel *pOrgPel, 326 const Pel *pRefPel, 327 const Int iWidth, 328 const Int iHeight, 329 const Int iOrgStride, 330 const Int iRefStride, 331 const Int iLog2Denom, 332 const Int iWeight, 333 const Int iOffset, 334 const Bool useHighPrecisionPredictionWeighting) 335 { 336 const Int64 iSize = iWidth*iHeight; 337 const Int64 iRealLog2Denom = useHighPrecisionPredictionWeighting ? iLog2Denom : (iLog2Denom + (bitDepth - 8)); 338 339 Int64 iSAD = 0; 340 for( Int y = 0; y < iHeight; y++ ) 341 { 342 for( Int x = 0; x < iWidth; x++ ) 343 { 344 iSAD += ABS(( ((Int64)pOrgPel[x]<<(Int64)iLog2Denom) - ( (Int64)pRefPel[x] * (Int64)iWeight + ((Int64)iOffset<<iRealLog2Denom) ) ) ); 345 } 346 pOrgPel += iOrgStride; 347 pRefPel += iRefStride; 348 } 349 350 return (iSAD/iSize); 351 } 644 // Alternatively, a SSE-based measure could be used instead. 645 // The respective function has been removed as it currently redundant. 646 static 647 Int64 xCalcSADvalueWP(const Int bitDepth, 648 const Pel *pOrgPel, 649 const Pel *pRefPel, 650 const Int width, 651 const Int height, 652 const Int orgStride, 653 const Int refStride, 654 const Int log2Denom, 655 const Int weight, 656 const Int offset, 657 const Bool useHighPrecision) 658 { 659 //const Int64 iSize = iWidth*iHeight; 660 const Int64 realLog2Denom = useHighPrecision ? log2Denom : (log2Denom + (bitDepth - 8)); 661 const Int64 realOffset = ((Int64)offset)<<realLog2Denom; 662 663 Int64 SAD = 0; 664 for( Int y = 0; y < height; y++ ) 665 { 666 for( Int x = 0; x < width; x++ ) 667 { 668 SAD += abs(( ((Int64)pOrgPel[x] << (Int64) log2Denom) - ( (Int64) pRefPel[x] * (Int64) weight + (realOffset) ) ) ); 669 } 670 pOrgPel += orgStride; 671 pRefPel += refStride; 672 } 673 674 //return (iSAD/iSize); 675 return SAD; 676 } 677 678 static 679 Int64 xCalcSADvalueWPOptionalClip(const Int bitDepth, 680 const Pel *pOrgPel, 681 const Pel *pRefPel, 682 const Int width, 683 const Int height, 684 const Int orgStride, 685 const Int refStride, 686 const Int log2Denom, 687 const Int weight, 688 const Int offset, 689 const Bool useHighPrecision, 690 const Bool clipped) 691 { 692 Int64 SAD = 0; 693 if (clipped) 694 { 695 const Int64 realLog2Denom = useHighPrecision ? 0 : (bitDepth - 8); 696 const Int64 realOffset = (Int64)offset<<realLog2Denom; 697 const Int64 roundOffset = (log2Denom == 0) ? 0 : 1 << (log2Denom - 1); 698 const Int64 minValue = 0; 699 const Int64 maxValue = (1 << bitDepth) - 1; 700 701 for( Int y = 0; y < height; y++ ) 702 { 703 for( Int x = 0; x < width; x++ ) 704 { 705 Int64 scaledValue = Clip3(minValue, maxValue, ((((Int64) pRefPel[x] * (Int64) weight + roundOffset) ) >> (Int64) log2Denom) + realOffset); 706 SAD += abs((Int64)pOrgPel[x] - scaledValue); 707 } 708 pOrgPel += orgStride; 709 pRefPel += refStride; 710 } 711 } 712 else 713 { 714 //const Int64 iSize = iWidth*iHeight; 715 const Int64 realLog2Denom = useHighPrecision ? log2Denom : (log2Denom + (bitDepth - 8)); 716 const Int64 realOffset = ((Int64)offset)<<realLog2Denom; 717 718 for( Int y = 0; y < height; y++ ) 719 { 720 for( Int x = 0; x < width; x++ ) 721 { 722 SAD += abs(( ((Int64)pOrgPel[x] << (Int64) log2Denom) - ( (Int64) pRefPel[x] * (Int64) weight + (realOffset) ) ) ); 723 } 724 pOrgPel += orgStride; 725 pRefPel += refStride; 726 } 727 } 728 return SAD; 729 } -
branches/HTM-15.2-dev/source/Lib/TLibEncoder/WeightPredAnalysis.h
r1313 r1360 52 52 53 53 Bool xSelectWP (TComSlice *const slice, const Int log2Denom); 54 Bool xSelectWPHistExtClip (TComSlice *const slice, const Int log2Denom, const Bool bDoEnhancement, const Bool bClipInitialSADWP, const Bool bUseHistogram); 54 55 Bool xUpdatingWPParameters(TComSlice *const slice, const Int log2Denom); 55 56 Int64 xCalcSADvalueWP (const Int bitDepth,57 const Pel *pOrgPel,58 const Pel *pRefPel,59 const Int iWidth,60 const Int iHeight,61 const Int iOrgStride,62 const Int iRefStride,63 const Int iLog2Denom,64 const Int iWeight,65 const Int iOffset,66 const Bool useHighPrecisionPredictionWeighting);67 56 68 57 public: … … 72 61 // WP analysis : 73 62 Void xCalcACDCParamSlice (TComSlice *const slice); 74 Void xEstimateWPParamSlice(TComSlice *const slice );63 Void xEstimateWPParamSlice(TComSlice *const slice, const WeightedPredictionMethod method); 75 64 Void xCheckWPEnable (TComSlice *const slice); 76 65 };
Note: See TracChangeset for help on using the changeset viewer.