﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
151	Reference wraparound bugs	bheng		"1.) In Picture.cpp, function extendPicBorder().

The padding for reference wraparound doesn’t work correctly if offset is less than xmargin.

        for (int x = 0; x < xmargin; x++ )
        {
             pi[ -xmargin + x ] = pi[ -xmargin + x + xoffset ];
        }

The initial pixels will be copying other pixels within the margin border that have not yet been initialized themselves. 

2.) In Mv.cpp, function clipMv().

  if( sps.getWrapAroundEnabledFlag() )
  {
    int iHorMax = ( sps.getPicWidthInLumaSamples() + sps.getMaxCUWidth() - size.width + iOffset - ( int ) pos.x - 1 ) << iMvShift;
    int iHorMin = ( -( int ) sps.getMaxCUWidth()                                      - iOffset - ( int ) pos.x + 1 ) << iMvShift;
    
    rcMv.setHor( std::min( iHorMax, std::max( iHorMin, rcMv.getHor() ) ) );
    rcMv.setVer( std::min( iVerMax, std::max( iVerMin, rcMv.getVer() ) ) );
    return;
  }

Clipping the motion vectors within an extended padded border does not implement the modulo-operation described in the text. 

Specifically, if a motion vector extended outside the size of the padded region defined in the software, such that this clipping above actually took effect, then the result will not be the same as modulo-wrapping the reference pixels.  The vectors need to be modulo-unwrapped, not clipped.

Something like the following might work.

    int iMvX = rcMv.getHor();
    while(iMvX > iHorMax) {
      iMvX -= (sps.getWrapAroundOffset() << iMvShift);
    }
    while(iMvX < iHorMin) {
      iMvX += (sps.getWrapAroundOffset() << iMvShift);
    }
    rcMv.setHor(iMvX);
"	defect	closed	minor		VTM	VTM-3.0	fixed		ksuehring XiangLi fbossen jvet@…
