Skip to content

Commit

Permalink
feat(YouTube/Video playback): add Disable VP9 codec setting inotia0…
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Sep 15, 2024
1 parent 6587ba7 commit 753a44f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import app.revanced.patches.youtube.video.playback.fingerprints.PlaybackSpeedCha
import app.revanced.patches.youtube.video.playback.fingerprints.PlaybackSpeedInitializeFingerprint
import app.revanced.patches.youtube.video.playback.fingerprints.QualityChangedFromRecyclerViewFingerprint
import app.revanced.patches.youtube.video.playback.fingerprints.QualitySetterFingerprint
import app.revanced.patches.youtube.video.playback.fingerprints.VP9CapabilityFingerprint
import app.revanced.patches.youtube.video.videoid.VideoIdPatch
import app.revanced.util.getReference
import app.revanced.util.getStringInstructionIndex
Expand Down Expand Up @@ -72,7 +73,8 @@ object VideoPlaybackPatch : BaseBytecodePatch(
QualityChangedFromRecyclerViewFingerprint,
QualityMenuViewInflateFingerprint,
QualitySetterFingerprint,
VideoEndFingerprint
VideoEndFingerprint,
VP9CapabilityFingerprint
)
) {
private const val PLAYBACK_SPEED_MENU_FILTER_CLASS_DESCRIPTOR =
Expand All @@ -81,6 +83,8 @@ object VideoPlaybackPatch : BaseBytecodePatch(
"$COMPONENTS_PATH/VideoQualityMenuFilter;"
private const val INTEGRATIONS_AV1_CODEC_CLASS_DESCRIPTOR =
"$VIDEO_PATH/AV1CodecPatch;"
private const val INTEGRATIONS_VP9_CODEC_CLASS_DESCRIPTOR =
"$VIDEO_PATH/VP9CodecPatch;"
private const val INTEGRATIONS_CUSTOM_PLAYBACK_SPEED_CLASS_DESCRIPTOR =
"$VIDEO_PATH/CustomPlaybackSpeedPatch;"
private const val INTEGRATIONS_HDR_VIDEO_CLASS_DESCRIPTOR =
Expand Down Expand Up @@ -326,6 +330,21 @@ object VideoPlaybackPatch : BaseBytecodePatch(

// endregion

// region patch for disable VP9 codec

VP9CapabilityFingerprint.resultOrThrow().mutableMethod.apply {
addInstructionsWithLabels(
0, """
invoke-static {}, $INTEGRATIONS_VP9_CODEC_CLASS_DESCRIPTOR->disableVP9Codec()Z
move-result v0
if-nez v0, :default
return v0
""", ExternalLabel("default", getInstruction(0))
)
}

// endregion

/**
* Add settings
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app.revanced.patches.youtube.video.playback.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

internal object VP9CapabilityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "Z",
strings = listOf(
"vp9_supported",
"video/x-vnd.on2.vp9"
)
)
7 changes: 7 additions & 0 deletions src/main/resources/youtube/settings/host/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,13 @@ Info:
<string name="revanced_spoof_device_dimensions_title">Spoof device dimensions</string>
<string name="revanced_spoof_device_dimensions_summary">"Spoofs the device dimensions to the maximum value.
High quality may be unlocked on some videos that require high device dimensions, but not all videos."</string>
<string name="revanced_disable_vp9_codec_title">Disable VP9 codec</string>
<string name="revanced_disable_vp9_codec_summary_on">"VP9 codec is disabled.

• Maximum resolution is 1080p.
• Video playback will use more internet data than VP9.
• To get HDR playback, HDR video still uses the VP9 codec."</string>
<string name="revanced_disable_vp9_codec_summary_off">VP9 codec is enabled.</string>
<string name="revanced_replace_av1_codec_title">Replace software AV1 codec</string>
<string name="revanced_replace_av1_codec_summary">Replaces the software AV1 codec with the VP9 codec.</string>
<string name="revanced_reject_av1_codec_title">Reject software AV1 codec response</string>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/youtube/settings/xml/revanced_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@
<SwitchPreference android:title="@string/revanced_enable_default_playback_speed_shorts_title" android:key="revanced_enable_default_playback_speed_shorts" android:summaryOn="@string/revanced_enable_default_playback_speed_shorts_summary_on" android:summaryOff="@string/revanced_enable_default_playback_speed_shorts_summary_off" />
<SwitchPreference android:title="@string/revanced_skip_preloaded_buffer_title" android:key="revanced_skip_preloaded_buffer" android:summary="@string/revanced_skip_preloaded_buffer_summary" />
<SwitchPreference android:title="@string/revanced_skip_preloaded_buffer_toast_title" android:key="revanced_skip_preloaded_buffer_toast" android:summaryOn="@string/revanced_skip_preloaded_buffer_toast_summary_on" android:summaryOff="@string/revanced_skip_preloaded_buffer_toast_summary_off" android:dependency="revanced_skip_preloaded_buffer" />
<SwitchPreference android:title="@string/revanced_spoof_device_dimensions_title" android:key="revanced_spoof_device_dimensions" android:summary="@string/revanced_spoof_device_dimensions_summary" />PREFERENCE_SCREEN: VIDEO -->
<SwitchPreference android:title="@string/revanced_spoof_device_dimensions_title" android:key="revanced_spoof_device_dimensions" android:summary="@string/revanced_spoof_device_dimensions_summary" />
<SwitchPreference android:title="@string/revanced_disable_vp9_codec_title" android:key="revanced_disable_vp9_codec" android:summaryOn="@string/revanced_disable_vp9_codec_summary_on" android:summaryOff="@string/revanced_disable_vp9_codec_summary_off" />PREFERENCE_SCREEN: VIDEO -->

<!-- SETTINGS: REPLACE_AV1_CODEC
<SwitchPreference android:title="@string/revanced_replace_av1_codec_title" android:key="revanced_replace_av1_codec" android:summary="@string/revanced_replace_av1_codec_summary" />SETTINGS: REPLACE_AV1_CODEC -->
Expand Down

0 comments on commit 753a44f

Please sign in to comment.