Ticket #1282: fix_1282.patch

File fix_1282.patch, 5.9 KB (added by barrouxg, 10 years ago)

This new patch should solve the problem whatever cfg file we use

  • source/Lib/TLibEncoder/TEncCfg.h

     
    6666  Bool m_interRPSPrediction;
    6767#endif
    6868  Int m_deltaRPS;
    6969  Int m_numRefIdc;
    7070  Int m_refIdc[MAX_NUM_REF_PICS+1];
     71  Bool m_isEncoded;
    7172  GOPEntry()
    7273  : m_POC(-1)
    7374  , m_QPOffset(0)
    7475  , m_QPFactor(0)
    7576  , m_tcOffsetDiv2(0)
     
    8081  , m_sliceType('P')
    8182  , m_numRefPics(0)
    8283  , m_interRPSPrediction(false)
    8384  , m_deltaRPS(0)
    8485  , m_numRefIdc(0)
     86  , m_isEncoded(false)
    8587  {
    8688    ::memset( m_referencePics, 0, sizeof(m_referencePics) );
    8789    ::memset( m_usedByCurrPic, 0, sizeof(m_usedByCurrPic) );
    8890    ::memset( m_refIdc,        0, sizeof(m_refIdc) );
    8991  }
     
    396398  Void      setDecodingRefreshType          ( Int   i )      { m_uiDecodingRefreshType = (UInt)i; }
    397399  Void      setGOPSize                      ( Int   i )      { m_iGOPSize = i; }
    398400  Void      setGopList                      ( GOPEntry*  GOPList ) {  for ( Int i = 0; i < MAX_GOP; i++ ) m_GOPList[i] = GOPList[i]; }
    399401  Void      setExtraRPSs                    ( Int   i )      { m_extraRPSs = i; }
    400402  GOPEntry  getGOPEntry                     ( Int   i )      { return m_GOPList[i]; }
     403  Void      setEncodedFlag                  ( Int  i, Bool value )  { m_GOPList[i].m_isEncoded = value; }
    401404  Void      setMaxDecPicBuffering           ( UInt u, UInt tlayer ) { m_maxDecPicBuffering[tlayer] = u;    }
    402405  Void      setNumReorderPics               ( Int  i, UInt tlayer ) { m_numReorderPics[tlayer] = i;    }
    403406
    404407  Void      setQP                           ( Int   i )      { m_iQP = i; }
    405408
  • source/Lib/TLibEncoder/TEncGOP.cpp

     
    609609        }
    610610      }
    611611    }
    612612  }
    613613#endif
     614  // reset flag indicating whether pictures have been encoded
     615  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
     616  {
     617    m_pcCfg->setEncodedFlag(iGOPid, false);
     618  }
    614619
    615620  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
    616621  {
    617622#if EFFICIENT_FIELD_IRAP
    618623    if(IRAPtoReorder)
     
    18761881      /* insert the SEI message NALUnit before any Slice NALUnits */
    18771882      AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
    18781883      accessUnit.insert(it, new NALUnitEBSP(nalu));
    18791884    }
    18801885
     1886    m_pcCfg->setEncodedFlag(iGOPid, true);
    18811887    xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE );
    18821888
    18831889    //In case of field coding, compute the interlaced PSNR for both fields
    1884     if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff)) && (pcPic->getPOC()%m_iGopSize != 1))
     1890    if(isField)
    18851891    {
    1886       //get complementary top field
    1887 
    1888       TComList<TComPic*>::iterator   iterPic = rcListPic.begin();
    1889       while ((*iterPic)->getPOC() != pcPic->getPOC()-1)
     1892      Bool bothFieldsAreEncoded = false;
     1893      Int correspondingFieldPOC = pcPic->getPOC();
     1894      Int currentPicGOPPoc = m_pcCfg->getGOPEntry(iGOPid).m_POC;
     1895      if(pcPic->getPOC() == 0)
     1896      {
     1897        // particular case for POC 0 and 1.
     1898        // If they are not encoded first and separaltely from other pictures, we need to change this
     1899        // POC 0 is always encoded first then POC 1 is encoded
     1900        bothFieldsAreEncoded = false;
     1901      }
     1902      else if(pcPic->getPOC() == 1)
     1903      {
     1904        // if we are at POC 1, POC 0 has been encoded for sure
     1905        correspondingFieldPOC = 0;
     1906        bothFieldsAreEncoded = true;
     1907      }
     1908      else
    18901909      {
    1891         iterPic ++;
     1910        if(pcPic->getPOC()%2 == 1)
     1911        {
     1912            correspondingFieldPOC -= 1; // all odd POC are associated with the preceding even POC (e.g poc 1 is associated to poc 0)
     1913            currentPicGOPPoc      -= 1;
    18921914      }
    1893       TComPic* pcPicFirstField = *(iterPic);
    1894       xCalculateInterlacedAddPSNR(pcPicFirstField, pcPic, pcPicFirstField->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE );
     1915        else
     1916        {
     1917            correspondingFieldPOC += 1; // all even POC are associated with the following odd POC (e.g poc 0 is associated to poc 1)
     1918            currentPicGOPPoc      += 1;
    18951919    }
    1896     else if (isField && pcPic->getPOC()!= 0 && (pcPic->getPOC()%m_iGopSize == 0))
     1920        for(Int i = 0; i < m_iGopSize; i ++)
    18971921    {
    1898       //get complementary bottom field
     1922          if(m_pcCfg->getGOPEntry(i).m_POC == currentPicGOPPoc)
     1923          {
     1924            bothFieldsAreEncoded = m_pcCfg->getGOPEntry(i).m_isEncoded;
     1925            break;
     1926          }
     1927        }
     1928      }
    18991929
     1930      if(bothFieldsAreEncoded)
     1931      {       
     1932        //get complementary top field
    19001933      TComList<TComPic*>::iterator   iterPic = rcListPic.begin();
    1901       while ((*iterPic)->getPOC() != pcPic->getPOC()+1)
     1934        while ((*iterPic)->getPOC() != correspondingFieldPOC)
    19021935      {
    19031936        iterPic ++;
    19041937      }
    1905       TComPic* pcPicFirstField = *(iterPic);
    1906       xCalculateInterlacedAddPSNR(pcPic, pcPicFirstField, pcPic->getPicYuvRec(), pcPicFirstField->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE );
     1938        TComPic* correspondingFieldPic = *(iterPic);
     1939
     1940        if(pcPic->isTopField() && isTff || !pcPic->isTopField() && !isTff)
     1941        {
     1942          xCalculateInterlacedAddPSNR(pcPic, correspondingFieldPic, pcPic->getPicYuvRec(), correspondingFieldPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE );
     1943        }
     1944        else
     1945        {
     1946          xCalculateInterlacedAddPSNR(correspondingFieldPic, pcPic, correspondingFieldPic->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE );
     1947        }
     1948      }
    19071949    }
    19081950
    19091951    if (!digestStr.empty())
    19101952    {
    19111953      if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1)