[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.102, Mon Mar 22 22:36:23 2004 UTC revision 1.102.2.2, Sat Apr 3 10:39:27 2004 UTC
# 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 123  Line 121 
121          if (create->width%2 || create->height%2)          if (create->width%2 || create->height%2)
122                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
123    
124            if (create->width<=0 || create->height<=0)
125                    return XVID_ERR_FAIL;
126    
127          /* allocate encoder struct */          /* allocate encoder struct */
128    
129          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);
# Line 1086  Line 1087 
1087                                  DPRINTF(XVID_DEBUG_DEBUG,"*** PFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i\n",                                  DPRINTF(XVID_DEBUG_DEBUG,"*** PFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i\n",
1088                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
1089                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
1090                                    pEnc->mbParam.frame_drop_ratio = -1; /* it must be a coded vop */
1091    
1092                                  FrameCodeP(pEnc, &bs, 1, 0);                                  FrameCodeP(pEnc, &bs);
1093    
1094    
1095                                  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 1339  Line 1341 
1341                                     pEnc->mbParam.edged_width, pEnc->mbParam.height);                                     pEnc->mbParam.edged_width, pEnc->mbParam.height);
1342                  }                  }
1343    
1344                  FrameCodeP(pEnc, &bs, 1, 0);                  if ( FrameCodeP(pEnc, &bs) == 0 ) {
1345                            /* N-VOP, we mustn't code b-frames yet */
1346                            call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
1347                            goto done;
1348                    }
1349          }          }
1350    
1351    
# Line 1517  Line 1523 
1523  /* FrameCodeP also handles S(GMC)-VOPs */  /* FrameCodeP also handles S(GMC)-VOPs */
1524  static int  static int
1525  FrameCodeP(Encoder * pEnc,  FrameCodeP(Encoder * pEnc,
1526                     Bitstream * bs,                     Bitstream * bs)
                    bool force_inter,  
                    bool vol_header)  
1527  {  {
1528          float fSigma;          float fSigma;
1529          int bits = BitstreamPos(bs);          int bits = BitstreamPos(bs);
# Line 1527  Line 1531 
1531          DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE);
1532          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);
1533    
         int iLimit;  
1534          int x, y, k;          int x, y, k;
1535          int iSearchRange;          int iSearchRange;
1536          int bIntra=0, skip_possible;          int skip_possible;
1537          FRAMEINFO *const current = pEnc->current;          FRAMEINFO *const current = pEnc->current;
1538          FRAMEINFO *const reference = pEnc->reference;          FRAMEINFO *const reference = pEnc->reference;
1539          MBParam * const pParam = &pEnc->mbParam;          MBParam * const pParam = &pEnc->mbParam;
1540          int mb_width = pParam->mb_width;          int mb_width = pParam->mb_width;
1541          int mb_height = pParam->mb_height;          int mb_height = pParam->mb_height;
1542            int coded = 1;
1543    
1544    
1545          /* IMAGE *pCurrent = &current->image; */          /* IMAGE *pCurrent = &current->image; */
# Line 1560  Line 1564 
1564          current->rounding_type = pParam->m_rounding_type;          current->rounding_type = pParam->m_rounding_type;
1565          current->fcode = pParam->m_fcode;          current->fcode = pParam->m_fcode;
1566    
         if (!force_inter)  
                 iLimit = (int)(mb_width * mb_height *  INTRA_THRESHOLD);  
         else  
                 iLimit = mb_width * mb_height + 1;  
   
1567          if ((current->vop_flags & XVID_VOP_HALFPEL)) {          if ((current->vop_flags & XVID_VOP_HALFPEL)) {
1568                  if (reference->is_interpolated != current->rounding_type) {                  if (reference->is_interpolated != current->rounding_type) {
1569                          start_timer();                          start_timer();
# Line 1635  Line 1634 
1634                  }                  }
1635          }          }
1636    
         bIntra =  
1637                  MotionEstimation(&pEnc->mbParam, current, reference,                  MotionEstimation(&pEnc->mbParam, current, reference,
1638                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1639                                           &pEnc->vGMC, iLimit);                                           &pEnc->vGMC, 256*4096);
1640    
1641    
1642          stop_motion_timer();          stop_motion_timer();
1643    
         if (bIntra == 1) return FrameCodeI(pEnc, bs);  
   
1644          set_timecodes(current,reference,pParam->fbase);          set_timecodes(current,reference,pParam->fbase);
         if (vol_header)  
         {       BitstreamWriteVolHeader(bs, &pEnc->mbParam, current);  
                 BitstreamPad(bs);  
         }  
1645    
1646          BitstreamWriteVopHeader(bs, &pEnc->mbParam, current, 1, current->mbs[0].quant);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, current, 1, current->mbs[0].quant);
1647    
# Line 1662  Line 1654 
1654                          MACROBLOCK *pMB =                          MACROBLOCK *pMB =
1655                                  &current->mbs[x + y * pParam->mb_width];                                  &current->mbs[x + y * pParam->mb_width];
1656    
1657                          bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q);                          int bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q);
1658    
1659                          if (bIntra) {                          if (bIntra) {
1660                                  CodeIntraMB(pEnc, pMB);                                  CodeIntraMB(pEnc, pMB);
# Line 1863  Line 1855 
1855  #if 0  #if 0
1856          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);
1857  #endif  #endif
1858          if (current->sStat.kblks + current->sStat.mblks <          if (current->sStat.kblks + current->sStat.mblks <=
1859                  (pParam->frame_drop_ratio * mb_width * mb_height) / 100)                  (pParam->frame_drop_ratio * mb_width * mb_height) / 100)
1860          {          {
1861                  current->sStat.kblks = current->sStat.mblks = 0;                  current->sStat.kblks = current->sStat.mblks = 0;
# Line 1880  Line 1872 
1872                  current->rounding_type = reference->rounding_type;                  current->rounding_type = reference->rounding_type;
1873                  current->fcode = reference->fcode;                  current->fcode = reference->fcode;
1874                  current->bcode = reference->bcode;                  current->bcode = reference->bcode;
1875                    current->stamp = reference->stamp;
1876                  image_copy(&current->image, &reference->image, pParam->edged_width, pParam->height);                  image_copy(&current->image, &reference->image, pParam->edged_width, pParam->height);
1877                  memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height);                  memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height);
1878          }                  coded = 0;
1879    
1880            } else {
1881    
1882          pEnc->current->is_edged = 0; /* not edged */          pEnc->current->is_edged = 0; /* not edged */
1883          pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */          pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */
# Line 1893  Line 1888 
1888          image_swap(&pEnc->vInterH, &pEnc->f_refh);          image_swap(&pEnc->vInterH, &pEnc->f_refh);
1889          image_swap(&pEnc->vInterV, &pEnc->f_refv);          image_swap(&pEnc->vInterV, &pEnc->f_refv);
1890          image_swap(&pEnc->vInterHV, &pEnc->f_refhv);          image_swap(&pEnc->vInterHV, &pEnc->f_refhv);
1891            }
1892    
1893          /* XXX: debug          /* XXX: debug
1894          {          {
# Line 1914  Line 1909 
1909    
1910          current->length = (BitstreamPos(bs) - bits) / 8;          current->length = (BitstreamPos(bs) - bits) / 8;
1911    
1912          return 0;                                       /* inter */          return coded;
1913  }  }
1914    
1915    

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.102.2.2

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