Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. private fun isSoftwareOnly(codecInfo: MediaCodecInfo): Boolean {
  2. if (SDK_INT >= Q) {
  3. return codecInfo.isSoftwareOnly
  4. }
  5.  
  6. val codecName = codecInfo.name.toLowerCase(Locale.ENGLISH)
  7.  
  8. // Some Broadcom codecs specifically mention HW acceleration in their names.
  9. if (codecName.contains("omx.brcm.video", true) && codecName.contains("hw", true)) {
  10. return false
  11. }
  12.  
  13. // ARC++ (App Runtime for Chrome) codecs, which are always HW-accelerated.
  14. // c2.vda.arc.* appears on Chromebooks with a newer ARC++ version
  15. // based on Android 9.0 and arc.* appears on the older, Android 7.1.1-based version.
  16. if (codecName.startsWith("c2.vda.arc") || codecName.startsWith("arc.")) {
  17. return false
  18. }
  19.  
  20. return codecName.startsWith("omx.google.")
  21. || codecName.startsWith("omx.ffmpeg.")
  22. || (codecName.startsWith("omx.sec.") && codecName.contains(".sw."))
  23. || codecName == "omx.qcom.video.decoder.hevcswvdec"
  24. || codecName.startsWith("c2.android.")
  25. || codecName.startsWith("c2.google.")
  26. || codecName.endsWith("sw", true)
  27. || codecName.endsWith("sw.dec", true)
  28. || codecName.contains("sw_vd", true)
  29. || (!codecName.startsWith("omx.") && !codecName.startsWith("c2."))
  30. }
  31.  
  32. private fun isHardwareAccelerated(codecInfo: MediaCodecInfo): Boolean {
  33. return if (SDK_INT >= Q) {
  34. codecInfo.isHardwareAccelerated
  35. } else {
  36. !isSoftwareOnly(codecInfo)
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement