Program: 154082
Project: 154082
Buggy source:
/** 
 * Performs convolution on a specified rectangle. The sources are cobbled.
 * @param sources an array of source Rasters, guaranteed to provide allnecessary source data for computing the output.
 * @param dest a WritableRaster tile containing the area to be computed.
 * @param destRect the rectangle within dest to be processed.
 */
protected void computeRect(Raster[] sources,WritableRaster dest,Rectangle destRect){
  Raster source=sources[0];
  Rectangle srcRect=mapDestRect(destRect,0);
  int formatTag=MediaLibAccessor.findCompatibleTag(sources,dest);
  MediaLibAccessor srcAccessor=new MediaLibAccessor(source,srcRect,formatTag,true);
  MediaLibAccessor dstAccessor=new MediaLibAccessor(dest,destRect,formatTag,true);
  int numBands=getSampleModel().getNumBands();
  mediaLibImage[] srcML=srcAccessor.getMediaLibImages();
  mediaLibImage[] dstML=dstAccessor.getMediaLibImages();
  for (int i=0; i < dstML.length; i++) {
switch (dstAccessor.getDataType()) {
case DataBuffer.TYPE_BYTE:
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_SHORT:
case DataBuffer.TYPE_INT:
      if (shift == -1) {
        setShift(formatTag);
      }
    if (kw == 3) {
      Image.Conv3x3(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
 else {
      Image.Conv5x5(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
  break;
case DataBuffer.TYPE_FLOAT:
case DataBuffer.TYPE_DOUBLE:
if (kw == 3) {
  Image.Conv3x3_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
 else {
  Image.Conv5x5_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
break;
default :
String className=this.getClass().getName();
throw new RuntimeException(JaiI18N.getString("String_Node_Str"));
}
}
if (dstAccessor.isDataCopy()) {
dstAccessor.copyDataToRaster();
}
}

Fixed version (ground truth):
/** 
 * Performs convolution on a specified rectangle. The sources are cobbled.
 * @param sources an array of source Rasters, guaranteed to provide allnecessary source data for computing the output.
 * @param dest a WritableRaster tile containing the area to be computed.
 * @param destRect the rectangle within dest to be processed.
 */
protected void computeRect(Raster[] sources,WritableRaster dest,Rectangle destRect){
  Raster source=sources[0];
  Rectangle srcRect=mapDestRect(destRect,0);
  int formatTag=MediaLibAccessor.findCompatibleTag(sources,dest);
  MediaLibAccessor srcAccessor=new MediaLibAccessor(source,srcRect,formatTag,true);
  MediaLibAccessor dstAccessor=new MediaLibAccessor(dest,destRect,formatTag,true);
  int numBands=getSampleModel().getNumBands();
  mediaLibImage[] srcML=srcAccessor.getMediaLibImages();
  mediaLibImage[] dstML=dstAccessor.getMediaLibImages();
  for (int i=0; i < dstML.length; i++) {
switch (dstAccessor.getDataType()) {
case DataBuffer.TYPE_BYTE:
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_SHORT:
case DataBuffer.TYPE_INT:
      if (shift == -1) {
        setShift(formatTag);
      }
    if (kw == 2) {
      Image.Conv2x2(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
 else     if (kw == 3) {
      Image.Conv3x3(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
 else     if (kw == 4) {
      Image.Conv4x4(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
 else     if (kw == 5) {
      Image.Conv5x5(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
 else     if (kw == 7) {
      Image.Conv7x7(dstML[i],srcML[i],intkData,shift,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
    }
  break;
case DataBuffer.TYPE_FLOAT:
case DataBuffer.TYPE_DOUBLE:
if (kw == 2) {
  Image.Conv2x2_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
 else if (kw == 3) {
  Image.Conv3x3_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
 else if (kw == 4) {
  Image.Conv4x4_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
 else if (kw == 5) {
  Image.Conv5x5_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
 else if (kw == 7) {
  Image.Conv7x7_Fp(dstML[i],srcML[i],doublekData,((1 << numBands) - 1),Constants.MLIB_EDGE_DST_NO_WRITE);
}
break;
default :
String className=this.getClass().getName();
throw new RuntimeException(JaiI18N.getString("String_Node_Str"));
}
}
if (dstAccessor.isDataCopy()) {
dstAccessor.copyDataToRaster();
}
}