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

Diff of /trunk/xvidcore/src/encoder.c

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

revision 1391, Tue Mar 30 12:31:52 2004 UTC revision 1565, Sun Dec 5 13:01:27 2004 UTC
# Line 21  Line 21 
21   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23   *   *
24   * $Id: encoder.c,v 1.103 2004-03-30 12:31:52 syskin Exp $   * $Id: encoder.c,v 1.109 2004-12-05 13:01:27 syskin Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 57  Line 57 
57                                            Bitstream * bs);                                            Bitstream * bs);
58    
59  static int FrameCodeP(Encoder * pEnc,  static int FrameCodeP(Encoder * pEnc,
60                                            Bitstream * bs,                                            Bitstream * bs);
                                           bool force_inter,  
                                           bool vol_header);  
61    
62  static void FrameCodeB(Encoder * pEnc,  static void FrameCodeB(Encoder * pEnc,
63                                             FRAMEINFO * frame,                                             FRAMEINFO * frame,
# Line 102  Line 100 
100                  i--;                  i--;
101          }          }
102    
103          /* if neccessary, round to 65535 accuracy */          if (*base > 65535 || *inc > 65535) {
104          if (*base > 65535) {                  int *biggest;
105                  float div = (float) *base / 65535;                  int *other;
106                  *base = (int) (*base / div);                  float div;
107                  *inc = (int) (*inc / div);  
108                    if (*base > *inc) {
109                            biggest = base;
110                            other = inc;
111                    } else {
112                            biggest = inc;
113                            other = base;
114                    }
115    
116                    div = ((float)*biggest)/((float)65535);
117                    *biggest = (int)(((float)*biggest)/div);
118                    *other = (int)(((float)*other)/div);
119          }          }
120  }  }
121    
# Line 1091  Line 1100 
1100                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
1101                                  pEnc->mbParam.frame_drop_ratio = -1; /* it must be a coded vop */                                  pEnc->mbParam.frame_drop_ratio = -1; /* it must be a coded vop */
1102    
1103                                  FrameCodeP(pEnc, &bs, 1, 0);                                  FrameCodeP(pEnc, &bs);
1104    
1105    
1106                                  if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail==0) {                                  if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail==0) {
# Line 1343  Line 1352 
1352                                     pEnc->mbParam.edged_width, pEnc->mbParam.height);                                     pEnc->mbParam.edged_width, pEnc->mbParam.height);
1353                  }                  }
1354    
1355                  if ( FrameCodeP(pEnc, &bs, 1, 0) == 0 ) {                  if ( FrameCodeP(pEnc, &bs) == 0 ) {
1356                          /* N-VOP, we mustn't code b-frames yet */                          /* N-VOP, we mustn't code b-frames yet */
1357                          call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);                          call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
1358                          goto done;                          goto done;
# Line 1525  Line 1534 
1534  /* FrameCodeP also handles S(GMC)-VOPs */  /* FrameCodeP also handles S(GMC)-VOPs */
1535  static int  static int
1536  FrameCodeP(Encoder * pEnc,  FrameCodeP(Encoder * pEnc,
1537                     Bitstream * bs,                     Bitstream * bs)
                    bool force_inter,  
                    bool vol_header)  
1538  {  {
1539          float fSigma;          float fSigma;
1540          int bits = BitstreamPos(bs);          int bits = BitstreamPos(bs);
# Line 1535  Line 1542 
1542          DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE);
1543          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);
1544    
         int iLimit;  
1545          int x, y, k;          int x, y, k;
1546          int iSearchRange;          int iSearchRange;
1547          int bIntra=0, skip_possible;          int skip_possible;
1548          FRAMEINFO *const current = pEnc->current;          FRAMEINFO *const current = pEnc->current;
1549          FRAMEINFO *const reference = pEnc->reference;          FRAMEINFO *const reference = pEnc->reference;
1550          MBParam * const pParam = &pEnc->mbParam;          MBParam * const pParam = &pEnc->mbParam;
# Line 1569  Line 1575 
1575          current->rounding_type = pParam->m_rounding_type;          current->rounding_type = pParam->m_rounding_type;
1576          current->fcode = pParam->m_fcode;          current->fcode = pParam->m_fcode;
1577    
         if (!force_inter)  
                 iLimit = (int)(mb_width * mb_height *  INTRA_THRESHOLD);  
         else  
                 iLimit = mb_width * mb_height + 1;  
   
1578          if ((current->vop_flags & XVID_VOP_HALFPEL)) {          if ((current->vop_flags & XVID_VOP_HALFPEL)) {
1579                  if (reference->is_interpolated != current->rounding_type) {                  if (reference->is_interpolated != current->rounding_type) {
1580                          start_timer();                          start_timer();
# Line 1644  Line 1645 
1645                  }                  }
1646          }          }
1647    
         bIntra =  
1648                  MotionEstimation(&pEnc->mbParam, current, reference,                  MotionEstimation(&pEnc->mbParam, current, reference,
1649                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1650                                           &pEnc->vGMC, iLimit);                                           &pEnc->vGMC, 256*4096);
1651    
1652    
1653          stop_motion_timer();          stop_motion_timer();
1654    
         if (bIntra == 1) return FrameCodeI(pEnc, bs);  
   
1655          set_timecodes(current,reference,pParam->fbase);          set_timecodes(current,reference,pParam->fbase);
         if (vol_header)  
         {       BitstreamWriteVolHeader(bs, &pEnc->mbParam, current);  
                 BitstreamPad(bs);  
         }  
1656    
1657          BitstreamWriteVopHeader(bs, &pEnc->mbParam, current, 1, current->mbs[0].quant);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, current, 1, current->mbs[0].quant);
1658    
# Line 1671  Line 1665 
1665                          MACROBLOCK *pMB =                          MACROBLOCK *pMB =
1666                                  &current->mbs[x + y * pParam->mb_width];                                  &current->mbs[x + y * pParam->mb_width];
1667    
1668                          bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q);                          int bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q);
1669    
1670                          if (bIntra) {                          if (bIntra) {
1671                                  CodeIntraMB(pEnc, pMB);                                  CodeIntraMB(pEnc, pMB);
# Line 1703  Line 1697 
1697                                                                   pParam->height,                                                                   pParam->height,
1698                                                                   pParam->edged_width,                                                                   pParam->edged_width,
1699                                                                   (current->vol_flags & XVID_VOL_QUARTERPEL),                                                                   (current->vol_flags & XVID_VOL_QUARTERPEL),
                                                                  (current->vop_flags & XVID_VOP_REDUCED),  
1700                                                                   current->rounding_type);                                                                   current->rounding_type);
1701    
1702                          stop_comp_timer();                          stop_comp_timer();
# Line 1873  Line 1866 
1866          DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks);          DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks);
1867  #endif  #endif
1868          if (current->sStat.kblks + current->sStat.mblks <=          if (current->sStat.kblks + current->sStat.mblks <=
1869                  (pParam->frame_drop_ratio * mb_width * mb_height) / 100)                  (pParam->frame_drop_ratio * mb_width * mb_height) / 100 &&
1870                    ( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) )
1871          {          {
1872                  current->sStat.kblks = current->sStat.mblks = 0;                  current->sStat.kblks = current->sStat.mblks = 0;
1873                  current->sStat.ublks = mb_width * mb_height;                  current->sStat.ublks = mb_width * mb_height;
# Line 2022  Line 2016 
2016                          if (mb->mode == MODE_NOT_CODED) {                          if (mb->mode == MODE_NOT_CODED) {
2017                                  if (pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) {                                  if (pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) {
2018                                          MBMotionCompensation(mb, x, y, f_ref, NULL, f_ref, NULL, NULL, &frame->image,                                          MBMotionCompensation(mb, x, y, f_ref, NULL, f_ref, NULL, NULL, &frame->image,
2019                                                                                          NULL, 0, 0, pEnc->mbParam.edged_width, 0, 0, 0);                                                                                          NULL, 0, 0, pEnc->mbParam.edged_width, 0, 0);
2020                                  }                                  }
2021    
2022                                  continue;                                  continue;

Legend:
Removed from v.1391  
changed lines
  Added in v.1565

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