[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 349, Mon Jul 29 19:21:23 2002 UTC revision 387, Tue Sep 3 17:25:45 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.66 2002-07-29 19:21:23 chl Exp $   *  $Id: encoder.c,v 1.76 2002-09-03 17:25:18 chl Exp $
43   *   *
44   ****************************************************************************/   ****************************************************************************/
45    
# Line 425  Line 425 
425          pEnc->mbParam.m_ticks = 0;          pEnc->mbParam.m_ticks = 0;
426          pEnc->m_framenum = 0;          pEnc->m_framenum = 0;
427          pEnc->last_pframe = 0;          pEnc->last_pframe = 0;
428            pEnc->last_sync = 0;
429  #endif  #endif
430    
431          pParam->handle = (void *) pEnc;          pParam->handle = (void *) pEnc;
# Line 620  Line 621 
621  }  }
622    
623    
 #ifdef BFRAMES  
624  void inc_frame_num(Encoder * pEnc)  void inc_frame_num(Encoder * pEnc)
625  {  {
         pEnc->iFrameNum++;  
626          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;
627    
628    #ifdef BFRAMES
629            pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;
630            if (pEnc->mbParam.m_ticks < pEnc->last_sync)
631                    pEnc->mbParam.m_seconds = 1;            // more than 1 second since last I or P is not supported.
632            else
633                    pEnc->mbParam.m_seconds = 0;
634    
635            if (pEnc->current->coding_type != B_VOP)
636                    pEnc->last_sync = pEnc->mbParam.m_ticks;
637    #else
638    
639          pEnc->mbParam.m_seconds = pEnc->mbParam.m_ticks / pEnc->mbParam.fbase;          pEnc->mbParam.m_seconds = pEnc->mbParam.m_ticks / pEnc->mbParam.fbase;
640          pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;          pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;
641  }  
642  #endif  #endif
643    
644    }
645    
646    
647  #ifdef BFRAMES  #ifdef BFRAMES
648  void queue_image(Encoder * pEnc, XVID_ENC_FRAME * pFrame)  void queue_image(Encoder * pEnc, XVID_ENC_FRAME * pFrame)
# Line 826  Line 838 
838    
839                  pFrame->intra = 0;                  pFrame->intra = 0;
840    
841                  BitstreamPutBits(&bs, 0x7f, 8);                  BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); // write N_VOP
842                  BitstreamPad(&bs);                  BitstreamPad(&bs);
843                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
844    
# Line 1044  Line 1056 
1056                  goto bvop_loop;                  goto bvop_loop;
1057          }          }
1058    
1059            pEnc->iFrameNum++;
1060    
1061          BitstreamPad(&bs);          BitstreamPad(&bs);
1062          pFrame->length = BitstreamLength(&bs);          pFrame->length = BitstreamLength(&bs);
1063    
# Line 1118  Line 1132 
1132    
1133          pEnc->current->global_flags = pFrame->general;          pEnc->current->global_flags = pFrame->general;
1134          pEnc->current->motion_flags = pFrame->motion;          pEnc->current->motion_flags = pFrame->motion;
 #ifdef BFRAMES  
1135          pEnc->current->seconds = pEnc->mbParam.m_seconds;          pEnc->current->seconds = pEnc->mbParam.m_seconds;
1136          pEnc->current->ticks = pEnc->mbParam.m_ticks;          pEnc->current->ticks = pEnc->mbParam.m_ticks;
 #endif  
1137          pEnc->mbParam.hint = &pFrame->hint;          pEnc->mbParam.hint = &pFrame->hint;
1138    
1139          start_timer();          start_timer();
# Line 1251  Line 1263 
1263          DEBUG(temp);          DEBUG(temp);
1264  #endif  #endif
1265    
 #ifdef BFRAMES  
1266          inc_frame_num(pEnc);          inc_frame_num(pEnc);
 #else  
1267          pEnc->iFrameNum++;          pEnc->iFrameNum++;
 #endif  
   
1268    
1269          stop_global_timer();          stop_global_timer();
1270          write_timer();          write_timer();
# Line 1536  Line 1544 
1544                          stop_prediction_timer();                          stop_prediction_timer();
1545    
1546                          start_timer();                          start_timer();
1547                            if (pEnc->current->global_flags & XVID_GREYSCALE)
1548                            {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1549                                    qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */
1550                                    qcoeff[5*64+0]=0;
1551                            }
1552                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1553                          stop_coding_timer();                          stop_coding_timer();
1554                  }                  }
# Line 1572  Line 1585 
1585          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);
1586    
1587          int iLimit;          int iLimit;
1588          int k;          int x, y, k;
         int x, y;  
1589          int iSearchRange;          int iSearchRange;
1590          int bIntra;          int bIntra;
1591    
# Line 1725  Line 1737 
1737                                  }                                  }
1738                                  if (!bSkip)                                  if (!bSkip)
1739                                  {                                  {
1740                                            if (pEnc->current->global_flags & XVID_GREYSCALE)
1741                                            {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1742                                                    qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */
1743                                                    qcoeff[5*64+0]=0;
1744                                            }
1745                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1746                                          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 */
1747                                  }                                  }
1748                                  else                                  else
1749                                          MBSkip(bs);                                          MBSkip(bs);
1750    
   
1751  #else  #else
1752                                          MBSkip(bs);     /* without B-frames, no precautions are needed */                                          MBSkip(bs);     /* without B-frames, no precautions are needed */
1753    
1754  #endif  #endif
1755    
1756                          } else {                          } else {
1757                                    if (pEnc->current->global_flags & XVID_GREYSCALE)
1758                                    {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1759                                            qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */
1760                                            qcoeff[5*64+0]=0;
1761                                    }
1762                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->sStat);
1763                          }                          }
1764    
# Line 1777  Line 1798 
1798  #ifdef BFRAMES  #ifdef BFRAMES
1799          /* frame drop code */          /* frame drop code */
1800          // DPRINTF(DPRINTF_DEBUG, "kmu %i %i %i", pEnc->sStat.kblks, pEnc->sStat.mblks, pEnc->sStat.ublks);          // DPRINTF(DPRINTF_DEBUG, "kmu %i %i %i", pEnc->sStat.kblks, pEnc->sStat.mblks, pEnc->sStat.ublks);
1801          if (pEnc->sStat.kblks + pEnc->sStat.mblks <=          if (pEnc->sStat.kblks + pEnc->sStat.mblks <
1802                  (pEnc->frame_drop_ratio * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height) / 100)                  (pEnc->frame_drop_ratio * pEnc->mbParam.mb_width * pEnc->mbParam.mb_height) / 100)
1803          {          {
1804                  pEnc->sStat.kblks = pEnc->sStat.mblks = 0;                  pEnc->sStat.kblks = pEnc->sStat.mblks = 0;
# Line 1923  Line 1944 
1944    
1945                          mb->quant = frame->quant;                          mb->quant = frame->quant;
1946                          mb->cbp =                          mb->cbp =
1947                                  MBTransQuantInter(&pEnc->mbParam, frame, mb, x, y, dct_codes,                                  MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, dct_codes, qcoeff);
                                                                   qcoeff);  
1948                          //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);
1949    
1950                          if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0)                          if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0)

Legend:
Removed from v.349  
changed lines
  Added in v.387

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