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
+16 -16
View File
@@ -7,20 +7,20 @@ import android.graphics.BitmapFactory
import android.opengl.GLFixture
import android.view.TextureView
fun mediaFixtureIndex(): EmotionActionIndex {
val packs=linkedMapOf("neutral" to dynamicPack(97,24,"c".repeat(64)).copy(root="neutral/"),
"happy" to dynamicPack(49,24,"d".repeat(64)).copy(root="happy/"),
"sad" to dynamicPack(121,30,"e".repeat(64)).copy(root="sad/"))
fun mediaFixtureIndex(width: Int=480,height: Int=848): EmotionActionIndex {
val packs=linkedMapOf("neutral" to dynamicPack(97,24,"c".repeat(64),width,height).copy(root="neutral/"),
"happy" to dynamicPack(49,24,"d".repeat(64),width,height).copy(root="happy/"),
"sad" to dynamicPack(121,30,"e".repeat(64),width,height).copy(root="sad/"))
val visuals=packs.map { (id,p)->TalkPackage(id,RoleEmotion.entries.single { it.wire==id },p.body.sha256,p.body.sha256,p.body.ptsUs,p.body.ptsUs,true) }
val bridges=packs.map { (id,p)->ConversationEdge("$id-loop",id,id,p.body.frameCount-1,0,p.body,true) }+
listOf("happy","sad").flatMap { id->listOf("neutral" to id,id to "neutral").map { (from,to)->
ConversationEdge("$from-$to",from,to,packs.getValue(from).body.frameCount-1,0,
ContinuousBodyAsset("clips/$from-$to.mp4","f".repeat(64),480,848,3,125000,List(3) { it*1_000_000L/24 }),
mouthRuntime=dynamicPack(3,24,"f".repeat(64)).copy(root="bridge-$from-$to/"))
ContinuousBodyAsset("clips/$from-$to.mp4","f".repeat(64),width,height,3,125000,List(3) { it*1_000_000L/24 }),
mouthRuntime=dynamicPack(3,24,"f".repeat(64),width,height).copy(root="bridge-$from-$to/"))
} }
val musicPts=List(24) { it*1_000_000L/24 }
val actions=ReviewedActionPack("a".repeat(64),listOf("asset_01","asset_02").map {
ActionAsset(it,1000,ActionMedia("clips/$it.mp4","a".repeat(64),"",musicPts,1_000_000,480,848,"neutral",96,"neutral",0,950_000))
ActionAsset(it,1000,ActionMedia("clips/$it.mp4","a".repeat(64),"",musicPts,1_000_000,width,height,"neutral",96,"neutral",0,950_000))
})
return EmotionActionIndex("neutral",packs,visuals,actions,bridges)
}
@@ -28,13 +28,13 @@ fun mediaFixtureIndex(): EmotionActionIndex {
fun mediaReply(emotion: RoleEmotion,turn: Long=7,seq: Long=2,intensity: Int=if(emotion==RoleEmotion.NEUTRAL) 0 else 1)=
ReplyEmotion(emotion,intensity,EmotionSource.MODEL,turn,seq)
fun actualMediaViewCheck() {
fun actualMediaViewCheck(width: Int=480,height: Int=848) {
var cases=0
fun reset() {
TestScheduler.reset();CodecFixture.reset();GLFixture.reset();BitmapFactory.wrongSize=false;MediaPlayer.created.clear()
CodecFixture.emitNativeSurface=true
CodecFixture.emitNativeSurface=true;CodecFixture.width=width;CodecFixture.height=height
}
fun rig(index: EmotionActionIndex=mediaFixtureIndex()): Triple<EmotionActionAvatarView,AvatarMediaBinding,MutableList<VideoPresentation>> {
fun rig(index: EmotionActionIndex=mediaFixtureIndex(width,height)): Triple<EmotionActionAvatarView,AvatarMediaBinding,MutableList<VideoPresentation>> {
index.packages.values.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
index.edges.filterNot { it.nativeLoop }.forEach { CodecFixture.timelines[(it.mouthRuntime?.root ?: index.root)+(it.mouthRuntime?.body?.path ?: it.clip.path)]=it.clip.ptsUs }
index.actionPack?.assets?.mapNotNull { it.media }?.forEach { CodecFixture.timelines[it.root+it.path]=it.ptsUs;CodecFixture.audioPaths.add(it.root+it.path) }
@@ -93,7 +93,7 @@ fun actualMediaViewCheck() {
reset();val (cancelView,cancelBinding,_)=rig()
var stop: ((Boolean)->Unit)?=null;var resumed=0
val statuses=mutableListOf<ActionStatus>()
val controller=ActionController(mediaFixtureIndex().actionPack,cancelBinding,{TestScheduler.now},{stop=it},statuses::add,
val controller=ActionController(mediaFixtureIndex(width,height).actionPack,cancelBinding,{TestScheduler.now},{stop=it},statuses::add,
{ active->if(!active) resumed++ })
check(controller.offer(ActionPlan("p".repeat(24),7,"a".repeat(64),15000)))
controller.cancel();TestScheduler.advanceBy(100)
@@ -105,7 +105,7 @@ fun actualMediaViewCheck() {
}
for(mode in listOf("complete","cancel","failed","background","late_final_frame")) {
reset();val index=mediaFixtureIndex();val (actionView,actionBinding,trace)=rig(index)
reset();val index=mediaFixtureIndex(width,height);val (actionView,actionBinding,trace)=rig(index)
var stopped: ((Boolean)->Unit)?=null
val statuses=mutableListOf<ActionStatus>()
val controller=ActionController(index.actionPack,actionBinding,{TestScheduler.now},{stopped=it},statuses::add)
@@ -143,7 +143,7 @@ fun actualMediaViewCheck() {
// the movie TextureView. Native/codec/record ports remain deterministic doubles.
for(mode in listOf("complete", "cancel", "failed", "background", "newturn")) {
reset()
val base=mediaFixtureIndex()
val base=mediaFixtureIndex(width,height)
val original=base.actionPack!!.assets.first()
val media=original.media!!.copy(ptsUs=List(241) { it*1_000_000L/24 },durationUs=10_041_667,
sourceFrame=0,returnFrame=96,audioEndUs=10_000_000)
@@ -188,7 +188,7 @@ fun actualMediaViewCheck() {
// New idle rows use the actual view/renderer/codec path and reviewed graph.
reset()
val idleIndex=mediaFixtureIndex().let { it.copy(actionPack=null,visuals=it.visuals.map { p->p.copy(emotion=RoleEmotion.NEUTRAL) }) }
val idleIndex=mediaFixtureIndex(width,height).let { it.copy(actionPack=null,visuals=it.visuals.map { p->p.copy(emotion=RoleEmotion.NEUTRAL) }) }
val (idleView,idleBinding,idleTrace)=rig(idleIndex)
TestScheduler.advanceBy(3000)
check(idleTrace.all { it.actual=="body_neutral" });cases++
@@ -211,7 +211,7 @@ fun actualMediaViewCheck() {
// Real renderer path over a25-frame own-mouth bridge, no loop or endpoint patches.
reset()
val ownBridge=dynamicPack(25,24,"f".repeat(64)).copy(root="bridge25/")
val ownBridge=dynamicPack(25,24,"f".repeat(64),width,height).copy(root="bridge25/")
CodecFixture.timelines[ownBridge.root+ownBridge.body.path]=ownBridge.body.ptsUs
val clock=ConversationMouthClock();val prior=Any()
clock.intent(prior,ownBridge.curves,true,1,1,0);clock.sample(prior,0)
@@ -229,5 +229,5 @@ fun actualMediaViewCheck() {
renderer.close();TestScheduler.advanceBy(50)
check(GLFixture.deleted>=126 && CodecFixture.releases==1);cases++
CodecFixture.reset();MediaPlayer.created.clear()
println("PASS: $cases actual EmotionActionAvatarView/binding/held GLES renderer/MediaPlayer callback assertions: hidden header/final mismatch, final slight,97→49→121 and24→30fps/native loops, real bridge frames/latest turn, settings continuity, mic-confirm/cancel-pending/failure gate, safe exit/music first+last PTS/native end/release/idle-A, completion order, cancel/error/background/stale callbacks; deterministic Android doubles, device/naturalness not_run")
println("PASS: $cases ${width}x$height actual EmotionActionAvatarView/binding/held GLES renderer/MediaPlayer callback assertions: hidden header/final mismatch, final slight,97→49→121 and24→30fps/native loops, real bridge frames/latest turn, settings continuity, mic-confirm/cancel-pending/failure gate, safe exit/music first+last PTS/native end/release/idle-A, completion order, cancel/error/background/stale callbacks; deterministic Android doubles, device/naturalness not_run")
}