diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedLimiterFallBackFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedLimiterFallBackFingerprint.kt new file mode 100644 index 000000000..2264035e4 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedLimiterFallBackFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.video.customspeed.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object SpeedLimiterFallBackFingerprint : MethodFingerprint( + returnType = "F", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( + Opcode.CONST_HIGH16, + Opcode.GOTO, + Opcode.CONST_HIGH16, + Opcode.CONST_HIGH16, + Opcode.INVOKE_STATIC, + ), + strings = listOf("Playback rate: %f") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt index 82911d55c..0e167f2fa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt @@ -17,6 +17,7 @@ import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.patch.OldSpeedLay import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedArrayGeneratorFingerprint +import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedLimiterFallBackFingerprint import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedLimiterFingerprint import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.Opcode @@ -40,6 +41,7 @@ import org.jf.dexlib2.iface.reference.MethodReference class CustomVideoSpeedPatch : BytecodePatch( listOf( SpeedArrayGeneratorFingerprint, + SpeedLimiterFallBackFingerprint, SpeedLimiterFingerprint ) ) { @@ -97,28 +99,33 @@ class CustomVideoSpeedPatch : BytecodePatch( } } ?: return SpeedArrayGeneratorFingerprint.toErrorResult() - SpeedLimiterFingerprint.result?.let { result -> - result.mutableMethod.apply { - val limiterMinConstIndex = - implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } - val limiterMaxConstIndex = - implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } + arrayOf( + SpeedLimiterFallBackFingerprint, + SpeedLimiterFingerprint + ).forEach { fingerprint -> + fingerprint.result?.let { result -> + result.mutableMethod.apply { + val limiterMinConstIndex = + implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } + val limiterMaxConstIndex = + implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } - val limiterMinConstDestination = - getInstruction(limiterMinConstIndex).registerA - val limiterMaxConstDestination = - getInstruction(limiterMaxConstIndex).registerA + val limiterMinConstDestination = + getInstruction(limiterMinConstIndex).registerA + val limiterMaxConstDestination = + getInstruction(limiterMaxConstIndex).registerA - replaceInstruction( - limiterMinConstIndex, - "const/high16 v$limiterMinConstDestination, 0x0" - ) - replaceInstruction( - limiterMaxConstIndex, - "const/high16 v$limiterMaxConstDestination, 0x42c80000 # 100.0f" - ) - } - } ?: return SpeedLimiterFingerprint.toErrorResult() + replaceInstruction( + limiterMinConstIndex, + "const/high16 v$limiterMinConstDestination, 0x0" + ) + replaceInstruction( + limiterMaxConstIndex, + "const/high16 v$limiterMaxConstDestination, 0x41200000 # 10.0f" + ) + } + } ?: return fingerprint.toErrorResult() + } /** * Add settings