- Timestamp:
- 11 Oct 2013, 05:54:02 (11 years ago)
- Location:
- branches/SHM-3.1-dev/source
- Files:
-
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-3.1-dev/source/App/TAppDecoder/TAppDecTop.cpp
r389 r431 56 56 TAppDecTop::TAppDecTop() 57 57 { 58 ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));59 58 for(UInt layer=0; layer < MAX_LAYERS; layer++) 60 59 { … … 67 66 : m_iPOCLastDisplay(-MAX_INT) 68 67 { 69 ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));70 68 } 71 69 #endif … … 146 144 147 145 // main decoder loop 148 Bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)146 Bool openedReconFile[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen) 149 147 for(UInt layer=0; layer<=m_tgtLayerId; layer++) 150 148 { 151 recon_opened[layer] = false;149 openedReconFile[layer] = false; 152 150 m_aiPOCLastDisplay[layer] += m_iSkipFrame; // set the last displayed POC correctly for skip forward. 153 151 } … … 235 233 if( pcListPic ) 236 234 { 237 if ( m_pchReconFile[curLayerId] && ! recon_opened[curLayerId] )235 if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] ) 238 236 { 239 237 if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } … … 242 240 m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 243 241 244 recon_opened[curLayerId] = true;242 openedReconFile[curLayerId] = true; 245 243 } 246 244 if ( bNewPicture && bNewPOC && … … 278 276 pcBLPic.destroy(); 279 277 280 for(UInt layer = 1; layer <= m_tgtLayerId; layer++) 278 UInt layerIdmin = m_acTDecTop[0].getBLReconFile() == NULL ? 0 : 1; 279 280 for(UInt layer = layerIdmin; layer <= m_tgtLayerId; layer++) 281 281 #else 282 282 for(UInt layer = 0; layer <= m_tgtLayerId; layer++) … … 310 310 311 311 // main decoder loop 312 Bool recon_opened= false; // reconstruction file not yet opened. (must be performed after SPS is seen)312 Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen) 313 313 314 314 #if SYNTAX_OUTPUT … … 341 341 streampos location = bitstreamFile.tellg(); 342 342 AnnexBStats stats = AnnexBStats(); 343 Bool bPreviousPictureDecoded = false;344 343 345 344 vector<uint8_t> nalUnit; … … 363 362 if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) 364 363 { 365 if(bPreviousPictureDecoded)366 {367 bNewPicture = true;368 bPreviousPictureDecoded = false;369 }370 else371 {372 364 bNewPicture = false; 373 365 } 374 }375 366 else 376 367 { … … 386 377 bytestream.reset(); 387 378 } 388 bPreviousPictureDecoded = true;389 379 } 390 380 } … … 396 386 if( pcListPic ) 397 387 { 398 if ( m_pchReconFile && ! recon_opened)388 if ( m_pchReconFile && !openedReconFile ) 399 389 { 400 390 if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } … … 402 392 403 393 m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode 404 recon_opened= true;394 openedReconFile = true; 405 395 } 406 396 if ( bNewPicture && … … 508 498 509 499 /** \param pcListPic list of pictures to be written to file 510 511 500 \todo DYN_REF_FREE should be revised 501 */ 512 502 #if SVC_EXTENSION 513 503 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId ) … … 517 507 { 518 508 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); 519 Int n ot_displayed = 0;509 Int numPicsNotYetDisplayed = 0; 520 510 521 511 while (iterPic != pcListPic->end()) … … 528 518 #endif 529 519 { 530 not_displayed++;520 numPicsNotYetDisplayed++; 531 521 } 532 522 iterPic++; 533 523 } 534 524 iterPic = pcListPic->begin(); 535 536 while (iterPic != pcListPic->end()) 537 { 538 TComPic* pcPic = *(iterPic); 539 540 #if SVC_EXTENSION 541 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId])) 542 #else 543 if ( pcPic->getOutputMark() && (not_displayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) 544 #endif 545 { 546 // write to file 547 not_displayed--; 548 #if SVC_EXTENSION 549 if ( m_pchReconFile[layerId] ) 550 { 551 const Window &conf = pcPic->getConformanceWindow(); 552 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 525 if (numPicsNotYetDisplayed>2) 526 { 527 iterPic++; 528 } 529 530 TComPic* pcPic = *(iterPic); 531 if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding 532 { 533 TComList<TComPic*>::iterator endPic = pcListPic->end(); 534 endPic--; 535 iterPic = pcListPic->begin(); 536 while (iterPic != endPic) 537 { 538 TComPic* pcPicTop = *(iterPic); 539 iterPic++; 540 TComPic* pcPicBottom = *(iterPic); 541 542 #if SVC_EXTENSION 543 if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed > pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) 544 && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed > pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_aiPOCLastDisplay[layerId]+1 || m_aiPOCLastDisplay[layerId]<0))) 545 #else 546 if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed > pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) 547 && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed > pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0))) 548 #endif 549 { 550 // write to file 551 numPicsNotYetDisplayed = numPicsNotYetDisplayed-2; 552 #if SVC_EXTENSION 553 if ( m_pchReconFile[layerId] ) 554 { 555 const Window &conf = pcPicTop->getConformanceWindow(); 556 const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); 557 const Bool isTff = pcPicTop->isTopField(); 553 558 #if REPN_FORMAT_IN_VPS 554 UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc(); 555 Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 556 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 557 conf.getWindowLeftOffset() * xScal + defDisp.getWindowLeftOffset(), 558 conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(), 559 conf.getWindowTopOffset() * yScal + defDisp.getWindowTopOffset(), 560 conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() ); 561 562 #else 563 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 564 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 565 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 566 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 567 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 568 #endif 569 } 570 571 // update POC of display order 572 m_aiPOCLastDisplay[layerId] = pcPic->getPOC(); 573 #else 574 if ( m_pchReconFile ) 575 { 559 UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc(); 560 Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 561 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 562 conf.getWindowLeftOffset() * xScal + defDisp.getWindowLeftOffset(), 563 conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(), 564 conf.getWindowTopOffset() * yScal + defDisp.getWindowTopOffset(), 565 conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() ); 566 567 #else 568 m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), 569 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 570 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 571 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 572 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); 573 #endif 574 } 575 576 // update POC of display order 577 m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC(); 578 #else 579 if ( m_pchReconFile ) 580 { 581 const Window &conf = pcPicTop->getConformanceWindow(); 582 const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); 583 const Bool isTff = pcPicTop->isTopField(); 584 m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), 585 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 586 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 587 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 588 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); 589 } 590 591 // update POC of display order 592 m_iPOCLastDisplay = pcPicBottom->getPOC(); 593 #endif 594 595 // erase non-referenced picture in the reference picture list after display 596 if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true ) 597 { 598 #if !DYN_REF_FREE 599 pcPicTop->setReconMark(false); 600 601 // mark it should be extended later 602 pcPicTop->getPicYuvRec()->setBorderExtension( false ); 603 604 #else 605 pcPicTop->destroy(); 606 pcListPic->erase( iterPic ); 607 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 608 continue; 609 #endif 610 } 611 if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true ) 612 { 613 #if !DYN_REF_FREE 614 pcPicBottom->setReconMark(false); 615 616 // mark it should be extended later 617 pcPicBottom->getPicYuvRec()->setBorderExtension( false ); 618 619 #else 620 pcPicBottom->destroy(); 621 pcListPic->erase( iterPic ); 622 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 623 continue; 624 #endif 625 } 626 pcPicTop->setOutputMark(false); 627 pcPicBottom->setOutputMark(false); 628 } 629 } 630 } 631 else if (!pcPic->isField()) //Frame Decoding 632 { 633 iterPic = pcListPic->begin(); 634 while (iterPic != pcListPic->end()) 635 { 636 pcPic = *(iterPic); 637 638 #if SVC_EXTENSION 639 if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId])) 640 #else 641 if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) 642 #endif 643 { 644 // write to file 645 numPicsNotYetDisplayed--; 646 #if SVC_EXTENSION 647 if ( m_pchReconFile[layerId] ) 648 { 649 const Window &conf = pcPic->getConformanceWindow(); 650 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 651 #if REPN_FORMAT_IN_VPS 652 UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc(); 653 Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 654 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 655 conf.getWindowLeftOffset() * xScal + defDisp.getWindowLeftOffset(), 656 conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(), 657 conf.getWindowTopOffset() * yScal + defDisp.getWindowTopOffset(), 658 conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() ); 659 660 #else 661 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 662 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 663 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 664 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 665 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 666 #endif 667 } 668 669 // update POC of display order 670 m_aiPOCLastDisplay[layerId] = pcPic->getPOC(); 671 #else 672 if ( m_pchReconFile ) 673 { 576 674 #if SYNTAX_OUTPUT 577 const Window &conf = pcPic->getConformanceWindow();578 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();579 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),580 581 582 583 584 #endif 585 }586 587 // update POC of display order588 m_iPOCLastDisplay = pcPic->getPOC();589 #endif 590 591 // erase non-referenced picture in the reference picture list after display592 if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )593 {675 const Window &conf = pcPic->getConformanceWindow(); 676 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 677 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 678 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 679 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 680 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 681 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 682 #endif 683 } 684 685 // update POC of display order 686 m_iPOCLastDisplay = pcPic->getPOC(); 687 #endif 688 689 // erase non-referenced picture in the reference picture list after display 690 if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) 691 { 594 692 #if !DYN_REF_FREE 595 pcPic->setReconMark(false); 596 597 // mark it should be extended later 598 pcPic->getPicYuvRec()->setBorderExtension( false ); 599 600 #else 601 pcPic->destroy(); 602 pcListPic->erase( iterPic ); 603 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 604 continue; 605 #endif 606 } 607 pcPic->setOutputMark(false); 608 } 609 610 iterPic++; 693 pcPic->setReconMark(false); 694 695 // mark it should be extended later 696 pcPic->getPicYuvRec()->setBorderExtension( false ); 697 698 #else 699 pcPic->destroy(); 700 pcListPic->erase( iterPic ); 701 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 702 continue; 703 #endif 704 } 705 pcPic->setOutputMark(false); 706 } 707 708 iterPic++; 709 } 611 710 } 612 711 } … … 628 727 629 728 iterPic = pcListPic->begin(); 630 631 while (iterPic != pcListPic->end()) 632 { 633 TComPic* pcPic = *(iterPic); 634 635 if ( pcPic->getOutputMark() ) 636 { 637 // write to file 638 #if SVC_EXTENSION 639 if ( m_pchReconFile[layerId] ) 640 { 641 const Window &conf = pcPic->getConformanceWindow(); 642 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 729 TComPic* pcPic = *(iterPic); 730 731 if (pcPic->isField()) //Field Decoding 732 { 733 TComList<TComPic*>::iterator endPic = pcListPic->end(); 734 endPic--; 735 TComPic *pcPicTop, *pcPicBottom = NULL; 736 while (iterPic != endPic) 737 { 738 pcPicTop = *(iterPic); 739 iterPic++; 740 pcPicBottom = *(iterPic); 741 742 if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) ) 743 { 744 // write to file 745 #if SVC_EXTENSION 746 if ( m_pchReconFile[layerId] ) 747 { 748 const Window &conf = pcPicTop->getConformanceWindow(); 749 const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); 750 const Bool isTff = pcPicTop->isTopField(); 643 751 #if REPN_FORMAT_IN_VPS 644 UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc(); 645 Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 646 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 647 conf.getWindowLeftOffset() *xScal + defDisp.getWindowLeftOffset(), 648 conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(), 649 conf.getWindowTopOffset() *yScal + defDisp.getWindowTopOffset(), 650 conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() ); 651 652 #else 653 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 654 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 655 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 656 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 657 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 658 #endif 659 } 660 661 // update POC of display order 662 m_aiPOCLastDisplay[layerId] = pcPic->getPOC(); 663 #else 664 if ( m_pchReconFile ) 665 { 666 const Window &conf = pcPic->getConformanceWindow(); 667 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 668 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 669 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 670 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 671 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 672 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 673 } 674 675 // update POC of display order 676 m_iPOCLastDisplay = pcPic->getPOC(); 677 #endif 678 679 // erase non-referenced picture in the reference picture list after display 680 if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) 681 { 752 UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc(); 753 Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 754 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 755 conf.getWindowLeftOffset() *xScal + defDisp.getWindowLeftOffset(), 756 conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(), 757 conf.getWindowTopOffset() *yScal + defDisp.getWindowTopOffset(), 758 conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() ); 759 760 #else 761 m_cTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), 762 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 763 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 764 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 765 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); 766 #endif 767 } 768 769 // update POC of display order 770 m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC(); 771 #else 772 if ( m_pchReconFile ) 773 { 774 const Window &conf = pcPicTop->getConformanceWindow(); 775 const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); 776 const Bool isTff = pcPicTop->isTopField(); 777 m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), 778 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 779 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 780 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 781 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); 782 } 783 784 // update POC of display order 785 m_iPOCLastDisplay = pcPicBottom->getPOC(); 786 #endif 787 788 // erase non-referenced picture in the reference picture list after display 789 if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true ) 790 { 682 791 #if !DYN_REF_FREE 683 pcPic->setReconMark(false); 684 685 // mark it should be extended later 686 pcPic->getPicYuvRec()->setBorderExtension( false ); 687 688 #else 689 pcPic->destroy(); 690 pcListPic->erase( iterPic ); 691 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 692 continue; 693 #endif 694 } 695 pcPic->setOutputMark(false); 696 } 792 pcPicTop->setReconMark(false); 793 794 // mark it should be extended later 795 pcPicTop->getPicYuvRec()->setBorderExtension( false ); 796 797 #else 798 pcPicTop->destroy(); 799 pcListPic->erase( iterPic ); 800 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 801 continue; 802 #endif 803 } 804 if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true ) 805 { 806 #if !DYN_REF_FREE 807 pcPicBottom->setReconMark(false); 808 809 // mark it should be extended later 810 pcPicBottom->getPicYuvRec()->setBorderExtension( false ); 811 812 #else 813 pcPicBottom->destroy(); 814 pcListPic->erase( iterPic ); 815 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 816 continue; 817 #endif 818 } 819 pcPicTop->setOutputMark(false); 820 pcPicBottom->setOutputMark(false); 821 822 #if !DYN_REF_FREE 823 if(pcPicTop) 824 { 825 pcPicTop->destroy(); 826 delete pcPicTop; 827 pcPicTop = NULL; 828 } 829 #endif 830 } 831 } 832 if(pcPicBottom) 833 { 834 pcPicBottom->destroy(); 835 delete pcPicBottom; 836 pcPicBottom = NULL; 837 } 838 } 839 else //Frame decoding 840 { 841 while (iterPic != pcListPic->end()) 842 { 843 pcPic = *(iterPic); 844 845 if ( pcPic->getOutputMark() ) 846 { 847 // write to file 848 #if SVC_EXTENSION 849 if ( m_pchReconFile[layerId] ) 850 { 851 const Window &conf = pcPic->getConformanceWindow(); 852 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 853 #if REPN_FORMAT_IN_VPS 854 UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc(); 855 Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 856 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 857 conf.getWindowLeftOffset() *xScal + defDisp.getWindowLeftOffset(), 858 conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(), 859 conf.getWindowTopOffset() *yScal + defDisp.getWindowTopOffset(), 860 conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() ); 861 862 #else 863 m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), 864 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 865 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 866 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 867 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 868 #endif 869 } 870 871 // update POC of display order 872 m_aiPOCLastDisplay[layerId] = pcPic->getPOC(); 873 #else 874 if ( m_pchReconFile ) 875 { 876 const Window &conf = pcPic->getConformanceWindow(); 877 const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); 878 m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), 879 conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), 880 conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), 881 conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), 882 conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); 883 } 884 885 // update POC of display order 886 m_iPOCLastDisplay = pcPic->getPOC(); 887 #endif 888 889 // erase non-referenced picture in the reference picture list after display 890 if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) 891 { 892 #if !DYN_REF_FREE 893 pcPic->setReconMark(false); 894 895 // mark it should be extended later 896 pcPic->getPicYuvRec()->setBorderExtension( false ); 897 898 #else 899 pcPic->destroy(); 900 pcListPic->erase( iterPic ); 901 iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! 902 continue; 903 #endif 904 } 905 pcPic->setOutputMark(false); 906 } 697 907 #if !SVC_EXTENSION 698 908 #if !DYN_REF_FREE 699 if(pcPic)700 {701 pcPic->destroy();702 delete pcPic;703 pcPic = NULL;704 }909 if(pcPic) 910 { 911 pcPic->destroy(); 912 delete pcPic; 913 pcPic = NULL; 914 } 705 915 #endif 706 916 #endif 707 iterPic++; 917 iterPic++; 918 } 708 919 } 709 920 #if SVC_EXTENSION -
branches/SHM-3.1-dev/source/App/TAppDecoder/TAppDecTop.h
r313 r431 70 70 #endif 71 71 72 // for output control 73 Bool m_abDecFlag[ MAX_GOP ]; ///< decoded flag in one GOP 72 // for output control 74 73 #if SVC_EXTENSION 75 74 Int m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order -
branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp
r405 r431 348 348 349 349 #if SVC_EXTENSION 350 string cfg_LayerCfgFile [MAX_LAYERS];350 string cfg_LayerCfgFile [MAX_LAYERS]; 351 351 string cfg_BitstreamFile; 352 string* cfg_InputFile [MAX_LAYERS];353 string* cfg_ReconFile [MAX_LAYERS];354 Double* cfg_fQP [MAX_LAYERS];352 string* cfg_InputFile [MAX_LAYERS]; 353 string* cfg_ReconFile [MAX_LAYERS]; 354 Double* cfg_fQP [MAX_LAYERS]; 355 355 356 356 #if REPN_FORMAT_IN_VPS … … 565 565 ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") 566 566 #endif 567 568 //Field coding parameters 569 ("FieldCoding", m_isField, false, "Signals if it's a field based coding") 570 ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not") 567 571 ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") 568 572 ("FramesToBeEncoded,f", m_framesToBeEncoded, 0, "Number of frames to be encoded (default=all)") … … 862 866 const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv); 863 867 868 if(m_isField) 869 { 870 #if SVC_EXTENSION 871 for(Int layer = 0; layer < MAX_LAYERS; layer++) 872 { 873 //Frame height 874 m_acLayerCfg[layer].m_iSourceHeightOrg = m_acLayerCfg[layer].m_iSourceHeight; 875 //Field height 876 m_acLayerCfg[layer].m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight >> 1; 877 } 878 #else 879 //Frame height 880 m_iSourceHeightOrg = m_iSourceHeight; 881 //Field height 882 m_iSourceHeight = m_iSourceHeight >> 1; 883 #endif 884 //number of fields to encode 885 m_framesToBeEncoded *= 2; 886 } 887 864 888 for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) 865 889 { … … 1193 1217 m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; 1194 1218 m_iSourceHeight += m_confBottom; 1219 if ( m_isField ) 1220 { 1221 m_iSourceHeightOrg += m_confBottom << 1; 1222 m_aiPad[1] = m_confBottom << 1; 1223 } 1195 1224 } 1196 1225 if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0) … … 1515 1544 #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 1516 1545 Int checkGOP=1; 1517 Int numRefs = 1;1546 Int numRefs = m_isField ? 2 : 1; 1518 1547 #endif 1519 1548 Int refList[MAX_NUM_REF_PICS+1]; 1520 1549 refList[0]=0; 1550 if(m_isField) 1551 { 1552 refList[1] = 1; 1553 } 1521 1554 Bool isOK[MAX_GOP]; 1522 1555 for(Int i=0; i<MAX_GOP; i++) … … 1546 1579 for(UInt layer=0; layer<m_numLayers; layer++) 1547 1580 { 1548 if(m_acLayerCfg[layer].xCheckParameter( ))1581 if(m_acLayerCfg[layer].xCheckParameter(m_isField)) 1549 1582 { 1550 1583 printf("\nError: invalid configuration parameter found in layer %d \n", layer); … … 2181 2214 printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); 2182 2215 #endif 2183 printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded ); 2216 if (m_isField) 2217 { 2218 printf("Frame/Field : Field based coding\n"); 2219 printf("Field index : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded ); 2220 if (m_isTopFieldFirst) 2221 { 2222 printf("Field Order : Top field first\n"); 2223 } 2224 else 2225 { 2226 printf("Field Order : Bottom field first\n"); 2227 } 2228 } 2229 else 2230 { 2231 printf("Frame/Field : Frame based coding\n"); 2232 printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded ); 2233 } 2184 2234 printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); 2185 2235 printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); -
branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.h
r402 r431 88 88 UInt m_FrameSkip; ///< number of skipped frames from the beginning 89 89 Int m_iSourceWidth; ///< source width in pixel 90 Int m_iSourceHeight; ///< source height in pixel 90 Int m_iSourceHeight; ///< source height in pixel (when interlaced = field height) 91 92 Int m_iSourceHeightOrg; ///< original source height in pixel (when interlaced = frame height) 93 94 91 95 Int m_conformanceMode; 92 96 Int m_confLeft; … … 97 101 Int m_aiPad[2]; ///< number of padded pixels for width and height 98 102 #endif 103 104 Bool m_isField; ///< enable field coding 105 Bool m_isTopFieldFirst; 99 106 100 107 // profile/level -
branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
r389 r431 161 161 Bool confirmPara(Bool bflag, const char* message); 162 162 163 Bool TAppEncLayerCfg::xCheckParameter( )163 Bool TAppEncLayerCfg::xCheckParameter( Bool isField ) 164 164 { 165 165 switch (m_conformanceMode) … … 185 185 m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; 186 186 m_iSourceHeight += m_confBottom; 187 if ( isField ) 188 { 189 m_iSourceHeightOrg += m_confBottom << 1; 190 m_aiPad[1] = m_confBottom << 1; 191 } 187 192 } 188 193 break; -
branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
r403 r431 33 33 Int m_iFrameRate; ///< source frame-rates (Hz) 34 34 Int m_iSourceWidth; ///< source width in pixel 35 Int m_iSourceHeight; ///< source height in pixel 35 Int m_iSourceHeight; ///< source height in pixel (when interlaced = field height) 36 Int m_iSourceHeightOrg; ///< original source height in pixel (when interlaced = frame height) 36 37 Int m_conformanceMode; 37 38 Int m_confLeft; … … 104 105 Void xPrintParameter(); 105 106 #endif 106 Bool xCheckParameter( );107 Bool xCheckParameter( Bool isField ); 107 108 108 109 Void setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p; } … … 113 114 Int getSourceWidth() {return m_iSourceWidth; } 114 115 Int getSourceHeight() {return m_iSourceHeight; } 116 Int getSourceHeightOrg() {return m_iSourceHeightOrg; } 115 117 Int getConformanceMode() { return m_conformanceMode; } 116 118 Int* getPad() {return m_aiPad; } -
branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
r427 r431 888 888 } 889 889 890 Void TAppEncTop::xInitLib( )890 Void TAppEncTop::xInitLib(Bool isFieldCoding) 891 891 { 892 892 #if SVC_EXTENSION 893 893 for(UInt layer=0; layer<m_numLayers; layer++) 894 894 { 895 m_acTEncTop[layer].init( );895 m_acTEncTop[layer].init(isFieldCoding); 896 896 } 897 897 #if VPS_RENAME … … 1091 1091 vps->setExtensionOffset( 0xffff ); 1092 1092 #endif 1093 #else 1094 m_cTEncTop.init( );1095 #endif 1093 #else //SVC_EXTENSION 1094 m_cTEncTop.init(isFieldCoding); 1095 #endif //SVC_EXTENSION 1096 1096 } 1097 1097 … … 1124 1124 xInitLibCfg(); 1125 1125 xCreateLib(); 1126 xInitLib( );1126 xInitLib(m_isField); 1127 1127 1128 1128 // main encoder loop … … 1136 1136 // allocate original YUV buffer 1137 1137 pcPicYuvOrg[layer] = new TComPicYuv; 1138 if( m_isField ) 1139 { 1138 1140 #if SVC_UPSAMPLING 1139 pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); 1140 #else 1141 pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 1142 #endif 1141 pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); 1142 #else 1143 pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 1144 #endif 1145 } 1146 else 1147 { 1148 #if SVC_UPSAMPLING 1149 pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); 1150 #else 1151 pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 1152 #endif 1153 } 1143 1154 } 1144 1155 … … 1182 1193 m_iFrameRcvd++; 1183 1194 // check end of file 1184 bEos = (m_i FrameRcvd == m_framesToBeEncoded);1195 bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); 1185 1196 } 1186 1197 1187 m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); 1198 if ( m_isField ) 1199 { 1200 m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst ); 1201 } 1202 else 1203 { 1204 m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); 1205 } 1188 1206 } 1189 1207 … … 1232 1250 { 1233 1251 // call encoding function for one frame 1234 m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); 1252 if ( m_isField ) 1253 { 1254 m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); 1255 } 1256 else 1257 { 1258 m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); 1259 } 1235 1260 } 1236 1261 } … … 1269 1294 if (bEos) 1270 1295 { 1271 printOutSummary( );1296 printOutSummary(m_isTopFieldFirst); 1272 1297 } 1273 1298 … … 1301 1326 } 1302 1327 1303 Void TAppEncTop::printOutSummary( )1328 Void TAppEncTop::printOutSummary(Bool isField) 1304 1329 { 1305 1330 UInt layer; … … 1308 1333 for(layer = 0; layer < m_numLayers; layer++) 1309 1334 { 1310 m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); 1311 m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); 1312 m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); 1313 m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); 1335 if(isField) 1336 { 1337 m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); 1338 m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); 1339 m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); 1340 m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); 1341 } 1342 else 1343 { 1344 m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2); 1345 m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); 1346 m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); 1347 m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); 1348 } 1314 1349 } 1315 1350 … … 1342 1377 m_gcAnalyzeB[layer].printOut('b', layer); 1343 1378 } 1379 1380 if(isField) 1381 { 1382 for(layer = 0; layer < m_numLayers; layer++) 1383 { 1384 //-- interlaced summary 1385 m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate()); 1386 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 1387 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll[layer].getBits()); 1388 1389 #if _SUMMARY_OUT_ 1390 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 1391 #endif 1392 } 1393 } 1344 1394 } 1345 1395 … … 1360 1410 xInitLibCfg(); 1361 1411 xCreateLib(); 1362 xInitLib( );1412 xInitLib(m_isField); 1363 1413 1364 1414 // main encoder loop … … 1369 1419 1370 1420 // allocate original YUV buffer 1371 pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 1421 if( m_isField ) 1422 { 1423 pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 1424 } 1425 else 1426 { 1427 pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 1428 } 1372 1429 1373 1430 while ( !bEos ) … … 1382 1439 m_iFrameRcvd++; 1383 1440 1384 bEos = (m_iFrameRcvd == m_framesToBeEncoded); 1385 1441 bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); 1386 1442 Bool flush = 0; 1387 1443 // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures … … 1395 1451 1396 1452 // call encoding function for one frame 1453 if ( m_isField ) 1454 { 1455 m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); 1456 } 1457 else 1458 { 1397 1459 m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); 1460 } 1398 1461 1399 1462 // write bistream to file if necessary … … 1405 1468 } 1406 1469 1407 m_cTEncTop.printSummary( );1470 m_cTEncTop.printSummary(m_isField); 1408 1471 1409 1472 // delete original YUV buffer … … 1479 1542 Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) 1480 1543 { 1481 Int i; 1482 1483 TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); 1484 1485 for ( i = 0; i < iNumEncoded; i++ ) 1486 { 1487 --iterPicYuvRec; 1488 } 1489 1490 for ( i = 0; i < iNumEncoded; i++ ) 1491 { 1492 TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); 1544 if (m_isField) 1545 { 1546 //Reinterlace fields 1547 Int i; 1548 TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); 1549 1550 for ( i = 0; i < iNumEncoded; i++ ) 1551 { 1552 --iterPicYuvRec; 1553 } 1554 1555 for ( i = 0; i < iNumEncoded/2; i++ ) 1556 { 1557 TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); 1558 TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); 1559 1493 1560 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1494 if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) 1495 #else 1496 if (!m_acLayerCfg[layer].getReconFile().empty()) 1497 #endif 1498 { 1499 m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), 1500 m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() ); 1561 if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed()) 1562 #else 1563 if (!m_acLayerCfg[layer].getReconFile().empty()) 1564 #endif 1565 { 1566 m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst ); 1567 } 1568 } 1569 } 1570 else 1571 { 1572 Int i; 1573 1574 TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); 1575 1576 for ( i = 0; i < iNumEncoded; i++ ) 1577 { 1578 --iterPicYuvRec; 1579 } 1580 1581 for ( i = 0; i < iNumEncoded; i++ ) 1582 { 1583 TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); 1584 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1585 if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) 1586 #else 1587 if (!m_acLayerCfg[layer].getReconFile().empty()) 1588 #endif 1589 { 1590 m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), 1591 m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() ); 1592 } 1501 1593 } 1502 1594 } … … 1505 1597 Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) 1506 1598 { 1507 Int i; 1508 1509 list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); 1599 if (m_isField) 1600 { 1601 //Reinterlace fields 1602 Int i; 1603 list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); 1510 1604 1511 1605 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1512 for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) 1513 #else 1514 for ( i = 0; i < iNumEncoded; i++ ) 1515 #endif 1516 { 1517 const AccessUnit& au = *(iterBitstream++); 1518 const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); 1519 rateStatsAccum(au, stats); 1606 for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) 1607 #else 1608 for ( i = 0; i < iNumEncoded/2; i++ ) 1609 #endif 1610 { 1611 const AccessUnit& auTop = *(iterBitstream++); 1612 const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); 1613 rateStatsAccum(auTop, statsTop); 1614 1615 const AccessUnit& auBottom = *(iterBitstream++); 1616 const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); 1617 rateStatsAccum(auBottom, statsBottom); 1618 } 1619 } 1620 else 1621 { 1622 Int i; 1623 1624 list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); 1625 1626 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 1627 for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) 1628 #else 1629 for ( i = 0; i < iNumEncoded; i++ ) 1630 #endif 1631 { 1632 const AccessUnit& au = *(iterBitstream++); 1633 const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); 1634 rateStatsAccum(au, stats); 1635 } 1520 1636 } 1521 1637 } … … 1561 1677 Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) 1562 1678 { 1563 Int i; 1564 1565 TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); 1566 list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); 1567 1568 for ( i = 0; i < iNumEncoded; i++ ) 1569 { 1570 --iterPicYuvRec; 1571 } 1572 1573 for ( i = 0; i < iNumEncoded; i++ ) 1574 { 1575 TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); 1576 if (m_pchReconFile) 1577 { 1679 if (m_isField) 1680 { 1681 //Reinterlace fields 1682 Int i; 1683 TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); 1684 list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); 1685 1686 for ( i = 0; i < iNumEncoded; i++ ) 1687 { 1688 --iterPicYuvRec; 1689 } 1690 1691 for ( i = 0; i < iNumEncoded/2; i++ ) 1692 { 1693 TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); 1694 TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); 1695 1696 if (m_pchReconFile) 1697 { 1698 m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst ); 1699 } 1700 1701 const AccessUnit& auTop = *(iterBitstream++); 1702 const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); 1703 rateStatsAccum(auTop, statsTop); 1704 1705 const AccessUnit& auBottom = *(iterBitstream++); 1706 const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); 1707 rateStatsAccum(auBottom, statsBottom); 1708 } 1709 } 1710 else 1711 { 1712 Int i; 1713 1714 TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); 1715 list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); 1716 1717 for ( i = 0; i < iNumEncoded; i++ ) 1718 { 1719 --iterPicYuvRec; 1720 } 1721 1722 for ( i = 0; i < iNumEncoded; i++ ) 1723 { 1724 TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); 1725 if (m_pchReconFile) 1726 { 1578 1727 #if SYNTAX_OUTPUT 1579 m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); 1580 #endif 1581 } 1582 1583 const AccessUnit& au = *(iterBitstream++); 1584 const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); 1585 rateStatsAccum(au, stats); 1728 m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); 1729 #endif 1730 } 1731 1732 const AccessUnit& au = *(iterBitstream++); 1733 const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); 1734 rateStatsAccum(au, stats); 1735 } 1586 1736 } 1587 1737 } … … 1602 1752 case NAL_UNIT_CODED_SLICE_TRAIL_R: 1603 1753 case NAL_UNIT_CODED_SLICE_TRAIL_N: 1604 case NAL_UNIT_CODED_SLICE_T SA_R:1754 case NAL_UNIT_CODED_SLICE_TLA_R: 1605 1755 case NAL_UNIT_CODED_SLICE_TSA_N: 1606 1756 case NAL_UNIT_CODED_SLICE_STSA_R: -
branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.h
r313 r431 82 82 Void xCreateLib (); ///< create files & encoder class 83 83 Void xInitLibCfg (); ///< initialize internal variables 84 Void xInitLib ( );///< initialize encoder class84 Void xInitLib (Bool isFieldCoding); ///< initialize encoder class 85 85 Void xDestroyLib (); ///< destroy encoder class 86 86 … … 99 99 Void xWriteRecon(UInt layer, Int iNumEncoded); 100 100 Void xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); 101 Void printOutSummary( );101 Void printOutSummary(Bool isField); 102 102 #else 103 103 Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file -
branches/SHM-3.1-dev/source/Lib/TLibCommon/CommonDef.h
r412 r431 59 59 #define NV_VERSION "3.0.1" ///< Current software version 60 60 #else 61 #define NV_VERSION "1 1.0" ///< Current software version61 #define NV_VERSION "12.0" ///< Current software version 62 62 #endif 63 63 … … 200 200 201 201 NAL_UNIT_CODED_SLICE_TSA_N, // 2 202 NAL_UNIT_CODED_SLICE_T SA_R, // 3202 NAL_UNIT_CODED_SLICE_TLA_R, // 3 203 203 204 204 NAL_UNIT_CODED_SLICE_STSA_N, // 4 -
branches/SHM-3.1-dev/source/Lib/TLibCommon/NAL.h
r412 r431 76 76 return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R 77 77 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N 78 || m_nalUnitType == NAL_UNIT_CODED_SLICE_T SA_R78 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA_R 79 79 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N 80 80 || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComMv.h
r370 r431 40 40 41 41 #include "CommonDef.h" 42 #include <cstdlib> 42 43 43 44 //! \ingroup TLibCommon -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPic.cpp
r389 r431 53 53 , m_bUsedByCurr (false) 54 54 , m_bIsLongTerm (false) 55 , m_bIsUsedAsLongTerm (false)56 55 , m_apcPicSym (NULL) 57 56 , m_pcPicYuvPred (NULL) -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPic.h
r377 r431 66 66 Bool m_bUsedByCurr; // Used by current picture 67 67 Bool m_bIsLongTerm; // IS long term picture 68 Bool m_bIsUsedAsLongTerm; // long term picture is used as reference before69 68 TComPicSym* m_apcPicSym; // Symbol 70 69 … … 88 87 Window m_defaultDisplayWindow; 89 88 89 Bool m_isTop; 90 Bool m_isField; 91 90 92 std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink; 91 93 … … 194 196 std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter (Int sliceID) { return m_vSliceCUDataLink[sliceID];} 195 197 198 /* field coding parameters*/ 199 200 Void setTopField(bool b) {m_isTop = b;} 201 Bool isTopField() {return m_isTop;} 202 Void setField(bool b) {m_isField = b;} 203 Bool isField() {return m_isField;} 204 196 205 /** transfer ownership of seis to this picture */ 197 206 void setSEIs(SEIMessages& seis) { m_SEIs = seis; } -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPicSym.cpp
r377 r431 61 61 ,m_uiNumAllocatedSlice (0) 62 62 ,m_apcTComDataCU (NULL) 63 ,m_iTileBoundaryIndependenceIdr (0)64 63 ,m_iNumColumnsMinus1 (0) 65 64 ,m_iNumRowsMinus1(0) -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPicSym.h
r313 r431 100 100 TComDataCU** m_apcTComDataCU; ///< array of CU data 101 101 102 Int m_iTileBoundaryIndependenceIdr;103 102 Int m_iNumColumnsMinus1; 104 103 Int m_iNumRowsMinus1; -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPrediction.cpp
r345 r431 696 696 Int k, l, bottomLeft, topRight; 697 697 Int horPred; 698 Int leftColumn[MAX_CU_SIZE ], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];698 Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; 699 699 UInt blkSize = width; 700 700 UInt offset2D = width; -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComRdCost.h
r313 r431 116 116 private: 117 117 // for distortion 118 Int m_iBlkWidth;119 Int m_iBlkHeight;120 118 121 119 #if AMP_SAD -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComRom.cpp
r414 r431 55 55 ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); 56 56 c=0; 57 for ( i=4; i< MAX_CU_SIZE; i*=2 )57 for ( i=4; i<=MAX_CU_SIZE; i*=2 ) 58 58 { 59 59 g_aucConvertToBit[ i ] = c; 60 60 c++; 61 61 } 62 g_aucConvertToBit[ i ] = c;63 62 64 63 c=2; … … 278 277 279 278 #if FAST_UDI_USE_MPM 280 const UChar g_aucIntraModeNumFast[ 7] =279 const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = 281 280 { 282 281 3, // 2x2 … … 285 284 3, // 16x16 286 285 3, // 32x32 287 3, // 64x64 288 3 // 128x128 286 3 // 64x64 289 287 }; 290 288 #else // FAST_UDI_USE_MPM 291 const UChar g_aucIntraModeNumFast[ 7] =289 const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = 292 290 { 293 291 3, // 2x2 … … 296 294 4, // 16x16 33 297 295 4, // 32x32 33 298 5, // 64x64 33 299 4 // 128x128 33 296 5 // 64x64 33 300 297 }; 301 298 #endif // FAST_UDI_USE_MPM -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComRom.h
r414 r431 51 51 // ==================================================================================================================== 52 52 53 #define MAX_CU_DEPTH 7// log2(LCUSize)53 #define MAX_CU_DEPTH 6 // log2(LCUSize) 54 54 #define MAX_CU_SIZE (1<<(MAX_CU_DEPTH)) // maximum allowable size of CU 55 55 #define MIN_PU_SIZE 4 … … 131 131 // ==================================================================================================================== 132 132 133 extern const UChar g_aucIntraModeNumFast[ 7];133 extern const UChar g_aucIntraModeNumFast[ MAX_CU_DEPTH ]; 134 134 135 135 #if FAST_INTRA_SHVC -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComSlice.cpp
r430 r431 186 186 m_aiNumRefIdx[0] = 0; 187 187 m_aiNumRefIdx[1] = 0; 188 188 189 m_colFromL0Flag = 1; 189 190 … … 292 293 if (!pocHasMsb) 293 294 { 294 poc = poc % pocCycle;295 poc = poc & (pocCycle - 1); 295 296 } 296 297 … … 303 304 if (!pocHasMsb) 304 305 { 305 picPoc = picPoc % pocCycle;306 picPoc = picPoc & (pocCycle - 1); 306 307 } 307 308 … … 966 967 } 967 968 968 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)969 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) 969 970 { 970 971 for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) … … 992 993 { 993 994 pocCRA = getPOC(); 994 prevRAPisBLA = false;995 associatedIRAPType = getNalUnitType(); 995 996 } 996 997 else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found 997 998 { 998 999 pocCRA = getPOC(); 999 prevRAPisBLA = false;1000 associatedIRAPType = getNalUnitType(); 1000 1001 } 1001 1002 else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP … … 1004 1005 { 1005 1006 pocCRA = getPOC(); 1006 prevRAPisBLA = true;1007 associatedIRAPType = getNalUnitType(); 1007 1008 } 1008 1009 } … … 1029 1030 { 1030 1031 TComPic* rpcPic; 1032 setAssociatedIRAPPOC(pocCRA); 1031 1033 Int pocCurr = getPOC(); 1032 1034 … … 1195 1197 } 1196 1198 1197 Int TComSlice::m_prev POC = 0;1199 Int TComSlice::m_prevTid0POC = 0; 1198 1200 1199 1201 /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. … … 1250 1252 } 1251 1253 1254 1255 Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) 1256 { 1257 TComPic* rpcPic; 1258 1259 Int nalUnitType = this->getNalUnitType(); 1260 1261 // When a picture is a leading picture, it shall be a RADL or RASL picture. 1262 if(this->getAssociatedIRAPPOC() > this->getPOC()) 1263 { 1264 // Do not check IRAP pictures since they may get a POC lower than their associated IRAP 1265 if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || 1266 nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) 1267 { 1268 assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1269 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || 1270 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1271 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); 1272 } 1273 } 1274 1275 // When a picture is a trailing picture, it shall not be a RADL or RASL picture. 1276 if(this->getAssociatedIRAPPOC() < this->getPOC()) 1277 { 1278 assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && 1279 nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && 1280 nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && 1281 nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); 1282 } 1283 1284 // No RASL pictures shall be present in the bitstream that are associated 1285 // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. 1286 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1287 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1288 { 1289 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && 1290 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); 1291 } 1292 1293 // No RASL pictures shall be present in the bitstream that are associated with 1294 // an IDR picture. 1295 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1296 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1297 { 1298 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && 1299 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); 1300 } 1301 1302 // No RADL pictures shall be present in the bitstream that are associated with 1303 // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated 1304 // with an IDR picture having nal_unit_type equal to IDR_N_LP. 1305 if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1306 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) 1307 { 1308 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && 1309 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); 1310 } 1311 1312 // loop through all pictures in the reference picture buffer 1313 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 1314 while ( iterPic != rcListPic.end()) 1315 { 1316 rpcPic = *(iterPic++); 1317 if (rpcPic->getPOC() == this->getPOC()) 1318 { 1319 continue; 1320 } 1321 1322 // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture 1323 // in decoding order shall precede the IRAP picture in output order. 1324 // (Note that any picture following in output order would be present in the DPB) 1325 if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) 1326 { 1327 if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || 1328 nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || 1329 nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 1330 nalUnitType == NAL_UNIT_CODED_SLICE_CRA || 1331 nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || 1332 nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) 1333 { 1334 assert(rpcPic->getPOC() < this->getPOC()); 1335 } 1336 } 1337 1338 // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture 1339 // in decoding order shall precede any RADL picture associated with the IRAP 1340 // picture in output order. 1341 if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) 1342 { 1343 if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1344 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) 1345 { 1346 // rpcPic precedes the IRAP in decoding order 1347 if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) 1348 { 1349 // rpcPic must not be the IRAP picture 1350 if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) 1351 { 1352 assert(rpcPic->getPOC() < this->getPOC()); 1353 } 1354 } 1355 } 1356 } 1357 1358 // When a picture is a leading picture, it shall precede, in decoding order, 1359 // all trailing pictures that are associated with the same IRAP picture. 1360 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1361 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || 1362 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1363 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) 1364 { 1365 if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) 1366 { 1367 // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB 1368 // rpcPic would violate the constraint if it was a trailing picture 1369 assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); 1370 } 1371 } 1372 1373 // Any RASL picture associated with a CRA or BLA picture shall precede any 1374 // RADL picture associated with the CRA or BLA picture in output order 1375 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1376 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1377 { 1378 if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || 1379 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || 1380 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 1381 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && 1382 this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) 1383 { 1384 if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 1385 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) 1386 { 1387 assert(rpcPic->getPOC() > this->getPOC()); 1388 } 1389 } 1390 } 1391 1392 // Any RASL picture associated with a CRA picture shall follow, in output 1393 // order, any IRAP picture that precedes the CRA picture in decoding order. 1394 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1395 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1396 { 1397 if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) 1398 { 1399 if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && 1400 (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || 1401 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || 1402 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 1403 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || 1404 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || 1405 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 1406 { 1407 assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); 1408 } 1409 } 1410 } 1411 } 1412 } 1413 1252 1414 /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. 1253 1415 */ … … 1256 1418 TComPic* rpcPic; 1257 1419 Int i, isReference; 1420 1421 checkLeadingPictureRestrictions(rcListPic); 1258 1422 1259 1423 // loop through all pictures in the reference picture buffer … … 1292 1456 else 1293 1457 { 1294 if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) 1458 Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); 1459 Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); 1460 Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); 1461 if(rpcPic->getIsLongTerm() && curPoc == refPoc) 1295 1462 { 1296 1463 isReference = 1; … … 1311 1478 assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); 1312 1479 //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture 1313 if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_T SA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)1480 if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) 1314 1481 { 1315 1482 assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); … … 1352 1519 else 1353 1520 { 1354 if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) 1521 Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); 1522 Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); 1523 Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); 1524 if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) 1355 1525 { 1356 1526 isAvailable = 1; … … 1371 1541 if (!pReferencePictureSet->getCheckLTMSBPresent(i)) 1372 1542 { 1373 curPoc = curPoc % pocCycle;1374 refPoc = refPoc % pocCycle;1543 curPoc = curPoc & (pocCycle - 1); 1544 refPoc = refPoc & (pocCycle - 1); 1375 1545 } 1376 1546 … … 2114 2284 } 2115 2285 2116 2286 /* 2117 2287 Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. 2118 2288 */ 2119 2289 Int i, j; 2120 2290 UInt birateValue, cpbSizeValue; … … 2410 2580 TComScalingList::TComScalingList() 2411 2581 { 2412 m_useTransformSkip = false;2413 2582 init(); 2414 2583 } 2584 2415 2585 TComScalingList::~TComScalingList() 2416 2586 { … … 2495 2665 { 2496 2666 src = getScalingListAddress(sizeIdc, listIdc); 2667 2497 2668 fseek(fp,0,0); 2498 2669 do -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComSlice.h
r425 r431 166 166 #endif 167 167 168 Bool getUseTransformSkip () { return m_useTransformSkip; }169 Void setUseTransformSkip (Bool b) { m_useTransformSkip = b; }170 171 168 Int* getScalingListAddress (UInt sizeId, UInt listId) { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient 172 173 169 Bool checkPredMode (UInt sizeId, UInt listId); 174 175 170 Void setRefMatrixId (UInt sizeId, UInt listId, UInt u) { m_refMatrixId[sizeId][listId] = u; } //!< set reference matrix ID 176 171 UInt getRefMatrixId (UInt sizeId, UInt listId) { return m_refMatrixId[sizeId][listId]; } //!< get reference matrix ID … … 201 196 Void init (); 202 197 Void destroy (); 203 204 198 Int m_scalingListDC [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< the DC value of the matrix coefficient for 16x16 205 199 Bool m_useDefaultScalingMatrixFlag [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< UseDefaultScalingMatrixFlag … … 213 207 214 208 UInt m_predMatrixId [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index 215 216 Int *m_scalingListCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix 217 218 Bool m_useTransformSkip; //!< transform skipping flag for setting default scaling matrix for 4x4 209 Int *m_scalingListCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix 219 210 }; 220 211 … … 1627 1618 Int m_iPOC; 1628 1619 Int m_iLastIDR; 1629 static Int m_prevPOC; 1620 Int m_iAssociatedIRAP; 1621 NalUnitType m_iAssociatedIRAPType; 1622 static Int m_prevTid0POC; 1630 1623 TComReferencePictureSet *m_pcRPS; 1631 1624 TComReferencePictureSet m_LocalRPS; … … 1788 1781 Void setRPSidx ( Int iBDidx ) { m_iBDidx = iBDidx; } 1789 1782 Int getRPSidx () { return m_iBDidx; } 1790 Int getPrev POC () { return m_prevPOC; }1783 Int getPrevTid0POC () { return m_prevTid0POC; } 1791 1784 TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; } 1792 1785 Void setLastIDR(Int iIDRPOC) { m_iLastIDR = iIDRPOC; } 1793 1786 Int getLastIDR() { return m_iLastIDR; } 1787 Void setAssociatedIRAPPOC(Int iAssociatedIRAPPOC) { m_iAssociatedIRAP = iAssociatedIRAPPOC; } 1788 Int getAssociatedIRAPPOC() { return m_iAssociatedIRAP; } 1789 Void setAssociatedIRAPType(NalUnitType associatedIRAPType) { m_iAssociatedIRAPType = associatedIRAPType; } 1790 NalUnitType getAssociatedIRAPType() { return m_iAssociatedIRAPType; } 1794 1791 SliceType getSliceType () { return m_eSliceType; } 1795 1792 Int getPOC () { return m_iPOC; } … … 1817 1814 Void checkColRefIdx (UInt curSliceIdx, TComPic* pic); 1818 1815 Bool getIsUsedAsLongTerm (Int i, Int j) { return m_bIsUsedAsLongTerm[i][j]; } 1816 Void setIsUsedAsLongTerm (Int i, Int j, Bool value) { m_bIsUsedAsLongTerm[i][j] = value; } 1819 1817 Bool getCheckLDC () { return m_bCheckLDC; } 1820 1818 Bool getMvdL1ZeroFlag () { return m_bLMvdL1Zero; } … … 1826 1824 Void setReferenced(Bool b) { m_bRefenced = b; } 1827 1825 Bool isReferenced() { return m_bRefenced; } 1828 Void setPOC ( Int i ) { m_iPOC = i; if(getTLayer()==0) m_prevPOC=i; } 1826 Bool isReferenceNalu() { return ((getNalUnitType() <= NAL_UNIT_RESERVED_VCL_R15) && (getNalUnitType()%2 != 0)) || ((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_RESERVED_IRAP_VCL23) ); } 1827 Void setPOC ( Int i ) { m_iPOC = i; if ((getTLayer()==0) && (isReferenceNalu() && (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) {m_prevTid0POC=i;} } 1829 1828 Void setNalUnitType ( NalUnitType e ) { m_eNalUnitType = e; } 1830 1829 NalUnitType getNalUnitType () const { return m_eNalUnitType; } … … 1848 1847 #endif 1849 1848 1850 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic);1849 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic); 1851 1850 Void decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic); 1852 1851 Void setSliceType ( SliceType e ) { m_eSliceType = e; } … … 1917 1916 Void setTLayerInfo( UInt uiTLayer ); 1918 1917 Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum ); 1918 Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic ); 1919 1919 Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList); 1920 1920 Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ); -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComWeightPrediction.h
r313 r431 53 53 class TComWeightPrediction 54 54 { 55 wpScalingParam m_wp0[3], m_wp1[3];56 57 55 public: 58 56 TComWeightPrediction(); -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TypeDef.h
r425 r431 43 43 #define SYNTAX_BYTES 10 ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)] 44 44 45 #define HM12_RANDOM_ACCESS 146 45 #define RANDOM_ACCESS_SEI_FIX 1 46 #if SVC_EXTENSION 47 47 #define VPS_NUH_LAYER_ID 1 ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0 48 #if SVC_EXTENSION49 48 #define MAX_LAYERS 2 ///< max number of layers the codec is supposed to handle 50 49 #define POC_RESET_FLAG 1 ///< JCTVC-N0244: POC reset flag for layer pictures. … … 156 155 #define RC_SHVC_HARMONIZATION 1 ///< JCTVC-M0037: rate control for SHVC 157 156 157 #define VIEW_ID_RELATED_SIGNALING 1 ///< Introduce syntax elements view_id_len_minus1 and view_id_val 158 #define M0043_LAYERS_PRESENT_SEI 0 ///< JCTVC-M0043: add layers present SEI. Macro shall be equal to 0 according to the JCTVC-N0174 discussion. The code is to be removed. 158 159 #else 159 160 #define SYNTAX_OUTPUT 0 … … 165 166 166 167 #define FIX1071 1 ///< fix for issue #1071 167 #define VIEW_ID_RELATED_SIGNALING 1 ///< Introduce syntax elements view_id_len_minus1 and view_id_val168 #define M0043_LAYERS_PRESENT_SEI 0 ///< JCTVC-M0043: add layers present SEI. Macro shall be equal to 0 according to the JCTVC-N0174 discussion. The code is to be removed.169 168 170 169 #define MAX_NUM_PICS_IN_SOP 1024 -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/NALread.cpp
r412 r431 126 126 else 127 127 { 128 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_T SA_R128 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA_R 129 129 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 130 130 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/SEIread.cpp
r313 r431 349 349 350 350 /* restore primary bitstream for sei_message */ 351 getBitstream()->deleteFifo(); 351 352 delete getBitstream(); 352 353 setBitstream(bs); -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/SyntaxElementParser.cpp
r313 r431 52 52 if (length < 10) 53 53 { 54 fprintf( g_hTrace, "%-50s u(%d) : % d\n", pSymbolName, length, rValue );54 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 55 55 } 56 56 else 57 57 { 58 fprintf( g_hTrace, "%-50s u(%d) : % d\n", pSymbolName, length, rValue );58 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 59 59 } 60 60 fflush ( g_hTrace ); … … 65 65 xReadUvlc (rValue); 66 66 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 67 fprintf( g_hTrace, "%-50s ue(v) : % d\n", pSymbolName, rValue );67 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 68 68 fflush ( g_hTrace ); 69 69 } -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
r427 r431 1614 1614 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 1615 1615 Int iPOClsb = uiCode; 1616 Int iPrevPOC = rpcSlice->getPrev POC();1616 Int iPrevPOC = rpcSlice->getPrevTid0POC(); 1617 1617 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 1618 Int iPrevPOClsb = iPrevPOC %iMaxPOClsb;1618 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 1619 1619 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 1620 1620 Int iPOCmsb; … … 1738 1738 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 1739 1739 rps->setCheckLTMSBPresent(j,false); 1740 1741 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 1742 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 1743 { 1744 deltaPocMSBCycleLT = 0; 1745 } 1740 1746 } 1741 1747 prevDeltaMSB = deltaPocMSBCycleLT; -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecSlice.h
r313 r431 65 65 TDecEntropy* m_pcEntropyDecoder; 66 66 TDecCu* m_pcCuDecoder; 67 UInt m_uiCurrSliceIdx;68 67 69 68 TDecSbac* m_pcBufferSbacDecoders; ///< line to store temporary contexts, one per column of tiles. -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
r424 r431 57 57 g_nSymbolCounter = 0; 58 58 #endif 59 m_associatedIRAPType = NAL_UNIT_INVALID; 59 60 m_pocCRA = 0; 60 m_prevRAPisBLA = false;61 61 m_pocRandomAccess = MAX_INT; 62 62 #if !SVC_EXTENSION … … 77 77 m_pBLSyntaxFile = NULL; 78 78 #endif 79 #if HM12_RANDOM_ACCESS80 79 m_prevSliceSkipped = false; 81 80 m_skippedPOC = 0; 82 #endif83 81 } 84 82 … … 700 698 #endif 701 699 702 #if HM12_RANDOM_ACCESS703 700 // set POC for dependent slices in skipped pictures 704 701 if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) … … 706 703 m_apcSlicePilot->setPOC(m_skippedPOC); 707 704 } 708 #endif 705 706 m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); 707 m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); 709 708 710 709 // Skip pictures due to random access 711 710 if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) 712 711 { 713 #if HM12_RANDOM_ACCESS714 712 m_prevSliceSkipped = true; 715 713 m_skippedPOC = m_apcSlicePilot->getPOC(); 716 #endif717 714 return false; 718 715 } … … 720 717 if (isSkipPictureForBLA(iPOCLastDisplay)) 721 718 { 722 #if HM12_RANDOM_ACCESS723 719 m_prevSliceSkipped = true; 724 720 m_skippedPOC = m_apcSlicePilot->getPOC(); 725 #endif726 721 return false; 727 722 } 728 723 729 #if HM12_RANDOM_ACCESS730 724 // clear previous slice skipped flag 731 725 m_prevSliceSkipped = false; 732 #endif733 726 734 727 // exit when a new picture is found … … 913 906 xGetNewPicBuffer (m_apcSlicePilot, pcPic); 914 907 908 Bool isField = false; 909 Bool isTff = false; 910 911 if(!m_SEIs.empty()) 912 { 913 // Check if any new Picture Timing SEI has arrived 914 SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); 915 if (pictureTimingSEIs.size()>0) 916 { 917 SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); 918 isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); 919 isTff = (pictureTiming->m_picStruct == 1); 920 } 921 } 922 923 //Set Field/Frame coding mode 924 m_pcPic->setField(isField); 925 m_pcPic->setTopField(isTff); 926 915 927 // transfer any SEI messages that have been received to the picture 916 928 pcPic->setSEIs(m_SEIs); … … 1052 1064 if (bNextSlice) 1053 1065 { 1054 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_ prevRAPisBLA, m_cListPic );1066 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); 1055 1067 // Set reference list 1056 1068 #if SVC_EXTENSION … … 1251 1263 pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); 1252 1264 } 1253 pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip());1254 1265 if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) 1255 1266 { … … 1497 1508 case NAL_UNIT_CODED_SLICE_TRAIL_R: 1498 1509 case NAL_UNIT_CODED_SLICE_TRAIL_N: 1499 case NAL_UNIT_CODED_SLICE_T SA_R:1510 case NAL_UNIT_CODED_SLICE_TLA_R: 1500 1511 case NAL_UNIT_CODED_SLICE_TSA_N: 1501 1512 case NAL_UNIT_CODED_SLICE_STSA_R: … … 1532 1543 Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) 1533 1544 { 1534 if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 1545 if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 1546 m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 1535 1547 { 1536 1548 iPOCLastDisplay++; -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecTop.h
r414 r431 67 67 Int m_iMaxRefPicNum; 68 68 69 NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture 69 70 Int m_pocCRA; ///< POC number of the latest CRA picture 70 Bool m_prevRAPisBLA; ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture71 71 Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) 72 72 … … 107 107 Bool m_bFirstSliceInSequence; 108 108 #endif 109 #if HM12_RANDOM_ACCESS110 109 Bool m_prevSliceSkipped; 111 110 Int m_skippedPOC; 112 #endif113 111 114 112 #if SVC_EXTENSION … … 122 120 fstream* m_pBLReconFile; 123 121 Int m_iBLSourceWidth; 124 Int m_iBLSourceHeight; 122 Int m_iBLSourceHeight; 125 123 #endif 126 124 #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS … … 159 157 160 158 Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); 159 #if SVC_EXTENSION 161 160 #if EARLY_REF_PIC_MARKING 162 161 Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); 163 162 #endif 164 165 #if SVC_EXTENSION166 163 UInt getLayerId () { return m_layerId; } 167 164 Void setLayerId (UInt layer) { m_layerId = layer; } -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncAnalyze.cpp
r313 r431 57 57 #endif 58 58 59 TEncAnalyze m_gcAnalyzeAll_in; 59 60 //! \} -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncAnalyze.h
r313 r431 131 131 fclose(pFile); 132 132 } 133 134 Void printOutInterlaced ( Char cDelim, Double bits ) 135 { 136 Double dFps = m_dFrmRate; //--CFG_KDY 137 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 138 139 printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); 140 //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); 141 printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", 142 getNumPic(), cDelim, 143 bits * dScale, 144 getPsnrY() / (Double)getNumPic(), 145 getPsnrU() / (Double)getNumPic(), 146 getPsnrV() / (Double)getNumPic() ); 147 } 148 149 Void printSummaryOutInterlaced (Int bits) 150 { 151 FILE* pFile = fopen ("summaryTotal.txt", "at"); 152 Double dFps = m_dFrmRate; //--CFG_KDY 153 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 154 155 fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale, 156 getPsnrY() / (Double)getNumPic(), 157 getPsnrU() / (Double)getNumPic(), 158 getPsnrV() / (Double)getNumPic() ); 159 fclose(pFile); 160 } 133 161 134 162 Void printSummary(Char ch) … … 178 206 #endif 179 207 208 extern TEncAnalyze m_gcAnalyzeAll_in; 180 209 //! \} 181 210 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r427 r431 1281 1281 if( !pcSlice->getPocResetFlag() ) 1282 1282 { 1283 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1283 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1284 1284 } 1285 1285 else 1286 1286 { 1287 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1288 } 1289 #else 1290 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1287 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1288 } 1289 #else 1290 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1291 1291 #endif 1292 1292 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); … … 2142 2142 { 2143 2143 // Bool state = true, state2 = false; 2144 Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC());2144 Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 2145 2145 for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) 2146 2146 { -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCu.cpp
r389 r431 379 379 m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); 380 380 381 // variables for fast encoder decision382 Bool bEarlySkip = false;383 Bool bTrySplit = true;384 Double fRD_Skip = MAX_DOUBLE;385 386 381 // variable for Early CU determination 387 382 Bool bSubBranch = true; … … 390 385 Bool doNotBlockPu = true; 391 386 Bool earlyDetectionSkipMode = false; 392 393 Bool bTrySplitDQP = true;394 395 static Double afCost[ MAX_CU_DEPTH ];396 static Int aiNum [ MAX_CU_DEPTH ];397 398 if ( rpcBestCU->getAddr() == 0 )399 {400 ::memset( afCost, 0, sizeof( afCost ) );401 ::memset( aiNum, 0, sizeof( aiNum ) );402 }403 387 404 388 Bool bBoundary = false; … … 471 455 if (rpcBestCU->getLayerId() > 0) 472 456 { 473 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 474 testInter = false; 475 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 476 testInter = false; 457 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 458 { 459 testInter = false; 460 } 461 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 462 { 463 testInter = false; 464 } 477 465 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 478 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 479 testInter = false; 466 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 467 { 468 testInter = false; 469 } 480 470 #endif 481 471 } … … 487 477 iQP = lowestQP; 488 478 } 489 // variables for fast encoder decision490 bEarlySkip = false;491 bTrySplit = true;492 fRD_Skip = MAX_DOUBLE;493 479 494 480 rpcTempCU->initEstData( uiDepth, iQP ); … … 509 495 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 510 496 rpcTempCU->initEstData( uiDepth, iQP ); 511 512 // fast encoder decision for early skip 513 if ( m_pcEncCfg->getUseFastEnc() ) 514 { 515 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; 516 if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] ) 517 { 518 bEarlySkip = true; 519 bTrySplit = false; 520 } 521 } 497 522 498 #if (ENCODER_FAST_MODE == 2) 523 499 if (testInter) 524 500 { 525 501 #endif 526 527 502 if(!m_pcEncCfg->getUseEarlySkipDetection()) 528 503 { 529 504 // 2Nx2N, NxN 530 if ( !bEarlySkip ) 505 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 506 if(m_pcEncCfg->getUseCbfFastMode()) 531 507 { 532 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 533 if(m_pcEncCfg->getUseCbfFastMode()) 534 { 535 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 536 } 508 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 537 509 } 538 510 } 539 511 #if (ENCODER_FAST_MODE == 2) 540 } 541 #endif 542 543 } 544 545 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 546 { 547 if(iQP == iBaseQP) 548 { 549 bTrySplitDQP = bTrySplit; 550 } 551 } 552 else 553 { 554 bTrySplitDQP = bTrySplit; 555 } 512 } 513 #endif 514 } 515 556 516 if (isAddLowestQP && (iQP == lowestQP)) 557 517 { … … 580 540 // do inter modes, NxN, 2NxN, and Nx2N 581 541 #if (ENCODER_FAST_MODE) 582 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter )542 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter ) 583 543 #else 584 544 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) … … 586 546 { 587 547 // 2Nx2N, NxN 588 if ( !bEarlySkip)548 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 589 549 { 590 if( !( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))550 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 591 551 { 592 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 593 { 594 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 595 rpcTempCU->initEstData( uiDepth, iQP ); 596 } 552 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 553 rpcTempCU->initEstData( uiDepth, iQP ); 597 554 } 598 555 } … … 734 691 735 692 // do normal intra modes 736 if ( !bEarlySkip )737 {738 693 // speedup for inter frames 739 694 #if (ENCODER_FAST_MODE) … … 761 716 } 762 717 } 763 }764 718 765 719 // test PCM … … 803 757 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 804 758 805 // accumulate statistics for early skip806 if ( m_pcEncCfg->getUseFastEnc() )807 {808 if ( rpcBestCU->isSkipped(0) )809 {810 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];811 afCost[ iIdx ] += rpcBestCU->getTotalCost();812 aiNum [ iIdx ] ++;813 }814 }815 816 759 // Early CU determination 817 760 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) … … 896 839 897 840 // further split 898 if( bSubBranch && bTrySplitDQP &&uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )841 if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 899 842 { 900 843 UChar uhNextDepth = uiDepth+1; -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r429 r431 375 375 // ==================================================================================================================== 376 376 #if SVC_EXTENSION 377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 380 380 #endif 381 381 { … … 390 390 TComOutputBitstream* pcSubstreamsOut = NULL; 391 391 392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); 393 393 394 394 m_iNumPicCoded = 0; … … 463 463 464 464 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding 465 Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; 466 Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 467 if(iPOCLast == 0) 465 Int iTimeOffset; 466 Int pocCurr; 467 468 if(iPOCLast == 0) //case first frame or first top field 468 469 { 469 470 pocCurr=0; 470 471 iTimeOffset = 1; 471 472 } 473 else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value 474 { 475 pocCurr = 1; 476 iTimeOffset = 1; 477 } 478 else 479 { 480 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 481 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 482 } 483 472 484 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) 473 485 { … … 490 502 accessUnitsInGOP.push_back(AccessUnit()); 491 503 AccessUnit& accessUnit = accessUnitsInGOP.back(); 492 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr );504 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField ); 493 505 494 506 // Slice data initialization … … 499 511 #if SVC_EXTENSION 500 512 pcPic->setLayerId( m_layerId ); 501 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS() ); 502 #else 503 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 504 #endif 513 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS(), isField ); 514 #else 515 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField ); 516 #endif 517 518 //Set Frame/Field coding 519 pcSlice->getPic()->setField(isField); 520 505 521 #if POC_RESET_FLAG 506 522 if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files. … … 602 618 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); 603 619 pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); 604 pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());605 620 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 606 621 { … … 818 833 } 819 834 } 820 #endif // SVC_EXTENSION835 #endif //#if SVC_EXTENSION 821 836 if(pcSlice->getTemporalLayerNonReferenceFlag()) 822 837 { 823 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 838 if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R && 839 !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE)) 840 // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker) 824 841 { 825 842 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); … … 863 880 else 864 881 { 865 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_T SA_R);882 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R); 866 883 } 867 884 #if ALIGN_TSA_STSA_PICS … … 875 892 { 876 893 assert( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ) || 877 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_T SA_R ) );894 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R ) ); 878 895 // TSA pictures are aligned within an access unit. 879 896 } … … 1019 1036 if( pcSlice->getMFMEnabledFlag() ) 1020 1037 #else 1021 1022 #endif 1023 1024 1038 if( pcSlice->getSPS()->getMFMEnabledFlag() ) 1039 #endif 1040 { 1041 pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic()); 1025 1042 #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING 1026 1027 #endif 1028 1029 #else 1030 // Set reference list1031 pcSlice->setRefPicList ( rcListPic );1043 pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); 1044 #endif 1045 } 1046 #else 1047 // Set reference list 1048 pcSlice->setRefPicList ( rcListPic ); 1032 1049 #endif //SVC_EXTENSION 1033 1050 pcSlice->setRefPicListModificationSvc(); … … 1080 1097 #endif 1081 1098 } 1082 #endif 1099 #else //SVC_EXTENSION 1100 // Set reference list 1101 pcSlice->setRefPicList ( rcListPic ); 1102 #endif //#if SVC_EXTENSION 1083 1103 1084 1104 // Slice info. refinement … … 1662 1682 } 1663 1683 } 1664 pictureTimingSEI.m_auCpbRemovalDelay = std::m ax<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .1684 pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the . 1665 1685 #if POC_RESET_FLAG 1666 1686 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pocCurr - m_totalCoded; … … 2201 2221 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2202 2222 2223 //In case of field coding, compute the interlaced PSNR for both fields 2224 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff))) 2225 { 2226 //get complementary top field 2227 TComPic* pcPicTop; 2228 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 2229 while ((*iterPic)->getPOC() != pcPic->getPOC()-1) 2230 { 2231 iterPic ++; 2232 } 2233 pcPicTop = *(iterPic); 2234 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2235 } 2236 2203 2237 if (digestStr) 2204 2238 { … … 2333 2367 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2334 2368 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2369 pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0; 2335 2370 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2336 2371 writeRBSPTrailingBits(nalu.m_Bitstream); … … 2451 2486 2452 2487 #if SVC_EXTENSION 2453 assert ( m_iNumPicCoded <= 1 );2454 #else 2455 assert ( m_iNumPicCoded == iNumPicRcvd);2488 assert ( m_iNumPicCoded <= 1 || (isField && iPOCLast == 1) ); 2489 #else 2490 assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) ); 2456 2491 #endif 2457 2492 } 2458 2493 2459 2494 #if !SVC_EXTENSION 2460 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded )2495 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, Bool isField) 2461 2496 { 2462 2497 assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic()); … … 2464 2499 2465 2500 //--CFG_KDY 2466 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2467 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2468 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2469 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2501 if(isField) 2502 { 2503 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2); 2504 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2); 2505 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2); 2506 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2); 2507 } 2508 else 2509 { 2510 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2511 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2512 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2513 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2514 } 2470 2515 2471 2516 //-- all … … 2490 2535 m_gcAnalyzeB.printSummary('B'); 2491 2536 #endif 2537 2538 if(isField) 2539 { 2540 //-- interlaced summary 2541 m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate()); 2542 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 2543 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll.getBits()); 2544 2545 #if _SUMMARY_OUT_ 2546 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 2547 #endif 2548 } 2492 2549 2493 2550 printf("\nRVM: %.3lf\n" , xCalculateRVM()); … … 2531 2588 // ==================================================================================================================== 2532 2589 2590 2591 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ) 2592 { 2593 assert( iNumPicRcvd > 0 ); 2594 // Exception for the first frames 2595 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) ) 2596 { 2597 m_iGopSize = 1; 2598 } 2599 else 2600 { 2601 m_iGopSize = m_pcCfg->getGOPSize(); 2602 } 2603 assert (m_iGopSize > 0); 2604 2605 return; 2606 } 2607 2533 2608 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) 2534 2609 { … … 2553 2628 TComPic*& rpcPic, 2554 2629 TComPicYuv*& rpcPicYuvRecOut, 2555 Int pocCurr ) 2630 Int pocCurr, 2631 Bool isField) 2556 2632 { 2557 2633 Int i; 2558 2634 // Rec. output 2559 2635 TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); 2560 for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) 2561 { 2562 iterPicYuvRec--; 2563 } 2564 2636 2637 if (isField) 2638 { 2639 for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ ) 2640 { 2641 iterPicYuvRec--; 2642 } 2643 } 2644 else 2645 { 2646 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ ) 2647 { 2648 iterPicYuvRec--; 2649 } 2650 } 2651 2652 if (isField) 2653 { 2654 if(pocCurr == 1) 2655 { 2656 iterPicYuvRec++; 2657 } 2658 } 2565 2659 rpcPicYuvRecOut = *(iterPicYuvRec); 2566 2660 … … 2647 2741 switch (type) 2648 2742 { 2649 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";2650 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";2651 case NAL_UNIT_CODED_SLICE_T SA_R: return "TSA_R";2652 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";2653 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";2654 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";2743 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2744 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2745 case NAL_UNIT_CODED_SLICE_TLA_R: return "TLA_R"; 2746 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2747 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 2748 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 2655 2749 case NAL_UNIT_CODED_SLICE_BLA_W_LP: return "BLA_W_LP"; 2656 2750 case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL"; 2657 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";2751 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 2658 2752 case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL"; 2659 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";2660 case NAL_UNIT_CODED_SLICE_CRA: return "CRA";2753 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 2754 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2661 2755 case NAL_UNIT_CODED_SLICE_RADL_R: return "RADL_R"; 2662 2756 case NAL_UNIT_CODED_SLICE_RASL_R: return "RASL_R"; 2663 case NAL_UNIT_VPS: return "VPS";2664 case NAL_UNIT_SPS: return "SPS";2665 case NAL_UNIT_PPS: return "PPS";2666 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD";2667 case NAL_UNIT_EOS: return "EOS";2668 case NAL_UNIT_EOB: return "EOB";2669 case NAL_UNIT_FILLER_DATA: return "FILLER";2757 case NAL_UNIT_VPS: return "VPS"; 2758 case NAL_UNIT_SPS: return "SPS"; 2759 case NAL_UNIT_PPS: return "PPS"; 2760 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD"; 2761 case NAL_UNIT_EOS: return "EOS"; 2762 case NAL_UNIT_EOB: return "EOB"; 2763 case NAL_UNIT_FILLER_DATA: return "FILLER"; 2670 2764 case NAL_UNIT_PREFIX_SEI: return "SEI"; 2671 2765 case NAL_UNIT_SUFFIX_SEI: return "SEI"; 2672 default: return "UNK";2766 default: return "UNK"; 2673 2767 } 2674 2768 } … … 2874 2968 printf("]"); 2875 2969 } 2970 } 2971 2972 2973 Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, Bool isTff) 2974 { 2975 2976 for (Int y = 0; y < height; y++) 2977 { 2978 for (Int x = 0; x < width; x++) 2979 { 2980 dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 2981 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 2982 } 2983 top += stride; 2984 bottom += stride; 2985 dst += stride*2; 2986 } 2987 } 2988 2989 Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ) 2990 { 2991 Int x, y; 2992 2993 UInt64 uiSSDY_in = 0; 2994 UInt64 uiSSDU_in = 0; 2995 UInt64 uiSSDV_in = 0; 2996 2997 Double dYPSNR_in = 0.0; 2998 Double dUPSNR_in = 0.0; 2999 Double dVPSNR_in = 0.0; 3000 3001 /*------ INTERLACED PSNR -----------*/ 3002 3003 /* Luma */ 3004 3005 Pel* pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr(); 3006 Pel* pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr(); 3007 Pel* pRecTop = pcPicRecTop->getLumaAddr(); 3008 Pel* pRecBottom = pcPicRecBottom->getLumaAddr(); 3009 3010 Int iWidth; 3011 Int iHeight; 3012 Int iStride; 3013 3014 iWidth = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0); 3015 iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1); 3016 iStride = pcPicOrgTop->getPicYuvOrg()->getStride(); 3017 Int iSize = iWidth*iHeight; 3018 bool isTff = pcPicOrgTop->isTopField(); 3019 3020 TComPicYuv* pcOrgInterlaced = new TComPicYuv; 3021 pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3022 3023 TComPicYuv* pcRecInterlaced = new TComPicYuv; 3024 pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3025 3026 Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr(); 3027 Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr(); 3028 3029 //=== Interlace fields ==== 3030 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3031 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3032 3033 //===== calculate PSNR ===== 3034 for( y = 0; y < iHeight << 1; y++ ) 3035 { 3036 for( x = 0; x < iWidth; x++ ) 3037 { 3038 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3039 uiSSDY_in += iDiff * iDiff; 3040 } 3041 pOrgInterlaced += iStride; 3042 pRecInterlaced += iStride; 3043 } 3044 3045 /*Chroma*/ 3046 3047 iHeight >>= 1; 3048 iWidth >>= 1; 3049 iStride >>= 1; 3050 3051 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr(); 3052 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr(); 3053 pRecTop = pcPicRecTop->getCbAddr(); 3054 pRecBottom = pcPicRecBottom->getCbAddr(); 3055 pOrgInterlaced = pcOrgInterlaced->getCbAddr(); 3056 pRecInterlaced = pcRecInterlaced->getCbAddr(); 3057 3058 //=== Interlace fields ==== 3059 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3060 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3061 3062 //===== calculate PSNR ===== 3063 for( y = 0; y < iHeight << 1; y++ ) 3064 { 3065 for( x = 0; x < iWidth; x++ ) 3066 { 3067 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3068 uiSSDU_in += iDiff * iDiff; 3069 } 3070 pOrgInterlaced += iStride; 3071 pRecInterlaced += iStride; 3072 } 3073 3074 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr(); 3075 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr(); 3076 pRecTop = pcPicRecTop->getCrAddr(); 3077 pRecBottom = pcPicRecBottom->getCrAddr(); 3078 pOrgInterlaced = pcOrgInterlaced->getCrAddr(); 3079 pRecInterlaced = pcRecInterlaced->getCrAddr(); 3080 3081 //=== Interlace fields ==== 3082 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3083 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3084 3085 //===== calculate PSNR ===== 3086 for( y = 0; y < iHeight << 1; y++ ) 3087 { 3088 for( x = 0; x < iWidth; x++ ) 3089 { 3090 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3091 uiSSDV_in += iDiff * iDiff; 3092 } 3093 pOrgInterlaced += iStride; 3094 pRecInterlaced += iStride; 3095 } 3096 3097 Int maxvalY = 255 << (g_bitDepthY-8); 3098 Int maxvalC = 255 << (g_bitDepthC-8); 3099 Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2; 3100 Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0; 3101 dYPSNR_in = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 ); 3102 dUPSNR_in = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 ); 3103 dVPSNR_in = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 ); 3104 3105 /* calculate the size of the access unit, excluding: 3106 * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) 3107 * - SEI NAL units 3108 */ 3109 UInt numRBSPBytes = 0; 3110 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) 3111 { 3112 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 3113 3114 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 3115 numRBSPBytes += numRBSPBytes_nal; 3116 } 3117 3118 UInt uibits = numRBSPBytes * 8 ; 3119 3120 //===== add PSNR ===== 3121 m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits); 3122 3123 printf("\n Interlaced frame %d: [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", pcPicOrgBottom->getPOC()/2 , dYPSNR_in, dUPSNR_in, dVPSNR_in ); 3124 3125 pcOrgInterlaced->destroy(); 3126 delete pcOrgInterlaced; 3127 pcRecInterlaced->destroy(); 3128 delete pcRecInterlaced; 2876 3129 } 2877 3130 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.h
r345 r431 145 145 Void init ( TEncTop* pcTEncTop ); 146 146 #if SVC_EXTENSION 147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 148 148 #else 149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 150 150 #endif 151 151 Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); … … 156 156 TComList<TComPic*>* getListPic() { return m_pcListPic; } 157 157 158 Void printOutSummary ( UInt uiNumAllPicCoded ); 158 #if !SVC_EXTENSION 159 Void printOutSummary ( UInt uiNumAllPicCoded, Bool isField); 160 #endif 159 161 Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); 160 162 … … 166 168 167 169 protected: 170 171 Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ); 168 172 Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); 169 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr );173 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); 170 174 171 175 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); 176 Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); 172 177 173 178 UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r401 r431 180 180 #if SVC_EXTENSION 181 181 //\param vps VPS associated with the slice 182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ) 183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ) 185 185 #endif 186 186 { … … 298 298 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); 299 299 Int SHIFT_QP = 12; 300 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); 300 301 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 302 301 303 #if FULL_NBIT 302 304 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncSlice.h
r313 r431 118 118 #if SVC_EXTENSION 119 119 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps );120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ); 121 121 #else 122 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ); 124 124 #endif 125 125 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncTop.cpp
r414 r431 308 308 } 309 309 310 Void TEncTop::init( )310 Void TEncTop::init(Bool isFieldCoding) 311 311 { 312 312 // initialize SPS … … 319 319 m_cPPS.setSPS(&m_cSPS); 320 320 xInitPPS(); 321 xInitRPS( );321 xInitRPS(isFieldCoding); 322 322 323 323 xInitPPSforTiles(); … … 396 396 397 397 // compress GOP 398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut );398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 399 399 400 400 #if RATE_CONTROL_LAMBDA_DOMAIN … … 456 456 457 457 // compress GOP 458 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 458 459 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 459 460 460 461 #if RATE_CONTROL_LAMBDA_DOMAIN … … 467 468 iNumEncoded = m_iNumPicRcvd; 468 469 m_iNumPicRcvd = 0; 470 m_uiNumAllPicCoded += iNumEncoded; 471 } 472 #endif 473 474 /**------------------------------------------------ 475 Separate interlaced frame into two fields 476 -------------------------------------------------**/ 477 void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) 478 { 479 if (!isTop) 480 { 481 org += stride; 482 } 483 for (Int y = 0; y < height>>1; y++) 484 { 485 for (Int x = 0; x < width; x++) 486 { 487 dstField[x] = org[x]; 488 } 489 490 dstField += stride; 491 org += stride*2; 492 } 493 494 } 495 496 #if SVC_EXTENSION 497 Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ) 498 { 499 if (pcPicYuvOrg) 500 { 501 /* -- TOP FIELD -- */ 502 /* -- Top field initialization -- */ 503 504 TComPic *pcTopField; 505 xGetNewPicBuffer( pcTopField ); 506 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 507 pcTopField->setReconMark (false); 508 509 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 510 pcTopField->getPicYuvRec()->setBorderExtension(false); 511 pcTopField->setTopField(isTff); 512 513 Int nHeight = pcPicYuvOrg->getHeight(); 514 Int nWidth = pcPicYuvOrg->getWidth(); 515 Int nStride = pcPicYuvOrg->getStride(); 516 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 517 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 518 519 // Get pointers 520 Pel * PicBufY = pcPicYuvOrg->getBufY(); 521 Pel * PicBufU = pcPicYuvOrg->getBufU(); 522 Pel * PicBufV = pcPicYuvOrg->getBufV(); 523 524 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 525 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 526 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 527 528 // compute image characteristics 529 if ( getUseAdaptiveQP() ) 530 { 531 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 532 } 533 534 /* -- Defield -- */ 535 536 Bool isTop = isTff; 537 538 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 539 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 540 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 541 542 /* -- BOTTOM FIELD -- */ 543 /* -- Bottom field initialization -- */ 544 545 TComPic* pcBottomField; 546 xGetNewPicBuffer( pcBottomField ); 547 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 548 pcBottomField->setReconMark (false); 549 550 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 551 pcBottomField->getPicYuvRec()->setBorderExtension(false); 552 pcBottomField->setTopField(!isTff); 553 554 nHeight = pcPicYuvOrg->getHeight(); 555 nWidth = pcPicYuvOrg->getWidth(); 556 nStride = pcPicYuvOrg->getStride(); 557 nPadLuma = pcPicYuvOrg->getLumaMargin(); 558 nPadChroma = pcPicYuvOrg->getChromaMargin(); 559 560 // Get pointers 561 PicBufY = pcPicYuvOrg->getBufY(); 562 PicBufU = pcPicYuvOrg->getBufU(); 563 PicBufV = pcPicYuvOrg->getBufV(); 564 565 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 566 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 567 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 568 569 // Compute image characteristics 570 if ( getUseAdaptiveQP() ) 571 { 572 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 573 } 574 575 /* -- Defield -- */ 576 577 isTop = !isTff; 578 579 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 580 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 581 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 582 583 } 584 } 585 586 Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ) 587 { 588 // compress GOP 589 if (m_iPOCLast == 0) // compress field 0 590 { 591 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 592 } 593 594 if (pcPicYuvOrg) 595 { 596 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 597 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 598 { 599 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 600 } 601 else 602 { 603 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 604 } 605 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 606 } 607 608 // compress GOP 609 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 610 611 m_uiNumAllPicCoded ++; 612 } 613 #else 614 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) 615 { 616 /* -- TOP FIELD -- */ 617 618 if (pcPicYuvOrg) 619 { 620 621 /* -- Top field initialization -- */ 622 623 TComPic *pcTopField; 624 xGetNewPicBuffer( pcTopField ); 625 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 626 pcTopField->setReconMark (false); 627 628 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 629 pcTopField->getPicYuvRec()->setBorderExtension(false); 630 pcTopField->setTopField(isTff); 631 632 Int nHeight = pcPicYuvOrg->getHeight(); 633 Int nWidth = pcPicYuvOrg->getWidth(); 634 Int nStride = pcPicYuvOrg->getStride(); 635 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 636 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 637 638 // Get pointers 639 Pel * PicBufY = pcPicYuvOrg->getBufY(); 640 Pel * PicBufU = pcPicYuvOrg->getBufU(); 641 Pel * PicBufV = pcPicYuvOrg->getBufV(); 642 643 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 644 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 645 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 646 647 // compute image characteristics 648 if ( getUseAdaptiveQP() ) 649 { 650 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 651 } 652 653 /* -- Defield -- */ 654 655 Bool isTop = isTff; 656 657 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 658 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 659 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 660 661 } 662 663 if (m_iPOCLast == 0) // compress field 0 664 { 665 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 666 } 667 668 /* -- BOTTOM FIELD -- */ 669 670 if (pcPicYuvOrg) 671 { 672 673 /* -- Bottom field initialization -- */ 674 675 TComPic* pcBottomField; 676 xGetNewPicBuffer( pcBottomField ); 677 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 678 pcBottomField->setReconMark (false); 679 680 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 681 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 682 { 683 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 684 } 685 else 686 { 687 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 688 } 689 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 690 691 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 692 pcBottomField->getPicYuvRec()->setBorderExtension(false); 693 pcBottomField->setTopField(!isTff); 694 695 int nHeight = pcPicYuvOrg->getHeight(); 696 int nWidth = pcPicYuvOrg->getWidth(); 697 int nStride = pcPicYuvOrg->getStride(); 698 int nPadLuma = pcPicYuvOrg->getLumaMargin(); 699 int nPadChroma = pcPicYuvOrg->getChromaMargin(); 700 701 // Get pointers 702 Pel * PicBufY = pcPicYuvOrg->getBufY(); 703 Pel * PicBufU = pcPicYuvOrg->getBufU(); 704 Pel * PicBufV = pcPicYuvOrg->getBufV(); 705 706 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 707 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 708 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 709 710 // Compute image characteristics 711 if ( getUseAdaptiveQP() ) 712 { 713 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 714 } 715 716 /* -- Defield -- */ 717 718 Bool isTop = !isTff; 719 720 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 721 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 722 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 723 724 } 725 726 if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) ) 727 { 728 iNumEncoded = 0; 729 return; 730 } 731 732 // compress GOP 733 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 734 735 iNumEncoded = m_iNumPicRcvd; 736 m_iNumPicRcvd = 0; 469 737 m_uiNumAllPicCoded += iNumEncoded; 470 738 } … … 911 1179 912 1180 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 913 Void TEncTop::xInitRPS( )1181 Void TEncTop::xInitRPS(Bool isFieldCoding) 914 1182 { 915 1183 TComReferencePictureSet* rps; 916 1184 917 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs );1185 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1); 918 1186 TComRPSList* rpsList = m_cSPS.getRPSList(); 919 1187 … … 1016 1284 printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 1017 1285 rps->setNumberOfNegativePictures(numNeg); 1018 rps->setNumberOfP ositivePictures(numNeg+numPos);1286 rps->setNumberOfPictures(numNeg+numPos); 1019 1287 } 1020 1288 if (numPos != rps->getNumberOfPositivePictures()) … … 1022 1290 printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 1023 1291 rps->setNumberOfPositivePictures(numPos); 1024 rps->setNumberOfP ositivePictures(numNeg+numPos);1292 rps->setNumberOfPictures(numNeg+numPos); 1025 1293 } 1026 1294 RPSTemp.setNumberOfPictures(numNeg+numPos); … … 1086 1354 #endif //INTER_RPS_AUTO 1087 1355 } 1088 1356 //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file. 1357 //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. 1358 if (isFieldCoding) 1359 { 1360 rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); 1361 rps->setNumberOfPictures(1); 1362 rps->setNumberOfNegativePictures(1); 1363 rps->setNumberOfPositivePictures(0); 1364 rps->setNumberOfLongtermPictures(0); 1365 rps->setDeltaPOC(0,-1); 1366 rps->setPOC(0,0); 1367 rps->setUsed(0,true); 1368 rps->setInterRPSPrediction(false); 1369 rps->setDeltaRIdxMinus1(0); 1370 rps->setDeltaRPS(0); 1371 rps->setNumRefIdc(0); 1372 } 1089 1373 } 1090 1374 … … 1095 1379 { 1096 1380 slice->setRPSidx(GOPid); 1097 1098 1381 for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) 1099 1382 { … … 1119 1402 } 1120 1403 1404 if(POCCurr == 1 && slice->getPic()->isField()) 1405 { 1406 slice->setRPSidx(m_iGOPSize+m_extraRPSs); 1407 } 1408 1121 1409 slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); 1122 1410 slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); 1123 1124 1411 } 1125 1412 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncTop.h
r414 r431 144 144 Window m_scaledRefLayerWindow[MAX_LAYERS]; 145 145 #endif 146 #endif147 146 #if POC_RESET_FLAG 148 147 Int m_pocAdjustmentValue; 148 #endif 149 149 #endif 150 150 protected: … … 154 154 155 155 Void xInitPPSforTiles (); 156 Void xInitRPS ( );///< initialize PPS from encoder options156 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 157 157 #if SVC_EXTENSION 158 158 Void xInitILRP(); … … 164 164 Void create (); 165 165 Void destroy (); 166 Void init ( );166 Void init (Bool isFieldCoding); 167 167 Void deletePicBuffer (); 168 168 … … 209 209 Int getNumPicRcvd () { return m_iNumPicRcvd; } 210 210 Void setNumPicRcvd ( Int num ) { m_iNumPicRcvd = num; } 211 #endif212 211 #if SCALED_REF_LAYER_OFFSETS 213 212 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } 214 213 UInt getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; } 215 214 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 215 #endif 216 216 #endif 217 217 … … 236 236 fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } 237 237 #endif 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ); 239 239 Void encodePrep( TComPicYuv* pcPicYuvOrg ); 240 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ); 241 Void encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ); 240 242 #if VPS_EXTN_DIRECT_REF_LAYERS 241 243 TEncTop* getRefLayerEnc(UInt refLayerIdc); 242 244 #endif 243 #else244 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,245 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded );246 #endif247 248 void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }249 245 #if POC_RESET_FLAG 250 246 Int getPocAdjustmentValue() { return m_pocAdjustmentValue;} 251 247 Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x; } 252 248 #endif 249 #else //SVC_EXTENSION 250 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 251 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 252 253 /// encode several number of pictures until end-of-sequence 254 Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 255 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff); 256 257 Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); } 258 #endif //#if SVC_EXTENSION 253 259 }; 254 260 -
branches/SHM-3.1-dev/source/Lib/TLibVideoIO/TVideoIOYuv.cpp
r313 r431 339 339 } 340 340 341 static Bool writeField(ostream& fd, Pel* top, Pel* bottom, Bool is16bit, 342 UInt stride, 343 UInt width, UInt height, bool isTff) 344 { 345 Int write_len = width * (is16bit ? 2 : 1)*2; 346 UChar *buf = new UChar[write_len]; 347 for (Int y = 0; y < height; y++) 348 { 349 if (!is16bit) 350 { 351 for (Int x = 0; x < width; x++) 352 { 353 buf[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 354 buf[width+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 355 } 356 } 357 else 358 { 359 for (Int x = 0; x < width; x++) 360 { 361 buf[2*x] = isTff ? top[x] & 0xff : bottom[x] & 0xff; 362 buf[2*x+1] = isTff ? (top[x] >> 8) & 0xff : (bottom[x] >> 8) & 0xff; 363 364 buf[width+2*x] = isTff ? bottom[x] & 0xff : top[x] & 0xff; 365 buf[width+2*x+1] = isTff ? (bottom[x] >> 8) & 0xff : (top[x] >> 8) & 0xff; 366 } 367 } 368 369 fd.write(reinterpret_cast<Char*>(buf), write_len); 370 if (fd.eof() || fd.fail() ) 371 { 372 delete[] buf; 373 return false; 374 } 375 top += stride; 376 bottom += stride; 377 } 378 delete[] buf; 379 return true; 380 } 341 381 /** 342 382 * Read one Y'CbCr frame, performing any required input scaling to change … … 501 541 } 502 542 543 544 /** 545 * Write one Y'CbCr frame. No bit-depth conversion is performed, pcPicYuv is 546 * assumed to be at TVideoIO::m_fileBitdepth depth. 547 * 548 * @param pPicTop input top field YUV buffer class pointer 549 * @param pPicBottom input bottom field YUV buffer class pointer 550 * @param aiPad source padding size, aiPad[0] = horizontal, aiPad[1] = vertical 551 * @return true for success, false in case of error 552 */ 553 Bool TVideoIOYuv::write( TComPicYuv* pPicTop, TComPicYuv* pPicBottom, Int cropLeft, Int cropRight, Int cropTop, Int cropBottom , bool isTff) 554 { 555 // compute actual YUV frame size excluding padding size 556 Int iStride = pPicTop->getStride(); 557 UInt width = pPicTop->getWidth() - cropLeft - cropRight; 558 UInt height = pPicTop->getHeight() - cropTop - cropBottom; 559 Bool is16bit = m_fileBitDepthY > 8 || m_fileBitDepthC > 8; 560 561 TComPicYuv *dstPicTop = NULL; 562 TComPicYuv *dstPicBottom = NULL; 563 564 Bool retval = true; 565 566 if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0) 567 { 568 dstPicTop = new TComPicYuv; 569 dstPicTop->create( pPicTop->getWidth(), pPicTop->getHeight(), 1, 1, 0 ); 570 pPicTop->copyToPic(dstPicTop); 571 572 dstPicBottom = new TComPicYuv; 573 dstPicBottom->create( pPicBottom->getWidth(), pPicBottom->getHeight(), 1, 1, 0 ); 574 pPicBottom->copyToPic(dstPicBottom); 575 576 Pel minvalY = 0; 577 Pel minvalC = 0; 578 Pel maxvalY = (1 << m_fileBitDepthY) - 1; 579 Pel maxvalC = (1 << m_fileBitDepthC) - 1; 580 #if CLIP_TO_709_RANGE 581 if (-m_bitDepthShiftY < 0 && m_fileBitDepthY >= 8) 582 { 583 /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */ 584 minvalY = 1 << (m_fileBitDepthY - 8); 585 maxvalY = (0xff << (m_fileBitDepthY - 8)) -1; 586 } 587 if (-m_bitDepthShiftC < 0 && m_fileBitDepthC >= 8) 588 { 589 /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */ 590 minvalC = 1 << (m_fileBitDepthC - 8); 591 maxvalC = (0xff << (m_fileBitDepthC - 8)) -1; 592 } 593 #endif 594 scalePlane(dstPicTop->getLumaAddr(), dstPicTop->getStride(), dstPicTop->getWidth(), dstPicTop->getHeight(), -m_bitDepthShiftY, minvalY, maxvalY); 595 scalePlane(dstPicTop->getCbAddr(), dstPicTop->getCStride(), dstPicTop->getWidth()>>1, dstPicTop->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 596 scalePlane(dstPicTop->getCrAddr(), dstPicTop->getCStride(), dstPicTop->getWidth()>>1, dstPicTop->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 597 598 scalePlane(dstPicBottom->getLumaAddr(), dstPicBottom->getStride(), dstPicBottom->getWidth(), dstPicBottom->getHeight(), -m_bitDepthShiftY, minvalY, maxvalY); 599 scalePlane(dstPicBottom->getCbAddr(), dstPicBottom->getCStride(), dstPicBottom->getWidth()>>1, dstPicBottom->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 600 scalePlane(dstPicBottom->getCrAddr(), dstPicBottom->getCStride(), dstPicBottom->getWidth()>>1, dstPicBottom->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 601 } 602 else 603 { 604 dstPicTop = pPicTop; 605 dstPicBottom = pPicBottom; 606 } 607 // location of upper left pel in a plane 608 Int planeOffset = 0; //cropLeft + cropTop * iStride; 609 //Write luma 610 if (! writeField(m_cHandle, dstPicTop->getLumaAddr() + planeOffset, dstPicBottom->getLumaAddr() + planeOffset, is16bit, iStride, width, height, isTff)) 611 { 612 retval=false; 613 goto exit; 614 } 615 616 width >>= 1; 617 height >>= 1; 618 iStride >>= 1; 619 cropLeft >>= 1; 620 cropRight >>= 1; 621 622 planeOffset = 0; // cropLeft + cropTop * iStride; 623 624 //Write chroma U 625 if (! writeField(m_cHandle, dstPicTop->getCbAddr() + planeOffset, dstPicBottom->getCbAddr() + planeOffset, is16bit, iStride, width, height, isTff)) 626 { 627 retval=false; 628 goto exit; 629 } 630 631 //Write chroma V 632 if (! writeField(m_cHandle, dstPicTop->getCrAddr() + planeOffset, dstPicBottom->getCrAddr() + planeOffset, is16bit, iStride, width, height, isTff)) 633 634 { 635 retval=false; 636 goto exit; 637 } 638 639 exit: 640 if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0) 641 { 642 dstPicTop->destroy(); 643 delete dstPicTop; 644 dstPicBottom->destroy(); 645 delete dstPicBottom; 646 } 647 return retval; 648 } -
branches/SHM-3.1-dev/source/Lib/TLibVideoIO/TVideoIOYuv.h
r313 r431 72 72 Bool read ( TComPicYuv* pPicYuv, Int aiPad[2] ); ///< read one YUV frame with padding parameter 73 73 Bool write( TComPicYuv* pPicYuv, Int confLeft=0, Int confRight=0, Int confTop=0, Int confBottom=0 ); 74 Bool write( TComPicYuv* pPicYuv, TComPicYuv* pPicYuv2, Int confLeft=0, Int confRight=0, Int confTop=0, Int confBottom=0 , bool isTff=false); 74 75 75 76 Bool isEof (); ///< check for end-of-file
Note: See TracChangeset for help on using the changeset viewer.