[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.2, Thu Sep 26 01:54:54 2002 UTC revision 1.76.2.12, Sat Oct 5 21:36:35 2002 UTC
# Line 410  Line 410 
410          pEnc->queue_tail = 0;          pEnc->queue_tail = 0;
411          pEnc->queue_size = 0;          pEnc->queue_size = 0;
412    
413            pEnc->mbParam.m_stamp = 0;
414    
         pEnc->mbParam.m_seconds = 0;  
         pEnc->mbParam.m_ticks = 0;  
415          pEnc->m_framenum = 0;          pEnc->m_framenum = 0;
416          pEnc->last_pframe = 0;          pEnc->current->stamp = 0;
417          pEnc->last_sync = 0;          pEnc->reference->stamp = 0;
418    
419          pParam->handle = (void *) pEnc;          pParam->handle = (void *) pEnc;
420    
# Line 604  Line 603 
603    
604  static __inline void inc_frame_num(Encoder * pEnc)  static __inline void inc_frame_num(Encoder * pEnc)
605  {  {
606          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;          pEnc->current->stamp = pEnc->mbParam.m_stamp;   // first frame is zero
607            pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;
         pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;  
         if (pEnc->mbParam.m_ticks < pEnc->last_sync)  
                 pEnc->mbParam.m_seconds = 1;  
                                 // more than 1 second since last I or P is not supported.  
         else  
                 pEnc->mbParam.m_seconds = 0;  
   
608  }  }
609    
610    
# Line 641  Line 633 
633          pEnc->queue_tail =  (pEnc->queue_tail + 1) % pEnc->mbParam.max_bframes;          pEnc->queue_tail =  (pEnc->queue_tail + 1) % pEnc->mbParam.max_bframes;
634  }  }
635    
636    static __inline void
637    set_timecodes(FRAMEINFO* pCur,FRAMEINFO *pRef, int32_t time_base)
638    {
639    
640                    pCur->ticks = (int32_t)pCur->stamp % time_base;
641                    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
644    
645    /*              fprintf(stderr,"WriteVop:   %d - %d \n",
646                            ((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",
648                            pCur->coding_type, pCur->stamp, pRef->stamp, time_base);
649                    fprintf(stderr,"set_timecodes: VOP %1d   seconds=%d   ticks=%d   (ref-sec=%d  ref-tick=%d)\n",
650                            pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks);
651    
652    */
653    }
654    
655    
656    
657    
658    
659  /*****************************************************************************  /*****************************************************************************
# Line 659  Line 672 
672  {  {
673          uint16_t x, y;          uint16_t x, y;
674          Bitstream bs;          Bitstream bs;
675          uint32_t bits;          uint32_t bits, mode;
676    
677          int input_valid = 1;          int input_valid = 1;
678    
# Line 731  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    
                         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 801  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                    }
                 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 846  Line 869 
869                  pEnc->current->fcode = pEnc->mbParam.m_fcode;                  pEnc->current->fcode = pEnc->mbParam.m_fcode;
870                  pEnc->current->bcode = pEnc->mbParam.m_fcode;                  pEnc->current->bcode = pEnc->mbParam.m_fcode;
871    
                 pEnc->current->seconds = pEnc->mbParam.m_seconds;  
                 pEnc->current->ticks = pEnc->mbParam.m_ticks;  
   
872                  inc_frame_num(pEnc);                  inc_frame_num(pEnc);
873    
874  #ifdef _DEBUG_PSNR  #ifdef _DEBUG_PSNR
# Line 860  Line 880 
880    
881                  if ((pEnc->global & XVID_GLOBAL_DEBUG)) {                  if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
882                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5,                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5,
883                                  "%i  if:%i  st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks);                                  "%i  if:%i  st:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->stamp);
884                  }                  }
885    
886          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Line 907  Line 927 
927          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 ||          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 ||
928                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&
929                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)
930                  || image_mad(&pEnc->reference->image, &pEnc->current->image,                  || /*image_mad(&pEnc->reference->image, &pEnc->current->image,
931                                           pEnc->mbParam.edged_width, pEnc->mbParam.width,                                           pEnc->mbParam.edged_width, pEnc->mbParam.width,
932                                           pEnc->mbParam.height) > 30) {                                           pEnc->mbParam.height) > 30) {*/
933                            2 == (mode = MEanalysis(&pEnc->reference->image, &pEnc->current->image,
934                                             &pEnc->mbParam, pEnc->current->mbs, pEnc->current->fcode))) {
935    
936                  /*                  /*
937                   * This will be coded as an Intra Frame                   * This will be coded as an Intra Frame
938                   */                   */
# Line 948  Line 971 
971                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
972    
973                  if ((pEnc->global & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) {                  if ((pEnc->global & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) {
974                          BitstreamPad(&bs);                          BitstreamPadAlways(&bs);
975                          input_valid = 0;                          input_valid = 0;
976                          goto ipvop_loop;                          goto ipvop_loop;
977                  }                  }
# Line 957  Line 980 
980                   * NB : sequences like "IIBB" decode fine with msfdam but,                   * NB : sequences like "IIBB" decode fine with msfdam but,
981                   *      go screwy with divx 5.00                   *      go screwy with divx 5.00
982                   */                   */
983          } else if (pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) {          } else if (pEnc->bframenum_tail >= pEnc->mbParam.max_bframes || mode != 0) {
984                  /*                  /*
985                   * This will be coded as a Predicted Frame                   * This will be coded as a Predicted Frame
986                   */                   */
# Line 975  Line 998 
998                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
999    
1000                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
1001                          BitstreamPad(&bs);                          BitstreamPadAlways(&bs);
1002                          input_valid = 0;                          input_valid = 0;
1003                          goto ipvop_loop;                          goto ipvop_loop;
1004                  }                  }
# Line 1052  Line 1075 
1075                                                    pFrame->length, pFrame->intra);                                                    pFrame->length, pFrame->intra);
1076          }          }
1077    
   
1078          stop_global_timer();          stop_global_timer();
1079          write_timer();          write_timer();
1080    
# Line 1096  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;
         pEnc->current->seconds = pEnc->mbParam.m_seconds;  
         pEnc->current->ticks = pEnc->mbParam.m_ticks;  
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 1129  Line 1151 
1151                  pEnc->current->quant = pFrame->quant;                  pEnc->current->quant = pFrame->quant;
1152          }          }
1153    
1154            if ((pEnc->current->global_flags & XVID_QUARTERPEL))
1155                    pEnc->mbParam.m_quarterpel = 1;
1156            else
1157                    pEnc->mbParam.m_quarterpel = 0;
1158    
1159          if ((pEnc->current->global_flags & XVID_LUMIMASKING)) {          if ((pEnc->current->global_flags & XVID_LUMIMASKING)) {
1160                  int *temp_dquants =                  int *temp_dquants =
1161                          (int *) xvid_malloc(pEnc->mbParam.mb_width *                          (int *) xvid_malloc(pEnc->mbParam.mb_width *
# Line 1234  Line 1261 
1261          DEBUG(temp);          DEBUG(temp);
1262  #endif  #endif
1263    
         inc_frame_num(pEnc);  
1264          pEnc->iFrameNum++;          pEnc->iFrameNum++;
1265    
1266          stop_global_timer();          stop_global_timer();
# Line 1491  Line 1517 
1517          if ((pEnc->global & XVID_GLOBAL_PACKED)) {          if ((pEnc->global & XVID_GLOBAL_PACKED)) {
1518                  BitstreamWriteUserData(bs, DIVX501B481P, strlen(DIVX501B481P));                  BitstreamWriteUserData(bs, DIVX501B481P, strlen(DIVX501B481P));
1519          }          }
1520    
1521            set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
1522          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);
1523    
1524          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
# Line 1531  Line 1559 
1559          pEnc->sStat.iMvCount = 0;          pEnc->sStat.iMvCount = 0;
1560          pEnc->mbParam.m_fcode = 2;          pEnc->mbParam.m_fcode = 2;
1561    
         pEnc->last_pframe = pEnc->current->ticks;  
         pEnc->last_sync = pEnc->current->ticks;  
   
1562          if (pEnc->current->global_flags & XVID_HINTEDME_GET) {          if (pEnc->current->global_flags & XVID_HINTEDME_GET) {
1563                  HintedMEGet(pEnc, 1);                  HintedMEGet(pEnc, 1);
1564          }          }
# Line 1560  Line 1585 
1585          int iLimit;          int iLimit;
1586          int x, y, k;          int x, y, k;
1587          int iSearchRange;          int iSearchRange;
1588          int bIntra;          int bIntra, skip_possible;
1589    
1590          /* IMAGE *pCurrent = &pEnc->current->image; */          /* IMAGE *pCurrent = &pEnc->current->image; */
1591          IMAGE *pRef = &pEnc->reference->image;          IMAGE *pRef = &pEnc->reference->image;
# Line 1586  Line 1611 
1611                  image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV,                  image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV,
1612                                                    &pEnc->vInterHV, pEnc->mbParam.edged_width,                                                    &pEnc->vInterHV, pEnc->mbParam.edged_width,
1613                                                    pEnc->mbParam.edged_height,                                                    pEnc->mbParam.edged_height,
1614                                                      pEnc->mbParam.m_quarterpel,
1615                                                    pEnc->current->rounding_type);                                                    pEnc->current->rounding_type);
1616                  stop_inter_timer();                  stop_inter_timer();
1617          }          }
# Line 1593  Line 1619 
1619          start_timer();          start_timer();
1620          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {
1621                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
1622                  if (bIntra == 0) MotionEstimationHinted(&pEnc->mbParam, pEnc->current, pEnc->reference,          if (bIntra == 0) {
1623                            pEnc->current->fcode = FindFcode(&pEnc->mbParam, pEnc->current);
1624                            MotionEstimationHinted(&pEnc->mbParam, pEnc->current, pEnc->reference,
1625                                                                                          &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV);                                                                                          &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV);
1626                    }
1627    
1628          } else {          } else {
1629    
# Line 1613  Line 1642 
1642          if (vol_header)          if (vol_header)
1643                  BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);                  BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
1644    
1645    
1646            set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
1647          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);
1648    
1649          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
# Line 1635  Line 1666 
1666                                                                           dct_codes, pEnc->mbParam.width,                                                                           dct_codes, pEnc->mbParam.width,
1667                                                                           pEnc->mbParam.height,                                                                           pEnc->mbParam.height,
1668                                                                           pEnc->mbParam.edged_width,                                                                           pEnc->mbParam.edged_width,
1669                                                                             pEnc->mbParam.m_quarterpel,
1670                                                                           pEnc->current->rounding_type);                                                                           pEnc->current->rounding_type);
1671                                  stop_comp_timer();                                  stop_comp_timer();
1672    
# Line 1680  Line 1712 
1712    
1713                          /* Finished processing the MB, now check if to CODE or SKIP */                          /* Finished processing the MB, now check if to CODE or SKIP */
1714    
1715                          if ((pMB->mode == MODE_NOT_CODED) ||                          skip_possible = (pMB->cbp == 0) & (pMB->mode == MODE_INTER) &
1716                                  (pMB->cbp == 0 && pMB->mode == MODE_INTER && pMB->mvs[0].x == 0 &&                                                          (pMB->dquant == NO_CHANGE);
                                 pMB->mvs[0].y == 0 && pMB->dquant == NO_CHANGE)) {  
1717    
1718                            if(pEnc->mbParam.m_quarterpel)
1719                                    skip_possible &= (pMB->qmvs[0].x == 0) & (pMB->qmvs[0].y == 0);
1720                            else
1721                                    skip_possible &= (pMB->mvs[0].x == 0) & (pMB->mvs[0].y == 0);
1722    
1723                            if ((pMB->mode == MODE_NOT_CODED) || (skip_possible)) {
1724  /* This is a candidate for SKIPping, but check intermediate B-frames first */  /* This is a candidate for SKIPping, but check intermediate B-frames first */
1725    
1726                                  int bSkip = 1;                                  int bSkip = 1;
# Line 1703  Line 1740 
1740                                  if (!bSkip)                                  if (!bSkip)
1741                                  {                                  {
1742                                          VECTOR predMV;                                          VECTOR predMV;
1743                                            if(pEnc->mbParam.m_quarterpel)
1744                                                    predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);
1745                                            else
1746                                          predMV = get_pmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);                                          predMV = get_pmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);
1747                                          pMB->pmvs[0].x = -predMV.x; pMB->pmvs[0].y = -predMV.y;                                          pMB->pmvs[0].x = -predMV.x; pMB->pmvs[0].y = -predMV.y;
1748                                          pMB->mode = MODE_INTER;                                          pMB->mode = MODE_INTER;
# Line 1738  Line 1778 
1778          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);
1779    
1780          if ((fSigma > iSearchRange / 3)          if ((fSigma > iSearchRange / 3)
1781                  && (pEnc->mbParam.m_fcode <= 3))        // maximum search range 128                  && (pEnc->mbParam.m_fcode <= (3 + pEnc->mbParam.m_quarterpel))) // maximum search range 128
1782          {          {
1783                  pEnc->mbParam.m_fcode++;                  pEnc->mbParam.m_fcode++;
1784                  iSearchRange *= 2;                  iSearchRange *= 2;
1785          } else if ((fSigma < iSearchRange / 6)          } else if ((fSigma < iSearchRange / 6)
1786                             && (pEnc->sStat.fMvPrevSigma >= 0)                             && (pEnc->sStat.fMvPrevSigma >= 0)
1787                             && (pEnc->sStat.fMvPrevSigma < iSearchRange / 6)                             && (pEnc->sStat.fMvPrevSigma < iSearchRange / 6)
1788                             && (pEnc->mbParam.m_fcode >= 2))     // minimum search range 16                          && (pEnc->mbParam.m_fcode >= (2 + pEnc->mbParam.m_quarterpel))) // minimum search range 16
1789          {          {
1790                  pEnc->mbParam.m_fcode--;                  pEnc->mbParam.m_fcode--;
1791                  iSearchRange /= 2;                  iSearchRange /= 2;
# Line 1753  Line 1793 
1793    
1794          pEnc->sStat.fMvPrevSigma = fSigma;          pEnc->sStat.fMvPrevSigma = fSigma;
1795    
1796  #ifdef BFRAMES  #ifdef FRAMEDROP
1797          /* frame drop code */          /* frame drop code */
1798          // 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);
1799          if (pEnc->sStat.kblks + pEnc->sStat.mblks <          if (pEnc->sStat.kblks + pEnc->sStat.mblks <
# Line 1763  Line 1803 
1803                  pEnc->sStat.ublks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;                  pEnc->sStat.ublks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height;
1804    
1805                  BitstreamReset(bs);                  BitstreamReset(bs);
1806    
1807                    set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
1808                  BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 0);                  BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 0);
1809    
1810                  // copy reference frame details into the current frame                  // copy reference frame details into the current frame
# Line 1779  Line 1821 
1821    
1822          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1823    
         pEnc->time_pp = ((int32_t)pEnc->mbParam.fbase - (int32_t)pEnc->last_pframe + (int32_t)pEnc->current->ticks) %  
                         (int32_t)pEnc->mbParam.fbase;  
         pEnc->last_pframe = pEnc->current->ticks;  
   
1824          return 0;                                       // inter          return 0;                                       // inter
1825  }  }
1826    
# Line 1819  Line 1857 
1857          start_timer();          start_timer();
1858          image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,          image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,
1859                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
1860                                            0);                                            pEnc->mbParam.m_quarterpel, 0);
1861          stop_inter_timer();          stop_inter_timer();
1862    
1863          // backward          // backward
# Line 1829  Line 1867 
1867          start_timer();          start_timer();
1868          image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,          image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1869                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
1870                                            0);                                            pEnc->mbParam.m_quarterpel, 0);
1871          stop_inter_timer();          stop_inter_timer();
1872    
1873          start_timer();          start_timer();
1874    
1875          MotionEstimationBVOP(&pEnc->mbParam, frame,          MotionEstimationBVOP(&pEnc->mbParam, frame,
1876                  ((int32_t)pEnc->mbParam.fbase + pEnc->last_pframe - frame->ticks) % pEnc->mbParam.fbase,                  ((int32_t)(pEnc->current->stamp - frame->stamp)),                               // time_bp
1877                                                  pEnc->time_pp,                  ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),     // time_pp
1878                                                  pEnc->reference->mbs, f_ref,                                                  pEnc->reference->mbs, f_ref,
1879                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,
1880                                                   pEnc->current->mbs, b_ref, &pEnc->vInterH,                                                   pEnc->current->mbs, b_ref, &pEnc->vInterH,
# Line 1850  Line 1889 
1889             } */             } */
1890    
1891          frame->coding_type = B_VOP;          frame->coding_type = B_VOP;
1892    
1893            set_timecodes(frame, pEnc->reference,pEnc->mbParam.fbase);
1894          BitstreamWriteVopHeader(bs, &pEnc->mbParam, frame, 1);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, frame, 1);
1895    
1896          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);

Legend:
Removed from v.1.76.2.2  
changed lines
  Added in v.1.76.2.12

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