From: Keiichiro O. <ur...@us...> - 2016-10-10 14:34:06
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16382 Modified Files: input_source_interpolation.cc input_source_interpolation.h poledf.cc Log Message: add use_final_frame_for_exceeded_frame args to InputSourceInterpolation constructor Index: input_source_interpolation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interpolation.h 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_interpolation.h 10 Oct 2016 14:34:04 -0000 1.2 *************** *** 58,61 **** --- 58,62 ---- InputSourceInterpolation(int frame_period, int interpolation_period, + bool use_final_frame_for_exceeded_frame, InputSourcePreprocessingInterface* source); *************** *** 64,78 **** // ! virtual int GetFramePeriod() const { return frame_period_; } // ! virtual int GetInterpolationPeriod() const { return interpolation_period_; } // ! virtual bool IsValid() const { return is_valid_; } --- 65,84 ---- // ! int GetFramePeriod() const { return frame_period_; } // ! int GetInterpolationPeriod() const { return interpolation_period_; } // ! bool UseFinalFrameForExceededFrame() const { ! return use_final_frame_for_exceeded_frame_; ! } ! ! // ! bool IsValid() const { return is_valid_; } *************** *** 95,98 **** --- 101,110 ---- // + const bool use_final_frame_for_exceeded_frame_; + + // + int remained_num_samples_; + + // int data_length_; Index: input_source_interpolation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interpolation.cc 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_interpolation.cc 10 Oct 2016 14:34:04 -0000 1.2 *************** *** 54,76 **** int frame_period, int interpolation_period, InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), point_index_in_frame_(0), source_(source), ! is_valid_(false) { if (frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || ! NULL == source) { return; } if (!source_->Get(&curr_data_)) { return; } ! is_valid_ = true; data_length_ = curr_data_.size(); --- 54,83 ---- int frame_period, int interpolation_period, + bool use_final_frame_for_exceeded_frame, InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), + use_final_frame_for_exceeded_frame_(use_final_frame_for_exceeded_frame), + remained_num_samples_(0), + data_length_(0), point_index_in_frame_(0), source_(source), ! is_valid_(true) { if (frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || ! NULL == source || ! !source->IsValid()) { ! is_valid_ = false; return; } if (!source_->Get(&curr_data_)) { + remained_num_samples_ = 0; return; } ! remained_num_samples_ = frame_period_ + 1; data_length_ = curr_data_.size(); *************** *** 79,82 **** --- 86,90 ---- std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); + remained_num_samples_ = 1; } *************** *** 100,103 **** --- 108,115 ---- } + if (remained_num_samples_ <= 0) { + return false; + } + if (buffer->size() < static_cast<std::size_t>(data_length_)) { buffer->resize(data_length_); *************** *** 107,110 **** --- 119,131 ---- buffer->begin()); + --remained_num_samples_; + + if (remained_num_samples_ <= 0) { + if (use_final_frame_for_exceeded_frame_) { + remained_num_samples_ = 1; + } + return true; + } + // Update internal states for the next call. ++point_index_in_frame_; *************** *** 118,121 **** --- 139,145 ---- std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); + remained_num_samples_ = 1; + } else { + remained_num_samples_ = frame_period_ + 1; } Index: poledf.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/poledf.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** poledf.cc 8 Oct 2016 15:14:59 -0000 1.2 --- poledf.cc 10 Oct 2016 14:34:04 -0000 1.3 *************** *** 213,216 **** --- 213,217 ---- sptk::InputSourceInterpolation interpolation(frame_period, interpolation_period, + true, &preprocessing); double filter_input, filter_output; |