Skip to content

feat(hwdec): add Android MediaCodec backend - #62

Draft
justin13888 wants to merge 6 commits into
masterfrom
feat/30-android-mediacodec
Draft

feat(hwdec): add Android MediaCodec backend#62
justin13888 wants to merge 6 commits into
masterfrom
feat/30-android-mediacodec

Conversation

@justin13888

@justin13888 justin13888 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #30

Summary

  • add the Android API 29+ hardware still decoder using NDK AMediaCodec with an AImageReader CPU-readable output surface
  • use JNI MediaCodecList only for the definitive API-29 hardware and alias classification, then open each eligible component by exact name through AMediaCodec
  • support HEVC Main/Main10 and AV1 Profile 0, normalize output to dense I420/P010, reject silent 10-bit downconversion, and retry all eligible hardware components within one five-second deadline
  • expose explicit, retryable, same-VM-idempotent JavaVM initialization through rawshift-hwdec, rawshift-image, and the facade
  • add reproducible lossless fixtures, host-side parser/layout tests, Android cross-target CI, and an ARM64 Gradle physical-device harness with cold/warm session-reuse reporting

Android API boundary

MediaCodec is the sole Android decoding backend. Media3 and ExoPlayer orchestrate playback over MediaCodec, while ImageDecoder consumes complete image sources and is not the HEIF/AVIF item-codestream boundary needed here. Java MediaCodecList is used only because MediaCodecInfo.isHardwareAccelerated and isAlias are the public definitive classification methods starting at API 29; decoding and output acquisition remain NDK AMediaCodec and AImageReader.

Primary contracts:

Validation completed

  • RUSTFLAGS=-Dwarnings cargo test --workspace
  • RUSTFLAGS=-Dwarnings cargo clippy --workspace --all-targets
  • Android ARM64 Clippy for rawshift-hwdec with mediacodec
  • Android ARM64 checks for rawshift-image and the rawshift facade with hw-mediacodec
  • Android ARM64 Clippy for the standalone JNI harness crate
  • Gradle 9.4.1 help with all warnings enabled
  • Debug and release JNI merge dry-runs verify buildRust is automatically wired as a generated-source dependency
  • Gradle wrapper SHA-256 verified; shell scripts syntax-checked

Physical-device merge gate — pending

This remains draft until both report blocks are attached:

  • API 29 ARM64 physical device with hardware HEVC and AV1: byte-exact 8-bit HEVC/AV1, cold and warm
  • API 33+ ARM64 physical device with hardware HEVC and AV1: the same 8-bit checks plus byte-exact P010 from at least one codec

The instrumentation test rejects emulators because their codec inventory and acceleration path may depend on host passthrough. No performance threshold is imposed; cold_us and warm_us are diagnostic. Run instructions and pinned Linux/macOS build toolchains are in android/mediacodec-harness/README.md.

The current development host has no Android SDK/NDK, adb, or attached device, so no device report is claimed in this PR yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardware decode: MediaCodec backend (Android, HEVC + AV1)

1 participant