Ticket #514: pic_cropping_bug.patch

File pic_cropping_bug.patch, 3.0 KB (added by bheng, 11 years ago)
  • Lib/TLibDecoder/TDecCAVLC.cpp

     
    13361336#if PIC_CROPPING
    13371337  READ_FLAG(     uiCode, "pic_cropping_flag");                   pcSPS->setPicCroppingFlag ( uiCode ? true : false );
    13381338  if (uiCode != 0)
    1339   {
    1340     READ_UVLC(   uiCode, "pic_crop_left_offset" );               pcSPS->setPicCropLeftOffset( uiCode );
    1341     READ_UVLC(   uiCode, "pic_crop_right_offset" );              pcSPS->setPicCropRightOffset( uiCode );
    1342     READ_UVLC(   uiCode, "pic_crop_top_offset" );                pcSPS->setPicCropTopOffset( uiCode );
    1343     READ_UVLC(   uiCode, "pic_crop_bottom_offset" );             pcSPS->setPicCropBottomOffset( uiCode );
     1339  { 
     1340    UInt  CropUnitX;
     1341    UInt  CropUnitY;
     1342
     1343    // get cropping units based on chroma format
     1344    if(pcSPS->getChromaFormatIdc() == 1) {
     1345      CropUnitX = 2;
     1346      CropUnitY = 2;
     1347    }
     1348    else if(pcSPS->getChromaFormatIdc() == 2) {
     1349      CropUnitX = 2;
     1350      CropUnitY = 1;
     1351    }
     1352    else {
     1353      CropUnitX = 1;
     1354      CropUnitY = 1;
     1355    }
     1356
     1357    READ_UVLC(   uiCode, "pic_crop_left_offset" );               pcSPS->setPicCropLeftOffset( CropUnitX*uiCode );
     1358    READ_UVLC(   uiCode, "pic_crop_right_offset" );              pcSPS->setPicCropRightOffset( CropUnitX*uiCode );
     1359    READ_UVLC(   uiCode, "pic_crop_top_offset" );                pcSPS->setPicCropTopOffset( CropUnitY*uiCode );
     1360    READ_UVLC(   uiCode, "pic_crop_bottom_offset" );             pcSPS->setPicCropBottomOffset( CropUnitY*uiCode );
    13441361  }
    13451362#endif
    13461363
  • Lib/TLibEncoder/TEncCavlc.cpp

     
    391391#if PIC_CROPPING
    392392  WRITE_FLAG( pcSPS->getPicCroppingFlag(),          "pic_cropping_flag" );
    393393  if (pcSPS->getPicCroppingFlag())
    394   {
    395     WRITE_UVLC( pcSPS->getPicCropLeftOffset(),      "pic_crop_left_offset" );
    396     WRITE_UVLC( pcSPS->getPicCropRightOffset(),     "pic_crop_right_offset" );
    397     WRITE_UVLC( pcSPS->getPicCropTopOffset(),       "pic_crop_top_offset" );
    398     WRITE_UVLC( pcSPS->getPicCropBottomOffset(),    "pic_crop_bottom_offset" );
     394  {       
     395    UInt  CropUnitX;
     396    UInt  CropUnitY;
     397
     398    // get cropping units based on chroma format
     399    if(pcSPS->getChromaFormatIdc() == 1) {
     400      CropUnitX = 2;
     401      CropUnitY = 2;
     402    }
     403    else if(pcSPS->getChromaFormatIdc() == 2) {
     404      CropUnitX = 2;
     405      CropUnitY = 1;
     406    }
     407    else {
     408      CropUnitX = 1;
     409      CropUnitY = 1;
     410    }
     411
     412    WRITE_UVLC( pcSPS->getPicCropLeftOffset()/CropUnitX,      "pic_crop_left_offset" );
     413    WRITE_UVLC( pcSPS->getPicCropRightOffset()/CropUnitX,     "pic_crop_right_offset" );
     414    WRITE_UVLC( pcSPS->getPicCropTopOffset()/CropUnitY,       "pic_crop_top_offset" );
     415    WRITE_UVLC( pcSPS->getPicCropBottomOffset()/CropUnitY,    "pic_crop_bottom_offset" );
    399416  }
    400417#endif
    401418