Skip to content

Commit

Permalink
Merge pull request #27 from Parseus/dev
Browse files Browse the repository at this point in the history
Dev -> master: version 2.5.0
  • Loading branch information
Parseus committed Jun 21, 2023
2 parents b9a489e + 252af8b commit 4c8e2a5
Show file tree
Hide file tree
Showing 51 changed files with 663 additions and 289 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

3 changes: 1 addition & 2 deletions .idea/misc.xml

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

39 changes: 20 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.devtools.ksp' version '1.7.20-1.0.6'
id 'com.google.devtools.ksp' version '1.8.22-1.0.11'
}

android {
namespace 'com.parseus.codecinfo'
compileSdkVersion 33
compileSdkVersion 34
defaultConfig {
applicationId "com.parseus.codecinfo"
minSdkVersion 16
targetSdkVersion 33
versionCode 22
versionName "2.4.0"
targetSdkVersion 34
versionCode 23
versionName "2.5.0"
resConfigs 'en'

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -67,15 +67,16 @@ android {
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = "11"
kotlin {
jvmToolchain(11)
}
packagingOptions {
jniLibs {
excludes += ['kotlin/**']
}
resources {
excludes += ['kotlin/**', '**/*.kotlin_metadata', 'META-INF/*.kotlin_module', 'META-INF/*.version']
excludes += ['kotlin/**', '**/*.kotlin_metadata', 'META-INF/*.kotlin_module',
'META-INF/*.version']
}
}

Expand Down Expand Up @@ -111,18 +112,16 @@ configurations {
}

dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'

implementation 'androidx.appcompat:appcompat:1.7.0-alpha01'
implementation "androidx.core:core-ktx:1.9.0"
implementation 'androidx.appcompat:appcompat:1.7.0-alpha02'
implementation "androidx.core:core-ktx:1.12.0-alpha05"
implementation 'androidx.preference:preference-ktx:1.2.0'

implementation "com.squareup.leakcanary:plumber-android:$leakCanary_version"
implementation "com.squareup.moshi:moshi:$moshi_version"
ksp "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
implementation "com.squareup.okio:okio:3.2.0"

implementation 'me.saket:better-link-movement-method:2.2.0'
implementation "com.squareup.okio:okio:3.3.0"

debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanary_version"
standardMobileDebugImplementation 'androidx.multidex:multidex:2.0.1'
Expand All @@ -134,14 +133,16 @@ dependencies {
standardMobileImplementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'

mobileImplementation 'androidx.constraintlayout:constraintlayout:2.1.4'
mobileImplementation 'androidx.core:core-splashscreen:1.0.0'
mobileImplementation 'androidx.core:core-splashscreen:1.0.1'
mobileImplementation 'androidx.palette:palette-ktx:1.0.0'
mobileImplementation 'androidx.webkit:webkit:1.5.0'
mobileImplementation 'androidx.webkit:webkit:1.7.0'
mobileImplementation 'com.github.KieronQuinn:MonetCompat:0.4.1'
mobileImplementation 'com.github.marcoscgdev:Licenser:2.0.0'
mobileImplementation 'com.google.android.material:material:1.8.0-alpha02'
mobileImplementation 'com.google.android.material:material:1.10.0-alpha04'

nonFreeMobileImplementation fileTree(include: ['*.jar'], dir: 'libs')
nonFreeMobileImplementation 'com.google.android.play:app-update-ktx:2.0.0'
nonFreeMobileImplementation 'com.google.android.play:review-ktx:2.0.0'
nonFreeMobileImplementation 'com.google.android.play:app-update:2.1.0'
nonFreeMobileImplementation 'com.google.android.play:app-update-ktx:2.1.0'
nonFreeMobileImplementation 'com.google.android.play:review:2.0.1'
nonFreeMobileImplementation 'com.google.android.play:review-ktx:2.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ data class CodecSimpleInfo(val id: Long,
val codecId: String,
val codecName: String,
val isAudio: Boolean,
val isEncoder: Boolean) {
val isEncoder: Boolean,
val isHardwareAccelereated: Boolean) {

override fun toString(): String {
return "$codecId ($codecName)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.os.Build.VERSION.SDK_INT
import android.util.Range
import androidx.annotation.RequiresApi
import androidx.annotation.StringRes
import androidx.core.text.HtmlCompat
import androidx.preference.PreferenceManager
import com.parseus.codecinfo.*
import com.parseus.codecinfo.data.DetailsProperty
Expand All @@ -21,7 +22,6 @@ import com.parseus.codecinfo.data.codecinfo.profilelevels.*
import com.parseus.codecinfo.data.codecinfo.profilelevels.VP9Levels.*
import com.parseus.codecinfo.utils.*
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.min

// Source:
Expand Down Expand Up @@ -83,6 +83,16 @@ private val framerateClasses = arrayOf(
"8K"
)

private val knownVendorLowLatencyOptions = listOf(
// https://cs.android.com/android/platform/superproject/+/master:hardware/qcom/sdm845/media/mm-video-v4l2/vidc/vdec/src/omx_vdec_extensions.hpp
"vendor.qti-ext-dec-low-latency.enable",
// https://developer.huawei.com/consumer/cn/forum/topic/0202325564295980115
"vendor.hisi-ext-low-latency-video-dec.video-scene-for-low-latency-req",
"vendor.rtc-ext-dec-low-latency.enable",
// https://github.com/codewalkerster/android_vendor_amlogic_common_prebuilt_libstagefrighthw/commit/41fefc4e035c476d58491324a5fe7666bfc2989e
"vendor.low-latency.enable"
)

private var mediaCodecInfos: Array<MediaCodecInfo> = emptyArray()

val audioCodecList: MutableList<CodecSimpleInfo> = mutableListOf()
Expand Down Expand Up @@ -174,7 +184,7 @@ fun getSimpleCodecInfoList(context: Context, isAudio: Boolean): MutableList<Code

if (isAudio == isAudioCodec) {
val codecSimpleInfo = CodecSimpleInfo((codecIndex * 100 + index).toLong(), codecId, mediaCodecInfo.name,
isAudioCodec, mediaCodecInfo.isEncoder)
isAudioCodec, mediaCodecInfo.isEncoder, isHardwareAccelerated(mediaCodecInfo))
if (codecSimpleInfoList.find {
it.codecId == codecSimpleInfo.codecId
&& it.codecName == codecSimpleInfo.codecName
Expand Down Expand Up @@ -238,7 +248,7 @@ fun getDetailedCodecInfo(context: Context, codecId: String, codecName: String):
isSoftwareOnly(mediaCodecInfo).toString()))

if (!isEncoder && SDK_INT >= 30) {
propertyList.addFeature(context, capabilities, FEATURE_LowLatency, R.string.low_latency)
addLowLatencyFeatureIfSupported(context, codecName, capabilities, propertyList)
}

propertyList.add(DetailsProperty(propertyList.size.toLong(), context.getString(R.string.codec_provider),
Expand Down Expand Up @@ -317,6 +327,19 @@ fun getDetailedCodecInfo(context: Context, codecId: String, codecName: String):
handleQualityRange(encoderCapabilities, defaultMediaFormat, propertyList, context)
}

if (SDK_INT >= 31) {
try {
val codec = MediaCodec.createByCodecName(codecName)
val vendorParams = codec.supportedVendorParameters
if (vendorParams.isNotEmpty()) {
propertyList.add(
DetailsProperty(propertyList.size.toLong(),
context.getString(R.string.vendor_parameters), vendorParams.joinToString("\n")))
}
codec.release()
} catch (_: Throwable) {}
}

val profileString = if (codecId.contains("mp4a-latm") || codecId.contains("wma")) {
context.getString(R.string.profiles)
} else {
Expand All @@ -330,6 +353,32 @@ fun getDetailedCodecInfo(context: Context, codecId: String, codecName: String):
return propertyList
}

@RequiresApi(30)
private fun addLowLatencyFeatureIfSupported(context: Context,
codecName: String,
capabilities: MediaCodecInfo.CodecCapabilities,
propertyList: MutableList<DetailsProperty>) {
if (capabilities.isFeatureSupported(FEATURE_LowLatency)) {
propertyList.addFeature(context, capabilities, FEATURE_LowLatency, R.string.low_latency)
} else if (SDK_INT >= 31) {
var codec: MediaCodec? = null
try {
codec = MediaCodec.createByCodecName(codecName)
val vendorLowLatencyKey = codec.supportedVendorParameters.find { it in knownVendorLowLatencyOptions }
val featureString = if (vendorLowLatencyKey != null) {
HtmlCompat.fromHtml(context.getString(R.string.feature_low_latency_vendor_supported, vendorLowLatencyKey),
HtmlCompat.FROM_HTML_MODE_LEGACY).toString()
} else {
false.toString()
}
propertyList.add(DetailsProperty(propertyList.size.toLong(), context.getString(R.string.low_latency), featureString))
} catch (_: Exception) {}
finally {
codec?.release()
}
}
}

@RequiresApi(21)
private fun handleQualityRange(encoderCapabilities: MediaCodecInfo.EncoderCapabilities,
defaultMediaFormat: MediaFormat,
Expand Down Expand Up @@ -565,6 +614,7 @@ private fun adjustMaxInputChannelCount(codecId: String, codecName: String, maxCh
// The maximum channel count looks incorrect. Adjust it to an assumed default.
return when (codecId) {
"audio/ac3" -> 6
"audio/ac4" -> 24
// Source: http://www.voiceage.com/AMR-WBplus.html
"audio/amr-wb-plus" -> 2
"audio/dts" -> 8
Expand Down Expand Up @@ -778,6 +828,10 @@ private fun getProfileLevels(context: Context, codecId: String, codecName: Strin
codecId.contains("mp4a-latm") -> {
profile = AACProfiles.from(it.profile)
}
codecId.contains("ac4") -> {
profile = AC4Profiles.from(it.profile)
level = AC4Levels.from(it.level)
}
codecId.contains("av01") -> {
profile = AV1Profiles.from(it.profile)
level = AV1Levels.from(it.level)
Expand All @@ -801,6 +855,12 @@ private fun getProfileLevels(context: Context, codecId: String, codecName: Strin
profile = DolbyVisionProfiles.from(it.profile)
level = DolbyVisionLevels.from(it.level)
}
codecId.contains("vnd.dts.hd") -> {
profile = DTSHDProfiles.from(it.profile)
}
codecId.contains("vnd.dts.uhd") -> {
profile = DTSUHDProfiles.from(it.profile)
}
(codecId.contains("3gpp") && !codecName.contains("mpeg4", true))
|| codecId.contains("sorenson") || codecId.contains("flv") -> {
profile = H263Profiles.from(it.profile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ enum class StandardColorFormat(val value: Int) {
COLOR_Format32bitABGR2101010(0x7F00AAA2),
COLOR_Format64bitABGRFloat(0x7F000F16),

// https://android.googlesource.com/platform/frameworks/native/+/refs/heads/master/headers/media_plugin/media/openmax/OMX_IVCommon.h
COLOR_QCOM_FormatYUV420SemiPlanar (0x7FA30C00),
COLOR_QCOM_FormatYUV420PackedSemiPlanar64x32Tile2m8ka(0x7FA30C03),
COLOR_QCOM_FormatYUV420PackedSemiPlanar32m(0x7FA30C04),
COLOR_SEC_FormatNV12Tiled(0x7FC00002),
COLOR_TI_FormatYUV420PackedSemiPlanar(0x7F000100),

// Other
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@file:Suppress("unused")

package com.parseus.codecinfo.data.codecinfo.profilelevels

enum class AC4Profiles(val value: Int) {

AC4Profile00(0x101),
AC4Profile10(0x201),
AC4Profile11(0x202),
AC4Profile21(0x402),
AC4Profile22(0x404),
AC4ProfileMax(0x7FFFFFFF);

companion object {
fun from(findValue: Int): String? = values().find { it.value == findValue }?.name
}

}

enum class AC4Levels(val value: Int) {

AC4Level0(0x1),
AC4Level1(0x2),
AC4Level2(0x4),
AC4Level3(0x8),
AC4Level4(0x10),
AC4LevelMax(0x7FFFFFFF);

companion object {
fun from(findValue: Int): String? = values().find { it.value == findValue }?.name
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@file:Suppress("unused")

package com.parseus.codecinfo.data.codecinfo.profilelevels

@Suppress("EnumEntryName")
enum class DTSHDProfiles(val value: Int) {

DTS_HDProfileHRA(0x1),
DTS_HDProfileLBR(0x2),
DTS_HDProfileMA(0x4),
DTS_HDProfileMax(0x7FFFFFFF);

companion object {
fun from(findValue: Int): String? = values().find { it.value == findValue }?.name
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@file:Suppress("unused")

package com.parseus.codecinfo.data.codecinfo.profilelevels

@Suppress("EnumEntryName")
enum class DTSUHDProfiles(val value: Int) {

DTS_UHDProfileP1(0x1),
DTS_UHDProfileP2(0x2),
DTS_UDHProfileMax(0x7FFFFFFF);

companion object {
fun from(findValue: Int): String? = values().find { it.value == findValue }?.name
}

}
Loading

0 comments on commit 4c8e2a5

Please sign in to comment.