[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.95.2.14, Wed Mar 26 11:01:03 2003 UTC revision 1.95.2.15, Wed Mar 26 14:56:10 2003 UTC
# Line 181  Line 181 
181          }          }
182      }      }
183    
184      if ((pEnc->mbParam.global_flags & XVID_EXTRASTATS_ENABLE) ||      if ((pEnc->mbParam.global_flags & XVID_GLOBAL_EXTRASTATS_ENABLE) ||
185          (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {          (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
186          pEnc->mbParam.plugin_flags |= XVID_REQORIGINAL; /* psnr calculation requires the original */          pEnc->mbParam.plugin_flags |= XVID_REQORIGINAL; /* psnr calculation requires the original */
187      }      }
# Line 683  Line 683 
683              data.original.stride[2] = pEnc->mbParam.edged_width/2;              data.original.stride[2] = pEnc->mbParam.edged_width/2;
684          }          }
685    
686          if ((frame->vol_flags & XVID_EXTRASTATS) ||          if ((frame->vol_flags & XVID_VOL_EXTRASTATS) ||
687              (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {              (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
688    
689                          data.sse_y =                          data.sse_y =
# Line 855  Line 855 
855                  if (image_input                  if (image_input
856                          (&q->image, pEnc->mbParam.width, pEnc->mbParam.height,                          (&q->image, pEnc->mbParam.width, pEnc->mbParam.height,
857                          pEnc->mbParam.edged_width, (uint8_t**)xFrame->input.plane, xFrame->input.stride,                          pEnc->mbParam.edged_width, (uint8_t**)xFrame->input.plane, xFrame->input.stride,
858                          xFrame->input.csp, xFrame->vol_flags & XVID_INTERLACING))                          xFrame->input.csp, xFrame->vol_flags & XVID_VOL_INTERLACING))
859                  {                  {
860                          emms();                          emms();
861                          return XVID_ERR_FORMAT;                          return XVID_ERR_FORMAT;
862                  }                  }
863                  stop_conv_timer();                  stop_conv_timer();
864    
865                  if ((xFrame->vop_flags & XVID_CHROMAOPT)) {                  if ((xFrame->vop_flags & XVID_VOP_CHROMAOPT)) {
866                          image_chroma_optimize(&q->image,                          image_chroma_optimize(&q->image,
867                                  pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);                                  pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
868                  }                  }
# Line 919  Line 919 
919                     indentical to the future-referece frame.                     indentical to the future-referece frame.
920                  */                  */
921    
922                  if ((pEnc->mbParam.global_flags & XVID_PACKED && pEnc->bframenum_tail > 0)) {                  if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED && pEnc->bframenum_tail > 0)) {
923                          int tmp;                          int tmp;
924                          int bits;                          int bits;
925    
# Line 961  Line 961 
961                  if (xFrame->input.csp == XVID_CSP_NULL) /* no futher input */                  if (xFrame->input.csp == XVID_CSP_NULL) /* no futher input */
962                  {                  {
963    
964              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {              if (!(pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->mbParam.max_bframes > 0) {
965                  call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);                  call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
966              }              }
967    
# Line 1015  Line 1015 
1015          pEnc->current->bcode = pEnc->mbParam.m_fcode;          pEnc->current->bcode = pEnc->mbParam.m_fcode;
1016    
1017    
1018      if ((xFrame->vop_flags & XVID_CHROMAOPT)) {      if ((xFrame->vop_flags & XVID_VOP_CHROMAOPT)) {
1019              image_chroma_optimize(&pEnc->current->image,              image_chroma_optimize(&pEnc->current->image,
1020                      pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);                      pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
1021      }      }
# Line 1043  Line 1043 
1043                                          &pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval,                                          &pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval,
1044                                          pEnc->iFrameNum, pEnc->bframenum_tail);                                          pEnc->iFrameNum, pEnc->bframenum_tail);
1045    
1046              if (type == B_VOP && !(pEnc->current->vop_flags & XVID_DYNAMIC_BFRAMES)) {              if (type == B_VOP && !(pEnc->current->vop_flags & XVID_VOP_DYNAMIC_BFRAMES)) {
1047                  type = P_VOP;   /* disable dynamic bframes */                  type = P_VOP;   /* disable dynamic bframes */
1048              }              }
1049                  }                  }
# Line 1060  Line 1060 
1060    
1061          pEnc->iFrameNum++;          pEnc->iFrameNum++;
1062    
1063          if ((pEnc->current->vop_flags & XVID_DEBUG)) {          if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) {
1064                  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,
1065                          "%i  st:%i  if:%i", pEnc->current->frame_num, pEnc->current->stamp, pEnc->iFrameNum);                          "%i  st:%i  if:%i", pEnc->current->frame_num, pEnc->current->stamp, pEnc->iFrameNum);
1066          }          }
# Line 1070  Line 1070 
1070       * (we dont encode here, rather we store the frame in the bframes queue, to be encoded later)       * (we dont encode here, rather we store the frame in the bframes queue, to be encoded later)
1071           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1072          if (type == B_VOP) {          if (type == B_VOP) {
1073                  if ((pEnc->current->vop_flags & XVID_DEBUG)) {                  if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) {
1074                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");
1075                  }                  }
1076    
# Line 1101  Line 1101 
1101      }      }
1102    
1103      /* for unpacked bframes, output the stats for the last encoded frame */      /* for unpacked bframes, output the stats for the last encoded frame */
1104      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)      if (!(pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0)
1105      {      {
1106          if (pEnc->current->stamp > 0) {          if (pEnc->current->stamp > 0) {
1107              call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);              call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
# Line 1115  Line 1115 
1115       * if the frame prior to an iframe is scheduled as a bframe, we must change it to a pframe       * if the frame prior to an iframe is scheduled as a bframe, we must change it to a pframe
1116       * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */       * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1117    
1118      if (type == I_VOP && (pEnc->mbParam.global_flags & XVID_CLOSED_GOP) && pEnc->bframenum_tail > 0) {      if (type == I_VOP && (pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP) && pEnc->bframenum_tail > 0) {
1119    
1120                  // place this frame back on the encoding-queue (head)                  // place this frame back on the encoding-queue (head)
1121                  // we will deal with it next time                  // we will deal with it next time
# Line 1131  Line 1131 
1131                  pEnc->bframenum_tail--;                  pEnc->bframenum_tail--;
1132                  SWAP(FRAMEINFO*, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);                  SWAP(FRAMEINFO*, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);
1133    
1134                  if ((pEnc->current->vop_flags & XVID_DEBUG)) {                  if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) {
1135                          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");
1136                  }                  }
1137    
# Line 1151  Line 1151 
1151                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
1152                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
1153    
1154                  if ((pEnc->current->vop_flags & XVID_DEBUG)) {                  if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) {
1155                          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");
1156                  }                  }
1157    
# Line 1159  Line 1159 
1159                  /* ---- update vol flags at IVOP ----------- */                  /* ---- update vol flags at IVOP ----------- */
1160                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;
1161    
1162          if ((pEnc->mbParam.vol_flags & XVID_MPEGQUANT)) {          if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {
1163                          if (frame->quant_intra_matrix != NULL)                          if (frame->quant_intra_matrix != NULL)
1164                                  set_intra_matrix(frame->quant_intra_matrix);                                  set_intra_matrix(frame->quant_intra_matrix);
1165                          if (frame->quant_inter_matrix != NULL)                          if (frame->quant_inter_matrix != NULL)
# Line 1168  Line 1168 
1168    
1169          /* prevent vol/vop misuse */          /* prevent vol/vop misuse */
1170    
1171          if (!(pEnc->current->vol_flags & XVID_REDUCED_ENABLE))          if (!(pEnc->current->vol_flags & XVID_VOL_REDUCED_ENABLE))
1172              pEnc->current->vop_flags &= ~XVID_REDUCED;              pEnc->current->vop_flags &= ~XVID_VOP_REDUCED;
1173    
1174          if (!(pEnc->current->vol_flags & XVID_INTERLACING))          if (!(pEnc->current->vol_flags & XVID_VOL_INTERLACING))
1175              pEnc->current->vop_flags &= ~(XVID_TOPFIELDFIRST|XVID_ALTERNATESCAN);              pEnc->current->vop_flags &= ~(XVID_VOP_TOPFIELDFIRST|XVID_VOP_ALTERNATESCAN);
1176    
1177                  /* ^^^------------------------ */                  /* ^^^------------------------ */
1178    
# Line 1194  Line 1194 
1194                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
1195                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
1196    
1197                  if ((pEnc->current->vop_flags & XVID_DEBUG)) {                  if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) {
1198                          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");
1199                  }                  }
1200    
# Line 1216  Line 1216 
1216      pEnc->flush_bframes = 1;      pEnc->flush_bframes = 1;
1217    
1218          /* packed & queued_bframes: dont bother outputting stats, we do so after the flush */          /* packed & queued_bframes: dont bother outputting stats, we do so after the flush */
1219          if ((pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0) {          if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) {
1220                  goto repeat;                  goto repeat;
1221          }          }
1222    
1223      /* packed or no-bframes: output stats */      /* packed or no-bframes: output stats */
1224      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0) {      if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) || pEnc->mbParam.max_bframes == 0) {
1225          call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);          call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
1226          }          }
1227    
# Line 1290  Line 1290 
1290    
1291          uint16_t x, y;          uint16_t x, y;
1292    
1293          if ((pEnc->current->vol_flags & XVID_REDUCED_ENABLE))          if ((pEnc->current->vol_flags & XVID_VOL_REDUCED_ENABLE))
1294          {          {
1295                  mb_width = (pEnc->mbParam.width + 31) / 32;                  mb_width = (pEnc->mbParam.width + 31) / 32;
1296                  mb_height = (pEnc->mbParam.height + 31) / 32;                  mb_height = (pEnc->mbParam.height + 31) / 32;
# Line 1336  Line 1336 
1336                          stop_prediction_timer();                          stop_prediction_timer();
1337    
1338                          start_timer();                          start_timer();
1339                          if (pEnc->current->vop_flags & XVID_GREYSCALE)                          if (pEnc->current->vop_flags & XVID_VOP_GREYSCALE)
1340                          {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */                          {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1341                                  qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */                                  qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */
1342                                  qcoeff[5*64+0]=0;                                  qcoeff[5*64+0]=0;
# Line 1345  Line 1345 
1345                          stop_coding_timer();                          stop_coding_timer();
1346                  }                  }
1347    
1348          if ((pEnc->current->vop_flags & XVID_REDUCED))          if ((pEnc->current->vop_flags & XVID_VOP_REDUCED))
1349          {          {
1350                  image_deblock_rrv(&pEnc->current->image, pEnc->mbParam.edged_width,                  image_deblock_rrv(&pEnc->current->image, pEnc->mbParam.edged_width,
1351                          pEnc->current->mbs, mb_width, mb_height, pEnc->mbParam.mb_width,                          pEnc->current->mbs, mb_width, mb_height, pEnc->mbParam.mb_width,
# Line 1354  Line 1354 
1354          emms();          emms();
1355    
1356          /* for divx5 compatibility, we must always pad between the packed p and b frames */          /* for divx5 compatibility, we must always pad between the packed p and b frames */
1357          if ((pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)          if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0)
1358                  BitstreamPadAlways(bs);                  BitstreamPadAlways(bs);
1359          else          else
1360                  BitstreamPad(bs);                  BitstreamPad(bs);
# Line 1400  Line 1400 
1400          /* IMAGE *pCurrent = &pEnc->current->image; */          /* IMAGE *pCurrent = &pEnc->current->image; */
1401          IMAGE *pRef = &pEnc->reference->image;          IMAGE *pRef = &pEnc->reference->image;
1402    
1403          if ((pEnc->current->vop_flags & XVID_REDUCED))          if ((pEnc->current->vop_flags & XVID_VOP_REDUCED))
1404          {          {
1405                  mb_width = (pEnc->mbParam.width + 31) / 32;                  mb_width = (pEnc->mbParam.width + 31) / 32;
1406                  mb_height = (pEnc->mbParam.height + 31) / 32;                  mb_height = (pEnc->mbParam.height + 31) / 32;
# Line 1422  Line 1422 
1422          else          else
1423                  iLimit = mb_width * mb_height + 1;                  iLimit = mb_width * mb_height + 1;
1424    
1425          if ((pEnc->current->vop_flags & XVID_HALFPEL)) {          if ((pEnc->current->vop_flags & XVID_VOP_HALFPEL)) {
1426                  start_timer();                  start_timer();
1427                  image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV,                  image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV,
1428                                                    &pEnc->vInterHV, pEnc->mbParam.edged_width,                                                    &pEnc->vInterHV, pEnc->mbParam.edged_width,
1429                                                    pEnc->mbParam.edged_height,                                                    pEnc->mbParam.edged_height,
1430                                                    (pEnc->mbParam.vol_flags & XVID_QUARTERPEL),                                                    (pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL),
1431                                                    pEnc->current->rounding_type);                                                    pEnc->current->rounding_type);
1432                  stop_inter_timer();                  stop_inter_timer();
1433          }          }
# Line 1450  Line 1450 
1450    
1451          if (bIntra == 1) return FrameCodeI(pEnc, bs);          if (bIntra == 1) return FrameCodeI(pEnc, bs);
1452    
1453          if ( ( pEnc->current->vol_flags & XVID_GMC )          if ( ( pEnc->current->vol_flags & XVID_VOL_GMC )
1454                  && ( (pEnc->current->warp.duv[1].x != 0) || (pEnc->current->warp.duv[1].y != 0) ) )                  && ( (pEnc->current->warp.duv[1].x != 0) || (pEnc->current->warp.duv[1].y != 0) ) )
1455          {          {
1456                  pEnc->current->coding_type = S_VOP;                  pEnc->current->coding_type = S_VOP;
# Line 1462  Line 1462 
1462                  generate_GMCimage(&pEnc->current->gmc_data, &pEnc->reference->image,                  generate_GMCimage(&pEnc->current->gmc_data, &pEnc->reference->image,
1463                                  pEnc->mbParam.mb_width, pEnc->mbParam.mb_height,                                  pEnc->mbParam.mb_width, pEnc->mbParam.mb_height,
1464                                  pEnc->mbParam.edged_width, pEnc->mbParam.edged_width/2,                                  pEnc->mbParam.edged_width, pEnc->mbParam.edged_width/2,
1465                                  pEnc->mbParam.m_fcode, (pEnc->mbParam.vol_flags & XVID_QUARTERPEL), 0,                                  pEnc->mbParam.m_fcode, (pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0,
1466                                  pEnc->current->rounding_type, pEnc->current->mbs, &pEnc->vGMC);                                  pEnc->current->rounding_type, pEnc->current->mbs, &pEnc->vGMC);
1467    
1468          }          }
# Line 1511  Line 1511 
1511                                          pEnc->vGMC.y + 16*y*pEnc->mbParam.edged_width + 16*x,                                          pEnc->vGMC.y + 16*y*pEnc->mbParam.edged_width + 16*x,
1512                                          pEnc->mbParam.edged_width, 65536);                                          pEnc->mbParam.edged_width, 65536);
1513    
1514                                  if (pEnc->current->motion_flags & PMV_CHROMA16) {                                  if (pEnc->current->motion_flags & XVID_ME_CHROMA16) {
1515                                          iSAD += sad8(pEnc->current->image.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x,                                          iSAD += sad8(pEnc->current->image.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x,
1516                                          pEnc->vGMC.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, pEnc->mbParam.edged_width/2);                                          pEnc->vGMC.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, pEnc->mbParam.edged_width/2);
1517    
# Line 1521  Line 1521 
1521    
1522                                  if (iSAD <= pMB->sad16) {               /* mode decision GMC */                                  if (iSAD <= pMB->sad16) {               /* mode decision GMC */
1523    
1524                                          if ((pEnc->mbParam.vol_flags & XVID_QUARTERPEL))                                          if ((pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL))
1525                                                  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;
1526                                          else                                          else
1527                                                  pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv;                                                  pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv;
# Line 1544  Line 1544 
1544                                                                   dct_codes, pEnc->mbParam.width,                                                                   dct_codes, pEnc->mbParam.width,
1545                                                                   pEnc->mbParam.height,                                                                   pEnc->mbParam.height,
1546                                                                   pEnc->mbParam.edged_width,                                                                   pEnc->mbParam.edged_width,
1547                                                                   (pEnc->current->vol_flags & XVID_QUARTERPEL),                                                                   (pEnc->current->vol_flags & XVID_VOL_QUARTERPEL),
1548                                                                   (pEnc->current->vop_flags & XVID_REDUCED),                                                                   (pEnc->current->vop_flags & XVID_VOP_REDUCED),
1549                                                                   pEnc->current->rounding_type);                                                                   pEnc->current->rounding_type);
1550    
1551                          stop_comp_timer();                          stop_comp_timer();
# Line 1580  Line 1580 
1580                          if (pEnc->current->coding_type == S_VOP)                          if (pEnc->current->coding_type == S_VOP)
1581                                  skip_possible &= (pMB->mcsel == 1);                                  skip_possible &= (pMB->mcsel == 1);
1582                          else if (pEnc->current->coding_type == P_VOP) {                          else if (pEnc->current->coding_type == P_VOP) {
1583                                  if ((pEnc->mbParam.vol_flags & XVID_QUARTERPEL))                                  if ((pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL))
1584                                          skip_possible &= ( (pMB->qmvs[0].x == 0) && (pMB->qmvs[0].y == 0) );                                          skip_possible &= ( (pMB->qmvs[0].x == 0) && (pMB->qmvs[0].y == 0) );
1585                                  else                                  else
1586                                          skip_possible &= ( (pMB->mvs[0].x == 0) && (pMB->mvs[0].y == 0) );                                          skip_possible &= ( (pMB->mvs[0].x == 0) && (pMB->mvs[0].y == 0) );
# Line 1607  Line 1607 
1607                                          }                                          }
1608    
1609                                          if (!bSkip) {   /* no SKIP, but trivial block */                                          if (!bSkip) {   /* no SKIP, but trivial block */
1610                                                  if((pEnc->mbParam.vol_flags & XVID_QUARTERPEL)) {                                                  if((pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL)) {
1611                                                          VECTOR predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);                                                          VECTOR predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);
1612                                                          pMB->pmvs[0].x = - predMV.x;                                                          pMB->pmvs[0].x = - predMV.x;
1613                                                          pMB->pmvs[0].y = - predMV.y;                                                          pMB->pmvs[0].y = - predMV.y;
# Line 1634  Line 1634 
1634                          }                          }
1635                          /* ordinary case: normal coded INTER/INTER4V block */                          /* ordinary case: normal coded INTER/INTER4V block */
1636    
1637                          if ((pEnc->current->vop_flags & XVID_GREYSCALE))                          if ((pEnc->current->vop_flags & XVID_VOP_GREYSCALE))
1638                          {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */                          {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1639                                  qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */                                  qcoeff[4*64+0]=0;               /* zero, because DC for INTRA MBs DC value is saved */
1640                                  qcoeff[5*64+0]=0;                                  qcoeff[5*64+0]=0;
1641                          }                          }
1642    
1643                          if((pEnc->mbParam.vol_flags & XVID_QUARTERPEL)) {                          if((pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL)) {
1644                                  VECTOR predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);                                  VECTOR predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0);
1645                                  pMB->pmvs[0].x = pMB->qmvs[0].x - predMV.x;                                  pMB->pmvs[0].x = pMB->qmvs[0].x - predMV.x;
1646                                  pMB->pmvs[0].y = pMB->qmvs[0].y - predMV.y;                                  pMB->pmvs[0].y = pMB->qmvs[0].y - predMV.y;
# Line 1657  Line 1657 
1657                          {       int k;                          {       int k;
1658                                  for (k=1;k<4;k++)                                  for (k=1;k<4;k++)
1659                                  {                                  {
1660                                          if((pEnc->mbParam.vol_flags & XVID_QUARTERPEL)) {                                          if((pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL)) {
1661                                                  VECTOR predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, k);                                                  VECTOR predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, k);
1662                                                  pMB->pmvs[k].x = pMB->qmvs[k].x - predMV.x;                                                  pMB->pmvs[k].x = pMB->qmvs[k].x - predMV.x;
1663                                                  pMB->pmvs[k].y = pMB->qmvs[k].y - predMV.y;                                                  pMB->pmvs[k].y = pMB->qmvs[k].y - predMV.y;
# Line 1678  Line 1678 
1678                  }                  }
1679          }          }
1680    
1681          if ((pEnc->current->vop_flags & XVID_REDUCED))          if ((pEnc->current->vop_flags & XVID_VOP_REDUCED))
1682          {          {
1683                  image_deblock_rrv(&pEnc->current->image, pEnc->mbParam.edged_width,                  image_deblock_rrv(&pEnc->current->image, pEnc->mbParam.edged_width,
1684                          pEnc->current->mbs, mb_width, mb_height, pEnc->mbParam.mb_width,                          pEnc->current->mbs, mb_width, mb_height, pEnc->mbParam.mb_width,
# Line 1700  Line 1700 
1700          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);          iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode);
1701    
1702          if ((fSigma > iSearchRange / 3)          if ((fSigma > iSearchRange / 3)
1703          && (pEnc->mbParam.m_fcode <= (3 +  (pEnc->mbParam.vol_flags & XVID_QUARTERPEL?1:0)  ))) /* maximum search range 128 */          && (pEnc->mbParam.m_fcode <= (3 +  (pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL?1:0)  )))     /* maximum search range 128 */
1704          {          {
1705                  pEnc->mbParam.m_fcode++;                  pEnc->mbParam.m_fcode++;
1706                  iSearchRange *= 2;                  iSearchRange *= 2;
1707          } else if ((fSigma < iSearchRange / 6)          } else if ((fSigma < iSearchRange / 6)
1708                             && (pEnc->fMvPrevSigma >= 0)                             && (pEnc->fMvPrevSigma >= 0)
1709                             && (pEnc->fMvPrevSigma < iSearchRange / 6)                             && (pEnc->fMvPrevSigma < iSearchRange / 6)
1710                             && (pEnc->mbParam.m_fcode >= (2 + (pEnc->mbParam.vol_flags & XVID_QUARTERPEL?1:0) )))        /* minimum search range 16 */                             && (pEnc->mbParam.m_fcode >= (2 + (pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL?1:0) )))    /* minimum search range 16 */
1711          {          {
1712                  pEnc->mbParam.m_fcode--;                  pEnc->mbParam.m_fcode--;
1713                  iSearchRange /= 2;                  iSearchRange /= 2;
# Line 1755  Line 1755 
1755          */          */
1756    
1757          /* for divx5 compatibility, we must always pad between the packed p and b frames */          /* for divx5 compatibility, we must always pad between the packed p and b frames */
1758          if ((pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)          if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0)
1759                  BitstreamPadAlways(bs);                  BitstreamPadAlways(bs);
1760          else          else
1761                  BitstreamPad(bs);                  BitstreamPad(bs);
# Line 1786  Line 1786 
1786                  fprintf(fp,"Y=%3d   X=%3d   MB=%2d   CBP=%02X\n",y,x,mb->mode,mb->cbp); \                  fprintf(fp,"Y=%3d   X=%3d   MB=%2d   CBP=%02X\n",y,x,mb->mode,mb->cbp); \
1787          }          }
1788    
1789          /* XXX: pEnc->current->global_flags &= ~XVID_REDUCED;  reduced resoltion not yet supported */          /* XXX: pEnc->current->global_flags &= ~XVID_VOP_REDUCED;  reduced resoltion not yet supported */
1790    
1791          if (!first){          if (!first){
1792                  fp=fopen("C:\\XVIDDBGE.TXT","w");                  fp=fopen("C:\\XVIDDBGE.TXT","w");
# Line 1802  Line 1802 
1802          start_timer();          start_timer();
1803          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,
1804                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
1805                                            (pEnc->mbParam.vol_flags & XVID_QUARTERPEL), 0);                                            (pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0);
1806          stop_inter_timer();          stop_inter_timer();
1807    
1808          /* backward */          /* backward */
# Line 1812  Line 1812 
1812          start_timer();          start_timer();
1813          image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,          image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1814                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,                                            pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
1815                                            (pEnc->mbParam.vol_flags & XVID_QUARTERPEL), 0);                                            (pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0);
1816          stop_inter_timer();          stop_inter_timer();
1817    
1818          start_timer();          start_timer();
# Line 1849  Line 1849 
1849          for (y = 0; y < pEnc->mbParam.mb_height; y++) {          for (y = 0; y < pEnc->mbParam.mb_height; y++) {
1850                  for (x = 0; x < pEnc->mbParam.mb_width; x++) {                  for (x = 0; x < pEnc->mbParam.mb_width; x++) {
1851                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];                          MACROBLOCK * const mb = &frame->mbs[x + y * pEnc->mbParam.mb_width];
1852                          int direction = frame->vop_flags & XVID_ALTERNATESCAN ? 2 : 0;                          int direction = frame->vop_flags & XVID_VOP_ALTERNATESCAN ? 2 : 0;
1853    
1854                          /* decoder ignores mb when refence block is INTER(0,0), CBP=0 */                          /* decoder ignores mb when refence block is INTER(0,0), CBP=0 */
1855                          if (mb->mode == MODE_NOT_CODED) {                          if (mb->mode == MODE_NOT_CODED) {

Legend:
Removed from v.1.95.2.14  
changed lines
  Added in v.1.95.2.15

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