[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 350, Tue Jul 30 12:14:37 2002 UTC revision 402, Wed Sep 4 21:16:02 2002 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  -  Encoder main module  -   *  -  Encoder main module  -
5   *   *
6     *  Copyright(C) 2002 Michael Militzer
7     *
8   *  This program is an implementation of a part of one or more MPEG-4   *  This program is an implementation of a part of one or more MPEG-4
9   *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending   *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10   *  to use this software module in hardware or software products are   *  to use this software module in hardware or software products are
# Line 28  Line 30 
30   *   *
31   ****************************************************************************/   ****************************************************************************/
32    
 /*****************************************************************************  
  *  
  *  History  
  *  
  *  10.07.2002  added BFRAMES_DEC_DEBUG support  
  *              MinChen <chenm001@163.com>  
  *  20.06.2002 bframe patch  
  *  08.05.2002 fix some problem in DEBUG mode;  
  *             MinChen <chenm001@163.com>  
  *  14.04.2002 added FrameCodeB()  
  *  
  *  $Id: encoder.c,v 1.67 2002-07-30 12:14:37 chl Exp $  
  *  
  ****************************************************************************/  
   
   
33  #include <stdlib.h>  #include <stdlib.h>
34  #include <stdio.h>  #include <stdio.h>
35  #include <math.h>  #include <math.h>
# Line 425  Line 411 
411          pEnc->mbParam.m_ticks = 0;          pEnc->mbParam.m_ticks = 0;
412          pEnc->m_framenum = 0;          pEnc->m_framenum = 0;
413          pEnc->last_pframe = 0;          pEnc->last_pframe = 0;
414            pEnc->last_sync = 0;
415  #endif  #endif
416    
417          pParam->handle = (void *) pEnc;          pParam->handle = (void *) pEnc;
# Line 620  Line 607 
607  }  }
608    
609    
 #ifdef BFRAMES  
610  void inc_frame_num(Encoder * pEnc)  void inc_frame_num(Encoder * pEnc)
611  {  {
         pEnc->iFrameNum++;  
612          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;
613    
614    #ifdef BFRAMES
615            pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;
616            if (pEnc->mbParam.m_ticks < pEnc->last_sync)
617                    pEnc->mbParam.m_seconds = 1;            // more than 1 second since last I or P is not supported.
618            else
619                    pEnc->mbParam.m_seconds = 0;
620    
621            if (pEnc->current->coding_type != B_VOP)
622                    pEnc->last_sync = pEnc->mbParam.m_ticks;
623    #else
624    
625          pEnc->mbParam.m_seconds = pEnc->mbParam.m_ticks / pEnc->mbParam.fbase;          pEnc->mbParam.m_seconds = pEnc->mbParam.m_ticks / pEnc->mbParam.fbase;
626          pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;          pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;
627  }  
628  #endif  #endif
629    
630    }
631    
632    
633  #ifdef BFRAMES  #ifdef BFRAMES
634  void queue_image(Encoder * pEnc, XVID_ENC_FRAME * pFrame)  void queue_image(Encoder * pEnc, XVID_ENC_FRAME * pFrame)
# Line 826  Line 824 
824    
825                  pFrame->intra = 0;                  pFrame->intra = 0;
826    
827                  BitstreamPutBits(&bs, 0x7f, 8);                  BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); // write N_VOP
828                  BitstreamPad(&bs);                  BitstreamPad(&bs);
829                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
830    
# Line 1044  Line 1042 
1042                  goto bvop_loop;                  goto bvop_loop;
1043          }          }
1044    
1045            pEnc->iFrameNum++;
1046    
1047          BitstreamPad(&bs);          BitstreamPad(&bs);
1048          pFrame->length = BitstreamLength(&bs);          pFrame->length = BitstreamLength(&bs);
1049    
# Line 1118  Line 1118 
1118    
1119          pEnc->current->global_flags = pFrame->general;          pEnc->current->global_flags = pFrame->general;
1120          pEnc->current->motion_flags = pFrame->motion;          pEnc->current->motion_flags = pFrame->motion;
 #ifdef BFRAMES  
1121          pEnc->current->seconds = pEnc->mbParam.m_seconds;          pEnc->current->seconds = pEnc->mbParam.m_seconds;
1122          pEnc->current->ticks = pEnc->mbParam.m_ticks;          pEnc->current->ticks = pEnc->mbParam.m_ticks;
 #endif  
1123          pEnc->mbParam.hint = &pFrame->hint;          pEnc->mbParam.hint = &pFrame->hint;
1124    
1125          start_timer();          start_timer();
# Line 1251  Line 1249 
1249          DEBUG(temp);          DEBUG(temp);
1250  #endif  #endif
1251    
 #ifdef BFRAMES  
1252          inc_frame_num(pEnc);          inc_frame_num(pEnc);
 #else  
1253          pEnc->iFrameNum++;          pEnc->iFrameNum++;
 #endif  
   
1254    
1255          stop_global_timer();          stop_global_timer();
1256          write_timer();          write_timer();
# Line 1536  Line 1530 
1530                          stop_prediction_timer();                          stop_prediction_timer();
1531    
1532                          start_timer();                          start_timer();
1533                            if (pEnc->current->global_flags & XVID_GREYSCALE)
1534                            {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1535                                    qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */
1536                                    qcoeff[5*64+0]=0;
1537                            }
1538                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1539                          stop_coding_timer();                          stop_coding_timer();
1540                  }                  }
# Line 1572  Line 1571 
1571          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);
1572    
1573          int iLimit;          int iLimit;
1574          int k;          int x, y, k;
         int x, y;  
1575          int iSearchRange;          int iSearchRange;
1576          int bIntra;          int bIntra;
1577    
# Line 1725  Line 1723 
1723                                  }                                  }
1724                                  if (!bSkip)                                  if (!bSkip)
1725                                  {                                  {
1726                                            if (pEnc->current->global_flags & XVID_GREYSCALE)
1727                                            {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1728                                                    qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */
1729                                                    qcoeff[5*64+0]=0;
1730                                            }
1731                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1732                                          pMB->cbp = 0x80;                /* trick! so cbp!=0, but still nothing is written to bs */                                          pMB->cbp = 0x80;                /* trick! so cbp!=0, but still nothing is written to bs */
1733                                  }                                  }
1734                                  else                                  else
1735                                          MBSkip(bs);                                          MBSkip(bs);
1736    
   
1737  #else  #else
1738                                          MBSkip(bs);     /* without B-frames, no precautions are needed */                                          MBSkip(bs);     /* without B-frames, no precautions are needed */
1739    
1740  #endif  #endif
1741    
1742                          } else {                          } else {
1743                                    if (pEnc->current->global_flags & XVID_GREYSCALE)
1744                                    {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1745                                            qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */
1746                                            qcoeff[5*64+0]=0;
1747                                    }
1748                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1749                          }                          }
1750    
# Line 1923  Line 1930 
1930    
1931                          mb->quant = frame->quant;                          mb->quant = frame->quant;
1932                          mb->cbp =                          mb->cbp =
1933                                  MBTransQuantInter(&pEnc->mbParam, frame, mb, x, y, dct_codes,                                  MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, dct_codes, qcoeff);
                                                                   qcoeff);  
1934                          //mb->cbp = MBTransQuantBVOP(&pEnc->mbParam, x, y, dct_codes, qcoeff, &frame->image, frame->quant);                          //mb->cbp = MBTransQuantBVOP(&pEnc->mbParam, x, y, dct_codes, qcoeff, &frame->image, frame->quant);
1935    
1936                          if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0)                          if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0)

Legend:
Removed from v.350  
changed lines
  Added in v.402

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