[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.76.2.4, Sat Sep 28 13:01:02 2002 UTC revision 1.76.2.9, Wed Oct 2 12:57:25 2002 UTC
# Line 411  Line 411 
411          pEnc->queue_size = 0;          pEnc->queue_size = 0;
412    
413          pEnc->mbParam.m_stamp = 0;          pEnc->mbParam.m_stamp = 0;
414    
415          pEnc->m_framenum = 0;          pEnc->m_framenum = 0;
416            pEnc->current->stamp = 0;
417            pEnc->reference->stamp = 0;
418    
419          pParam->handle = (void *) pEnc;          pParam->handle = (void *) pEnc;
420    
# Line 600  Line 603 
603    
604  static __inline void inc_frame_num(Encoder * pEnc)  static __inline void inc_frame_num(Encoder * pEnc)
605  {  {
606            pEnc->current->stamp = pEnc->mbParam.m_stamp;   // first frame is zero
607          pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;          pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;
         pEnc->current->stamp = pEnc->mbParam.m_stamp;  
608  }  }
609    
610    
# Line 637  Line 640 
640                  pCur->ticks = (int32_t)pCur->stamp % time_base;                  pCur->ticks = (int32_t)pCur->stamp % time_base;
641                  pCur->seconds =  ((int32_t)pCur->stamp / time_base)     - ((int32_t)pRef->stamp / time_base) ;                  pCur->seconds =  ((int32_t)pCur->stamp / time_base)     - ((int32_t)pRef->stamp / time_base) ;
642    
643  /*              HEAVY DEBUG OUTPUT      remove when timecodes prove to be stable                  //HEAVY DEBUG OUTPUT    remove when timecodes prove to be stable
644    
645                  fprintf(stderr,"WriteVop:   %d - %d \n",  /*              fprintf(stderr,"WriteVop:   %d - %d \n",
646                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));
647                  fprintf(stderr,"set_timecodes: VOP %1d   stamp=%lld ref_stamp=%lld  base=%d\n",                  fprintf(stderr,"set_timecodes: VOP %1d   stamp=%lld ref_stamp=%lld  base=%d\n",
648                          pCur->coding_type, pCur->stamp, pRef->stamp, time_base);                          pCur->coding_type, pCur->stamp, pRef->stamp, time_base);
# Line 741  Line 744 
744          if (pEnc->bframenum_head > 0) {          if (pEnc->bframenum_head > 0) {
745                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;
746    
747                    /* write an empty marker to the bitstream.
748    
749                       for divx5 decoder compatibility, this marker must consist
750                       of a not-coded p-vop, with a time_base of zero, and time_increment
751                       indentical to the future-referece frame.
752                    */
753    
754                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
755                            int tmp;
756    
757                          DPRINTF(DPRINTF_DEBUG,"*** EMPTY bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                          DPRINTF(DPRINTF_DEBUG,"*** EMPTY bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
758                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
759                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
760    
                         set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);  
                         BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);  
761                          BitstreamPad(&bs);                          BitstreamPad(&bs);
762                          BitstreamPutBits(&bs, 0x7f, 8);  
763                            tmp = pEnc->current->seconds;
764                            pEnc->current->seconds = 0; /* force time_base = 0 */
765                            BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);
766                            pEnc->current->seconds = tmp;
767    
768                          pFrame->length = BitstreamLength(&bs);                          pFrame->length = BitstreamLength(&bs);
769                          pFrame->intra = 0;                          pFrame->intra = 0;
# Line 812  Line 825 
825                  pEnc->queue_head =  (pEnc->queue_head + 1) % pEnc->mbParam.max_bframes;                  pEnc->queue_head =  (pEnc->queue_head + 1) % pEnc->mbParam.max_bframes;
826                  pEnc->queue_size--;                  pEnc->queue_size--;
827    
828          } else if (BitstreamPos(&bs) == 0) {          } else {
829    
830                    /* if nothing was encoded, write an 'ignore this frame' flag
831                       to the bitstream */
832    
833                    if (BitstreamPos(&bs) == 0) {
834    
835                  DPRINTF(DPRINTF_DEBUG,"*** SKIP bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** SKIP bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
836                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
837                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
838    
839                            BitstreamPutBits(&bs, 0x7f, 8);
840                  pFrame->intra = 0;                  pFrame->intra = 0;
841                    }
                 set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);  
                 BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); // write N_VOP  
                 BitstreamPad(&bs);  
                 pFrame->length = BitstreamLength(&bs);  
   
                 return XVID_ERR_OK;  
   
         } else {  
842    
843                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
844                  return XVID_ERR_OK;                  return XVID_ERR_OK;
# Line 1109  Line 1120 
1120          pEnc->current->motion_flags = pFrame->motion;          pEnc->current->motion_flags = pFrame->motion;
1121          pEnc->mbParam.hint = &pFrame->hint;          pEnc->mbParam.hint = &pFrame->hint;
1122    
1123            inc_frame_num(pEnc);
1124    
1125          /* disable alternate scan flag if interlacing is not enabled */          /* disable alternate scan flag if interlacing is not enabled */
1126          if ((pEnc->current->global_flags & XVID_ALTERNATESCAN) &&          if ((pEnc->current->global_flags & XVID_ALTERNATESCAN) &&
1127                  !(pEnc->current->global_flags & XVID_INTERLACING))                  !(pEnc->current->global_flags & XVID_INTERLACING))
# Line 1243  Line 1256 
1256          DEBUG(temp);          DEBUG(temp);
1257  #endif  #endif
1258    
         inc_frame_num(pEnc);  
1259          pEnc->iFrameNum++;          pEnc->iFrameNum++;
1260    
1261          stop_global_timer();          stop_global_timer();
# Line 1542  Line 1554 
1554          pEnc->sStat.iMvCount = 0;          pEnc->sStat.iMvCount = 0;
1555          pEnc->mbParam.m_fcode = 2;          pEnc->mbParam.m_fcode = 2;
1556    
 //      pEnc->time_pp = ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp));  
   
1557          if (pEnc->current->global_flags & XVID_HINTEDME_GET) {          if (pEnc->current->global_flags & XVID_HINTEDME_GET) {
1558                  HintedMEGet(pEnc, 1);                  HintedMEGet(pEnc, 1);
1559          }          }
 //      pEnc->last_pframe = (int32_t)pEnc->mbParam.m_stamp;  
1560    
1561          return 1;                                       // intra          return 1;                                       // intra
1562  }  }
# Line 1794  Line 1803 
1803    
1804          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1805    
 //      pEnc->time_pp = ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp));  
 //      pEnc->last_pframe = (int32_t)pEnc->mbParam.m_stamp;  
   
1806          return 0;                                       // inter          return 0;                                       // inter
1807  }  }
1808    
# Line 1849  Line 1855 
1855          start_timer();          start_timer();
1856    
1857          MotionEstimationBVOP(&pEnc->mbParam, frame,          MotionEstimationBVOP(&pEnc->mbParam, frame,
1858                  ((int32_t)(frame->stamp - pEnc->reference->stamp)),                             // time_bp                  ((int32_t)(pEnc->current->stamp - frame->stamp)),                               // time_bp
1859                  ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),     // time_pp                  ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),     // time_pp
1860                          pEnc->reference->mbs, f_ref,                          pEnc->reference->mbs, f_ref,
1861                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,

Legend:
Removed from v.1.76.2.4  
changed lines
  Added in v.1.76.2.9

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