Extend SampleRange on either side
| 74 | |
| 75 | /// Extend SampleRange on either side |
| 76 | void Extend(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side) { |
| 77 | int remaining_samples = samples; |
| 78 | while (remaining_samples > 0) { |
| 79 | if (right_side) { |
| 80 | // Extend range to the right |
| 81 | int samples_per_frame = Frame::GetSamplesPerFrame(frame_end, fps, sample_rate, channels); |
| 82 | if (remaining_samples + sample_end < samples_per_frame) { |
| 83 | sample_end += remaining_samples; |
| 84 | remaining_samples = 0; |
| 85 | } else { |
| 86 | frame_end++; |
| 87 | remaining_samples -= (samples_per_frame - sample_end); |
| 88 | sample_end = 0; |
| 89 | } |
| 90 | } else { |
| 91 | // Extend range to the left |
| 92 | if (sample_start - remaining_samples >= 0) { |
| 93 | sample_start -= remaining_samples; |
| 94 | remaining_samples = 0; |
| 95 | } else { |
| 96 | frame_start--; |
| 97 | remaining_samples -= (sample_start + 1); |
| 98 | sample_start = Frame::GetSamplesPerFrame(frame_start, fps, sample_rate, channels) - 1; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // Increase total |
| 104 | total += samples; |
| 105 | } |
| 106 | |
| 107 | /// Shrink SampleRange on either side |
| 108 | void Shrink(int64_t samples, openshot::Fraction fps, int sample_rate, int channels, bool right_side) { |
no outgoing calls
no test coverage detected