[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.91, Sat Feb 15 15:22:17 2003 UTC revision 1.99.2.1, Sat May 3 23:24:30 2003 UTC
# Line 26  Line 26 
26   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
27   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
28   *   *
  ****************************************************************************/  
   
 /*****************************************************************************  
  *  
  *  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()  
  *  
29   *  $Id$   *  $Id$
30   *   *
31   ****************************************************************************/   ****************************************************************************/
# Line 86  Line 73 
73                                            Bitstream * bs,                                            Bitstream * bs,
74                                            uint32_t * pBits,                                            uint32_t * pBits,
75                                            bool force_inter,                                            bool force_inter,
76                                            bool vol_header);                                            bool vol_header,
77                                              int interpolate);
78    
79  static void FrameCodeB(Encoder * pEnc,  static void FrameCodeB(Encoder * pEnc,
80                                             FRAMEINFO * frame,                                             FRAMEINFO * frame,
81                                             Bitstream * bs,                                             Bitstream * bs,
82                                             uint32_t * pBits);                                             uint32_t * pBits,
83                                               int interpolate_forward,
84                                               int interpolate_backward);
85    
86  /*****************************************************************************  /*****************************************************************************
87   * Local data   * Local data
# Line 129  Line 119 
119  {  {
120          Encoder *pEnc;          Encoder *pEnc;
121          int i;          int i;
   
122          pParam->handle = NULL;          pParam->handle = NULL;
123    
124          ENC_CHECK(pParam);          ENC_CHECK(pParam);
# Line 379  Line 368 
368    
369          pEnc->queue = NULL;          pEnc->queue = NULL;
370    
   
371          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
372                  int n;                  int n;
373    
# Line 432  Line 420 
420    
421    xvid_err_memory5:    xvid_err_memory5:
422    
   
423          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
424    
425                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {
# Line 540  Line 527 
527                  xvid_free(pEnc->queue);                  xvid_free(pEnc->queue);
528          }          }
529    
   
530          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
531    
532                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {
# Line 605  Line 591 
591    
592  static __inline void inc_frame_num(Encoder * pEnc)  static __inline void inc_frame_num(Encoder * pEnc)
593  {  {
594          pEnc->current->stamp = pEnc->mbParam.m_stamp;   // first frame is zero          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */
595          pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;          pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;
596  }  }
597    
# Line 631  Line 617 
617                  return;                  return;
618          stop_conv_timer();          stop_conv_timer();
619    
620            if ((pFrame->general & XVID_CHROMAOPT)) {
621                    image_chroma_optimize(&pEnc->queue[pEnc->queue_tail],
622                            pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
623            }
624    
625          pEnc->queue_size++;          pEnc->queue_size++;
626          pEnc->queue_tail =  (pEnc->queue_tail + 1) % pEnc->mbParam.max_bframes;          pEnc->queue_tail =  (pEnc->queue_tail + 1) % pEnc->mbParam.max_bframes;
627  }  }
# Line 642  Line 633 
633                  pCur->ticks = (int32_t)pCur->stamp % time_base;                  pCur->ticks = (int32_t)pCur->stamp % time_base;
634                  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) ;
635    
636                  //HEAVY DEBUG OUTPUT    remove when timecodes prove to be stable                  /* HEAVY DEBUG OUTPUT remove when timecodes prove to be stable */
637    
638  /*              fprintf(stderr,"WriteVop:   %d - %d \n",  /*              fprintf(stderr,"WriteVop:   %d - %d \n",
639                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));
# Line 685  Line 676 
676          uint16_t x, y;          uint16_t x, y;
677          Bitstream bs;          Bitstream bs;
678          uint32_t bits;          uint32_t bits;
679          int mode;          int mode = -1; /* Just to shut up compiler warning */
680    
681          int input_valid = 1;          int input_valid = 1;
682          int bframes_count = 0;          int bframes_count = 0;
683            int interpolate_forward = 1;
684            int interpolate_backward = 1;
685    
686          ENC_CHECK(pEnc);          ENC_CHECK(pEnc);
687          ENC_CHECK(pFrame);          ENC_CHECK(pFrame);
# Line 723  Line 716 
716    
717                          SWAP(FRAMEINFO *, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);                          SWAP(FRAMEINFO *, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);
718    
719                          FrameCodeP(pEnc, &bs, &bits, 1, 0);                          if (pEnc->mbParam.m_quarterpel)
720                                    pEnc->current->global_flags |= XVID_QUARTERPEL;
721                            else
722                                    pEnc->current->global_flags &= ~XVID_QUARTERPEL;
723    
724                            FrameCodeP(pEnc, &bs, &bits, 1, 0, interpolate_backward);
725                          bframes_count = 0;                          bframes_count = 0;
726                            interpolate_forward = 0;
727                            interpolate_backward = 1;
728    
729                          BitstreamPadAlways(&bs);                          BitstreamPadAlways(&bs);
730                          pFrame->length = BitstreamLength(&bs);                          pFrame->length = BitstreamLength(&bs);
# Line 739  Line 739 
739                                  pResult->kblks = pEnc->current->sStat.kblks;                                  pResult->kblks = pEnc->current->sStat.kblks;
740                                  pResult->mblks = pEnc->current->sStat.mblks;                                  pResult->mblks = pEnc->current->sStat.mblks;
741                                  pResult->ublks = pEnc->current->sStat.ublks;                                  pResult->ublks = pEnc->current->sStat.ublks;
742                                    pResult->iblks = pEnc->current->sStat.iblks;
743                                    pResult->qblks = pEnc->current->sStat.qblks;
744                          }                          }
745    
746                          return XVID_ERR_OK;                          return XVID_ERR_OK;
# Line 749  Line 751 
751                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
752                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
753    
754                  FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs, &bits);                  if (pEnc->mbParam.m_quarterpel)
755                            pEnc->current->global_flags |= XVID_QUARTERPEL;
756                    else
757                            pEnc->current->global_flags &= ~XVID_QUARTERPEL;
758    
759                    FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs,
760                                       &bits, interpolate_forward, interpolate_backward);
761                  pEnc->bframenum_head++;                  pEnc->bframenum_head++;
762    
763                    interpolate_forward = 0;
764                    interpolate_backward = 0;
765    
766                  BitstreamPadAlways(&bs);                  BitstreamPadAlways(&bs);
767                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
768                  pFrame->intra = 2;                  pFrame->intra = 2;
# Line 762  Line 773 
773                          pResult->kblks = pEnc->current->sStat.kblks;                          pResult->kblks = pEnc->current->sStat.kblks;
774                          pResult->mblks = pEnc->current->sStat.mblks;                          pResult->mblks = pEnc->current->sStat.mblks;
775                          pResult->ublks = pEnc->current->sStat.ublks;                          pResult->ublks = pEnc->current->sStat.ublks;
776                            pResult->iblks = pEnc->current->sStat.iblks;
777                            pResult->qblks = pEnc->current->sStat.qblks;
778                    }
779    
780                    emms();
781    
782                    if (pFrame->quant == 0) {
783                            RateControlUpdate(&pEnc->rate_control, pEnc->current->quant,
784                                                              pFrame->length, pFrame->intra);
785                  }                  }
786    
787                  if (input_valid)                  if (input_valid)
# Line 776  Line 796 
796                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;
797    
798                  /* write an empty marker to the bitstream.                  /* write an empty marker to the bitstream.
   
799                     for divx5 decoder compatibility, this marker must consist                     for divx5 decoder compatibility, this marker must consist
800                     of a not-coded p-vop, with a time_base of zero, and time_increment                     of a not-coded p-vop, with a time_base of zero, and time_increment
801                     indentical to the future-referece frame.                     indentical to the future-referece frame.
# Line 789  Line 808 
808                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
809                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
810    
   
811                          tmp = pEnc->current->seconds;                          tmp = pEnc->current->seconds;
812                          pEnc->current->seconds = 0; /* force time_base = 0 */                          pEnc->current->seconds = 0; /* force time_base = 0 */
813    
# Line 806  Line 824 
824                                  pResult->kblks = pEnc->current->sStat.kblks;                                  pResult->kblks = pEnc->current->sStat.kblks;
825                                  pResult->mblks = pEnc->current->sStat.mblks;                                  pResult->mblks = pEnc->current->sStat.mblks;
826                                  pResult->ublks = pEnc->current->sStat.ublks;                                  pResult->ublks = pEnc->current->sStat.ublks;
827                                    pResult->iblks = pEnc->current->sStat.iblks;
828                                    pResult->qblks = pEnc->current->sStat.qblks;
829                            }
830    
831                            emms();
832    
833                            if (pFrame->quant == 0) {
834                                    RateControlUpdate(&pEnc->rate_control, pEnc->current->quant,
835                                                                      pFrame->length, pFrame->intra);
836                          }                          }
837    
838                          if (input_valid)                          if (input_valid)
# Line 850  Line 877 
877                  }                  }
878                  stop_conv_timer();                  stop_conv_timer();
879    
880                  // queue input frame, and dequue next image                  if ((pFrame->general & XVID_CHROMAOPT)) {
881                            image_chroma_optimize(&pEnc->current->image,
882                                    pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
883                    }
884    
885                    /* queue input frame, and dequue next image */
886                  if (pEnc->queue_size > 0)                  if (pEnc->queue_size > 0)
887                  {                  {
888                          image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_tail]);                          image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_tail]);
# Line 881  Line 913 
913                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
914                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
915    
916                            /* That disabled line of code was supposed to inform VirtualDub
917                             * that the frame was a dummy delay frame - now disabled (thx god :-)
918                             */
919                  //      BitstreamPutBits(&bs, 0x7f, 8);                  //      BitstreamPutBits(&bs, 0x7f, 8);
920                          pFrame->intra = 5;                          pFrame->intra = 5;
921    
# Line 902  Line 937 
937                                  pResult->kblks = 0;                                  pResult->kblks = 0;
938                                  pResult->mblks = 0;                                  pResult->mblks = 0;
939                                  pResult->ublks = 0;                                  pResult->ublks = 0;
940                                    pResult->iblks = 0;
941                                    pResult->qblks = 0;
942                          }                          }
   
943                  } else {                  } else {
944    
945                          if (pResult) {                          if (pResult) {
# Line 912  Line 948 
948                                  pResult->kblks = pEnc->current->sStat.kblks;                                  pResult->kblks = pEnc->current->sStat.kblks;
949                                  pResult->mblks = pEnc->current->sStat.mblks;                                  pResult->mblks = pEnc->current->sStat.mblks;
950                                  pResult->ublks = pEnc->current->sStat.ublks;                                  pResult->ublks = pEnc->current->sStat.ublks;
951                                    pResult->iblks = pEnc->current->sStat.iblks;
952                                    pResult->qblks = pEnc->current->sStat.qblks;
953                          }                          }
954    
955                  }                  }
# Line 927  Line 965 
965    
966          emms();          emms();
967    
968          // only inc frame num, adapt quant, etc. if we havent seen it before          /* only inc frame num, adapt quant, etc. if we havent seen it before */
969          if (pEnc->bframenum_dx50bvop < 0 )          if (pEnc->bframenum_dx50bvop < 0 )
970          {          {
971                  mode = intra2coding_type(pFrame->intra);                  mode = intra2coding_type(pFrame->intra);
# Line 990  Line 1028 
1028    
1029                                          pMB->dquant = iDQtab[temp_dquants[OFFSET(x, y)] + 2];                                          pMB->dquant = iDQtab[temp_dquants[OFFSET(x, y)] + 2];
1030                                  }                                  }
   
1031  #undef OFFSET  #undef OFFSET
1032                          }                          }
   
1033                          xvid_free(temp_dquants);                          xvid_free(temp_dquants);
1034                  }                  }
   
1035          }          }
1036    
1037          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Line 1006  Line 1041 
1041    
1042          if (pEnc->iFrameNum == 0 || pEnc->bframenum_dx50bvop >= 0 ||          if (pEnc->iFrameNum == 0 || pEnc->bframenum_dx50bvop >= 0 ||
1043                  (mode < 0 && pEnc->mbParam.iMaxKeyInterval > 0 &&                  (mode < 0 && pEnc->mbParam.iMaxKeyInterval > 0 &&
1044                          pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval))                          pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval)) {
         {  
1045                  mode = I_VOP;                  mode = I_VOP;
1046          }else{          }else{
1047                  mode = MEanalysis(&pEnc->reference->image, pEnc->current,                  mode = MEanalysis(&pEnc->reference->image, pEnc->current,
1048                                          &pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval,                                          &pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval,
1049                                          (mode < 0) ? pEnc->iFrameNum : 0,                                          (/*mode < 0*/1/*hack*/) ? pEnc->iFrameNum : 0,
1050                                          bframes_count++);                                          bframes_count++, pFrame->bframe_threshold);
1051          }          }
1052    
1053          if (mode == I_VOP) {          if (mode == I_VOP) {
# Line 1043  Line 1077 
1077                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP");                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP");
1078                  }                  }
1079    
1080                  // when we reach an iframe in DX50BVOP mode, encode the last bframe as a pframe                  /* when we reach an iframe in DX50BVOP mode, encode the last bframe as a pframe */
1081    
1082                  if ((pEnc->mbParam.global & XVID_GLOBAL_DX50BVOP) && pEnc->bframenum_tail > 0) {                  if ((pEnc->mbParam.global & XVID_GLOBAL_DX50BVOP) && pEnc->bframenum_tail > 0) {
1083    
# Line 1054  Line 1088 
1088                          if ((pEnc->mbParam.global & XVID_GLOBAL_DEBUG)) {                          if ((pEnc->mbParam.global & XVID_GLOBAL_DEBUG)) {
1089                                  image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");                                  image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");
1090                          }                          }
1091                          FrameCodeP(pEnc, &bs, &bits, 1, 0);  
1092                            if (pEnc->mbParam.m_quarterpel)
1093                                    pEnc->current->global_flags |= XVID_QUARTERPEL;
1094                            else
1095                                    pEnc->current->global_flags &= ~XVID_QUARTERPEL;
1096    
1097                            FrameCodeP(pEnc, &bs, &bits, 1, 0, interpolate_backward);
1098                          bframes_count = 0;                          bframes_count = 0;
1099                          pFrame->intra = 0;                          pFrame->intra = 0;
1100                            interpolate_forward = 0;
1101                            interpolate_backward = 1;
1102    
1103                  } else {                  } else {
1104    
1105                            if (pEnc->mbParam.m_quarterpel)
1106                                    pEnc->current->global_flags |= XVID_QUARTERPEL;
1107                            else
1108                                    pEnc->current->global_flags &= ~XVID_QUARTERPEL;
1109    
1110                          FrameCodeI(pEnc, &bs, &bits);                          FrameCodeI(pEnc, &bs, &bits);
1111                          bframes_count = 0;                          bframes_count = 0;
1112                            interpolate_forward = 1;
1113                            interpolate_backward = 1;
1114                          pFrame->intra = 1;                          pFrame->intra = 1;
1115    
1116                          pEnc->bframenum_dx50bvop = -1;                          pEnc->bframenum_dx50bvop = -1;
# Line 1092  Line 1141 
1141                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "PVOP");                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "PVOP");
1142                  }                  }
1143    
1144                  FrameCodeP(pEnc, &bs, &bits, 1, 0);                  if (pEnc->mbParam.m_quarterpel)
1145                            pEnc->current->global_flags |= XVID_QUARTERPEL;
1146                    else
1147                            pEnc->current->global_flags &= ~XVID_QUARTERPEL;
1148    
1149                    FrameCodeP(pEnc, &bs, &bits, 1, 0, interpolate_backward);
1150                  bframes_count = 0;                  bframes_count = 0;
1151                  pFrame->intra = 0;                  pFrame->intra = 0;
1152                    interpolate_forward = 0;
1153                    interpolate_backward = 1;
1154                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
1155    
1156                  if ((pEnc->mbParam.global & XVID_GLOBAL_PACKED) && (pEnc->bframenum_tail > 0)) {                  if ((pEnc->mbParam.global & XVID_GLOBAL_PACKED) && (pEnc->bframenum_tail > 0)) {
# Line 1135  Line 1191 
1191    
1192                  pEnc->bframenum_tail++;                  pEnc->bframenum_tail++;
1193    
1194  // bframe report by koepi                  /* bframe report by koepi */
1195                  pFrame->intra = 2;                  pFrame->intra = 2;
1196                  pFrame->length = 0;                  pFrame->length = 0;
1197    
# Line 1152  Line 1208 
1208                  pResult->kblks = pEnc->current->sStat.kblks;                  pResult->kblks = pEnc->current->sStat.kblks;
1209                  pResult->mblks = pEnc->current->sStat.mblks;                  pResult->mblks = pEnc->current->sStat.mblks;
1210                  pResult->ublks = pEnc->current->sStat.ublks;                  pResult->ublks = pEnc->current->sStat.ublks;
1211                    pResult->iblks = pEnc->current->sStat.iblks;
1212                    pResult->qblks = pEnc->current->sStat.qblks;
1213    
1214                  if (pFrame->general & XVID_EXTRASTATS)                  if (pFrame->general & XVID_EXTRASTATS)
1215                  {       pResult->sse_y =                  {       pResult->sse_y =
# Line 1205  Line 1263 
1263          Bitstream bs;          Bitstream bs;
1264          uint32_t bits;          uint32_t bits;
1265          uint16_t write_vol_header = 0;          uint16_t write_vol_header = 0;
1266            unsigned int old_qpel;
1267    
1268          float psnr;          float psnr;
1269          uint8_t temp[128];          char temp[128];
1270    
1271          start_global_timer();          start_global_timer();
1272    
# Line 1238  Line 1297 
1297                  return XVID_ERR_FORMAT;                  return XVID_ERR_FORMAT;
1298          stop_conv_timer();          stop_conv_timer();
1299    
1300            if ((pFrame->general & XVID_CHROMAOPT)) {
1301                    image_chroma_optimize(&pEnc->current->image,
1302                            pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
1303            }
1304    
1305          if (pFrame->general & XVID_EXTRASTATS)          if (pFrame->general & XVID_EXTRASTATS)
1306          {       image_copy(&pEnc->sOriginal, &pEnc->current->image,          {       image_copy(&pEnc->sOriginal, &pEnc->current->image,
1307                                     pEnc->mbParam.edged_width, pEnc->mbParam.height);                                     pEnc->mbParam.edged_width, pEnc->mbParam.height);
# Line 1253  Line 1317 
1317                  pEnc->current->quant = pFrame->quant;                  pEnc->current->quant = pFrame->quant;
1318          }          }
1319    
1320            old_qpel = pEnc->mbParam.m_quarterpel;
1321    
1322          if ((pEnc->current->global_flags & XVID_QUARTERPEL))          if ((pEnc->current->global_flags & XVID_QUARTERPEL))
1323                  pEnc->mbParam.m_quarterpel = 1;                  pEnc->mbParam.m_quarterpel = 1;
1324          else          else
# Line 1323  Line 1389 
1389                                  && (pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval))) {                                  && (pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval))) {
1390                          pFrame->intra = FrameCodeI(pEnc, &bs, &bits);                          pFrame->intra = FrameCodeI(pEnc, &bs, &bits);
1391                  } else {                  } else {
1392                          pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 0, write_vol_header);                          if (old_qpel != pEnc->mbParam.m_quarterpel)
1393                                    pEnc->mbParam.m_quarterpel = old_qpel;
1394                            pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 0, write_vol_header, 1);
1395                  }                  }
1396          } else {          } else {
1397                  if (pFrame->intra == 1) {                  if (pFrame->intra == 1) {
1398                          pFrame->intra = FrameCodeI(pEnc, &bs, &bits);                          pFrame->intra = FrameCodeI(pEnc, &bs, &bits);
1399                  } else {                  } else {
1400                          pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 1, write_vol_header);                          if (old_qpel != pEnc->mbParam.m_quarterpel)
1401                                    pEnc->mbParam.m_quarterpel = old_qpel;
1402                            pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 1, write_vol_header, 1);
1403                  }                  }
1404    
1405          }          }
1406    
1407  //      BitstreamPutBits(&bs, 0xFFFF, 16);          /* Relic from OpenDivX - now disabled
1408  //      BitstreamPutBits(&bs, 0xFFFF, 16);          BitstreamPutBits(&bs, 0xFFFF, 16);
1409            BitstreamPutBits(&bs, 0xFFFF, 16);
1410            */
1411    
1412          BitstreamPadAlways(&bs);          BitstreamPadAlways(&bs);
1413          pFrame->length = BitstreamLength(&bs);          pFrame->length = BitstreamLength(&bs);
1414    
# Line 1345  Line 1418 
1418                  pResult->kblks = pEnc->current->sStat.kblks;                  pResult->kblks = pEnc->current->sStat.kblks;
1419                  pResult->mblks = pEnc->current->sStat.mblks;                  pResult->mblks = pEnc->current->sStat.mblks;
1420                  pResult->ublks = pEnc->current->sStat.ublks;                  pResult->ublks = pEnc->current->sStat.ublks;
1421                    pResult->iblks = pEnc->current->sStat.iblks;
1422                    pResult->qblks = pEnc->current->sStat.qblks;
1423          }          }
1424    
1425          emms();          emms();
# Line 1426  Line 1501 
1501                  return;                  return;
1502          }          }
1503    
1504          pEnc->current->fcode =          pEnc->current->fcode = (hint->rawhints) ?
1505                  (hint->rawhints) ? hint->mvhint.fcode : BitstreamGetBits(&bs,                  (uint32_t)hint->mvhint.fcode : BitstreamGetBits(&bs, FCODEBITS);
                                                                                                                                  FCODEBITS);  
1506    
1507          length = pEnc->current->fcode + 5;          length = pEnc->current->fcode + 5;
1508          high = 1 << (length - 1);          high = 1 << (length - 1);
# Line 1443  Line 1517 
1517                          VECTOR tmp;                          VECTOR tmp;
1518                          int vec;                          int vec;
1519    
1520                          pMB->mode =                          pMB->mode =     (hint->rawhints) ?
1521                                  (hint->rawhints) ? bhint->mode : BitstreamGetBits(&bs,                                  (uint32_t)bhint->mode : BitstreamGetBits(&bs, MODEBITS);
                                                                                                                                   MODEBITS);  
1522    
1523                          pMB->mode = (pMB->mode == MODE_INTER_Q) ? MODE_INTER : pMB->mode;                          pMB->mode = (pMB->mode == MODE_INTER_Q) ? MODE_INTER : pMB->mode;
1524                          pMB->mode = (pMB->mode == MODE_INTRA_Q) ? MODE_INTRA : pMB->mode;                          pMB->mode = (pMB->mode == MODE_INTRA_Q) ? MODE_INTRA : pMB->mode;
1525    
1526                          if (pMB->mode == MODE_INTER) {                          if (pMB->mode == MODE_INTER) {
1527                                  tmp.x =                                  tmp.x = (hint->rawhints) ?
1528                                          (hint->rawhints) ? bhint->mvs[0].x : BitstreamGetBits(&bs,                                          bhint->mvs[0].x : (int)BitstreamGetBits(&bs, length);
1529                                                                                                                                                    length);                                  tmp.y = (hint->rawhints) ?
1530                                  tmp.y =                                          bhint->mvs[0].y : (int)BitstreamGetBits(&bs, length);
                                         (hint->rawhints) ? bhint->mvs[0].y : BitstreamGetBits(&bs,  
                                                                                                                                                   length);  
1531                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1532                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1533    
# Line 1470  Line 1541 
1541                                  }                                  }
1542                          } else if (pMB->mode == MODE_INTER4V) {                          } else if (pMB->mode == MODE_INTER4V) {
1543                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
1544                                          tmp.x =                                          tmp.x = (hint->rawhints) ?
1545                                                  (hint->rawhints) ? bhint->mvs[vec].                                                  bhint->mvs[vec].x : (int)BitstreamGetBits(&bs, length);
1546                                                  x : BitstreamGetBits(&bs, length);                                          tmp.y = (hint->rawhints) ?
1547                                          tmp.y =                                                  bhint->mvs[vec].y : (int)BitstreamGetBits(&bs, length);
                                                 (hint->rawhints) ? bhint->mvs[vec].  
                                                 y : BitstreamGetBits(&bs, length);  
1548                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1549                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1550    
# Line 1486  Line 1555 
1555                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x;                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x;
1556                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y;                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y;
1557                                  }                                  }
1558                          } else                          // intra / stuffing / not_coded                          } else                          /* intra / stuffing / not_coded */
1559                          {                          {
1560                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
1561                                          pMB->mvs[vec].x = pMB->mvs[vec].y = 0;                                          pMB->mvs[vec].x = pMB->mvs[vec].y = 0;
# Line 1623  Line 1692 
1692                          pEnc->mbParam.width, pEnc->mbParam.height);                          pEnc->mbParam.width, pEnc->mbParam.height);
1693                  stop_edges_timer();                  stop_edges_timer();
1694          }          }
   
1695          pEnc->iFrameNum = 0;          pEnc->iFrameNum = 0;
1696          pEnc->mbParam.m_rounding_type = 1;          pEnc->mbParam.m_rounding_type = 1;
1697          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
# Line 1642  Line 1710 
1710          pEnc->current->sStat.iTextBits = 0;          pEnc->current->sStat.iTextBits = 0;
1711          pEnc->current->sStat.kblks = mb_width * mb_height;          pEnc->current->sStat.kblks = mb_width * mb_height;
1712          pEnc->current->sStat.mblks = pEnc->current->sStat.ublks = 0;          pEnc->current->sStat.mblks = pEnc->current->sStat.ublks = 0;
1713            pEnc->current->sStat.iblks = pEnc->current->sStat.qblks = 0;
1714    
1715          for (y = 0; y < mb_height; y++)          for (y = 0; y < mb_height; y++)
1716                  for (x = 0; x < mb_width; x++) {                  for (x = 0; x < mb_width; x++) {
# Line 1683  Line 1752 
1752                  HintedMEGet(pEnc, 1);                  HintedMEGet(pEnc, 1);
1753          }          }
1754    
1755          return 1;                                       // intra          return 1;                                       /* intra */
1756  }  }
1757    
1758    
# Line 1697  Line 1766 
1766                     Bitstream * bs,                     Bitstream * bs,
1767                     uint32_t * pBits,                     uint32_t * pBits,
1768                     bool force_inter,                     bool force_inter,
1769                     bool vol_header)                     bool vol_header,
1770                       int interpolate)
1771  {  {
1772          float fSigma;          float fSigma;
1773    
# Line 1711  Line 1781 
1781          int x, y, k;          int x, y, k;
1782          int iSearchRange;          int iSearchRange;
1783          int bIntra, skip_possible;          int bIntra, skip_possible;
1784            IMAGE *refh, *refv, *refhv;
1785    
1786          /* IMAGE *pCurrent = &pEnc->current->image; */          /* IMAGE *pCurrent = &pEnc->current->image; */
1787          IMAGE *pRef = &pEnc->reference->image;          IMAGE *pRef = &pEnc->reference->image;
# Line 1721  Line 1792 
1792                  mb_height = (pEnc->mbParam.height + 31) / 32;                  mb_height = (pEnc->mbParam.height + 31) / 32;
1793          }          }
1794    
   
         start_timer();  
         image_setedges(pRef, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,  
                                    pEnc->mbParam.width, pEnc->mbParam.height);  
         stop_edges_timer();  
   
1795          pEnc->mbParam.m_rounding_type = 1 - pEnc->mbParam.m_rounding_type;          pEnc->mbParam.m_rounding_type = 1 - pEnc->mbParam.m_rounding_type;
1796          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
1797          pEnc->current->quarterpel =  pEnc->mbParam.m_quarterpel;          pEnc->current->quarterpel =  pEnc->mbParam.m_quarterpel;
# Line 1737  Line 1802 
1802          else          else
1803                  iLimit = mb_width * mb_height + 1;                  iLimit = mb_width * mb_height + 1;
1804    
1805            if((interpolate) || (pEnc->current->rounding_type != 0)) {
1806                    start_timer();
1807                    image_setedges(pRef, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
1808                                               pEnc->mbParam.width, pEnc->mbParam.height);
1809                    stop_edges_timer();
1810    
1811          if ((pEnc->current->global_flags & XVID_HALFPEL)) {          if ((pEnc->current->global_flags & XVID_HALFPEL)) {
1812                  start_timer();                  start_timer();
1813                  image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV,                  image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV,
# Line 1747  Line 1818 
1818                  stop_inter_timer();                  stop_inter_timer();
1819          }          }
1820    
1821                    refh = &pEnc->vInterH;
1822                    refv = &pEnc->vInterV;
1823                    refhv = &pEnc->vInterHV;
1824            }
1825            else {
1826                    refh = &pEnc->f_refh;
1827                    refv = &pEnc->f_refv;
1828                    refhv = &pEnc->f_refhv;
1829            }
1830    
1831          pEnc->current->coding_type = P_VOP;          pEnc->current->coding_type = P_VOP;
1832    
1833          start_timer();          start_timer();
# Line 1755  Line 1836 
1836          else          else
1837                  bIntra =                  bIntra =
1838                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
1839                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                                                   refh, refv, refhv,
1840                           iLimit);                           iLimit);
1841    
1842          stop_motion_timer();          stop_motion_timer();
# Line 1791  Line 1872 
1872    
1873          pEnc->current->sStat.iTextBits = pEnc->current->sStat.iMvSum = pEnc->current->sStat.iMvCount =          pEnc->current->sStat.iTextBits = pEnc->current->sStat.iMvSum = pEnc->current->sStat.iMvCount =
1874                  pEnc->current->sStat.kblks = pEnc->current->sStat.mblks = pEnc->current->sStat.ublks = 0;                  pEnc->current->sStat.kblks = pEnc->current->sStat.mblks = pEnc->current->sStat.ublks = 0;
1875            pEnc->current->sStat.iblks = pEnc->current->sStat.qblks = 0;
1876    
1877    
1878          for (y = 0; y < mb_height; y++) {          for (y = 0; y < mb_height; y++) {
# Line 1852  Line 1934 
1934    
1935                          start_timer();                          start_timer();
1936                          MBMotionCompensation(pMB, x, y, &pEnc->reference->image,                          MBMotionCompensation(pMB, x, y, &pEnc->reference->image,
1937                                                                   &pEnc->vInterH, &pEnc->vInterV,                                                                   refh, refv,
1938                                                                   &pEnc->vInterHV, &pEnc->vGMC,                                                                   refhv, &pEnc->vGMC,
1939                                                                   &pEnc->current->image,                                                                   &pEnc->current->image,
1940                                                                   dct_codes, pEnc->mbParam.width,                                                                   dct_codes, pEnc->mbParam.width,
1941                                                                   pEnc->mbParam.height,                                                                   pEnc->mbParam.height,
# Line 1892  Line 1974 
1974                                  pEnc->current->sStat.ublks++;                                  pEnc->current->sStat.ublks++;
1975                          }                          }
1976    
1977                            if(pEnc->mbParam.m_quarterpel) {
1978                                    for (k = 0; k < ((pMB->mode == MODE_INTER4V) ? 4 : 1); k++) {
1979                                            if (((pMB->qmvs[k].x % 4) != 0) || ((pMB->qmvs[k].y % 4) != 0))
1980                                                    pEnc->current->sStat.iblks++;
1981    
1982                                            if (((pMB->qmvs[k].x % 4) & 1) || ((pMB->qmvs[k].y % 4) & 1))
1983                                                    pEnc->current->sStat.qblks++;
1984                                    }
1985                            }
1986    
1987                          start_timer();                          start_timer();
1988    
1989                          /* Finished processing the MB, now check if to CODE or SKIP */                          /* Finished processing the MB, now check if to CODE or SKIP */
# Line 2021  Line 2113 
2113          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);
2114    
2115          if ((fSigma > iSearchRange / 3)          if ((fSigma > iSearchRange / 3)
2116                  && (pEnc->mbParam.m_fcode <= (3 + pEnc->mbParam.m_quarterpel))) // maximum search range 128                  && (pEnc->mbParam.m_fcode <= (3 + pEnc->mbParam.m_quarterpel))) /* maximum search range 128 */
2117          {          {
2118                  pEnc->mbParam.m_fcode++;                  pEnc->mbParam.m_fcode++;
2119                  iSearchRange *= 2;                  iSearchRange *= 2;
2120          } else if ((fSigma < iSearchRange / 6)          } else if ((fSigma < iSearchRange / 6)
2121                             && (pEnc->fMvPrevSigma >= 0)                             && (pEnc->fMvPrevSigma >= 0)
2122                             && (pEnc->fMvPrevSigma < iSearchRange / 6)                             && (pEnc->fMvPrevSigma < iSearchRange / 6)
2123                          && (pEnc->mbParam.m_fcode >= (2 + pEnc->mbParam.m_quarterpel))) // minimum search range 16                             && (pEnc->mbParam.m_fcode >= (2 + pEnc->mbParam.m_quarterpel)))      /* minimum search range 16 */
2124          {          {
2125                  pEnc->mbParam.m_fcode--;                  pEnc->mbParam.m_fcode--;
2126                  iSearchRange /= 2;                  iSearchRange /= 2;
# Line 2049  Line 2141 
2141                  set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);                  set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
2142                  BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 0);                  BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 0);
2143    
2144                  // copy reference frame details into the current frame                  /* copy reference frame details into the current frame */
2145                  pEnc->current->quant = pEnc->reference->quant;                  pEnc->current->quant = pEnc->reference->quant;
2146                  pEnc->current->motion_flags = pEnc->reference->motion_flags;                  pEnc->current->motion_flags = pEnc->reference->motion_flags;
2147                  pEnc->current->rounding_type = pEnc->reference->rounding_type;                  pEnc->current->rounding_type = pEnc->reference->rounding_type;
# Line 2078  Line 2170 
2170    
2171          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
2172    
2173          return 0;                                       // inter          return 0;                                       /* inter */
2174  }  }
2175    
2176    
# Line 2086  Line 2178 
2178  FrameCodeB(Encoder * pEnc,  FrameCodeB(Encoder * pEnc,
2179                     FRAMEINFO * frame,                     FRAMEINFO * frame,
2180                     Bitstream * bs,                     Bitstream * bs,
2181                     uint32_t * pBits)                     uint32_t * pBits,
2182                       int interpolate_forward,
2183                       int interpolate_backward)
2184  {  {
2185          DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE);
2186          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE);
# Line 2111  Line 2205 
2205    
2206          frame->quarterpel =  pEnc->mbParam.m_quarterpel;          frame->quarterpel =  pEnc->mbParam.m_quarterpel;
2207    
2208          // forward          if ((interpolate_forward) || ((pEnc->mbParam.m_rounding_type != 1) && interpolate_backward)) {
2209    
2210                    /* forward  */
2211          image_setedges(f_ref, pEnc->mbParam.edged_width,          image_setedges(f_ref, pEnc->mbParam.edged_width,
2212                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,
2213                                     pEnc->mbParam.height);                                     pEnc->mbParam.height);
2214          start_timer();          start_timer();
2215          image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                  image_interpolate(f_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
2216                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
2217                                            pEnc->mbParam.m_quarterpel, 0);                                            pEnc->mbParam.m_quarterpel, 0);
2218          stop_inter_timer();          stop_inter_timer();
2219            }
2220    
2221            if (interpolate_backward) {
2222    
2223          // backward                  /* backward */
2224          image_setedges(b_ref, pEnc->mbParam.edged_width,          image_setedges(b_ref, pEnc->mbParam.edged_width,
2225                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,
2226                                     pEnc->mbParam.height);                                     pEnc->mbParam.height);
2227          start_timer();          start_timer();
2228          image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                  image_interpolate(b_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,
2229                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
2230                                            pEnc->mbParam.m_quarterpel, 0);                                            pEnc->mbParam.m_quarterpel, 0);
2231          stop_inter_timer();          stop_inter_timer();
2232            }
2233    
2234          start_timer();          start_timer();
2235    
2236          MotionEstimationBVOP(&pEnc->mbParam, frame,          MotionEstimationBVOP(&pEnc->mbParam, frame,
2237                  ((int32_t)(pEnc->current->stamp - frame->stamp)),                               // time_bp                                                   ((int32_t)(pEnc->current->stamp - frame->stamp)),                              /* time_bp */
2238                  ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),     // time_pp                                                   ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),    /* time_pp */
2239                          pEnc->reference->mbs, f_ref,                                                   pEnc->reference->mbs, f_ref, &pEnc->vInterH,
2240                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                                                   &pEnc->vInterV, &pEnc->vInterHV,
2241                                                   pEnc->current, b_ref, &pEnc->vInterH,                                                   pEnc->current, b_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv);
                                                  &pEnc->vInterV, &pEnc->vInterHV);  
   
2242    
2243          stop_motion_timer();          stop_motion_timer();
2244            /*
2245          /*if (test_quant_type(&pEnc->mbParam, pEnc->current))          if (test_quant_type(&pEnc->mbParam, pEnc->current)) {
            {  
2246             BitstreamWriteVolHeader(bs, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.quant_type);             BitstreamWriteVolHeader(bs, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.quant_type);
2247             } */          }
2248            */
2249    
2250          frame->coding_type = B_VOP;          frame->coding_type = B_VOP;
2251    
# Line 2160  Line 2258 
2258          frame->sStat.iMvSum = 0;          frame->sStat.iMvSum = 0;
2259          frame->sStat.iMvCount = 0;          frame->sStat.iMvCount = 0;
2260          frame->sStat.kblks = frame->sStat.mblks = frame->sStat.ublks = 0;          frame->sStat.kblks = frame->sStat.mblks = frame->sStat.ublks = 0;
2261            frame->sStat.iblks = frame->sStat.qblks = 0;
2262    
2263    
2264          for (y = 0; y < pEnc->mbParam.mb_height; y++) {          for (y = 0; y < pEnc->mbParam.mb_height; y++) {
# Line 2167  Line 2266 
2266                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];
2267                          int direction = pEnc->mbParam.global & XVID_ALTERNATESCAN ? 2 : 0;                          int direction = pEnc->mbParam.global & XVID_ALTERNATESCAN ? 2 : 0;
2268    
2269                          // decoder ignores mb when refence block is INTER(0,0), CBP=0                          /* decoder ignores mb when refence block is INTER(0,0), CBP=0 */
2270                          if (mb->mode == MODE_NOT_CODED) {                          if (mb->mode == MODE_NOT_CODED) {
2271                                  //mb->mvs[0].x = mb->mvs[0].y = mb->cbp = 0;                                  /* mb->mvs[0].x = mb->mvs[0].y = mb->cbp = 0; */
2272                                  continue;                                  continue;
2273                          }                          }
2274    
2275                          if (mb->mode != MODE_DIRECT_NONE_MV) {                          if (mb->mode != MODE_DIRECT_NONE_MV) {
2276                                  MBMotionCompensationBVOP(&pEnc->mbParam, mb, x, y, &frame->image,                                  MBMotionCompensationBVOP(&pEnc->mbParam, mb, x, y, &frame->image,
2277                                                                           f_ref, &pEnc->f_refh, &pEnc->f_refv,                                                                           f_ref, &pEnc->vInterH, &pEnc->vInterV,
2278                                                                           &pEnc->f_refhv, b_ref, &pEnc->vInterH,                                                                           &pEnc->vInterHV, b_ref, &pEnc->f_refh,
2279                                                                           &pEnc->vInterV, &pEnc->vInterHV,                                                                           &pEnc->f_refv, &pEnc->f_refhv,
2280                                                                           dct_codes);                                                                           dct_codes);
2281    
2282                                  if (mb->mode == MODE_DIRECT_NO4V) mb->mode = MODE_DIRECT;                                  if (mb->mode == MODE_DIRECT_NO4V) mb->mode = MODE_DIRECT;
# Line 2188  Line 2287 
2287    
2288                                  if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0)                                  if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0)
2289                                          && (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) {                                          && (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) {
2290                                          mb->mode = MODE_DIRECT_NONE_MV; // skipped                                          mb->mode = MODE_DIRECT_NONE_MV; /* skipped */
2291                                  }                                  }
2292                          }                          }
2293    
# Line 2204  Line 2303 
2303    
2304          emms();          emms();
2305    
2306          // TODO: dynamic fcode/bcode ???          /* TODO: dynamic fcode/bcode ??? */
2307    
2308          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
2309    

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.99.2.1

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