Program: 103636
Project: 103636
Buggy source:
/** 
 * Attempts to set the <tt>Format</tt> to be reported by the <tt>FormatControl</tt> of a <tt>PushBufferStream</tt> at a specific zero-based index in the list of streams of this <tt>PushBufferDataSource</tt>. The <tt>PushBufferStream</tt> does not exist at the time of the attempt to set its <tt>Format</tt>.
 * @param streamIndex the zero-based index of the <tt>PushBufferStream</tt>the <tt>Format</tt> of which is to be set
 * @param oldValue the last-known <tt>Format</tt> for the<tt>PushBufferStream</tt> at the specified <tt>streamIndex</tt>
 * @param newValue the <tt>Format</tt> which is to be set
 * @return the <tt>Format</tt> to be reported by the <tt>FormatControl</tt>of the <tt>PushBufferStream</tt> at the specified <tt>streamIndex</tt> in the list of streams of this <tt>PushBufferStream</tt> or <tt>null</tt> if the attempt to set the <tt>Format</tt> did not success and any last-known <tt>Format</tt> is to be left in effect
 * @see AbstractPushBufferCaptureDevice#setFormat(int,Format,Format)
 */
@Override protected Format setFormat(int streamIndex,Format oldValue,Format newValue){
  if (newValue instanceof VideoFormat) {
    VideoFormat newVideoFormatValue=(VideoFormat)newValue;
    Dimension newSize=newVideoFormatValue.getSize();
    if ((newSize != null) && (newSize.width < DEFAULT_WIDTH) && (newSize.height < DEFAULT_HEIGHT)) {
      String encoding=newVideoFormatValue.getEncoding();
      Class<?> dataType=newVideoFormatValue.getDataType();
      float frameRate=newVideoFormatValue.getFrameRate();
      newSize=new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT);
      newValue=((Format)newVideoFormatValue.clone()).relax().intersects(new VideoFormat(encoding,newSize,Format.NOT_SPECIFIED,dataType,frameRate));
    }
    if (newValue instanceof AVFrameFormat) {
      AVFrameFormat f=(AVFrameFormat)newValue;
      long pixelFormat=-1;
      int pixFmt=f.getPixFmt();
      pixelFormat=getDSPixFmt(pixFmt);
      if (pixelFormat != -1) {
        DSFormat fmt=new DSFormat(newSize.width,newSize.height,pixelFormat);
        device.setFormat(fmt);
      }
    }
    return newValue;
  }
 else {
    return super.setFormat(streamIndex,oldValue,newValue);
  }
}

Fixed version (ground truth):
/** 
 * Attempts to set the <tt>Format</tt> to be reported by the <tt>FormatControl</tt> of a <tt>PushBufferStream</tt> at a specific zero-based index in the list of streams of this <tt>PushBufferDataSource</tt>. The <tt>PushBufferStream</tt> does not exist at the time of the attempt to set its <tt>Format</tt>.
 * @param streamIndex the zero-based index of the <tt>PushBufferStream</tt>the <tt>Format</tt> of which is to be set
 * @param oldValue the last-known <tt>Format</tt> for the<tt>PushBufferStream</tt> at the specified <tt>streamIndex</tt>
 * @param newValue the <tt>Format</tt> which is to be set
 * @return the <tt>Format</tt> to be reported by the <tt>FormatControl</tt>of the <tt>PushBufferStream</tt> at the specified <tt>streamIndex</tt> in the list of streams of this <tt>PushBufferStream</tt> or <tt>null</tt> if the attempt to set the <tt>Format</tt> did not success and any last-known <tt>Format</tt> is to be left in effect
 * @see AbstractPushBufferCaptureDevice#setFormat(int,Format,Format)
 */
@Override protected Format setFormat(int streamIndex,Format oldValue,Format newValue){
  if (newValue instanceof VideoFormat) {
    VideoFormat newVideoFormatValue=(VideoFormat)newValue;
    Dimension newSize=newVideoFormatValue.getSize();
    if ((newSize != null) && (newSize.width < DEFAULT_WIDTH) && (newSize.height < DEFAULT_HEIGHT)) {
      String encoding=newVideoFormatValue.getEncoding();
      Class<?> dataType=newVideoFormatValue.getDataType();
      float frameRate=newVideoFormatValue.getFrameRate();
      newSize=new Dimension(DEFAULT_WIDTH,DEFAULT_HEIGHT);
      newValue=((Format)newVideoFormatValue.clone()).relax().intersects(new VideoFormat(encoding,newSize,Format.NOT_SPECIFIED,dataType,frameRate));
    }
    if (newValue instanceof AVFrameFormat) {
      AVFrameFormat f=(AVFrameFormat)newValue;
      long pixelFormat=-1;
      int pixFmt=f.getPixFmt();
      pixelFormat=getDSPixFmt(pixFmt);
      if (pixelFormat != -1) {
        DSFormat fmt=new DSFormat(newSize.width,newSize.height,pixelFormat);
        nativeFormat=fmt;
      }
    }
    return newValue;
  }
 else {
    return super.setFormat(streamIndex,oldValue,newValue);
  }
}