Program: 104976
Project: 104976
Buggy source:
/** 
 * Returns whether or not the stream represented by 'sourceQualityIndex' is desirable to switch to given the values of currentQualityIndex and targetQualityIndex.  In either case (downscale or upscale), 'sourceQualityIndex' will be desirable if it falls in between currentQualityIndex and targetQualityIndex, e.g.: currentQualityIndex = 1, sourceQualityIndex = 4, targetQualityIndex = 7 -> we're trying to upscale and sourceQualityIndex represents a quality higher than what we currently have (but not the final target) so forwarding it is a step in the right direction currentQualityIndex = 7, sourceQualityIndex = 4, targetQualityIndex = 1 -> we're trying to downscale and sourceQualityIndex represents a quality lower than what we currently have (but not the final target) so forwarding it is a step in the right direction
 * @param currentQualityIndex the index of the stream currently beingforwarded
 * @param sourceQualityIndex the index of the stream to which the incomingframe belongs
 * @param targetQualityIndex the index of the stream we want to forward
 * @return true if the stream represented by sourceQualityIndex representsa step closer (or all the way) to the targetQualityIndex
 */
private boolean shouldSwitchToStream(int currentQualityIndex,int sourceQualityIndex,int targetQualityIndex){
  if ((currentQualityIndex < sourceQualityIndex) && sourceQualityIndex <= targetQualityIndex) {
    return true;
  }
 else   if ((currentQualityIndex > sourceQualityIndex) && (sourceQualityIndex >= targetQualityIndex)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns whether or not the stream represented by 'sourceQualityIndex' is desirable to switch to given the values of currentQualityIndex and targetQualityIndex.  In either case (downscale or upscale), 'sourceQualityIndex' will be desirable if it falls in between currentQualityIndex and targetQualityIndex, e.g.: currentQualityIndex = 1, sourceQualityIndex = 4, targetQualityIndex = 7 -> we're trying to upscale and sourceQualityIndex represents a quality higher than what we currently have (but not the final target) so forwarding it is a step in the right direction currentQualityIndex = 7, sourceQualityIndex = 4, targetQualityIndex = 1 -> we're trying to downscale and sourceQualityIndex represents a quality lower than what we currently have (but not the final target) so forwarding it is a step in the right direction
 * @param currentQualityIndex the index of the stream currently beingforwarded
 * @param sourceQualityIndex the index of the stream to which the incomingframe belongs
 * @param targetQualityIndex the index of the stream we want to forward
 * @return true if the stream represented by sourceQualityIndex representsa step closer (or all the way) to the targetQualityIndex
 */
private boolean shouldSwitchToStream(int currentQualityIndex,int sourceQualityIndex,int targetQualityIndex,RTPEncodingDesc[] encodings){
  if ((currentQualityIndex < sourceQualityIndex) && sourceQualityIndex <= targetQualityIndex) {
    return true;
  }
 else   if ((currentQualityIndex > sourceQualityIndex) && (sourceQualityIndex >= targetQualityIndex)) {
    return true;
  }
 else   if (encodings[targetQualityIndex].requires(sourceQualityIndex)) {
    return true;
  }
  return false;
}