[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 317, Fri Jul 19 14:56:00 2002 UTC revision 327, Mon Jul 22 18:03:47 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.57 2002-07-19 14:56:00 chl Exp $   *  $Id: encoder.c,v 1.63 2002-07-22 18:03:47 chl Exp $
43   *   *
44   ****************************************************************************/   ****************************************************************************/
45    
# Line 209  Line 209 
209    
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->fincr / pParam->fbase;
214    
215          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);
# Line 344  Line 344 
344          pEnc->global = pParam->global;          pEnc->global = pParam->global;
345          pEnc->mbParam.max_bframes = pParam->max_bframes;          pEnc->mbParam.max_bframes = pParam->max_bframes;
346          pEnc->bquant_ratio = pParam->bquant_ratio;          pEnc->bquant_ratio = pParam->bquant_ratio;
347            pEnc->frame_drop_ratio = pParam->frame_drop_ratio;
348          pEnc->bframes = NULL;          pEnc->bframes = NULL;
349    
350          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
# Line 852  Line 853 
853                  else                  else
854                          pEnc->current->quant = pFrame->quant;                          pEnc->current->quant = pFrame->quant;
855    
856                  if (pEnc->current->quant < 1)  /*              if (pEnc->current->quant < 1)
857                          pEnc->current->quant = 1;                          pEnc->current->quant = 1;
858    
859                  if (pEnc->current->quant > 31)                  if (pEnc->current->quant > 31)
860                          pEnc->current->quant = 31;                          pEnc->current->quant = 31;
861    */
862                  pEnc->current->global_flags = pFrame->general;                  pEnc->current->global_flags = pFrame->general;
863                  pEnc->current->motion_flags = pFrame->motion;                  pEnc->current->motion_flags = pFrame->motion;
864    
# Line 1004  Line 1005 
1005                   * This will be coded as a Bidirectional Frame                   * This will be coded as a Bidirectional Frame
1006                   */                   */
1007    
                 DPRINTF(DPRINTF_DEBUG,"*** BFRAME (store) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",  
                                 pEnc->bframenum_head, pEnc->bframenum_tail,  
                                 pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);  
   
1008                  if ((pEnc->global & XVID_GLOBAL_DEBUG)) {                  if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
1009                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");
1010                  }                  }
# Line 1019  Line 1016 
1016                  } else {                  } else {
1017                          pEnc->current->quant = pFrame->bquant;                          pEnc->current->quant = pFrame->bquant;
1018                  }                  }
1019                    if (pEnc->current->quant < 1)
1020                            pEnc->current->quant = 1;
1021    
1022                    if (pEnc->current->quant > 31)
1023                            pEnc->current->quant = 31;
1024    
1025    
1026                            DPRINTF(DPRINTF_DEBUG,"*** BFRAME (store) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i  quant=%i\n",
1027                                    pEnc->bframenum_head, pEnc->bframenum_tail,
1028                                    pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size,pEnc->current->quant);
1029    
1030    
1031    
1032                  /* store frame into bframe buffer & swap ref back to current */                  /* store frame into bframe buffer & swap ref back to current */
1033                  SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);                  SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);
# Line 1722  Line 1731 
1731    
1732          pEnc->sStat.fMvPrevSigma = fSigma;          pEnc->sStat.fMvPrevSigma = fSigma;
1733    
1734    #ifdef BFRAMES
1735            /* frame drop code */
1736            // DPRINTF(DPRINTF_DEBUG, "kmu %i %i %i", pEnc->sStat.kblks, pEnc->sStat.mblks, pEnc->sStat.ublks);
1737            if (pEnc->sStat.kblks + pEnc->sStat.mblks <=
1738                    (pEnc->frame_drop_ratio * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height) / 100)
1739            {
1740                    pEnc->sStat.kblks = pEnc->sStat.mblks = 0;
1741                    pEnc->sStat.ublks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;
1742    
1743                    BitstreamReset(bs);
1744                    BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 0);
1745    
1746                    // copy reference frame details into the current frame
1747                    pEnc->current->quant = pEnc->reference->quant;
1748                    pEnc->current->motion_flags = pEnc->reference->motion_flags;
1749                    pEnc->current->rounding_type = pEnc->reference->rounding_type;
1750                    pEnc->current->fcode = pEnc->reference->fcode;
1751                    pEnc->current->bcode = pEnc->reference->bcode;
1752                    image_copy(&pEnc->current->image, &pEnc->reference->image, pEnc->mbParam.edged_width, pEnc->mbParam.height);
1753                    memcpy(pEnc->current->mbs, pEnc->reference->mbs, sizeof(MACROBLOCK) * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height);
1754    
1755            }
1756    #endif
1757    
1758          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1759    
1760    #ifdef BFRAMES
1761          pEnc->time_pp = ((int32_t)pEnc->mbParam.fbase - (int32_t)pEnc->last_pframe + (int32_t)pEnc->mbParam.m_ticks) % (int32_t)pEnc->mbParam.fbase;          pEnc->time_pp = ((int32_t)pEnc->mbParam.fbase - (int32_t)pEnc->last_pframe + (int32_t)pEnc->mbParam.m_ticks) % (int32_t)pEnc->mbParam.fbase;
         fprintf(stderr,"fbase=%d last_p=%d ticks=%d time_pp = %d\n",pEnc->mbParam.fbase,pEnc->last_pframe,pEnc->mbParam.m_ticks,pEnc->time_pp);  
   
1762          pEnc->last_pframe = pEnc->mbParam.m_ticks;          pEnc->last_pframe = pEnc->mbParam.m_ticks;
1763    #endif
1764    
1765          return 0;                                       // inter          return 0;                                       // inter
1766  }  }
1767    
# Line 1783  Line 1817 
1817          stop_inter_timer();          stop_inter_timer();
1818    
1819          start_timer();          start_timer();
         fprintf(stderr,"m_ticks =%d\n",(int32_t)pEnc->mbParam.m_ticks+1);  
1820          MotionEstimationBVOP(&pEnc->mbParam, frame,          MotionEstimationBVOP(&pEnc->mbParam, frame,
1821            ((int32_t)pEnc->mbParam.fbase + (int32_t)pEnc->mbParam.m_ticks + 1 - (int32_t)pEnc->last_pframe) % pEnc->mbParam.fbase,            ((int32_t)pEnc->mbParam.fbase + (int32_t)pEnc->mbParam.m_ticks + 1 - (int32_t)pEnc->last_pframe) % pEnc->mbParam.fbase,
1822                                                  pEnc->time_pp,                                                  pEnc->time_pp,

Legend:
Removed from v.317  
changed lines
  Added in v.327

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