[cvs] / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/encoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.76.2.23, Thu Nov 28 14:45:21 2002 UTC revision 1.76.2.24, Wed Dec 4 12:31:18 2002 UTC
# Line 224  Line 224 
224    
225          pEnc->mbParam.m_quant_type = H263_QUANT;          pEnc->mbParam.m_quant_type = H263_QUANT;
226    
227          pEnc->sStat.fMvPrevSigma = -1;          pEnc->fMvPrevSigma = -1;
228    
229          /* Fill rate control parameters */          /* Fill rate control parameters */
230    
# Line 1069  Line 1069 
1069    
1070          if (pResult) {          if (pResult) {
1071                  pResult->quant = pEnc->current->quant;                  pResult->quant = pEnc->current->quant;
1072                  pResult->hlength = pFrame->length - (pEnc->sStat.iTextBits / 8);                  pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8);
1073                  pResult->kblks = pEnc->sStat.kblks;                  pResult->kblks = pEnc->current->sStat.kblks;
1074                  pResult->mblks = pEnc->sStat.mblks;                  pResult->mblks = pEnc->current->sStat.mblks;
1075                  pResult->ublks = pEnc->sStat.ublks;                  pResult->ublks = pEnc->current->sStat.ublks;
1076          }          }
1077    
1078          emms();          emms();
# Line 1257  Line 1257 
1257    
1258          if (pResult) {          if (pResult) {
1259                  pResult->quant = pEnc->current->quant;                  pResult->quant = pEnc->current->quant;
1260                  pResult->hlength = pFrame->length - (pEnc->sStat.iTextBits / 8);                  pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8);
1261                  pResult->kblks = pEnc->sStat.kblks;                  pResult->kblks = pEnc->current->sStat.kblks;
1262                  pResult->mblks = pEnc->sStat.mblks;                  pResult->mblks = pEnc->current->sStat.mblks;
1263                  pResult->ublks = pEnc->sStat.ublks;                  pResult->ublks = pEnc->current->sStat.ublks;
1264          }          }
1265    
1266          emms();          emms();
# Line 1545  Line 1545 
1545    
1546          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
1547    
1548          pEnc->sStat.iTextBits = 0;          pEnc->current->sStat.iTextBits = 0;
1549          pEnc->sStat.kblks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;          pEnc->current->sStat.kblks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;
1550          pEnc->sStat.mblks = pEnc->sStat.ublks = 0;          pEnc->current->sStat.mblks = pEnc->current->sStat.ublks = 0;
1551    
1552          for (y = 0; y < pEnc->mbParam.mb_height; y++)          for (y = 0; y < pEnc->mbParam.mb_height; y++)
1553                  for (x = 0; x < pEnc->mbParam.mb_width; x++) {                  for (x = 0; x < pEnc->mbParam.mb_width; x++) {
# Line 1569  Line 1569 
1569                                  qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */                                  qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */
1570                                  qcoeff[5*64+0]=0;                                  qcoeff[5*64+0]=0;
1571                          }                          }
1572                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);
1573                          stop_coding_timer();                          stop_coding_timer();
1574                  }                  }
1575    
1576          emms();          emms();
1577    
1578          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1579          pEnc->sStat.fMvPrevSigma = -1;          pEnc->fMvPrevSigma = -1;
         pEnc->sStat.iMvSum = 0;  
         pEnc->sStat.iMvCount = 0;  
1580          pEnc->mbParam.m_fcode = 2;          pEnc->mbParam.m_fcode = 2;
1581    
1582          if (pEnc->current->global_flags & XVID_HINTEDME_GET) {          if (pEnc->current->global_flags & XVID_HINTEDME_GET) {
# Line 1679  Line 1677 
1677    
1678          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
1679    
1680          pEnc->sStat.iTextBits = pEnc->sStat.iMvSum = pEnc->sStat.iMvCount =          pEnc->current->sStat.iTextBits = pEnc->current->sStat.iMvSum = pEnc->current->sStat.iMvCount =
1681                  pEnc->sStat.kblks = pEnc->sStat.mblks = pEnc->sStat.ublks = 0;                  pEnc->current->sStat.kblks = pEnc->current->sStat.mblks = pEnc->current->sStat.ublks = 0;
1682    
1683          for (y = 0; y < pEnc->mbParam.mb_height; y++) {          for (y = 0; y < pEnc->mbParam.mb_height; y++) {
1684                  for (x = 0; x < pEnc->mbParam.mb_width; x++) {                  for (x = 0; x < pEnc->mbParam.mb_width; x++) {
# Line 1730  Line 1728 
1728                          stop_prediction_timer();                          stop_prediction_timer();
1729    
1730                          if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) {                          if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) {
1731                                  pEnc->sStat.kblks++;                                  pEnc->current->sStat.kblks++;
1732                          } else if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y ||                          } else if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y ||
1733                                             pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x ||                                             pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x ||
1734                                             pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) {                                             pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) {
1735                                  pEnc->sStat.mblks++;                                  pEnc->current->sStat.mblks++;
1736                          }  else {                          }  else {
1737                                  pEnc->sStat.ublks++;                                  pEnc->current->sStat.ublks++;
1738                          }                          }
1739    
1740                          start_timer();                          start_timer();
# Line 1786  Line 1784 
1784                                          }                                          }
1785                                          pMB->mode = MODE_INTER;                                          pMB->mode = MODE_INTER;
1786                                          pMB->cbp = 0;                                          pMB->cbp = 0;
1787                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);
1788                                  }                                  }
1789                                  else                                  else
1790                                  {                                  {
# Line 1800  Line 1798 
1798                                          qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */                                          qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */
1799                                          qcoeff[5*64+0]=0;                                          qcoeff[5*64+0]=0;
1800                                  }                                  }
1801                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);
1802                          }                          }
1803    
1804                          stop_coding_timer();                          stop_coding_timer();
# Line 1813  Line 1811 
1811                  HintedMEGet(pEnc, 0);                  HintedMEGet(pEnc, 0);
1812          }          }
1813    
1814          if (pEnc->sStat.iMvCount == 0)          if (pEnc->current->sStat.iMvCount == 0)
1815                  pEnc->sStat.iMvCount = 1;                  pEnc->current->sStat.iMvCount = 1;
1816    
1817          fSigma = (float) sqrt((float) pEnc->sStat.iMvSum / pEnc->sStat.iMvCount);          fSigma = (float) sqrt((float) pEnc->current->sStat.iMvSum / pEnc->current->sStat.iMvCount);
1818    
1819          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);
1820    
# Line 1826  Line 1824 
1824                  pEnc->mbParam.m_fcode++;                  pEnc->mbParam.m_fcode++;
1825                  iSearchRange *= 2;                  iSearchRange *= 2;
1826          } else if ((fSigma < iSearchRange / 6)          } else if ((fSigma < iSearchRange / 6)
1827                             && (pEnc->sStat.fMvPrevSigma >= 0)                             && (pEnc->fMvPrevSigma >= 0)
1828                             && (pEnc->sStat.fMvPrevSigma < iSearchRange / 6)                             && (pEnc->fMvPrevSigma < iSearchRange / 6)
1829                          && (pEnc->mbParam.m_fcode >= (2 + pEnc->mbParam.m_quarterpel))) // minimum search range 16                          && (pEnc->mbParam.m_fcode >= (2 + pEnc->mbParam.m_quarterpel))) // minimum search range 16
1830          {          {
1831                  pEnc->mbParam.m_fcode--;                  pEnc->mbParam.m_fcode--;
1832                  iSearchRange /= 2;                  iSearchRange /= 2;
1833          }          }
1834    
1835          pEnc->sStat.fMvPrevSigma = fSigma;          pEnc->fMvPrevSigma = fSigma;
1836    
 #ifdef FRAMEDROP  
1837          /* frame drop code */          /* frame drop code */
1838          // DPRINTF(DPRINTF_DEBUG, "kmu %i %i %i", pEnc->sStat.kblks, pEnc->sStat.mblks, pEnc->sStat.ublks);          // DPRINTF(DPRINTF_DEBUG, "kmu %i %i %i", pEnc->current->sStat.kblks, pEnc->current->sStat.mblks, pEnc->current->sStat.ublks);
1839          if (pEnc->sStat.kblks + pEnc->sStat.mblks <          if (pEnc->current->sStat.kblks + pEnc->current->sStat.mblks <
1840                  (pEnc->frame_drop_ratio * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height) / 100)                  (pEnc->frame_drop_ratio * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height) / 100)
1841          {          {
1842                  pEnc->sStat.kblks = pEnc->sStat.mblks = 0;                  pEnc->current->sStat.kblks = pEnc->current->sStat.mblks = 0;
1843                  pEnc->sStat.ublks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;                  pEnc->current->sStat.ublks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;
1844    
1845                  BitstreamReset(bs);                  BitstreamReset(bs);
1846    
# Line 1861  Line 1858 
1858                  memcpy(pEnc->current->mbs, pEnc->reference->mbs, sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height);                  memcpy(pEnc->current->mbs, pEnc->reference->mbs, sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height);
1859    
1860          }          }
 #endif  
1861    
1862          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1863    
# Line 1941  Line 1937 
1937    
1938          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
1939    
1940          pEnc->sStat.iTextBits = 0;          frame->sStat.iTextBits = 0;
1941          pEnc->sStat.iMvSum = 0;          frame->sStat.iMvSum = 0;
1942          pEnc->sStat.iMvCount = 0;          frame->sStat.iMvCount = 0;
1943          pEnc->sStat.kblks = pEnc->sStat.mblks = pEnc->sStat.ublks = 0;          frame->sStat.kblks = frame->sStat.mblks = frame->sStat.ublks = 0;
1944    
1945    
1946          for (y = 0; y < pEnc->mbParam.mb_height; y++) {          for (y = 0; y < pEnc->mbParam.mb_height; y++) {
# Line 1982  Line 1978 
1978  #endif  #endif
1979                          start_timer();                          start_timer();
1980                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,
1981                                                   &pEnc->sStat, direction);                                                   &frame->sStat, direction);
1982                          stop_coding_timer();                          stop_coding_timer();
1983                  }                  }
1984          }          }

Legend:
Removed from v.1.76.2.23  
changed lines
  Added in v.1.76.2.24

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4