[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.35, Sat Jan 11 14:59:23 2003 UTC revision 1.76.2.44, Sat Feb 15 05:57:14 2003 UTC
# Line 229  Line 229 
229    
230          pEnc->bitrate = pParam->rc_bitrate;          pEnc->bitrate = pParam->rc_bitrate;
231    
232          pEnc->iFrameNum = 0;          pEnc->iFrameNum = -1;
233          pEnc->mbParam.iMaxKeyInterval = pParam->max_key_interval;          pEnc->mbParam.iMaxKeyInterval = pParam->max_key_interval;
234    
235          /* try to allocate frame memory */          /* try to allocate frame memory */
# Line 254  Line 254 
254    
255          /* try to allocate image memory */          /* try to allocate image memory */
256    
257  #ifdef _DEBUG_PSNR          if (pParam->global & XVID_GLOBAL_EXTRASTATS)
258          image_null(&pEnc->sOriginal);          image_null(&pEnc->sOriginal);
 #endif  
259    
260          image_null(&pEnc->f_refh);          image_null(&pEnc->f_refh);
261          image_null(&pEnc->f_refv);          image_null(&pEnc->f_refv);
# Line 270  Line 269 
269          image_null(&pEnc->vInterHV);          image_null(&pEnc->vInterHV);
270          image_null(&pEnc->vInterHVf);          image_null(&pEnc->vInterHVf);
271    
272  #ifdef _DEBUG_PSNR          if (pParam->global & XVID_GLOBAL_EXTRASTATS)
273          if (image_create          {       if (image_create
274                  (&pEnc->sOriginal, pEnc->mbParam.edged_width,                  (&pEnc->sOriginal, pEnc->mbParam.edged_width,
275                   pEnc->mbParam.edged_height) < 0)                   pEnc->mbParam.edged_height) < 0)
276                  goto xvid_err_memory3;                  goto xvid_err_memory3;
277  #endif          }
278    
279          if (image_create          if (image_create
280                  (&pEnc->f_refh, pEnc->mbParam.edged_width,                  (&pEnc->f_refh, pEnc->mbParam.edged_width,
# Line 326  Line 325 
325                  goto xvid_err_memory3;                  goto xvid_err_memory3;
326    
327    
         /* B Frames specific init */  
328    
329          pEnc->mbParam.global = pParam->global;          pEnc->mbParam.global = pParam->global;
330    
331            /* B Frames specific init */
332          pEnc->mbParam.max_bframes = pParam->max_bframes;          pEnc->mbParam.max_bframes = pParam->max_bframes;
333          pEnc->mbParam.bquant_ratio = pParam->bquant_ratio;          pEnc->mbParam.bquant_ratio = pParam->bquant_ratio;
334          pEnc->mbParam.bquant_offset = pParam->bquant_offset;          pEnc->mbParam.bquant_offset = pParam->bquant_offset;
# Line 464  Line 464 
464          }          }
465    
466    xvid_err_memory3:    xvid_err_memory3:
467  #ifdef _DEBUG_PSNR  
468          image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width,          if (pEnc->mbParam.global & XVID_GLOBAL_EXTRASTATS)
469            {       image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width,
470                                    pEnc->mbParam.edged_height);                                    pEnc->mbParam.edged_height);
471  #endif          }
472    
473          image_destroy(&pEnc->f_refh, pEnc->mbParam.edged_width,          image_destroy(&pEnc->f_refh, pEnc->mbParam.edged_width,
474                                    pEnc->mbParam.edged_height);                                    pEnc->mbParam.edged_height);
# Line 583  Line 584 
584          image_destroy(&pEnc->f_refhv, pEnc->mbParam.edged_width,          image_destroy(&pEnc->f_refhv, pEnc->mbParam.edged_width,
585                                    pEnc->mbParam.edged_height);                                    pEnc->mbParam.edged_height);
586    
587  #ifdef _DEBUG_PSNR          if (pEnc->mbParam.global & XVID_GLOBAL_EXTRASTATS)
588          image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width,          {       image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width,
589                                    pEnc->mbParam.edged_height);                                    pEnc->mbParam.edged_height);
590  #endif          }
591    
592          /* Encoder structure */          /* Encoder structure */
593    
# Line 630  Line 631 
631                  return;                  return;
632          stop_conv_timer();          stop_conv_timer();
633    
634            if ((pFrame->general & XVID_CHROMAOPT)) {
635                    image_chroma_optimize(&pEnc->queue[pEnc->queue_tail],
636                            pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
637            }
638    
639          pEnc->queue_size++;          pEnc->queue_size++;
640          pEnc->queue_tail =  (pEnc->queue_tail + 1) % pEnc->mbParam.max_bframes;          pEnc->queue_tail =  (pEnc->queue_tail + 1) % pEnc->mbParam.max_bframes;
641  }  }
# Line 689  Line 695 
695          int input_valid = 1;          int input_valid = 1;
696          int bframes_count = 0;          int bframes_count = 0;
697    
 #ifdef _DEBUG_PSNR  
         float psnr;  
         char temp[128];  
 #endif  
   
698          ENC_CHECK(pEnc);          ENC_CHECK(pEnc);
699          ENC_CHECK(pFrame);          ENC_CHECK(pFrame);
700          ENC_CHECK(pFrame->image);          ENC_CHECK(pFrame->image);
# Line 730  Line 731 
731                          FrameCodeP(pEnc, &bs, &bits, 1, 0);                          FrameCodeP(pEnc, &bs, &bits, 1, 0);
732                          bframes_count = 0;                          bframes_count = 0;
733    
734                          BitstreamPad(&bs);                          BitstreamPadAlways(&bs);
735                          pFrame->length = BitstreamLength(&bs);                          pFrame->length = BitstreamLength(&bs);
736                          pFrame->intra = 0;                          pFrame->intra = 0;
737    
738    
739                          emms();                          emms();
740    
741                            if (pResult) {
742                                    pResult->quant = pEnc->current->quant;
743                                    pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8);
744                                    pResult->kblks = pEnc->current->sStat.kblks;
745                                    pResult->mblks = pEnc->current->sStat.mblks;
746                                    pResult->ublks = pEnc->current->sStat.ublks;
747                            }
748    
749                          return XVID_ERR_OK;                          return XVID_ERR_OK;
750                  }                  }
751    
# Line 747  Line 757 
757                  FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs, &bits);                  FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs, &bits);
758                  pEnc->bframenum_head++;                  pEnc->bframenum_head++;
759    
760                  BitstreamPad(&bs);                  BitstreamPadAlways(&bs);
761                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
762                  pFrame->intra = 2;                  pFrame->intra = 2;
763    
764                    if (pResult) {
765                            pResult->quant = pEnc->current->quant;
766                            pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8);
767                            pResult->kblks = pEnc->current->sStat.kblks;
768                            pResult->mblks = pEnc->current->sStat.mblks;
769                            pResult->ublks = pEnc->current->sStat.ublks;
770                    }
771    
772                  if (input_valid)                  if (input_valid)
773                          queue_image(pEnc, pFrame);                          queue_image(pEnc, pFrame);
774    
# Line 776  Line 794 
794                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
795                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
796    
                         BitstreamPad(&bs);  
797    
798                          tmp = pEnc->current->seconds;                          tmp = pEnc->current->seconds;
799                          pEnc->current->seconds = 0; /* force time_base = 0 */                          pEnc->current->seconds = 0; /* force time_base = 0 */
800    
801                          BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);                          BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);
802                          pEnc->current->seconds = tmp;                          pEnc->current->seconds = tmp;
803    
804                            BitstreamPadAlways(&bs);
805                          pFrame->length = BitstreamLength(&bs);                          pFrame->length = BitstreamLength(&bs);
806                          pFrame->intra = 4;                          pFrame->intra = 4;
807    
808                            if (pResult) {
809                                    pResult->quant = pEnc->current->quant;
810                                    pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8);
811                                    pResult->kblks = pEnc->current->sStat.kblks;
812                                    pResult->mblks = pEnc->current->sStat.mblks;
813                                    pResult->ublks = pEnc->current->sStat.ublks;
814                            }
815    
816                          if (input_valid)                          if (input_valid)
817                                  queue_image(pEnc, pFrame);                                  queue_image(pEnc, pFrame);
818    
# Line 828  Line 855 
855                  }                  }
856                  stop_conv_timer();                  stop_conv_timer();
857    
858                    if ((pFrame->general & XVID_CHROMAOPT)) {
859                            image_chroma_optimize(&pEnc->current->image,
860                                    pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
861                    }
862    
863                  // queue input frame, and dequue next image                  // queue input frame, and dequue next image
864                  if (pEnc->queue_size > 0)                  if (pEnc->queue_size > 0)
865                  {                  {
# Line 859  Line 891 
891                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
892                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
893    
894                          BitstreamPutBits(&bs, 0x7f, 8);                  //      BitstreamPutBits(&bs, 0x7f, 8);
895                          pFrame->intra = 5;                          pFrame->intra = 5;
896    
897                            if (pResult) {
898                                    /*
899                                     * We must decide what to put there because i know some apps
900                                     * are storing statistics about quantizers and just do
901                                     * stats[quant]++ or stats[quant-1]++
902                                     * transcode is one of these app with its 2pass module
903                                     */
904    
905                                    /*
906                                     * For now i prefer 31 than 0 that could lead to a segfault
907                                     * in transcode
908                                     */
909                                    pResult->quant = 31;
910    
911                                    pResult->hlength = 0;
912                                    pResult->kblks = 0;
913                                    pResult->mblks = 0;
914                                    pResult->ublks = 0;
915                            }
916    
917                    } else {
918    
919                            if (pResult) {
920                                    pResult->quant = pEnc->current->quant;
921                                    pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8);
922                                    pResult->kblks = pEnc->current->sStat.kblks;
923                                    pResult->mblks = pEnc->current->sStat.mblks;
924                                    pResult->ublks = pEnc->current->sStat.ublks;
925                            }
926    
927                  }                  }
928    
929                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
930    
931                  emms();                  emms();
932    
933                  return XVID_ERR_OK;                  return XVID_ERR_OK;
934          }          }
935    
# Line 896  Line 961 
961    
962                  inc_frame_num(pEnc);                  inc_frame_num(pEnc);
963    
964  #ifdef _DEBUG_PSNR                  if (pFrame->general & XVID_EXTRASTATS)
965                  image_copy(&pEnc->sOriginal, &pEnc->current->image,                  {       image_copy(&pEnc->sOriginal, &pEnc->current->image,
966                             pEnc->mbParam.edged_width, pEnc->mbParam.height);                             pEnc->mbParam.edged_width, pEnc->mbParam.height);
967  #endif                  }
968    
969                  emms();                  emms();
970    
# Line 1001  Line 1066 
1066                          }                          }
1067                          FrameCodeP(pEnc, &bs, &bits, 1, 0);                          FrameCodeP(pEnc, &bs, &bits, 1, 0);
1068                          bframes_count = 0;                          bframes_count = 0;
   
1069                          pFrame->intra = 0;                          pFrame->intra = 0;
1070    
1071                  } else {                  } else {
# Line 1025  Line 1089 
1089                   * NB : sequences like "IIBB" decode fine with msfdam but,                   * NB : sequences like "IIBB" decode fine with msfdam but,
1090                   *      go screwy with divx 5.00                   *      go screwy with divx 5.00
1091                   */                   */
1092          } else if (mode == P_VOP || pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) {          } else if (mode == P_VOP || mode == S_VOP || pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) {
1093                  /*                  /*
1094                   * This will be coded as a Predicted Frame                   * This will be coded as a Predicted Frame
1095                   */                   */
# Line 1089  Line 1153 
1153                  goto bvop_loop;                  goto bvop_loop;
1154          }          }
1155    
1156          BitstreamPad(&bs);          BitstreamPadAlways(&bs);
1157          pFrame->length = BitstreamLength(&bs);          pFrame->length = BitstreamLength(&bs);
1158    
1159          if (pResult) {          if (pResult) {
# Line 1098  Line 1162 
1162                  pResult->kblks = pEnc->current->sStat.kblks;                  pResult->kblks = pEnc->current->sStat.kblks;
1163                  pResult->mblks = pEnc->current->sStat.mblks;                  pResult->mblks = pEnc->current->sStat.mblks;
1164                  pResult->ublks = pEnc->current->sStat.ublks;                  pResult->ublks = pEnc->current->sStat.ublks;
         }  
   
         emms();  
1165    
1166  #ifdef _DEBUG_PSNR                  if (pFrame->general & XVID_EXTRASTATS)
1167          psnr =                  {       pResult->sse_y =
1168                  image_psnr(&pEnc->sOriginal, &pEnc->current->image,                                  plane_sse( pEnc->sOriginal.y, pEnc->current->image.y,
1169                                     pEnc->mbParam.edged_width, pEnc->mbParam.width,                                     pEnc->mbParam.edged_width, pEnc->mbParam.width,
1170                                     pEnc->mbParam.height);                                     pEnc->mbParam.height);
1171    
1172          printf("PSNR: %f\n", psnr);                          pResult->sse_u =
1173  //      DEBUG(temp);                                  plane_sse( pEnc->sOriginal.u, pEnc->current->image.u,
1174  #endif                                                     pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
1175                                                       pEnc->mbParam.height/2);
1176    
1177                            pResult->sse_v =
1178                                    plane_sse( pEnc->sOriginal.v, pEnc->current->image.v,
1179                                                       pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
1180                                                       pEnc->mbParam.height/2);
1181                    }
1182            }
1183    
1184            emms();
1185    
1186          if (pFrame->quant == 0) {          if (pFrame->quant == 0) {
1187                  RateControlUpdate(&pEnc->rate_control, pEnc->current->quant,                  RateControlUpdate(&pEnc->rate_control, pEnc->current->quant,
# Line 1145  Line 1216 
1216          uint32_t bits;          uint32_t bits;
1217          uint16_t write_vol_header = 0;          uint16_t write_vol_header = 0;
1218    
 #ifdef _DEBUG_PSNR  
1219          float psnr;          float psnr;
1220          uint8_t temp[128];          uint8_t temp[128];
 #endif  
1221    
1222          start_global_timer();          start_global_timer();
1223    
# Line 1179  Line 1248 
1248                  return XVID_ERR_FORMAT;                  return XVID_ERR_FORMAT;
1249          stop_conv_timer();          stop_conv_timer();
1250    
1251  #ifdef _DEBUG_PSNR          if ((pFrame->general & XVID_CHROMAOPT)) {
1252          image_copy(&pEnc->sOriginal, &pEnc->current->image,                  image_chroma_optimize(&pEnc->current->image,
1253                            pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
1254            }
1255    
1256            if (pFrame->general & XVID_EXTRASTATS)
1257            {       image_copy(&pEnc->sOriginal, &pEnc->current->image,
1258                             pEnc->mbParam.edged_width, pEnc->mbParam.height);                             pEnc->mbParam.edged_width, pEnc->mbParam.height);
1259  #endif          }
1260    
1261          emms();          emms();
1262    
# Line 1259  Line 1333 
1333          }          }
1334    
1335          if (pFrame->intra < 0) {          if (pFrame->intra < 0) {
1336                  if ((pEnc->iFrameNum == 0)                  if ((pEnc->iFrameNum == -1)
1337                          || ((pEnc->mbParam.iMaxKeyInterval > 0)                          || ((pEnc->mbParam.iMaxKeyInterval > 0)
1338                                  && (pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval))) {                                  && (pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval))) {
1339                          pFrame->intra = FrameCodeI(pEnc, &bs, &bits);                          pFrame->intra = FrameCodeI(pEnc, &bs, &bits);
# Line 1275  Line 1349 
1349    
1350          }          }
1351    
1352          BitstreamPutBits(&bs, 0xFFFF, 16);  //      BitstreamPutBits(&bs, 0xFFFF, 16);
1353          BitstreamPutBits(&bs, 0xFFFF, 16);  //      BitstreamPutBits(&bs, 0xFFFF, 16);
1354          BitstreamPad(&bs);          BitstreamPadAlways(&bs);
1355          pFrame->length = BitstreamLength(&bs);          pFrame->length = BitstreamLength(&bs);
1356    
1357          if (pResult) {          if (pResult) {
# Line 1294  Line 1368 
1368                  RateControlUpdate(&pEnc->rate_control, pEnc->current->quant,                  RateControlUpdate(&pEnc->rate_control, pEnc->current->quant,
1369                                                    pFrame->length, pFrame->intra);                                                    pFrame->length, pFrame->intra);
1370          }          }
1371  #ifdef _DEBUG_PSNR          if (pFrame->general & XVID_EXTRASTATS)
1372            {
1373          psnr =          psnr =
1374                  image_psnr(&pEnc->sOriginal, &pEnc->current->image,                  image_psnr(&pEnc->sOriginal, &pEnc->current->image,
1375                                     pEnc->mbParam.edged_width, pEnc->mbParam.width,                                     pEnc->mbParam.edged_width, pEnc->mbParam.width,
1376                                     pEnc->mbParam.height);                                     pEnc->mbParam.height);
1377    
1378          snprintf(temp, 127, "PSNR: %f\n", psnr);          snprintf(temp, 127, "PSNR: %f\n", psnr);
1379  //      DEBUG(temp);          }
 #endif  
1380    
1381          pEnc->iFrameNum++;          pEnc->iFrameNum++;
1382    
# Line 1468  Line 1542 
1542    
1543          if (intra) {          if (intra) {
1544                  if (!hint->rawhints) {                  if (!hint->rawhints) {
1545                          BitstreamPad(&bs);                          BitstreamPadAlways(&bs);
1546                          hint->hintlength = BitstreamLength(&bs);                          hint->hintlength = BitstreamLength(&bs);
1547                  }                  }
1548                  return;                  return;
# Line 1574  Line 1648 
1648          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
1649    
1650          set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);          set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
1651    
1652            BitstreamPadAlways(bs);
1653          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);
1654    
1655          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
# Line 1713  Line 1789 
1789                  generate_GMCimage(&pEnc->current->gmc_data, &pEnc->reference->image,                  generate_GMCimage(&pEnc->current->gmc_data, &pEnc->reference->image,
1790                                  pEnc->mbParam.mb_width, pEnc->mbParam.mb_height,                                  pEnc->mbParam.mb_width, pEnc->mbParam.mb_height,
1791                                  pEnc->mbParam.edged_width, pEnc->mbParam.edged_width/2,                                  pEnc->mbParam.edged_width, pEnc->mbParam.edged_width/2,
1792                                  pEnc->mbParam.m_fcode, 0, 0,                                  pEnc->mbParam.m_fcode, pEnc->mbParam.m_quarterpel, 0,
1793                                  pEnc->current->rounding_type, pEnc->current->mbs, &pEnc->vGMC);                                  pEnc->current->rounding_type, pEnc->current->mbs, &pEnc->vGMC);
1794    
1795          }          }
1796    
1797            set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
1798          if (vol_header)          if (vol_header)
1799                  BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);          {       BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
1800                    BitstreamPadAlways(bs);
1801            }
1802    
         set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);  
1803          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);          BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);
1804    
1805          *pBits = BitstreamPos(bs);          *pBits = BitstreamPos(bs);
# Line 1738  Line 1816 
1816  /* Mode decision: Check, if the block should be INTRA / INTER or GMC-coded */  /* Mode decision: Check, if the block should be INTRA / INTER or GMC-coded */
1817  /* For a start, leave INTRA decision as is, only choose only between INTER/GMC  - gruel, 9.1.2002 */  /* For a start, leave INTRA decision as is, only choose only between INTER/GMC  - gruel, 9.1.2002 */
1818    
   
1819                          bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q);                          bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q);
1820    
1821                          if (bIntra) {                          if (bIntra) {
# Line 1753  Line 1830 
1830                                  pEnc->current->sStat.kblks++;                                  pEnc->current->sStat.kblks++;
1831    
1832                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);
1833                                    stop_coding_timer();
1834                                  continue;                                  continue;
1835                          }                          }
1836    
# Line 1762  Line 1840 
1840                                          pEnc->vGMC.y + 16*y*pEnc->mbParam.edged_width + 16*x,                                          pEnc->vGMC.y + 16*y*pEnc->mbParam.edged_width + 16*x,
1841                                          pEnc->mbParam.edged_width,65536);                                          pEnc->mbParam.edged_width,65536);
1842    
1843                                    if (pEnc->current->motion_flags & PMV_CHROMA16) {
1844                                            iSAD += sad8(pEnc->current->image.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x,
1845                                            pEnc->vGMC.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, pEnc->mbParam.edged_width/2);
1846    
1847                                            iSAD += sad8(pEnc->current->image.v + 8*y*(pEnc->mbParam.edged_width/2) + 8*x,
1848                                            pEnc->vGMC.v + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, pEnc->mbParam.edged_width/2);
1849                                    }
1850    
1851                                  if (iSAD <= pMB->sad16) {               /* mode decision GMC */                                  if (iSAD <= pMB->sad16) {               /* mode decision GMC */
1852    
1853                                          if (pEnc->mbParam.m_quarterpel)                                          if (pEnc->mbParam.m_quarterpel)
1854                                                  pMB->qmvs[0] = pMB->qmvs[1] =pMB->qmvs[2] =pMB->qmvs[3] = pMB->amv;                                                  pMB->qmvs[0] = pMB->qmvs[1] =pMB->qmvs[2] =pMB->qmvs[3] = pMB->amv;
1855                                          else                                          else
# Line 1774  Line 1861 
1861                                  } else {                                  } else {
1862                                          pMB->mcsel = 0;                                          pMB->mcsel = 0;
1863                                  }                                  }
1864                          } else                          } else {
                         {  
1865                                  pMB->mcsel = 0; /* just a precaution */                                  pMB->mcsel = 0; /* just a precaution */
1866                          }                          }
1867    
# Line 1813  Line 1899 
1899                                                                            dct_codes, qcoeff);                                                                            dct_codes, qcoeff);
1900                          }                          }
1901    
   
1902                          if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y ||                          if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y ||
1903                                     pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x ||                                     pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x ||
1904                                     pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) {                                     pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) {
# Line 1826  Line 1911 
1911    
1912                          /* Finished processing the MB, now check if to CODE or SKIP */                          /* Finished processing the MB, now check if to CODE or SKIP */
1913    
1914                          skip_possible = (pMB->cbp == 0) & (pMB->mode == MODE_INTER) &                          skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) &&
1915                                                          (pMB->dquant == NO_CHANGE);                                                          (pMB->dquant == NO_CHANGE);
1916    
1917                          if (pEnc->current->coding_type == S_VOP)                          if (pEnc->current->coding_type == S_VOP)
1918                                  skip_possible &= (pMB->mcsel == 1);                                  skip_possible &= (pMB->mcsel == 1);
1919                          else if (pEnc->current->coding_type == P_VOP) {                          else if (pEnc->current->coding_type == P_VOP) {
1920                                  if (pEnc->mbParam.m_quarterpel)                                  if (pEnc->mbParam.m_quarterpel)
1921                                          skip_possible &= (pMB->qmvs[0].x == 0) & (pMB->qmvs[0].y == 0);                                          skip_possible &= ( (pMB->qmvs[0].x == 0) && (pMB->qmvs[0].y == 0) );
1922                                  else                                  else
1923                                          skip_possible &= (pMB->mvs[0].x == 0) & (pMB->mvs[0].y == 0);                                          skip_possible &= ( (pMB->mvs[0].x == 0) && (pMB->mvs[0].y == 0) );
1924                          }                          }
1925    
1926                          if ( (pMB->mode == MODE_NOT_CODED) || (skip_possible)) {                          if ( (pMB->mode == MODE_NOT_CODED) || (skip_possible)) {
# Line 1873  Line 1958 
1958                                                  pMB->cbp = 0;                                                  pMB->cbp = 0;
1959                                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);                                                  MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);
1960                                                  stop_coding_timer();                                                  stop_coding_timer();
1961    
1962                                                  continue;       /* next MB */                                                  continue;       /* next MB */
1963                                          }                                          }
1964                                  }                                  }
# Line 1922  Line 2008 
2008    
2009                                  }                                  }
2010                          }                          }
2011    
2012                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);                          MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat);
2013                          stop_coding_timer();                          stop_coding_timer();
2014    
2015                  }                  }
2016          }          }
2017    

Legend:
Removed from v.1.76.2.35  
changed lines
  Added in v.1.76.2.44

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