Program: 110463
Project: 110463
Buggy source:
private void parseMediaFormat(NalUnitTargetBuffer sps,NalUnitTargetBuffer pps){
  byte[] spsData=new byte[sps.nalLength];
  byte[] ppsData=new byte[pps.nalLength];
  System.arraycopy(sps.nalData,0,spsData,0,sps.nalLength);
  System.arraycopy(pps.nalData,0,ppsData,0,pps.nalLength);
  List<byte[]> initializationData=new ArrayList<byte[]>();
  initializationData.add(spsData);
  initializationData.add(ppsData);
  byte[] unescapedSps=unescapeStream(spsData,0,spsData.length);
  ParsableBitArray bitArray=new ParsableBitArray(unescapedSps);
  bitArray.skipBits(32);
  int profileIdc=bitArray.readBits(8);
  bitArray.skipBits(16);
  bitArray.readUnsignedExpGolombCodedInt();
  int chromaFormatIdc=1;
  if (profileIdc == 100 || profileIdc == 110 || profileIdc == 122 || profileIdc == 244 || profileIdc == 44 || profileIdc == 83 || profileIdc == 86 || profileIdc == 118 || profileIdc == 128 || profileIdc == 138) {
    chromaFormatIdc=bitArray.readUnsignedExpGolombCodedInt();
    if (chromaFormatIdc == 3) {
      bitArray.skipBits(1);
    }
    bitArray.readUnsignedExpGolombCodedInt();
    bitArray.readUnsignedExpGolombCodedInt();
    bitArray.skipBits(1);
    boolean seqScalingMatrixPresentFlag=bitArray.readBit();
    if (seqScalingMatrixPresentFlag) {
      int limit=(chromaFormatIdc != 3) ? 8 : 12;
      for (int i=0; i < limit; i++) {
        boolean seqScalingListPresentFlag=bitArray.readBit();
        if (seqScalingListPresentFlag) {
          skipScalingList(bitArray,i < 6 ? 16 : 64);
        }
      }
    }
  }
  bitArray.readUnsignedExpGolombCodedInt();
  long picOrderCntType=bitArray.readUnsignedExpGolombCodedInt();
  if (picOrderCntType == 0) {
    bitArray.readUnsignedExpGolombCodedInt();
  }
 else   if (picOrderCntType == 1) {
    bitArray.skipBits(1);
    bitArray.readSignedExpGolombCodedInt();
    bitArray.readSignedExpGolombCodedInt();
    long numRefFramesInPicOrderCntCycle=bitArray.readUnsignedExpGolombCodedInt();
    for (int i=0; i < numRefFramesInPicOrderCntCycle; i++) {
      bitArray.readUnsignedExpGolombCodedInt();
    }
  }
  bitArray.readUnsignedExpGolombCodedInt();
  bitArray.skipBits(1);
  int picWidthInMbs=bitArray.readUnsignedExpGolombCodedInt() + 1;
  int picHeightInMapUnits=bitArray.readUnsignedExpGolombCodedInt() + 1;
  boolean frameMbsOnlyFlag=bitArray.readBit();
  int frameHeightInMbs=(2 - (frameMbsOnlyFlag ? 1 : 0)) * picHeightInMapUnits;
  if (!frameMbsOnlyFlag) {
    bitArray.skipBits(1);
  }
  bitArray.skipBits(1);
  int frameWidth=picWidthInMbs * 16;
  int frameHeight=frameHeightInMbs * 16;
  boolean frameCroppingFlag=bitArray.readBit();
  if (frameCroppingFlag) {
    int frameCropLeftOffset=bitArray.readUnsignedExpGolombCodedInt();
    int frameCropRightOffset=bitArray.readUnsignedExpGolombCodedInt();
    int frameCropTopOffset=bitArray.readUnsignedExpGolombCodedInt();
    int frameCropBottomOffset=bitArray.readUnsignedExpGolombCodedInt();
    int cropUnitX, cropUnitY;
    if (chromaFormatIdc == 0) {
      cropUnitX=1;
      cropUnitY=2 - (frameMbsOnlyFlag ? 1 : 0);
    }
 else {
      int subWidthC=(chromaFormatIdc == 3) ? 1 : 2;
      int subHeightC=(chromaFormatIdc == 1) ? 2 : 1;
      cropUnitX=subWidthC;
      cropUnitY=subHeightC * (2 - (frameMbsOnlyFlag ? 1 : 0));
    }
    frameWidth-=(frameCropLeftOffset + frameCropRightOffset) * cropUnitX;
    frameHeight-=(frameCropTopOffset + frameCropBottomOffset) * cropUnitY;
  }
  setMediaFormat(MediaFormat.createVideoFormat(MimeTypes.VIDEO_H264,MediaFormat.NO_VALUE,frameWidth,frameHeight,initializationData));
}

Fixed version (ground truth):
private void parseMediaFormat(NalUnitTargetBuffer sps,NalUnitTargetBuffer pps){
  byte[] spsData=new byte[sps.nalLength];
  byte[] ppsData=new byte[pps.nalLength];
  System.arraycopy(sps.nalData,0,spsData,0,sps.nalLength);
  System.arraycopy(pps.nalData,0,ppsData,0,pps.nalLength);
  List<byte[]> initializationData=new ArrayList<byte[]>();
  initializationData.add(spsData);
  initializationData.add(ppsData);
  unescapeStream(sps.nalData,sps.nalLength);
  ParsableBitArray bitArray=new ParsableBitArray(sps.nalData);
  bitArray.skipBits(32);
  int profileIdc=bitArray.readBits(8);
  bitArray.skipBits(16);
  bitArray.readUnsignedExpGolombCodedInt();
  int chromaFormatIdc=1;
  if (profileIdc == 100 || profileIdc == 110 || profileIdc == 122 || profileIdc == 244 || profileIdc == 44 || profileIdc == 83 || profileIdc == 86 || profileIdc == 118 || profileIdc == 128 || profileIdc == 138) {
    chromaFormatIdc=bitArray.readUnsignedExpGolombCodedInt();
    if (chromaFormatIdc == 3) {
      bitArray.skipBits(1);
    }
    bitArray.readUnsignedExpGolombCodedInt();
    bitArray.readUnsignedExpGolombCodedInt();
    bitArray.skipBits(1);
    boolean seqScalingMatrixPresentFlag=bitArray.readBit();
    if (seqScalingMatrixPresentFlag) {
      int limit=(chromaFormatIdc != 3) ? 8 : 12;
      for (int i=0; i < limit; i++) {
        boolean seqScalingListPresentFlag=bitArray.readBit();
        if (seqScalingListPresentFlag) {
          skipScalingList(bitArray,i < 6 ? 16 : 64);
        }
      }
    }
  }
  bitArray.readUnsignedExpGolombCodedInt();
  long picOrderCntType=bitArray.readUnsignedExpGolombCodedInt();
  if (picOrderCntType == 0) {
    bitArray.readUnsignedExpGolombCodedInt();
  }
 else   if (picOrderCntType == 1) {
    bitArray.skipBits(1);
    bitArray.readSignedExpGolombCodedInt();
    bitArray.readSignedExpGolombCodedInt();
    long numRefFramesInPicOrderCntCycle=bitArray.readUnsignedExpGolombCodedInt();
    for (int i=0; i < numRefFramesInPicOrderCntCycle; i++) {
      bitArray.readUnsignedExpGolombCodedInt();
    }
  }
  bitArray.readUnsignedExpGolombCodedInt();
  bitArray.skipBits(1);
  int picWidthInMbs=bitArray.readUnsignedExpGolombCodedInt() + 1;
  int picHeightInMapUnits=bitArray.readUnsignedExpGolombCodedInt() + 1;
  boolean frameMbsOnlyFlag=bitArray.readBit();
  int frameHeightInMbs=(2 - (frameMbsOnlyFlag ? 1 : 0)) * picHeightInMapUnits;
  if (!frameMbsOnlyFlag) {
    bitArray.skipBits(1);
  }
  bitArray.skipBits(1);
  int frameWidth=picWidthInMbs * 16;
  int frameHeight=frameHeightInMbs * 16;
  boolean frameCroppingFlag=bitArray.readBit();
  if (frameCroppingFlag) {
    int frameCropLeftOffset=bitArray.readUnsignedExpGolombCodedInt();
    int frameCropRightOffset=bitArray.readUnsignedExpGolombCodedInt();
    int frameCropTopOffset=bitArray.readUnsignedExpGolombCodedInt();
    int frameCropBottomOffset=bitArray.readUnsignedExpGolombCodedInt();
    int cropUnitX, cropUnitY;
    if (chromaFormatIdc == 0) {
      cropUnitX=1;
      cropUnitY=2 - (frameMbsOnlyFlag ? 1 : 0);
    }
 else {
      int subWidthC=(chromaFormatIdc == 3) ? 1 : 2;
      int subHeightC=(chromaFormatIdc == 1) ? 2 : 1;
      cropUnitX=subWidthC;
      cropUnitY=subHeightC * (2 - (frameMbsOnlyFlag ? 1 : 0));
    }
    frameWidth-=(frameCropLeftOffset + frameCropRightOffset) * cropUnitX;
    frameHeight-=(frameCropTopOffset + frameCropBottomOffset) * cropUnitY;
  }
  setMediaFormat(MediaFormat.createVideoFormat(MimeTypes.VIDEO_H264,MediaFormat.NO_VALUE,frameWidth,frameHeight,initializationData));
}