public long adjustTimestamp(long pts){
  if (lastPts != Long.MIN_VALUE) {
    long closestWrapCount=(lastPts + (MAX_PTS_PLUS_ONE / 2)) / MAX_PTS_PLUS_ONE;
    long ptsWrapBelow=pts + (MAX_PTS_PLUS_ONE * (closestWrapCount - 1));
    long ptsWrapAbove=pts + (MAX_PTS_PLUS_ONE * closestWrapCount);
    pts=Math.abs(ptsWrapBelow - lastPts) < Math.abs(ptsWrapAbove - lastPts) ? ptsWrapBelow : ptsWrapAbove;
  }
  long timeUs=ptsToUs(pts);
  if (firstSampleTimestampUs != DO_NOT_OFFSET && lastPts == Long.MIN_VALUE) {
    timestampOffsetUs=firstSampleTimestampUs - timeUs;
  }
  lastPts=pts;
  return timeUs + timestampOffsetUs;
}

public long adjustTimestamp ( long pts ) { if ( lastPts != Long . MIN_VALUE ) { long closestWrapCount = ( lastPts + ( MAX_PTS_PLUS_ONE / 2 ) ) / MAX_PTS_PLUS_ONE ; long ptsWrapBelow = pts + ( MAX_PTS_PLUS_ONE * ( closestWrapCount - 1 ) ) ; long ptsWrapAbove = pts + ( MAX_PTS_PLUS_ONE * closestWrapCount ) ; pts = Math . abs ( ptsWrapBelow - lastPts ) < Math . abs ( ptsWrapAbove - lastPts ) ? ptsWrapBelow : ptsWrapAbove ; } long timeUs = ptsToUs ( pts ) ; if ( firstSampleTimestampUs != DO_NOT_OFFSET && lastPts == Long . MIN_VALUE ) { timestampOffsetUs = firstSampleTimestampUs - timeUs ; } lastPts = pts ; return timeUs + timestampOffsetUs ; }
scales and offsets an mpeg - 2 ts presentation timestamp .
