Skip to content

Commit

Permalink
Allow SpeedTimeInterpolator reuse (#199)
Browse files Browse the repository at this point in the history
* Allow SpeedTimeInterpolator reuse

* Minor fixes
  • Loading branch information
natario1 authored Aug 11, 2024
1 parent 4ea35f4 commit 0a415ba
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ class IssuesTests {
transcode {
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(input("0.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 2000_000L, 3000_000L))
addDataSource(input("1.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 4000_000L, 5000_000L))
addDataSource(input("2.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 6000_000L, 7000_000L))
addDataSource(input("3.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 8000_000L, 9000_000L))
addDataSource(input("4.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 10000_000L, 11000_000L))
addDataSource(input("5.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 12000_000L, 13000_000L))
addDataSource(input("6.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 14000_000L, 15000_000L))
addDataSource(input("7.amr"))
addDataSource(ClipDataSource(input("main.mp3"), 0L, 1000_000L))
addDataSource(ClipDataSource(input("main.mp3"), 16000_000L, 17000_000L))
addDataSource(input("8.amr"))
}
Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal interface AudioRemixer {
companion object {
internal operator fun get(inputChannels: Int, outputChannels: Int): AudioRemixer = when {
inputChannels !in setOf(1, 2) -> error("Input channel count not supported: $inputChannels")
outputChannels !in setOf(1, 2) -> error("Input channel count not supported: $inputChannels")
outputChannels !in setOf(1, 2) -> error("Output channel count not supported: $inputChannels")
inputChannels < outputChannels -> UpMixAudioRemixer()
inputChannels > outputChannels -> DownMixAudioRemixer()
else -> PassThroughAudioRemixer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ internal class DefaultTranscodeEngine(
}

private fun createPipeline(
type: TrackType,
index: Int,
status: TrackStatus,
outputFormat: MediaFormat
type: TrackType,
index: Int,
status: TrackStatus,
outputFormat: MediaFormat
): Pipeline {
log.w("createPipeline($type, $index, $status), format=$outputFormat")
val interpolator = timer.interpolator(type, index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public void setOrientation(int rotation) {

@Override
public void setLocation(double latitude, double longitude) {
if (Build.VERSION.SDK_INT >= 19) {
mMuxer.setLocation((float) latitude, (float) longitude);
}
mMuxer.setLocation((float) latitude, (float) longitude);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SpeedTimeInterpolator(float factor) {
* @return the factor
*/
@SuppressWarnings("unused")
public float getFactor() {
public float getFactor(@NonNull TrackType type, long time) {
return (float) mFactor;
}

Expand All @@ -50,7 +50,7 @@ public long interpolate(@NonNull TrackType type, long time) {
data.lastCorrectedTime = time;
} else {
long realDelta = time - data.lastRealTime;
long correctedDelta = (long) ((double) realDelta / mFactor);
long correctedDelta = (long) ((double) realDelta / getFactor(type, time));
data.lastRealTime = time;
data.lastCorrectedTime += correctedDelta;
}
Expand Down

0 comments on commit 0a415ba

Please sign in to comment.