Program: 110412
Project: 110412
Buggy source:
@Override protected void parsePayload(ParsableByteArray data,long timeUs){
  int packetType=data.readUnsignedByte();
  int compositionTime=data.readUnsignedInt24();
  if (compositionTime > 0) {
    timeUs+=compositionTime * 1000;
  }
  if (packetType == AVC_PACKET_TYPE_SEQUENCE_HEADER && !hasOutputFormat) {
    ParsableByteArray videoSequence=new ParsableByteArray(new byte[data.bytesLeft()]);
    data.readBytes(videoSequence.data,0,data.bytesLeft());
    AvcSequenceHeaderData avcData;
    try {
      avcData=parseAvcCodecPrivate(videoSequence);
      nalUnitsLength=avcData.nalUnitLengthFieldLength;
    }
 catch (    ParserException e) {
      e.printStackTrace();
      return;
    }
    MediaFormat mediaFormat=MediaFormat.createVideoFormat(MimeTypes.VIDEO_H264,MediaFormat.NO_VALUE,MediaFormat.NO_VALUE,durationUs,avcData.width,avcData.height,avcData.initializationData,MediaFormat.NO_VALUE,avcData.pixelWidthAspectRatio);
    output.format(mediaFormat);
    hasOutputFormat=true;
  }
 else   if (packetType == AVC_PACKET_TYPE_AVC_NALU) {
    byte[] nalLengthData=nalLength.data;
    nalLengthData[0]=0;
    nalLengthData[1]=0;
    nalLengthData[2]=0;
    int nalUnitLengthFieldLength=nalUnitsLength;
    int nalUnitLengthFieldLengthDiff=4 - nalUnitsLength;
    int bytesWritten=0;
    int bytesToWrite;
    while (data.bytesLeft() > 0) {
      data.readBytes(nalLength.data,nalUnitLengthFieldLengthDiff,nalUnitLengthFieldLength);
      nalLength.setPosition(0);
      bytesToWrite=nalLength.readUnsignedIntToInt();
      nalStartCode.setPosition(0);
      output.sampleData(nalStartCode,4);
      bytesWritten+=4;
      output.sampleData(data,bytesToWrite);
      bytesWritten+=bytesToWrite;
    }
    output.sampleMetadata(timeUs,frameType == VIDEO_FRAME_KEYFRAME ? C.SAMPLE_FLAG_SYNC : 0,bytesWritten,0,null);
  }
 else   if (packetType == AVC_PACKET_TYPE_AVC_END_OF_SEQUENCE) {
    Log.d(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void parsePayload(ParsableByteArray data,long timeUs){
  int packetType=data.readUnsignedByte();
  int compositionTime=data.readUnsignedInt24();
  if (compositionTime > 0) {
    timeUs+=compositionTime * 1000;
  }
  if (packetType == AVC_PACKET_TYPE_SEQUENCE_HEADER && !hasOutputFormat) {
    ParsableByteArray videoSequence=new ParsableByteArray(new byte[data.bytesLeft()]);
    data.readBytes(videoSequence.data,0,data.bytesLeft());
    AvcSequenceHeaderData avcData;
    try {
      avcData=parseAvcCodecPrivate(videoSequence);
      nalUnitsLength=avcData.nalUnitLengthFieldLength;
    }
 catch (    ParserException e) {
      e.printStackTrace();
      return;
    }
    MediaFormat mediaFormat=MediaFormat.createVideoFormat(MediaFormat.NO_VALUE,MimeTypes.VIDEO_H264,MediaFormat.NO_VALUE,MediaFormat.NO_VALUE,durationUs,avcData.width,avcData.height,avcData.initializationData,MediaFormat.NO_VALUE,avcData.pixelWidthAspectRatio);
    output.format(mediaFormat);
    hasOutputFormat=true;
  }
 else   if (packetType == AVC_PACKET_TYPE_AVC_NALU) {
    byte[] nalLengthData=nalLength.data;
    nalLengthData[0]=0;
    nalLengthData[1]=0;
    nalLengthData[2]=0;
    int nalUnitLengthFieldLength=nalUnitsLength;
    int nalUnitLengthFieldLengthDiff=4 - nalUnitsLength;
    int bytesWritten=0;
    int bytesToWrite;
    while (data.bytesLeft() > 0) {
      data.readBytes(nalLength.data,nalUnitLengthFieldLengthDiff,nalUnitLengthFieldLength);
      nalLength.setPosition(0);
      bytesToWrite=nalLength.readUnsignedIntToInt();
      nalStartCode.setPosition(0);
      output.sampleData(nalStartCode,4);
      bytesWritten+=4;
      output.sampleData(data,bytesToWrite);
      bytesWritten+=bytesToWrite;
    }
    output.sampleMetadata(timeUs,frameType == VIDEO_FRAME_KEYFRAME ? C.SAMPLE_FLAG_SYNC : 0,bytesWritten,0,null);
  }
 else   if (packetType == AVC_PACKET_TYPE_AVC_END_OF_SEQUENCE) {
    Log.d(TAG,"String_Node_Str");
  }
}