Support bounded 720x1280 avatar shapes through GLES and production gates

This commit is contained in:
zenord
2026-10-13 17:32:21 +08:00
parent 62dce32bb7
commit ddd75fc571
18 changed files with 352 additions and 83 deletions
+37 -4
View File
@@ -8,7 +8,7 @@ import android.os.TestScheduler
import android.opengl.GLFixture
@Suppress("UNCHECKED_CAST")
fun dynamicRuntimeFixture(count: Int=121,fpsN: Int=30,fpsD: Int=1,sha: String="c".repeat(64)): Map<String,Any?> {
fun dynamicRuntimeFixture(count: Int=121,fpsN: Int=30,fpsD: Int=1,sha: String="c".repeat(64),width: Int=480,height: Int=848): Map<String,Any?> {
val old=continuousFixture()
val pts=List(count) { it*1_000_000L*fpsD/fpsN }
val base=(old["patches"] as List<Map<String,Any?>>).first()
@@ -21,13 +21,13 @@ fun dynamicRuntimeFixture(count: Int=121,fpsN: Int=30,fpsD: Int=1,sha: String="c
state+("ptsUs" to List(n) { it*1_000_000L/24 })
}
return old+mapOf("schemaVersion" to 2,"packId" to "a01-expression-action-v1-test-runtime-04",
"body" to (old["body"] as Map<String,Any?>)+mapOf("sha256" to sha,"frameCount" to count,
"body" to (old["body"] as Map<String,Any?>)+mapOf("sha256" to sha,"width" to width,"height" to height,"frameCount" to count,
"fpsNumerator" to fpsN,"fpsDenominator" to fpsD,"ptsUs" to pts,"durationUs" to (count*1_000_000L*fpsD+fpsN/2)/fpsN),
"patches" to patches,"mouthStates" to states,"patchFormat" to mapOf("bodySha256" to sha,
"format" to "PNG RGBA 8bit","alphaEncoding" to "straight_unassociated","apertureLevels" to listOf(0f,.25f,.5f,.75f,1f),"requiresRendererExtension" to true))
}
fun dynamicPack(count: Int,fps: Int,sha: String): ContinuousAvatarPack = checkNotNull(
ContinuousAvatarManifest.read(dynamicRuntimeFixture(count,fps,1,sha),sha,sha,true,"dynamic/"))
fun dynamicPack(count: Int,fps: Int,sha: String,width: Int=480,height: Int=848): ContinuousAvatarPack = checkNotNull(
ContinuousAvatarManifest.read(dynamicRuntimeFixture(count,fps,1,sha,width,height),sha,sha,true,"dynamic/"))
@Suppress("UNCHECKED_CAST")
fun dynamicBodyCheck() {
@@ -101,6 +101,39 @@ fun dynamicBodyCheck() {
val patches=(root["patches"] as List<Map<String,Any?>>).mapIndexed { i,p -> p+("ptsUs" to pts[i]) }
val variable=root+mapOf("body" to body+("ptsUs" to pts),"patches" to patches)
check(ContinuousAvatarManifest.read(variable,sha,sha,true,"variable/")!=null)
// Run the production decoder/shader driver with 720 format, not a copied state model.
run {
val large=dynamicRuntimeFixture(97,24,1,sha,720,1280)
val rows=large["patches"] as List<Map<String,Any?>>
val moved=large+("patches" to rows.map { it+mapOf("x" to 650.25f,"y" to 1200.5f) })
val pack=checkNotNull(ContinuousAvatarManifest.read(moved,sha,sha,true,"large/"))
check(pack.patches.all { it.x>480 && it.y>848 })
fun rejected(meta: Map<String,Any?>) { check(ContinuousAvatarManifest.read(meta,sha,sha,true,"large/")==null) }
rejected(moved+("patches" to rows.map { it+("x" to 690f) }))
rejected(moved+("patches" to rows.map { it+("y" to 1260f) }))
rejected(moved+("body" to (large["body"] as Map<String,Any?>)+mapOf("width" to 720,"height" to 848)))
rejected(moved+("body" to (large["body"] as Map<String,Any?>)+mapOf("width" to 1080,"height" to 1920)))
val legacy=continuousFixture()
rejected(legacy+("body" to (legacy["body"] as Map<String,Any?>)+mapOf("width" to 720,"height" to 1280)))
val fit=bodyFit(360,800,720,1280)
check(fit.left==0f && fit.top==80f && fit.width==360f && fit.height==640f)
fun render(codecW: Int,codecH: Int): Pair<List<ComposedBodyFrame>,List<String>> {
TestScheduler.reset();CodecFixture.reset();GLFixture.reset()
CodecFixture.width=codecW;CodecFixture.height=codecH;CodecFixture.frames=97;CodecFixture.fps=24
CodecFixture.onRender={ t -> SurfaceTexture.lastCreated?.emit(t*1000) }
val frames=mutableListOf<ComposedBodyFrame>();val errors=mutableListOf<String>()
val renderer=ContinuousBodyRenderer(android.content.Context(),pack,Surface(SurfaceTexture(0)),360,800,
{ frame,_ -> frames+=frame },errors::add)
renderer.intent(true,1,1);TestScheduler.advanceBy(8500)
if(errors.isEmpty()) check(GLFixture.bodySize==720f to 1280f && frames.size>97 && frames[97].key.loopOrdinal==1L)
renderer.close();TestScheduler.advanceBy(100);check(CodecFixture.releases==1 || errors.isNotEmpty())
val count=frames.size;SurfaceTexture.lastCreated?.emit(0);TestScheduler.advanceBy(100);check(frames.size==count)
return frames to errors
}
val ok=render(720,1280);check(ok.second.isEmpty() && ok.first.all { it.patch==pack.patches[it.key.index] })
val wrong=render(480,848);check(wrong.first.isEmpty() && wrong.second.isNotEmpty())
println("PASS: schema2 720x1280 production codec/render/uniform/wrap/release, pixel bounds/Fit, mismatched decoder and legacy/unsupported shape rejection; GPU/device not claimed")
}
val curve=MouthCurve("opening",400,listOf(0f,.25f,1f),listOf(0L,100_000L,300_000L))
val mouth=ContinuousMouth(continuousPack().curves+("opening" to curve))
mouth.request(true,1,1);mouth.sample(0)