nus-yam/ex-repair huggingface dataset:
Program: 110275
Project: 110275
Buggy source:
@Override public SubtitleOutputBuffer dequeueOutputBuffer() throws SubtitleDecoderException {
  if (availableOutputBuffers.isEmpty()) {
    return null;
  }
  while (!queuedInputBuffers.isEmpty() && queuedInputBuffers.first().timeUs <= playbackPositionUs) {
    SubtitleInputBuffer inputBuffer=queuedInputBuffers.pollFirst();
    if (inputBuffer.isEndOfStream()) {
      SubtitleOutputBuffer outputBuffer=availableOutputBuffers.pollFirst();
      outputBuffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
      releaseInputBuffer(inputBuffer);
      return outputBuffer;
    }
    decode(inputBuffer);
    if (isNewSubtitleDataAvailable()) {
      Subtitle subtitle=createSubtitle();
      if (!inputBuffer.isDecodeOnly()) {
        SubtitleOutputBuffer outputBuffer=availableOutputBuffers.pollFirst();
        outputBuffer.setContent(inputBuffer.timeUs,subtitle,Format.OFFSET_SAMPLE_RELATIVE);
        releaseInputBuffer(inputBuffer);
        return outputBuffer;
      }
    }
    releaseInputBuffer(inputBuffer);
  }
  return null;
}

Fixed version (ground truth):
@Override public SubtitleOutputBuffer dequeueOutputBuffer() throws SubtitleDecoderException {
  if (availableOutputBuffers.isEmpty()) {
    return null;
  }
  while (!queuedInputBuffers.isEmpty() && queuedInputBuffers.peek().timeUs <= playbackPositionUs) {
    SubtitleInputBuffer inputBuffer=queuedInputBuffers.poll();
    if (inputBuffer.isEndOfStream()) {
      SubtitleOutputBuffer outputBuffer=availableOutputBuffers.pollFirst();
      outputBuffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
      releaseInputBuffer(inputBuffer);
      return outputBuffer;
    }
    decode(inputBuffer);
    if (isNewSubtitleDataAvailable()) {
      Subtitle subtitle=createSubtitle();
      if (!inputBuffer.isDecodeOnly()) {
        SubtitleOutputBuffer outputBuffer=availableOutputBuffers.pollFirst();
        outputBuffer.setContent(inputBuffer.timeUs,subtitle,Format.OFFSET_SAMPLE_RELATIVE);
        releaseInputBuffer(inputBuffer);
        return outputBuffer;
      }
    }
    releaseInputBuffer(inputBuffer);
  }
  return null;
}
Program: 110276
Project: 110276
Buggy source:
@Override public void run(){
  action.doActionAndScheduleNext(player,trackSelector,surface,mainHandler,next);
  if (repeatIntervalMs != C.TIME_UNSET) {
    clock.postDelayed(mainHandler,this,repeatIntervalMs);
  }
}

Fixed version (ground truth):
@Override public void run(){
  action.doActionAndScheduleNext(player,trackSelector,surface,mainHandler,null);
  clock.postDelayed(mainHandler,this,repeatIntervalMs);
}
Program: 110277
Project: 110277
Buggy source:
/** 
 * Schedules a new source preparation action to be executed.
 * @see ExoPlayer#prepare(MediaSource, boolean, boolean).
 * @return The builder, for convenience.
 */
public Builder prepareSource(MediaSource mediaSource,boolean resetPosition,boolean resetState){
  return apply(new PrepareSource(tag,mediaSource,resetPosition,resetState));
}

Fixed version (ground truth):
/** 
 * Schedules a new source preparation action to be executed.
 * @see com.google.android.exoplayer2.ExoPlayer#prepare(MediaSource, boolean, boolean).
 * @return The builder, for convenience.
 */
public Builder prepareSource(MediaSource mediaSource,boolean resetPosition,boolean resetState){
  return apply(new PrepareSource(tag,mediaSource,resetPosition,resetState));
}
Program: 110278
Project: 110278
Buggy source:
/** 
 * Gets the view onto which video is rendered. This is either a   {@link SurfaceView} (default)or a  {@link TextureView} if the {@code use_texture_view} view attribute has been set to true.
 * @return Either a {@link SurfaceView} or a {@link TextureView}.
 */
public View getVideoSurfaceView(){
  return surfaceView;
}

Fixed version (ground truth):
/** 
 * Gets the view onto which video is rendered. This is a: <ul> <li>  {@link SurfaceView} by default, or if the {@code surface_type} attribute is set to{@code surface_view}.</li> <li>  {@link TextureView} if {@code surface_type} is {@code texture_view}.</li> <li>  {@code null} if {@code surface_type} is {@code none}.</li> </ul>
 * @return The {@link SurfaceView},   {@link TextureView} or {@code null}.
 */
public View getVideoSurfaceView(){
  return surfaceView;
}
Program: 110279
Project: 110279
Buggy source:
@Override public void getNextChunk(MediaChunk previous,long playbackPositionUs,ChunkHolder out){
  long bufferedDurationUs=previous != null ? (previous.endTimeUs - playbackPositionUs) : 0;
  trackSelection.updateSelectedTrack(bufferedDurationUs);
  int chunkIndex=previous == null ? dataSet.getChunkIndexByPosition(playbackPositionUs) : previous.getNextChunkIndex();
  if (chunkIndex >= dataSet.getChunkCount()) {
    out.endOfStream=true;
  }
 else {
    Format selectedFormat=trackSelection.getSelectedFormat();
    long startTimeUs=dataSet.getStartTime(chunkIndex);
    long endTimeUs=startTimeUs + dataSet.getChunkDuration(chunkIndex);
    String uri=dataSet.getUri(trackSelection.getSelectedIndex());
    Segment fakeDataChunk=dataSet.getData(uri).getSegments().get(chunkIndex);
    DataSpec dataSpec=new DataSpec(Uri.parse(uri),fakeDataChunk.byteOffset,fakeDataChunk.length,null);
    int trackType=MimeTypes.getTrackType(selectedFormat.sampleMimeType);
    out.chunk=new SingleSampleMediaChunk(dataSource,dataSpec,selectedFormat,trackSelection.getSelectionReason(),trackSelection.getSelectionData(),startTimeUs,endTimeUs,chunkIndex,trackType,selectedFormat);
  }
}

Fixed version (ground truth):
@Override public void getNextChunk(MediaChunk previous,long playbackPositionUs,ChunkHolder out){
  long bufferedDurationUs=previous != null ? (previous.endTimeUs - playbackPositionUs) : 0;
  trackSelection.updateSelectedTrack(bufferedDurationUs);
  int chunkIndex=previous == null ? dataSet.getChunkIndexByPosition(playbackPositionUs) : previous.getNextChunkIndex();
  if (chunkIndex >= dataSet.getChunkCount()) {
    out.endOfStream=true;
  }
 else {
    Format selectedFormat=trackSelection.getSelectedFormat();
    long startTimeUs=dataSet.getStartTime(chunkIndex);
    long endTimeUs=startTimeUs + dataSet.getChunkDuration(chunkIndex);
    int trackGroupIndex=trackSelection.getIndexInTrackGroup(trackSelection.getSelectedIndex());
    String uri=dataSet.getUri(trackGroupIndex);
    Segment fakeDataChunk=dataSet.getData(uri).getSegments().get(chunkIndex);
    DataSpec dataSpec=new DataSpec(Uri.parse(uri),fakeDataChunk.byteOffset,fakeDataChunk.length,null);
    int trackType=MimeTypes.getTrackType(selectedFormat.sampleMimeType);
    out.chunk=new SingleSampleMediaChunk(dataSource,dataSpec,selectedFormat,trackSelection.getSelectionReason(),trackSelection.getSelectionData(),startTimeUs,endTimeUs,chunkIndex,trackType,selectedFormat);
  }
}
Program: 110280
Project: 110280
Buggy source:
/** 
 * Gets the view onto which video is rendered. This is either a   {@link SurfaceView} (default)or a  {@link TextureView} if the {@code use_texture_view} view attribute has been set to true.
 * @return Either a {@link SurfaceView} or a {@link TextureView}.
 */
public View getVideoSurfaceView(){
  return surfaceView;
}

Fixed version (ground truth):
/** 
 * Gets the view onto which video is rendered. This is a: <ul> <li>  {@link SurfaceView} by default, or if the {@code surface_type} attribute is set to{@code surface_view}.</li> <li>  {@link TextureView} if {@code surface_type} is {@code texture_view}.</li> <li>  {@code null} if {@code surface_type} is {@code none}.</li> </ul>
 * @return The {@link SurfaceView},   {@link TextureView} or {@code null}.
 */
public View getVideoSurfaceView(){
  return surfaceView;
}
Program: 110281
Project: 110281
Buggy source:
public long getChunkDuration(int chunkIndex){
  return chunkIndex == getAllData().size() - 1 ? lastChunkDurationUs : chunkDurationUs;
}

Fixed version (ground truth):
public long getChunkDuration(int chunkIndex){
  return chunkIndex == getChunkCount() - 1 ? lastChunkDurationUs : chunkDurationUs;
}
Program: 110282
Project: 110282
Buggy source:
public FakeAdaptiveDataSet(TrackSelection trackSelection,long mediaDurationUs,long chunkDurationUs){
  this.chunkDurationUs=chunkDurationUs;
  int selectionCount=trackSelection.length();
  long lastChunkDurationUs=mediaDurationUs % chunkDurationUs;
  int fullChunks=(int)(mediaDurationUs / chunkDurationUs);
  for (int i=0; i < selectionCount; i++) {
    String uri=getUri(i);
    Format format=trackSelection.getFormat(i);
    int chunkLength=(int)(format.bitrate * chunkDurationUs / (8 * C.MICROS_PER_SECOND));
    FakeData newData=this.newData(uri);
    for (int j=0; j < fullChunks; j++) {
      newData.appendReadData(chunkLength);
    }
    if (lastChunkDurationUs > 0) {
      int lastChunkLength=(int)(format.bitrate * (mediaDurationUs % chunkDurationUs) / (8 * C.MICROS_PER_SECOND));
      newData.appendReadData(lastChunkLength);
    }
  }
  this.lastChunkDurationUs=lastChunkDurationUs == 0 ? chunkDurationUs : lastChunkDurationUs;
}

Fixed version (ground truth):
public FakeAdaptiveDataSet(TrackSelection trackSelection,long mediaDurationUs,long chunkDurationUs){
  this.chunkDurationUs=chunkDurationUs;
  int selectionCount=trackSelection.length();
  long lastChunkDurationUs=mediaDurationUs % chunkDurationUs;
  int fullChunks=(int)(mediaDurationUs / chunkDurationUs);
  for (int i=0; i < selectionCount; i++) {
    String uri=getUri(i);
    Format format=trackSelection.getFormat(i);
    int chunkLength=(int)(format.bitrate * chunkDurationUs / (8 * C.MICROS_PER_SECOND));
    FakeData newData=this.newData(uri);
    for (int j=0; j < fullChunks; j++) {
      newData.appendReadData(chunkLength);
    }
    if (lastChunkDurationUs > 0) {
      int lastChunkLength=(int)(format.bitrate * (mediaDurationUs % chunkDurationUs) / (8 * C.MICROS_PER_SECOND));
      newData.appendReadData(lastChunkLength);
    }
  }
  this.lastChunkDurationUs=lastChunkDurationUs == 0 ? chunkDurationUs : lastChunkDurationUs;
  this.chunkCount=lastChunkDurationUs == 0 ? fullChunks : fullChunks + 1;
}
Program: 110283
Project: 110283
Buggy source:
/** 
 * Paint a 2-bit/pixel code string, as defined by ETSI EN 300 743 7.2.5.2, to a canvas.
 */
private static int paint2BitPixelCodeString(ParsableBitArray data,int[] clutEntries,byte[] clutMapTable,int column,int line,Paint paint,Canvas canvas){
  boolean endOfPixelCodeString=false;
  do {
    int runLength=0;
    int clutIndex=0;
    int peek=data.readBits(2);
    if (!data.readBit()) {
      runLength=1;
      clutIndex=peek;
    }
 else     if (data.readBit()) {
      runLength=3 + data.readBits(3);
      clutIndex=data.readBits(2);
    }
 else     if (!data.readBit()) {
switch (data.readBits(2)) {
case 0x00:
        endOfPixelCodeString=true;
      break;
case 0x01:
    runLength=2;
  break;
case 0x02:
runLength=12 + data.readBits(4);
clutIndex=data.readBits(2);
break;
case 0x03:
runLength=29 + data.readBits(8);
clutIndex=data.readBits(2);
break;
}
}
if (runLength != 0 && paint != null) {
paint.setColor(clutEntries[clutMapTable != null ? clutMapTable[clutIndex] : clutIndex]);
canvas.drawRect(column,line,column + runLength,line + 1,paint);
}
column+=runLength;
}
 while (!endOfPixelCodeString);
return column;
}

Fixed version (ground truth):
/** 
 * Paint a 2-bit/pixel code string, as defined by ETSI EN 300 743 7.2.5.2, to a canvas.
 */
private static int paint2BitPixelCodeString(ParsableBitArray data,int[] clutEntries,byte[] clutMapTable,int column,int line,Paint paint,Canvas canvas){
  boolean endOfPixelCodeString=false;
  do {
    int runLength=0;
    int clutIndex=0;
    int peek=data.readBits(2);
    if (peek != 0x00) {
      runLength=1;
      clutIndex=peek;
    }
 else     if (data.readBit()) {
      runLength=3 + data.readBits(3);
      clutIndex=data.readBits(2);
    }
 else     if (data.readBit()) {
      runLength=1;
    }
 else {
switch (data.readBits(2)) {
case 0x00:
        endOfPixelCodeString=true;
      break;
case 0x01:
    runLength=2;
  break;
case 0x02:
runLength=12 + data.readBits(4);
clutIndex=data.readBits(2);
break;
case 0x03:
runLength=29 + data.readBits(8);
clutIndex=data.readBits(2);
break;
}
}
if (runLength != 0 && paint != null) {
paint.setColor(clutEntries[clutMapTable != null ? clutMapTable[clutIndex] : clutIndex]);
canvas.drawRect(column,line,column + runLength,line + 1,paint);
}
column+=runLength;
}
 while (!endOfPixelCodeString);
return column;
}
Program: 110284
Project: 110284
Buggy source:
/** 
 * Paint a 2-bit/pixel code string, as defined by ETSI EN 300 743 7.2.5.2, to a canvas.
 */
private static int paint2BitPixelCodeString(ParsableBitArray data,int[] clutEntries,byte[] clutMapTable,int column,int line,Paint paint,Canvas canvas){
  boolean endOfPixelCodeString=false;
  do {
    int runLength=0;
    int clutIndex=0;
    int peek=data.readBits(2);
    if (!data.readBit()) {
      runLength=1;
      clutIndex=peek;
    }
 else     if (data.readBit()) {
      runLength=3 + data.readBits(3);
      clutIndex=data.readBits(2);
    }
 else     if (!data.readBit()) {
switch (data.readBits(2)) {
case 0x00:
        endOfPixelCodeString=true;
      break;
case 0x01:
    runLength=2;
  break;
case 0x02:
runLength=12 + data.readBits(4);
clutIndex=data.readBits(2);
break;
case 0x03:
runLength=29 + data.readBits(8);
clutIndex=data.readBits(2);
break;
}
}
if (runLength != 0 && paint != null) {
paint.setColor(clutEntries[clutMapTable != null ? clutMapTable[clutIndex] : clutIndex]);
canvas.drawRect(column,line,column + runLength,line + 1,paint);
}
column+=runLength;
}
 while (!endOfPixelCodeString);
return column;
}

Fixed version (ground truth):
/** 
 * Paint a 2-bit/pixel code string, as defined by ETSI EN 300 743 7.2.5.2, to a canvas.
 */
private static int paint2BitPixelCodeString(ParsableBitArray data,int[] clutEntries,byte[] clutMapTable,int column,int line,Paint paint,Canvas canvas){
  boolean endOfPixelCodeString=false;
  do {
    int runLength=0;
    int clutIndex=0;
    int peek=data.readBits(2);
    if (peek != 0x00) {
      runLength=1;
      clutIndex=peek;
    }
 else     if (data.readBit()) {
      runLength=3 + data.readBits(3);
      clutIndex=data.readBits(2);
    }
 else     if (data.readBit()) {
      runLength=1;
    }
 else {
switch (data.readBits(2)) {
case 0x00:
        endOfPixelCodeString=true;
      break;
case 0x01:
    runLength=2;
  break;
case 0x02:
runLength=12 + data.readBits(4);
clutIndex=data.readBits(2);
break;
case 0x03:
runLength=29 + data.readBits(8);
clutIndex=data.readBits(2);
break;
}
}
if (runLength != 0 && paint != null) {
paint.setColor(clutEntries[clutMapTable != null ? clutMapTable[clutIndex] : clutIndex]);
canvas.drawRect(column,line,column + runLength,line + 1,paint);
}
column+=runLength;
}
 while (!endOfPixelCodeString);
return column;
}
Program: 110286
Project: 110286
Buggy source:
@Override public void updateSelectedTrack(long bufferedDurationUs){
  long nowMs=SystemClock.elapsedRealtime();
  int currentSelectedIndex=selectedIndex;
  Format currentFormat=getSelectedFormat();
  int idealSelectedIndex=determineIdealSelectedIndex(nowMs);
  Format idealFormat=getFormat(idealSelectedIndex);
  selectedIndex=idealSelectedIndex;
  if (currentFormat != null && !isBlacklisted(selectedIndex,nowMs)) {
    if (idealFormat.bitrate > currentFormat.bitrate && bufferedDurationUs < minDurationForQualityIncreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
 else     if (idealFormat.bitrate < currentFormat.bitrate && bufferedDurationUs >= maxDurationForQualityDecreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
  }
  if (selectedIndex != currentSelectedIndex) {
    reason=C.SELECTION_REASON_ADAPTIVE;
  }
}

Fixed version (ground truth):
@Override public void updateSelectedTrack(long bufferedDurationUs){
  long nowMs=SystemClock.elapsedRealtime();
  int currentSelectedIndex=selectedIndex;
  int idealSelectedIndex=determineIdealSelectedIndex(nowMs);
  selectedIndex=idealSelectedIndex;
  if (!isBlacklisted(currentSelectedIndex,nowMs)) {
    Format currentFormat=getFormat(currentSelectedIndex);
    Format idealFormat=getFormat(idealSelectedIndex);
    if (idealFormat.bitrate > currentFormat.bitrate && bufferedDurationUs < minDurationForQualityIncreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
 else     if (idealFormat.bitrate < currentFormat.bitrate && bufferedDurationUs >= maxDurationForQualityDecreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
  }
  if (selectedIndex != currentSelectedIndex) {
    reason=C.SELECTION_REASON_ADAPTIVE;
  }
}
Program: 110287
Project: 110287
Buggy source:
@Override public void updateSelectedTrack(long bufferedDurationUs){
  long nowMs=SystemClock.elapsedRealtime();
  int currentSelectedIndex=selectedIndex;
  Format currentFormat=getSelectedFormat();
  int idealSelectedIndex=determineIdealSelectedIndex(nowMs);
  Format idealFormat=getFormat(idealSelectedIndex);
  selectedIndex=idealSelectedIndex;
  if (currentFormat != null && !isBlacklisted(selectedIndex,nowMs)) {
    if (idealFormat.bitrate > currentFormat.bitrate && bufferedDurationUs < minDurationForQualityIncreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
 else     if (idealFormat.bitrate < currentFormat.bitrate && bufferedDurationUs >= maxDurationForQualityDecreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
  }
  if (selectedIndex != currentSelectedIndex) {
    reason=C.SELECTION_REASON_ADAPTIVE;
  }
}

Fixed version (ground truth):
@Override public void updateSelectedTrack(long bufferedDurationUs){
  long nowMs=SystemClock.elapsedRealtime();
  int currentSelectedIndex=selectedIndex;
  int idealSelectedIndex=determineIdealSelectedIndex(nowMs);
  selectedIndex=idealSelectedIndex;
  if (!isBlacklisted(currentSelectedIndex,nowMs)) {
    Format currentFormat=getFormat(currentSelectedIndex);
    Format idealFormat=getFormat(idealSelectedIndex);
    if (idealFormat.bitrate > currentFormat.bitrate && bufferedDurationUs < minDurationForQualityIncreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
 else     if (idealFormat.bitrate < currentFormat.bitrate && bufferedDurationUs >= maxDurationForQualityDecreaseUs) {
      selectedIndex=currentSelectedIndex;
    }
  }
  if (selectedIndex != currentSelectedIndex) {
    reason=C.SELECTION_REASON_ADAPTIVE;
  }
}
Program: 110289
Project: 110289
Buggy source:
@TargetApi(14) @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){
  super.onInitializeAccessibilityNodeInfo(info);
  info.setClassName(DefaultTimeBar.class.getCanonicalName());
  info.setContentDescription(getProgressText());
  if (duration <= 0) {
    return;
  }
  if (Util.SDK_INT >= 21) {
    info.addAction(AccessibilityAction.ACTION_SCROLL_FORWARD);
    info.addAction(AccessibilityAction.ACTION_SCROLL_BACKWARD);
  }
 else   if (Util.SDK_INT >= 16) {
    info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
    info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
  }
}

Fixed version (ground truth):
@TargetApi(21) @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){
  super.onInitializeAccessibilityNodeInfo(info);
  info.setClassName(DefaultTimeBar.class.getCanonicalName());
  info.setContentDescription(getProgressText());
  if (duration <= 0) {
    return;
  }
  if (Util.SDK_INT >= 21) {
    info.addAction(AccessibilityAction.ACTION_SCROLL_FORWARD);
    info.addAction(AccessibilityAction.ACTION_SCROLL_BACKWARD);
  }
 else   if (Util.SDK_INT >= 16) {
    info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
    info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
  }
}
Program: 110291
Project: 110291
Buggy source:
public void clear(){
  rolledUpCaptions.clear();
  captionStringBuilder.clear();
  italicsStartPosition=C.POSITION_UNSET;
  underlineStartPosition=C.POSITION_UNSET;
  foregroundColorStartPosition=C.POSITION_UNSET;
  backgroundColorStartPosition=C.POSITION_UNSET;
}

Fixed version (ground truth):
public void clear(){
  rolledUpCaptions.clear();
  captionStringBuilder.clear();
  italicsStartPosition=C.POSITION_UNSET;
  underlineStartPosition=C.POSITION_UNSET;
  foregroundColorStartPosition=C.POSITION_UNSET;
  backgroundColorStartPosition=C.POSITION_UNSET;
  row=0;
}
Program: 110292
Project: 110292
Buggy source:
public void setPenLocation(int row,int column){
}

Fixed version (ground truth):
public void setPenLocation(int row,int column){
  if (this.row != row) {
    append('\n');
  }
  this.row=row;
}
Program: 110294
Project: 110294
Buggy source:
private void setupBitmapLayout(){
  int parentWidth=parentRight - parentLeft;
  int parentHeight=parentBottom - parentTop;
  float anchorX=parentLeft + (parentWidth * cuePosition);
  float anchorY=parentTop + (parentHeight * cueLine);
  int width=(int)(parentWidth * cueSize);
  int height=(int)(width * ((float)cueBitmap.getHeight() / cueBitmap.getWidth()));
  int x=(int)(cueLineAnchor == Cue.ANCHOR_TYPE_END ? (anchorX - width) : cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
  int y=(int)(cuePositionAnchor == Cue.ANCHOR_TYPE_END ? (anchorY - width) : cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (width / 2)) : anchorY);
  bitmapRect=new Rect(x,y,x + width,y + height);
}

Fixed version (ground truth):
private void setupBitmapLayout(){
  int parentWidth=parentRight - parentLeft;
  int parentHeight=parentBottom - parentTop;
  float anchorX=parentLeft + (parentWidth * cuePosition);
  float anchorY=parentTop + (parentHeight * cueLine);
  int width=(int)(parentWidth * cueSize);
  int height=(int)(width * ((float)cueBitmap.getHeight() / cueBitmap.getWidth()));
  int x=(int)(cueLineAnchor == Cue.ANCHOR_TYPE_END ? (anchorX - width) : cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
  int y=(int)(cuePositionAnchor == Cue.ANCHOR_TYPE_END ? (anchorY - height) : cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (height / 2)) : anchorY);
  bitmapRect=new Rect(x,y,x + width,y + height);
}
Program: 110297
Project: 110297
Buggy source:
private boolean handleCtrl(byte cc1,byte cc2){
  boolean isRepeatableControl=isRepeatable(cc1);
  if (isRepeatableControl) {
    if (repeatableControlSet && repeatableControlCc1 == cc1 && repeatableControlCc2 == cc2) {
      repeatableControlSet=false;
      return true;
    }
 else {
      repeatableControlSet=true;
      repeatableControlCc1=cc1;
      repeatableControlCc2=cc2;
    }
  }
  if (isMidrowCtrlCode(cc1,cc2)) {
    handleMidrowCtrl(cc2);
  }
 else   if (isPreambleAddressCode(cc1,cc2)) {
    handlePreambleAddressCode(cc1,cc2);
  }
 else   if (isTabCtrlCode(cc1,cc2)) {
    currentCueBuilder.tab(cc2 - 0x20);
  }
 else   if (isMiscCode(cc1,cc2)) {
    handleMiscCode(cc2);
  }
  return isRepeatableControl;
}

Fixed version (ground truth):
private boolean handleCtrl(byte cc1,byte cc2){
  boolean isRepeatableControl=isRepeatable(cc1);
  if (isRepeatableControl) {
    if (repeatableControlSet && repeatableControlCc1 == cc1 && repeatableControlCc2 == cc2) {
      repeatableControlSet=false;
      return true;
    }
 else {
      repeatableControlSet=true;
      repeatableControlCc1=cc1;
      repeatableControlCc2=cc2;
    }
  }
  if (isMidrowCtrlCode(cc1,cc2)) {
    handleMidrowCtrl(cc2);
  }
 else   if (isPreambleAddressCode(cc1,cc2)) {
    handlePreambleAddressCode(cc1,cc2);
  }
 else   if (isTabCtrlCode(cc1,cc2)) {
    currentCueBuilder.setTab(cc2 - 0x20);
  }
 else   if (isMiscCode(cc1,cc2)) {
    handleMiscCode(cc2);
  }
  return isRepeatableControl;
}
Program: 110298
Project: 110298
Buggy source:
/** 
 * Returns whether the track at the specified index in the selection is blaclisted.
 * @param index The index of the track in the selection.
 * @param nowMs The current time in the timebase of {@link SystemClock#elapsedRealtime()}.
 */
protected final boolean isBlacklisted(int index,long nowMs){
  return blacklistUntilTimes[index] > nowMs;
}

Fixed version (ground truth):
/** 
 * Returns whether the track at the specified index in the selection is blacklisted.
 * @param index The index of the track in the selection.
 * @param nowMs The current time in the timebase of {@link SystemClock#elapsedRealtime()}.
 */
protected final boolean isBlacklisted(int index,long nowMs){
  return blacklistUntilTimes[index] > nowMs;
}
Program: 110299
Project: 110299
Buggy source:
private void setCaptionMode(int captionMode){
  if (this.captionMode == captionMode) {
    return;
  }
  this.captionMode=captionMode;
  resetCueBuilders();
  if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_UNKNOWN) {
    cues=null;
  }
}

Fixed version (ground truth):
private void setCaptionMode(int captionMode){
  if (this.captionMode == captionMode) {
    return;
  }
  int oldCaptionMode=this.captionMode;
  this.captionMode=captionMode;
  resetCueBuilders();
  if (oldCaptionMode == CC_MODE_PAINT_ON || captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_UNKNOWN) {
    cues=null;
  }
}
Program: 110300
Project: 110300
Buggy source:
@Override protected void decode(SubtitleInputBuffer inputBuffer){
  ccData.reset(inputBuffer.data.array(),inputBuffer.data.limit());
  while (ccData.bytesLeft() >= 3) {
    int ccTypeAndValid=(ccData.readUnsignedByte() & 0x07);
    int ccType=ccTypeAndValid & (DTVCC_PACKET_DATA | DTVCC_PACKET_START);
    boolean ccValid=(ccTypeAndValid & CC_VALID_FLAG) == CC_VALID_FLAG;
    byte ccData1=(byte)ccData.readUnsignedByte();
    byte ccData2=(byte)ccData.readUnsignedByte();
    if (ccType != DTVCC_PACKET_DATA && ccType != DTVCC_PACKET_START) {
      continue;
    }
    if (!ccValid) {
      finalizeCurrentPacket();
      continue;
    }
    if (ccType == DTVCC_PACKET_START) {
      finalizeCurrentPacket();
      int sequenceNumber=(ccData1 & 0xC0) >> 6;
      int packetSize=ccData1 & 0x3F;
      if (packetSize == 0) {
        packetSize=64;
      }
      currentDtvCcPacket=new DtvCcPacket(sequenceNumber,packetSize);
      currentDtvCcPacket.packetData[currentDtvCcPacket.currentIndex++]=ccData2;
    }
 else {
      Assertions.checkArgument(ccType == DTVCC_PACKET_DATA);
      if (currentDtvCcPacket == null) {
        Log.e(TAG,"String_Node_Str");
        continue;
      }
      currentDtvCcPacket.packetData[currentDtvCcPacket.currentIndex++]=ccData1;
      currentDtvCcPacket.packetData[currentDtvCcPacket.currentIndex++]=ccData2;
    }
    if (currentDtvCcPacket.currentIndex == (currentDtvCcPacket.packetSize * 2 - 1)) {
      finalizeCurrentPacket();
    }
  }
}

Fixed version (ground truth):
@Override protected void decode(SubtitleInputBuffer inputBuffer){
  ccData.reset(inputBuffer.data.array(),inputBuffer.data.limit());
  while (ccData.bytesLeft() >= 3) {
    int ccTypeAndValid=(ccData.readUnsignedByte() & 0x07);
    int ccType=ccTypeAndValid & (DTVCC_PACKET_DATA | DTVCC_PACKET_START);
    boolean ccValid=(ccTypeAndValid & CC_VALID_FLAG) == CC_VALID_FLAG;
    byte ccData1=(byte)ccData.readUnsignedByte();
    byte ccData2=(byte)ccData.readUnsignedByte();
    if (ccType != DTVCC_PACKET_DATA && ccType != DTVCC_PACKET_START) {
      continue;
    }
    if (!ccValid) {
      continue;
    }
    if (ccType == DTVCC_PACKET_START) {
      finalizeCurrentPacket();
      int sequenceNumber=(ccData1 & 0xC0) >> 6;
      int packetSize=ccData1 & 0x3F;
      if (packetSize == 0) {
        packetSize=64;
      }
      currentDtvCcPacket=new DtvCcPacket(sequenceNumber,packetSize);
      currentDtvCcPacket.packetData[currentDtvCcPacket.currentIndex++]=ccData2;
    }
 else {
      Assertions.checkArgument(ccType == DTVCC_PACKET_DATA);
      if (currentDtvCcPacket == null) {
        Log.e(TAG,"String_Node_Str");
        continue;
      }
      currentDtvCcPacket.packetData[currentDtvCcPacket.currentIndex++]=ccData1;
      currentDtvCcPacket.packetData[currentDtvCcPacket.currentIndex++]=ccData2;
    }
    if (currentDtvCcPacket.currentIndex == (currentDtvCcPacket.packetSize * 2 - 1)) {
      finalizeCurrentPacket();
    }
  }
}
Program: 110302
Project: 110302
Buggy source:
@Override public void onPositionDiscontinuity(){
}

Fixed version (ground truth):
@Override public void onPositionDiscontinuity(){
  if (playerNeedsSource) {
    updateResumePosition();
  }
}
Program: 110304
Project: 110304
Buggy source:
@Override public void queueInputBuffer(SubtitleInputBuffer inputBuffer) throws SubtitleDecoderException {
  Assertions.checkArgument(inputBuffer != null);
  Assertions.checkArgument(inputBuffer == dequeuedInputBuffer);
  queuedInputBuffers.add(inputBuffer);
  dequeuedInputBuffer=null;
}

Fixed version (ground truth):
@Override public void queueInputBuffer(SubtitleInputBuffer inputBuffer) throws SubtitleDecoderException {
  Assertions.checkArgument(inputBuffer != null);
  Assertions.checkArgument(inputBuffer == dequeuedInputBuffer);
  if (inputBuffer.isDecodeOnly()) {
    releaseInputBuffer(inputBuffer);
  }
 else {
    queuedInputBuffers.add(inputBuffer);
  }
  dequeuedInputBuffer=null;
}
Program: 110306
Project: 110306
Buggy source:
private void maybeInitExtraTracks(){
  if ((flags & FLAG_ENABLE_EMSG_TRACK) != 0 && eventMessageTrackOutput == null) {
    eventMessageTrackOutput=extractorOutput.track(trackBundles.size());
    eventMessageTrackOutput.format(Format.createSampleFormat(null,MimeTypes.APPLICATION_EMSG,Format.OFFSET_SAMPLE_RELATIVE));
  }
  if ((flags & FLAG_ENABLE_CEA608_TRACK) != 0 && cea608TrackOutput == null) {
    cea608TrackOutput=extractorOutput.track(trackBundles.size());
    cea608TrackOutput.format(Format.createTextSampleFormat(null,MimeTypes.APPLICATION_CEA608,null,Format.NO_VALUE,0,null,null));
  }
}

Fixed version (ground truth):
private void maybeInitExtraTracks(){
  if ((flags & FLAG_ENABLE_EMSG_TRACK) != 0 && eventMessageTrackOutput == null) {
    eventMessageTrackOutput=extractorOutput.track(trackBundles.size());
    eventMessageTrackOutput.format(Format.createSampleFormat(null,MimeTypes.APPLICATION_EMSG,Format.OFFSET_SAMPLE_RELATIVE));
  }
  if ((flags & FLAG_ENABLE_CEA608_TRACK) != 0 && cea608TrackOutput == null) {
    cea608TrackOutput=extractorOutput.track(trackBundles.size() + 1);
    cea608TrackOutput.format(Format.createTextSampleFormat(null,MimeTypes.APPLICATION_CEA608,null,Format.NO_VALUE,0,null,null));
  }
}
Program: 110307
Project: 110307
Buggy source:
private void onKeyResponse(Object response){
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    return;
  }
  if (response instanceof Exception) {
    onKeysError((Exception)response);
    return;
  }
  try {
    if (mode == MODE_RELEASE) {
      mediaDrm.provideKeyResponse(offlineLicenseKeySetId,(byte[])response);
      if (eventHandler != null && eventListener != null) {
        eventHandler.post(new Runnable(){
          @Override public void run(){
            eventListener.onDrmKeysRemoved();
          }
        }
);
      }
    }
 else {
      byte[] keySetId=mediaDrm.provideKeyResponse(sessionId,(byte[])response);
      if (offlineLicenseKeySetId != null && (keySetId == null || keySetId.length == 0)) {
      }
 else {
        offlineLicenseKeySetId=keySetId;
      }
      state=STATE_OPENED_WITH_KEYS;
      if (eventHandler != null && eventListener != null) {
        eventHandler.post(new Runnable(){
          @Override public void run(){
            eventListener.onDrmKeysLoaded();
          }
        }
);
      }
    }
  }
 catch (  Exception e) {
    onKeysError(e);
  }
}

Fixed version (ground truth):
private void onKeyResponse(Object response){
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    return;
  }
  if (response instanceof Exception) {
    onKeysError((Exception)response);
    return;
  }
  try {
    if (mode == MODE_RELEASE) {
      mediaDrm.provideKeyResponse(offlineLicenseKeySetId,(byte[])response);
      if (eventHandler != null && eventListener != null) {
        eventHandler.post(new Runnable(){
          @Override public void run(){
            eventListener.onDrmKeysRemoved();
          }
        }
);
      }
    }
 else {
      byte[] keySetId=mediaDrm.provideKeyResponse(sessionId,(byte[])response);
      if (keySetId != null && keySetId.length != 0) {
        offlineLicenseKeySetId=keySetId;
      }
      state=STATE_OPENED_WITH_KEYS;
      if (eventHandler != null && eventListener != null) {
        eventHandler.post(new Runnable(){
          @Override public void run(){
            eventListener.onDrmKeysLoaded();
          }
        }
);
      }
    }
  }
 catch (  Exception e) {
    onKeysError(e);
  }
}
Program: 110308
Project: 110308
Buggy source:
private void printMetadata(Metadata metadata,String prefix){
  for (int i=0; i < metadata.length(); i++) {
    Metadata.Entry entry=metadata.get(i);
    if (entry instanceof TextInformationFrame) {
      TextInformationFrame textInformationFrame=(TextInformationFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",textInformationFrame.id,textInformationFrame.value));
    }
 else     if (entry instanceof PrivFrame) {
      PrivFrame privFrame=(PrivFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",privFrame.id,privFrame.owner));
    }
 else     if (entry instanceof GeobFrame) {
      GeobFrame geobFrame=(GeobFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",geobFrame.id,geobFrame.mimeType,geobFrame.filename,geobFrame.description));
    }
 else     if (entry instanceof ApicFrame) {
      ApicFrame apicFrame=(ApicFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",apicFrame.id,apicFrame.mimeType,apicFrame.description));
    }
 else     if (entry instanceof CommentFrame) {
      CommentFrame commentFrame=(CommentFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",commentFrame.id,commentFrame.language,commentFrame.description));
    }
 else     if (entry instanceof Id3Frame) {
      Id3Frame id3Frame=(Id3Frame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",id3Frame.id));
    }
  }
}

Fixed version (ground truth):
private void printMetadata(Metadata metadata,String prefix){
  for (int i=0; i < metadata.length(); i++) {
    Metadata.Entry entry=metadata.get(i);
    if (entry instanceof TextInformationFrame) {
      TextInformationFrame textInformationFrame=(TextInformationFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",textInformationFrame.id,textInformationFrame.value));
    }
 else     if (entry instanceof UrlLinkFrame) {
      UrlLinkFrame urlLinkFrame=(UrlLinkFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",urlLinkFrame.id,urlLinkFrame.url));
    }
 else     if (entry instanceof PrivFrame) {
      PrivFrame privFrame=(PrivFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",privFrame.id,privFrame.owner));
    }
 else     if (entry instanceof GeobFrame) {
      GeobFrame geobFrame=(GeobFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",geobFrame.id,geobFrame.mimeType,geobFrame.filename,geobFrame.description));
    }
 else     if (entry instanceof ApicFrame) {
      ApicFrame apicFrame=(ApicFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",apicFrame.id,apicFrame.mimeType,apicFrame.description));
    }
 else     if (entry instanceof CommentFrame) {
      CommentFrame commentFrame=(CommentFrame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",commentFrame.id,commentFrame.language,commentFrame.description));
    }
 else     if (entry instanceof Id3Frame) {
      Id3Frame id3Frame=(Id3Frame)entry;
      Log.d(TAG,prefix + String.format("String_Node_Str",id3Frame.id));
    }
  }
}
Program: 110309
Project: 110309
Buggy source:
private static ChapterFrame decodeChapterFrame(ParsableByteArray id3Data,int frameSize,int majorVersion,boolean unsignedIntFrameSizeHack,int frameHeaderSize) throws UnsupportedEncodingException {
  int framePosition=id3Data.getPosition();
  int chapterIdEndIndex=indexOfZeroByte(id3Data.data,framePosition);
  String chapterId=new String(id3Data.data,framePosition,chapterIdEndIndex - framePosition,"String_Node_Str");
  id3Data.setPosition(chapterIdEndIndex + 1);
  int startTime=id3Data.readUnsignedByte();
  int endTime=id3Data.readUnsignedByte();
  int startOffset=id3Data.readUnsignedByte();
  int endOffset=id3Data.readUnsignedByte();
  ArrayList<Id3Frame> subFrames=new ArrayList<>();
  int limit=framePosition + frameSize;
  while (id3Data.getPosition() < limit) {
    Id3Frame frame=decodeFrame(majorVersion,id3Data,unsignedIntFrameSizeHack,frameHeaderSize);
    if (frame != null) {
      subFrames.add(frame);
    }
  }
  Id3Frame[] subFrameArray=new Id3Frame[subFrames.size()];
  subFrames.toArray(subFrameArray);
  return new ChapterFrame(chapterId,startTime,endTime,startOffset,endOffset,subFrameArray);
}

Fixed version (ground truth):
private static ChapterFrame decodeChapterFrame(ParsableByteArray id3Data,int frameSize,int majorVersion,boolean unsignedIntFrameSizeHack,int frameHeaderSize) throws UnsupportedEncodingException {
  int framePosition=id3Data.getPosition();
  int chapterIdEndIndex=indexOfZeroByte(id3Data.data,framePosition);
  String chapterId=new String(id3Data.data,framePosition,chapterIdEndIndex - framePosition,"String_Node_Str");
  id3Data.setPosition(chapterIdEndIndex + 1);
  int startTime=id3Data.readInt();
  int endTime=id3Data.readInt();
  int startOffset=id3Data.readInt();
  int endOffset=id3Data.readInt();
  ArrayList<Id3Frame> subFrames=new ArrayList<>();
  int limit=framePosition + frameSize;
  while (id3Data.getPosition() < limit) {
    Id3Frame frame=decodeFrame(majorVersion,id3Data,unsignedIntFrameSizeHack,frameHeaderSize);
    if (frame != null) {
      subFrames.add(frame);
    }
  }
  Id3Frame[] subFrameArray=new Id3Frame[subFrames.size()];
  subFrames.toArray(subFrameArray);
  return new ChapterFrame(chapterId,startTime,endTime,startOffset,endOffset,subFrameArray);
}
Program: 110310
Project: 110310
Buggy source:
private static UrlLinkFrame decodeWxxxFrame(ParsableByteArray id3Data,int frameSize) throws UnsupportedEncodingException {
  int encoding=id3Data.readUnsignedByte();
  String charset=getCharsetName(encoding);
  byte[] data=new byte[frameSize - 1];
  id3Data.readBytes(data,0,frameSize - 1);
  int descriptionEndIndex=indexOfEos(data,0,encoding);
  String description=new String(data,0,descriptionEndIndex,charset);
  String url;
  int urlStartIndex=descriptionEndIndex + delimiterLength(encoding);
  if (urlStartIndex < data.length) {
    int urlEndIndex=indexOfZeroByte(data,0);
    url=new String(data,urlStartIndex,urlEndIndex - urlStartIndex,"String_Node_Str");
  }
 else {
    url="String_Node_Str";
  }
  return new UrlLinkFrame("String_Node_Str",description,url);
}

Fixed version (ground truth):
private static UrlLinkFrame decodeWxxxFrame(ParsableByteArray id3Data,int frameSize) throws UnsupportedEncodingException {
  int encoding=id3Data.readUnsignedByte();
  String charset=getCharsetName(encoding);
  byte[] data=new byte[frameSize - 1];
  id3Data.readBytes(data,0,frameSize - 1);
  int descriptionEndIndex=indexOfEos(data,0,encoding);
  String description=new String(data,0,descriptionEndIndex,charset);
  String url;
  int urlStartIndex=descriptionEndIndex + delimiterLength(encoding);
  if (urlStartIndex < data.length) {
    int urlEndIndex=indexOfZeroByte(data,urlStartIndex);
    url=new String(data,urlStartIndex,urlEndIndex - urlStartIndex,"String_Node_Str");
  }
 else {
    url="String_Node_Str";
  }
  return new UrlLinkFrame("String_Node_Str",description,url);
}
Program: 110311
Project: 110311
Buggy source:
private static ChapterTOCFrame decodeChapterTOCFrame(ParsableByteArray id3Data,int frameSize,int majorVersion,boolean unsignedIntFrameSizeHack,int frameHeaderSize) throws UnsupportedEncodingException {
  int framePosition=id3Data.getPosition();
  int elementIdEndIndex=indexOfZeroByte(id3Data.data,framePosition);
  String elementId=new String(id3Data.data,framePosition,elementIdEndIndex - framePosition,"String_Node_Str");
  id3Data.setPosition(elementIdEndIndex + 1);
  int ctocFlags=id3Data.readUnsignedByte();
  boolean isRoot=(ctocFlags & 0x0002) != 0;
  boolean isOrdered=(ctocFlags & 0x0001) != 0;
  int childCount=id3Data.readUnsignedByte();
  String[] children=new String[childCount];
  for (int i=0; i < childCount; i++) {
    int startIndex=id3Data.getPosition();
    int endIndex=indexOfZeroByte(id3Data.data,startIndex);
    children[i]=new String(id3Data.data,startIndex,endIndex - startIndex,"String_Node_Str");
  }
  ArrayList<Id3Frame> subFrames=new ArrayList<>();
  int limit=framePosition + frameSize;
  while (id3Data.getPosition() < limit) {
    Id3Frame frame=decodeFrame(majorVersion,id3Data,unsignedIntFrameSizeHack,frameHeaderSize);
    if (frame != null) {
      subFrames.add(frame);
    }
  }
  Id3Frame[] subFrameArray=new Id3Frame[subFrames.size()];
  subFrames.toArray(subFrameArray);
  return new ChapterTOCFrame(elementId,isRoot,isOrdered,children,subFrameArray);
}

Fixed version (ground truth):
private static ChapterTOCFrame decodeChapterTOCFrame(ParsableByteArray id3Data,int frameSize,int majorVersion,boolean unsignedIntFrameSizeHack,int frameHeaderSize) throws UnsupportedEncodingException {
  int framePosition=id3Data.getPosition();
  int elementIdEndIndex=indexOfZeroByte(id3Data.data,framePosition);
  String elementId=new String(id3Data.data,framePosition,elementIdEndIndex - framePosition,"String_Node_Str");
  id3Data.setPosition(elementIdEndIndex + 1);
  int ctocFlags=id3Data.readUnsignedByte();
  boolean isRoot=(ctocFlags & 0x0002) != 0;
  boolean isOrdered=(ctocFlags & 0x0001) != 0;
  int childCount=id3Data.readUnsignedByte();
  String[] children=new String[childCount];
  for (int i=0; i < childCount; i++) {
    int startIndex=id3Data.getPosition();
    int endIndex=indexOfZeroByte(id3Data.data,startIndex);
    children[i]=new String(id3Data.data,startIndex,endIndex - startIndex,"String_Node_Str");
    id3Data.setPosition(endIndex + 1);
  }
  ArrayList<Id3Frame> subFrames=new ArrayList<>();
  int limit=framePosition + frameSize;
  while (id3Data.getPosition() < limit) {
    Id3Frame frame=decodeFrame(majorVersion,id3Data,unsignedIntFrameSizeHack,frameHeaderSize);
    if (frame != null) {
      subFrames.add(frame);
    }
  }
  Id3Frame[] subFrameArray=new Id3Frame[subFrames.size()];
  subFrames.toArray(subFrameArray);
  return new ChapterTOCFrame(elementId,isRoot,isOrdered,children,subFrameArray);
}
Program: 110312
Project: 110312
Buggy source:
private void handlePreambleAddressCode(byte cc1,byte cc2){
  int row=ROW_INDICES[cc1 & 0x07];
  boolean nextRowDown=(cc2 & 0x20) != 0;
  if (row != currentCueBuilder.getRow() || nextRowDown) {
    if (!currentCueBuilder.isEmpty()) {
      currentCueBuilder=new CueBuilder(captionMode,captionRowCount);
      cueBuilders.add(currentCueBuilder);
    }
    currentCueBuilder.setRow(nextRowDown ? ++row : row);
  }
  if ((cc2 & 0x01) == 0x01) {
    currentCueBuilder.setPreambleStyle(new UnderlineSpan());
  }
  int attribute=cc2 >> 1 & 0x0F;
  if (attribute <= 0x07) {
    if (attribute == 0x07) {
      currentCueBuilder.setPreambleStyle(new StyleSpan(Typeface.ITALIC));
      currentCueBuilder.setPreambleStyle(new ForegroundColorSpan(Color.WHITE));
    }
 else {
      currentCueBuilder.setPreambleStyle(new ForegroundColorSpan(COLORS[attribute]));
    }
  }
 else {
    currentCueBuilder.setIndent(COLUMN_INDICES[attribute & 0x07]);
  }
}

Fixed version (ground truth):
private void handlePreambleAddressCode(byte cc1,byte cc2){
  int row=ROW_INDICES[cc1 & 0x07];
  boolean nextRowDown=(cc2 & 0x20) != 0;
  if (row != currentCueBuilder.getRow() || nextRowDown) {
    if (captionMode != CC_MODE_ROLL_UP && !currentCueBuilder.isEmpty()) {
      currentCueBuilder=new CueBuilder(captionMode,captionRowCount);
      cueBuilders.add(currentCueBuilder);
    }
    currentCueBuilder.setRow(nextRowDown ? ++row : row);
  }
  if ((cc2 & 0x01) == 0x01) {
    currentCueBuilder.setPreambleStyle(new UnderlineSpan());
  }
  int attribute=cc2 >> 1 & 0x0F;
  if (attribute <= 0x07) {
    if (attribute == 0x07) {
      currentCueBuilder.setPreambleStyle(new StyleSpan(Typeface.ITALIC));
      currentCueBuilder.setPreambleStyle(new ForegroundColorSpan(Color.WHITE));
    }
 else {
      currentCueBuilder.setPreambleStyle(new ForegroundColorSpan(COLORS[attribute]));
    }
  }
 else {
    currentCueBuilder.setIndent(COLUMN_INDICES[attribute & 0x07]);
  }
}
Program: 110313
Project: 110313
Buggy source:
/** 
 * Attempts to locate the keyframe before the specified time, if it's present in the buffer.
 * @param timeUs The seek time.
 * @return The offset of the keyframe's data if the keyframe was present.{@link C#POSITION_UNSET} otherwise.
 */
public synchronized long skipToKeyframeBefore(long timeUs){
  if (queueSize == 0 || timeUs < timesUs[relativeReadIndex]) {
    return C.POSITION_UNSET;
  }
  int lastWriteIndex=(relativeWriteIndex == 0 ? capacity : relativeWriteIndex) - 1;
  long lastTimeUs=timesUs[lastWriteIndex];
  if (timeUs > lastTimeUs) {
    return C.POSITION_UNSET;
  }
  int sampleCount=0;
  int sampleCountToKeyframe=-1;
  int searchIndex=relativeReadIndex;
  while (searchIndex != relativeWriteIndex) {
    if (timesUs[searchIndex] > timeUs) {
      break;
    }
 else     if ((flags[searchIndex] & C.BUFFER_FLAG_KEY_FRAME) != 0) {
      sampleCountToKeyframe=sampleCount;
    }
    searchIndex=(searchIndex + 1) % capacity;
    sampleCount++;
  }
  if (sampleCountToKeyframe == -1) {
    return C.POSITION_UNSET;
  }
  queueSize-=sampleCountToKeyframe;
  relativeReadIndex=(relativeReadIndex + sampleCountToKeyframe) % capacity;
  absoluteReadIndex+=sampleCountToKeyframe;
  return offsets[relativeReadIndex];
}

Fixed version (ground truth):
/** 
 * Attempts to locate the keyframe before the specified time, if it's present in the buffer.
 * @param timeUs The seek time.
 * @return The offset of the keyframe's data if the keyframe was present.{@link C#POSITION_UNSET} otherwise.
 */
public synchronized long skipToKeyframeBefore(long timeUs){
  if (queueSize == 0 || timeUs < timesUs[relativeReadIndex]) {
    return C.POSITION_UNSET;
  }
  if (timeUs > largestQueuedTimestampUs) {
    return C.POSITION_UNSET;
  }
  int sampleCount=0;
  int sampleCountToKeyframe=-1;
  int searchIndex=relativeReadIndex;
  while (searchIndex != relativeWriteIndex) {
    if (timesUs[searchIndex] > timeUs) {
      break;
    }
 else     if ((flags[searchIndex] & C.BUFFER_FLAG_KEY_FRAME) != 0) {
      sampleCountToKeyframe=sampleCount;
    }
    searchIndex=(searchIndex + 1) % capacity;
    sampleCount++;
  }
  if (sampleCountToKeyframe == -1) {
    return C.POSITION_UNSET;
  }
  queueSize-=sampleCountToKeyframe;
  relativeReadIndex=(relativeReadIndex + sampleCountToKeyframe) % capacity;
  absoluteReadIndex+=sampleCountToKeyframe;
  return offsets[relativeReadIndex];
}