[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.87, Sat Nov 16 23:38:16 2002 UTC revision 1.90.2.3, Mon Jul 28 12:39:23 2003 UTC
# Line 78  Line 78 
78  #include "quant/quant_matrix.h"  #include "quant/quant_matrix.h"
79  #include "utils/mem_align.h"  #include "utils/mem_align.h"
80    
 #ifdef _SMP  
 #include "motion/smp_motion_est.h"  
 #endif  
81  /*****************************************************************************  /*****************************************************************************
82   * Local macros   * Local macros
83   ****************************************************************************/   ****************************************************************************/
# Line 213  Line 210 
210          /* 1 keyframe each 10 seconds */          /* 1 keyframe each 10 seconds */
211    
212          if (pParam->max_key_interval <= 0)          if (pParam->max_key_interval <= 0)
213                  pParam->max_key_interval = 10 * pParam->fincr / pParam->fbase;                  pParam->max_key_interval = 10 * pParam->fbase / pParam->fincr;
214    
215          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);
216          if (pEnc == NULL)          if (pEnc == NULL)
# Line 239  Line 236 
236    
237          pEnc->mbParam.m_quant_type = H263_QUANT;          pEnc->mbParam.m_quant_type = H263_QUANT;
238    
 #ifdef _SMP  
         pEnc->mbParam.num_threads = MIN(pParam->num_threads, MAXNUMTHREADS);  
 #endif  
   
239          pEnc->sStat.fMvPrevSigma = -1;          pEnc->sStat.fMvPrevSigma = -1;
240    
241          /* Fill rate control parameters */          /* Fill rate control parameters */
# Line 550  Line 543 
543    
544          }          }
545    
546          BitstreamPutBits(&bs, 0xFFFF, 16);          /* Fix from CVS_HEAD (2003-03-17)
547          BitstreamPutBits(&bs, 0xFFFF, 16);           *
548          BitstreamPad(&bs);           * Relic from OpenDivX - now disabled
549             *
550             * BitstreamPutBits(&bs, 0xFFFF, 16);
551             * BitstreamPutBits(&bs, 0xFFFF, 16);
552             */
553            BitstreamPadAlways(&bs); /* next_start_code() at the end of Video Object Plane */
554          pFrame->length = BitstreamLength(&bs);          pFrame->length = BitstreamLength(&bs);
555    
556          if (pResult) {          if (pResult) {
# Line 643  Line 641 
641                  return;                  return;
642          }          }
643    
644          pEnc->current->fcode =          pEnc->current->fcode = (hint->rawhints != 0) ?
645                  (hint->rawhints) ? hint->mvhint.fcode : BitstreamGetBits(&bs,                  (uint32_t)hint->mvhint.fcode : BitstreamGetBits(&bs, FCODEBITS);
                                                                                                                                  FCODEBITS);  
646    
647          length = pEnc->current->fcode + 5;          length = pEnc->current->fcode + 5;
648          high = 1 << (length - 1);          high = 1 << (length - 1);
# Line 660  Line 657 
657                          VECTOR tmp;                          VECTOR tmp;
658                          int vec;                          int vec;
659    
660                          pMB->mode =                          pMB->mode = (hint->rawhints != 0) ?
661                                  (hint->rawhints) ? bhint->mode : BitstreamGetBits(&bs,                                  (uint32_t)bhint->mode : BitstreamGetBits(&bs, MODEBITS);
                                                                                                                                   MODEBITS);  
662    
663                          pMB->mode = (pMB->mode == MODE_INTER_Q) ? MODE_INTER : pMB->mode;                          pMB->mode = (pMB->mode == MODE_INTER_Q) ? MODE_INTER : pMB->mode;
664                          pMB->mode = (pMB->mode == MODE_INTRA_Q) ? MODE_INTRA : pMB->mode;                          pMB->mode = (pMB->mode == MODE_INTRA_Q) ? MODE_INTRA : pMB->mode;
665    
666                          if (pMB->mode == MODE_INTER) {                          if (pMB->mode == MODE_INTER) {
667                                  tmp.x =                                  tmp.x = (hint->rawhints) ?
668                                          (hint->rawhints) ? bhint->mvs[0].x : BitstreamGetBits(&bs,                                          bhint->mvs[0].x : (int)BitstreamGetBits(&bs, length);
669                                                                                                                                                    length);                                  tmp.y = (hint->rawhints) ?
670                                  tmp.y =                                          bhint->mvs[0].y : (int)BitstreamGetBits(&bs, length);
                                         (hint->rawhints) ? bhint->mvs[0].y : BitstreamGetBits(&bs,  
                                                                                                                                                   length);  
671                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;
672                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;
673    
# Line 687  Line 681 
681                                  }                                  }
682                          } else if (pMB->mode == MODE_INTER4V) {                          } else if (pMB->mode == MODE_INTER4V) {
683                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
684                                          tmp.x =                                          tmp.x = (hint->rawhints) ?
685                                                  (hint->rawhints) ? bhint->mvs[vec].                                                  bhint->mvs[vec].x : (int)BitstreamGetBits(&bs, length);
686                                                  x : BitstreamGetBits(&bs, length);                                          tmp.y = (hint->rawhints) ?
687                                          tmp.y =                                                  bhint->mvs[vec].y : (int)BitstreamGetBits(&bs, length);
                                                 (hint->rawhints) ? bhint->mvs[vec].  
                                                 y : BitstreamGetBits(&bs, length);  
688                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;
689                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;
690    
# Line 703  Line 695 
695                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x;                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x;
696                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y;                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y;
697                                  }                                  }
698                          } else                          // intra / stuffing / not_coded                          } else                          /* intra / stuffing / not_coded */
699                          {                          {
700                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
701                                          pMB->mvs[vec].x = pMB->mvs[vec].y = 0;                                          pMB->mvs[vec].x = pMB->mvs[vec].y = 0;
# Line 876  Line 868 
868                  HintedMEGet(pEnc, 1);                  HintedMEGet(pEnc, 1);
869          }          }
870    
871          return 1;                                       // intra          return 1;                                       /* intra */
872  }  }
873    
874    
# Line 932  Line 924 
924                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
925          } else {          } else {
926    
 #ifdef _SMP  
         if (pEnc->mbParam.num_threads > 1)  
                 bIntra =  
                         SMP_MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,  
                                                  &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,  
                                                  iLimit);  
         else  
 #endif  
927                  bIntra =                  bIntra =
928                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
929                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
# Line 1058  Line 1042 
1042          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);
1043    
1044          if ((fSigma > iSearchRange / 3)          if ((fSigma > iSearchRange / 3)
1045                  && (pEnc->mbParam.m_fcode <= 3))        // maximum search range 128                  && (pEnc->mbParam.m_fcode <= 3))        /* maximum search range 128 */
1046          {          {
1047                  pEnc->mbParam.m_fcode++;                  pEnc->mbParam.m_fcode++;
1048                  iSearchRange *= 2;                  iSearchRange *= 2;
1049          } else if ((fSigma < iSearchRange / 6)          } else if ((fSigma < iSearchRange / 6)
1050                             && (pEnc->sStat.fMvPrevSigma >= 0)                             && (pEnc->sStat.fMvPrevSigma >= 0)
1051                             && (pEnc->sStat.fMvPrevSigma < iSearchRange / 6)                             && (pEnc->sStat.fMvPrevSigma < iSearchRange / 6)
1052                             && (pEnc->mbParam.m_fcode >= 2))     // minimum search range 16                             && (pEnc->mbParam.m_fcode >= 2))     /* minimum search range 16 */
1053          {          {
1054                  pEnc->mbParam.m_fcode--;                  pEnc->mbParam.m_fcode--;
1055                  iSearchRange /= 2;                  iSearchRange /= 2;
# Line 1075  Line 1059 
1059    
1060          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1061    
1062          return 0;                                       // inter          return 0;                                       /* inter */
1063    
1064  }  }

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.90.2.3

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