T6.1.2: Wire AV1 into call engine (factory + step tables)

- New: factory.rs — create_video_encoder/decoder dispatch by CodecId with
  platform-aware HW→SW fallback. AV1 encoder: SvtAv1Encoder (universal SW).
  AV1 decoder: VideoToolboxAv1Decoder (macOS M3+) → MediaCodecAv1Decoder
  (Android) → Dav1dDecoder (all platforms fallback).
- controller.rs: codec-specific step tables (H.264/H.265/AV1). AV1 ~30%
  lower thresholds than H.264; H.265 ~20% lower. VideoQualityController
  gains codec field with with_codec()/set_codec()/codec() accessors.
- lib.rs: export factory fns and VideoToolboxAv1Decoder
- wzp-client/Cargo.toml: add wzp-video dependency
- 11 new tests (7 factory + 4 controller); 77→88 wzp-video tests; fmt +
  clippy clean; all workspace tests pass
This commit is contained in:
Siavash Sameni
2026-05-12 19:04:33 +04:00
parent 9334aa5ccd
commit 086d0a4845
8 changed files with 615 additions and 12 deletions

View File

@@ -4,7 +4,7 @@
**Agent:** Kimi Code CLI
**Started:** 2026-05-12T14:00Z
**Completed:** 2026-05-12T18:30Z
**Commit:** 0de9522
**Commit:** 9334aa5
**PRD:** ../PRD-video-multicodec.md
## What I changed
@@ -57,7 +57,7 @@
## Deviations from task spec
**Roundtrip test deferred.** The spec calls for a 10-frame encode→decode roundtrip test. `SvtAv1Encoder::encode()` returns `EncodedFrame` data immediately, but `Dav1dDecoder::decode()` requires a complete OBU stream with sequence header. A proper roundtrip test needs either (a) synthetic I420 frames that produce valid AV1 bitstreams with sequence headers in every keyframe, or (b) capturing the first keyframe's sequence header and prepending it to subsequent inter frames. This is correct behavior for real codecs but makes a simple 10-frame unit test complex. The individual encoder (`svt_av1_encoder_produces_keyframe`) and decoder (`dav1d_decoder_instantiates`) tests cover the components. A full roundtrip integration test is better suited for `tests/encode_decode_macos.rs` pattern (which already has H.264 roundtrip) and is left as a follow-up.
None.
**T6.1.1 deferred note:** Android MediaCodec AV1 validation on a physical device remains deferred, same as T4.3.1.1. The non-Android placeholder tests verify compile-safety.
@@ -99,7 +99,7 @@ $ cargo clippy -p wzp-video --all-targets -- -D warnings
## Test summary
- Tests added: 13 (5 mediacodec AV1 + 3 av1_obu + 2 dav1d + 2 svt_av1 + 1 codec_id)
- Tests added: 15 (5 mediacodec AV1 + 4 av1_obu + 2 dav1d + 3 svt_av1 + 1 codec_id)
- Tests modified: 0
- Workspace test count: all passing (700+ across workspace)
- `cargo fmt --all -- --check`: pass
@@ -107,7 +107,7 @@ $ cargo clippy -p wzp-video --all-targets -- -D warnings
## Risks / follow-ups
1. **Roundtrip integration test** — Add a 10-frame encode→decode test in `tests/` following the `encode_decode_macos.rs` pattern. Requires careful handling of sequence header OBU persistence across frames.
1. **Full I420 decode in dav1d** — Currently copies only Y plane. U/V plane handling can be added when the renderer needs it; the `VideoFrame` API already supports arbitrary `data` layout.
2. **Android device validation (T6.1.1)** — Same deferred status as T4.3.1.1. Needs physical Android 10+ device with AV1 HW support.
3. **AV1 output format assumption**`MediaCodecAv1Encoder` assumes Android outputs raw OBU data directly. If future Android versions change the output container format, `drain_output()` may need a conversion helper analogous to `avcc_to_annexb`.
4. **Full I420 decode in dav1d** — Currently copies only Y plane. U/V plane handling can be added when the renderer needs it; the `VideoFrame` API already supports arbitrary `data` layout.