Program: 38137
Project: 38137
Buggy source:
private void setUpMediaRecorder(int cameraId) throws IOException {
  Log.d(TAG,"String_Node_Str");
  String videoSize=mSettingsManager.getValue(SettingsManager.KEY_VIDEO_QUALITY);
  int size=CameraSettings.VIDEO_QUALITY_TABLE.get(videoSize);
  if (mCaptureTimeLapse) {
    size=CameraSettings.getTimeLapseQualityFor(size);
  }
  updateHFRSetting();
  boolean hfr=mHighSpeedCapture && !mHighSpeedCaptureSlowMode;
  mProfile=CamcorderProfile.get(cameraId,size);
  int videoEncoder=SettingTranslation.getVideoEncoder(mSettingsManager.getValue(SettingsManager.KEY_VIDEO_ENCODER));
  int audioEncoder=SettingTranslation.getAudioEncoder(mSettingsManager.getValue(SettingsManager.KEY_AUDIO_ENCODER));
  int outputFormat=MediaRecorder.OutputFormat.MPEG_4;
  if (!mCaptureTimeLapse && !hfr) {
    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  }
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setOutputFormat(mProfile.fileFormat);
  String fileName=generateVideoFilename(outputFormat);
  Log.v(TAG,"String_Node_Str" + fileName);
  mMediaRecorder.setOutputFile(fileName);
  mMediaRecorder.setVideoFrameRate(mProfile.videoFrameRate);
  mMediaRecorder.setVideoEncodingBitRate(mProfile.videoBitRate);
  if (mFrameProcessor.isFrameFilterEnabled()) {
    mMediaRecorder.setVideoSize(mProfile.videoFrameHeight,mProfile.videoFrameWidth);
  }
 else {
    mMediaRecorder.setVideoSize(mProfile.videoFrameWidth,mProfile.videoFrameHeight);
  }
  mMediaRecorder.setVideoEncoder(videoEncoder);
  if (!mCaptureTimeLapse && !hfr) {
    mMediaRecorder.setAudioEncodingBitRate(mProfile.audioBitRate);
    mMediaRecorder.setAudioChannels(mProfile.audioChannels);
    mMediaRecorder.setAudioSamplingRate(mProfile.audioSampleRate);
    mMediaRecorder.setAudioEncoder(audioEncoder);
  }
  mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
  if (mCaptureTimeLapse) {
    double fps=1000 / (double)mTimeBetweenTimeLapseFrameCaptureMs;
    mMediaRecorder.setCaptureRate(fps);
  }
 else   if (mHighSpeedCapture) {
    mHighSpeedFPSRange=new Range(mHighSpeedCaptureRate,mHighSpeedCaptureRate);
    int fps=(int)mHighSpeedFPSRange.getUpper();
    mMediaRecorder.setCaptureRate(fps);
    if (mHighSpeedCaptureSlowMode) {
      mMediaRecorder.setVideoFrameRate(30);
    }
 else {
      mMediaRecorder.setVideoFrameRate(fps);
    }
    int scaledBitrate=mProfile.videoBitRate * fps / mProfile.videoFrameRate;
    Log.i(TAG,"String_Node_Str" + scaledBitrate);
    mMediaRecorder.setVideoEncodingBitRate(scaledBitrate);
  }
  Location loc=mLocationManager.getCurrentLocation();
  if (loc != null) {
    mMediaRecorder.setLocation((float)loc.getLatitude(),(float)loc.getLongitude());
  }
  int rotation=CameraUtil.getJpegRotation(cameraId,mOrientation);
  String videoRotation=mSettingsManager.getValue(SettingsManager.KEY_VIDEO_ROTATION);
  if (videoRotation != null) {
    rotation+=Integer.parseInt(videoRotation);
    rotation=rotation % 360;
  }
  if (mFrameProcessor.isFrameFilterEnabled()) {
    mMediaRecorder.setOrientationHint(0);
  }
 else {
    mMediaRecorder.setOrientationHint(rotation);
  }
  mMediaRecorder.prepare();
}

Fixed version (ground truth):
private void setUpMediaRecorder(int cameraId) throws IOException {
  Log.d(TAG,"String_Node_Str");
  String videoSize=mSettingsManager.getValue(SettingsManager.KEY_VIDEO_QUALITY);
  int size=CameraSettings.VIDEO_QUALITY_TABLE.get(videoSize);
  if (mCaptureTimeLapse) {
    size=CameraSettings.getTimeLapseQualityFor(size);
  }
  updateHFRSetting();
  boolean hfr=mHighSpeedCapture && !mHighSpeedCaptureSlowMode;
  mProfile=CamcorderProfile.get(cameraId,size);
  int videoEncoder=SettingTranslation.getVideoEncoder(mSettingsManager.getValue(SettingsManager.KEY_VIDEO_ENCODER));
  int audioEncoder=SettingTranslation.getAudioEncoder(mSettingsManager.getValue(SettingsManager.KEY_AUDIO_ENCODER));
  int outputFormat=MediaRecorder.OutputFormat.MPEG_4;
  if (!mCaptureTimeLapse && !hfr) {
    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  }
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setOutputFormat(mProfile.fileFormat);
  String fileName=generateVideoFilename(outputFormat);
  Log.v(TAG,"String_Node_Str" + fileName);
  mMediaRecorder.setOutputFile(fileName);
  mMediaRecorder.setVideoFrameRate(mProfile.videoFrameRate);
  mMediaRecorder.setVideoEncodingBitRate(mProfile.videoBitRate);
  if (mFrameProcessor.isFrameFilterEnabled()) {
    mMediaRecorder.setVideoSize(mProfile.videoFrameHeight,mProfile.videoFrameWidth);
  }
 else {
    mMediaRecorder.setVideoSize(mProfile.videoFrameWidth,mProfile.videoFrameHeight);
  }
  mMediaRecorder.setVideoEncoder(videoEncoder);
  if (!mCaptureTimeLapse && !hfr) {
    mMediaRecorder.setAudioEncodingBitRate(mProfile.audioBitRate);
    mMediaRecorder.setAudioChannels(mProfile.audioChannels);
    mMediaRecorder.setAudioSamplingRate(mProfile.audioSampleRate);
    mMediaRecorder.setAudioEncoder(audioEncoder);
  }
  mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
  if (mCaptureTimeLapse) {
    double fps=1000 / (double)mTimeBetweenTimeLapseFrameCaptureMs;
    mMediaRecorder.setCaptureRate(fps);
  }
 else   if (mHighSpeedCapture) {
    mHighSpeedFPSRange=new Range(mHighSpeedCaptureRate,mHighSpeedCaptureRate);
    int fps=(int)mHighSpeedFPSRange.getUpper();
    mMediaRecorder.setCaptureRate(fps);
    if (mHighSpeedCaptureSlowMode) {
      mMediaRecorder.setVideoFrameRate(30);
    }
 else {
      mMediaRecorder.setVideoFrameRate(fps);
    }
    int scaledBitrate=mProfile.videoBitRate * (fps / mProfile.videoFrameRate);
    Log.i(TAG,"String_Node_Str" + scaledBitrate);
    mMediaRecorder.setVideoEncodingBitRate(scaledBitrate);
  }
  Location loc=mLocationManager.getCurrentLocation();
  if (loc != null) {
    mMediaRecorder.setLocation((float)loc.getLatitude(),(float)loc.getLongitude());
  }
  int rotation=CameraUtil.getJpegRotation(cameraId,mOrientation);
  String videoRotation=mSettingsManager.getValue(SettingsManager.KEY_VIDEO_ROTATION);
  if (videoRotation != null) {
    rotation+=Integer.parseInt(videoRotation);
    rotation=rotation % 360;
  }
  if (mFrameProcessor.isFrameFilterEnabled()) {
    mMediaRecorder.setOrientationHint(0);
  }
 else {
    mMediaRecorder.setOrientationHint(rotation);
  }
  mMediaRecorder.prepare();
}