[svn] / branches / dev-api-3 / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/xvidcore/src/encoder.c

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

revision 602, Thu Oct 17 19:10:57 2002 UTC revision 619, Sat Nov 2 15:52:31 2002 UTC
# Line 39  Line 39 
39   *             MinChen <chenm001@163.com>   *             MinChen <chenm001@163.com>
40   *  14.04.2002 added FrameCodeB()   *  14.04.2002 added FrameCodeB()
41   *   *
42   *  $Id: encoder.c,v 1.76.2.13 2002-10-17 19:10:57 Isibaar Exp $   *  $Id: encoder.c,v 1.76.2.14 2002-11-02 15:52:30 chl Exp $
43   *   *
44   ****************************************************************************/   ****************************************************************************/
45    
# Line 54  Line 54 
54  #include "global.h"  #include "global.h"
55  #include "utils/timer.h"  #include "utils/timer.h"
56  #include "image/image.h"  #include "image/image.h"
 #ifdef BFRAMES  
57  #include "image/font.h"  #include "image/font.h"
58  #include "motion/sad.h"  #include "motion/sad.h"
 #endif  
59  #include "motion/motion.h"  #include "motion/motion.h"
60  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
61  #include "utils/mbfunctions.h"  #include "utils/mbfunctions.h"
# Line 1509  Line 1507 
1507          pEnc->iFrameNum = 0;          pEnc->iFrameNum = 0;
1508          pEnc->mbParam.m_rounding_type = 1;          pEnc->mbParam.m_rounding_type = 1;
1509          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
1510            pEnc->current->quarterpel =  pEnc->mbParam.m_quarterpel;
1511          pEnc->current->coding_type = I_VOP;          pEnc->current->coding_type = I_VOP;
1512    
1513          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
# Line 1600  Line 1599 
1599    
1600          pEnc->mbParam.m_rounding_type = 1 - pEnc->mbParam.m_rounding_type;          pEnc->mbParam.m_rounding_type = 1 - pEnc->mbParam.m_rounding_type;
1601          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
1602            pEnc->current->quarterpel =  pEnc->mbParam.m_quarterpel;
1603          pEnc->current->fcode = pEnc->mbParam.m_fcode;          pEnc->current->fcode = pEnc->mbParam.m_fcode;
1604    
1605          if (!force_inter)          if (!force_inter)
# Line 1619  Line 1619 
1619                  stop_inter_timer();                  stop_inter_timer();
1620          }          }
1621    
1622            if (pEnc->current->global_flags & XVID_GMC) {
1623                    printf("Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel);
1624                    pEnc->current->coding_type = S_VOP;
1625            } else
1626                    pEnc->current->coding_type = P_VOP;
1627    
1628          start_timer();          start_timer();
1629          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {
1630                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
# Line 1634  Line 1640 
1640                  MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,                  MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
1641                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1642                           iLimit);                           iLimit);
   
1643          }          }
1644          stop_motion_timer();          stop_motion_timer();
1645    
1646          if (bIntra == 1) return FrameCodeI(pEnc, bs, pBits);          if (bIntra == 1) return FrameCodeI(pEnc, bs, pBits);
1647    
1648          pEnc->current->coding_type = P_VOP;          if ( (pEnc->current->GMC_MV.x == 0) && (pEnc->current->GMC_MV.y == 0) )
1649                            pEnc->current->coding_type = P_VOP;             /* no global motion -> no GMC */
1650    
1651    
1652          if (vol_header)          if (vol_header)
1653                  BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);                  BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
# Line 1719  Line 1726 
1726                                                          (pMB->dquant == NO_CHANGE);                                                          (pMB->dquant == NO_CHANGE);
1727    
1728                          if(pEnc->mbParam.m_quarterpel)                          if(pEnc->mbParam.m_quarterpel)
1729                                  skip_possible &= (pMB->qmvs[0].x == 0) & (pMB->qmvs[0].y == 0);                          {       skip_possible &= (pMB->qmvs[0].x == pEnc->current->GMC_MV.x) & (pMB->qmvs[0].y == pEnc->current->GMC_MV.y);
1730                            }
1731                          else                          else
1732                                  skip_possible &= (pMB->mvs[0].x == 0) & (pMB->mvs[0].y == 0);                          {       skip_possible &= (pMB->mvs[0].x == pEnc->current->GMC_MV.x) & (pMB->mvs[0].y == pEnc->current->GMC_MV.y);
1733                            }
1734    
1735                          if ((pMB->mode == MODE_NOT_CODED) || (skip_possible)) {                          if ((pMB->mode == MODE_NOT_CODED) || (skip_possible)) {
 /* This is a candidate for SKIPping, but check intermediate B-frames first */  
1736    
1737    /* This is a candidate for SKIPping, but for P-VOPs check intermediate B-frames first */
1738                                  int bSkip = 1;                                  int bSkip = 1;
                                 pMB->mode = MODE_NOT_CODED;  
1739    
1740                                    if (pEnc->current->coding_type == P_VOP)        /* special rule for P-VOP's SKIP */
1741                                  for (k=pEnc->bframenum_head; k< pEnc->bframenum_tail; k++)                                  for (k=pEnc->bframenum_head; k< pEnc->bframenum_tail; k++)
1742                                  {                                  {
1743                                          int iSAD;                                          int iSAD;
# Line 1740  Line 1749 
1749                                                  break;                                                  break;
1750                                          }                                          }
1751                                  }                                  }
1752    
1753                                  if (!bSkip)                                  if (!bSkip)
1754                                  {                                  {
1755                                          VECTOR predMV;                                          VECTOR predMV;
1756                                          if(pEnc->mbParam.m_quarterpel)                                          if(pEnc->mbParam.m_quarterpel) {
1757                                                  predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);                                                  predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);
1758                                          else                                                  pMB->pmvs[0].x = pMB->qmvs[0].x - predMV.x;  /* with GMC, qmvs doesn't have to be (0,0)! */
1759                                                    pMB->pmvs[0].y = pMB->qmvs[0].y - predMV.y;
1760                                            }
1761                                            else {
1762                                                  predMV = get_pmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);                                                  predMV = get_pmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);
1763                                          pMB->pmvs[0].x = -predMV.x; pMB->pmvs[0].y = -predMV.y;                                                  pMB->pmvs[0].x = pMB->mvs[0].x - predMV.x; /* with GMC, mvs doesn't have to be (0,0)! */
1764                                                    pMB->pmvs[0].y = pMB->mvs[0].y - predMV.y;
1765                                            }
1766                                          pMB->mode = MODE_INTER;                                          pMB->mode = MODE_INTER;
1767                                          pMB->cbp = 0;                                          pMB->cbp = 0;
1768                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1769                                  }                                  }
1770                                  else MBSkip(bs);                                  else
1771                                    {
1772                                            pMB->mode = MODE_NOT_CODED;
1773                                            MBSkip(bs);
1774                                    }
1775    
1776                          } else {                          } else {
1777                                  if (pEnc->current->global_flags & XVID_GREYSCALE)                                  if (pEnc->current->global_flags & XVID_GREYSCALE)
# Line 1814  Line 1833 
1833                  pEnc->current->quant = pEnc->reference->quant;                  pEnc->current->quant = pEnc->reference->quant;
1834                  pEnc->current->motion_flags = pEnc->reference->motion_flags;                  pEnc->current->motion_flags = pEnc->reference->motion_flags;
1835                  pEnc->current->rounding_type = pEnc->reference->rounding_type;                  pEnc->current->rounding_type = pEnc->reference->rounding_type;
1836                    pEnc->current->quarterpel =  pEnc->reference->quarterpel;
1837                  pEnc->current->fcode = pEnc->reference->fcode;                  pEnc->current->fcode = pEnc->reference->fcode;
1838                  pEnc->current->bcode = pEnc->reference->bcode;                  pEnc->current->bcode = pEnc->reference->bcode;
1839                  image_copy(&pEnc->current->image, &pEnc->reference->image, pEnc->mbParam.edged_width, pEnc->mbParam.height);                  image_copy(&pEnc->current->image, &pEnc->reference->image, pEnc->mbParam.edged_width, pEnc->mbParam.height);
# Line 1853  Line 1873 
1873          }          }
1874  #endif  #endif
1875    
1876            frame->quarterpel =  pEnc->mbParam.m_quarterpel;
1877    
1878          // forward          // forward
1879          image_setedges(f_ref, pEnc->mbParam.edged_width,          image_setedges(f_ref, pEnc->mbParam.edged_width,
1880                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,

Legend:
Removed from v.602  
changed lines
  Added in v.619

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