Add uniform Yangmi framing candidate for code37

This commit is contained in:
zenord
2026-10-14 21:16:22 +08:00
parent 99a03e0487
commit 5c4ea077ee
15 changed files with 169 additions and 21 deletions
+10
View File
@@ -57,6 +57,12 @@ def characterMedia = characterCatalog.mediaBundles[characterMediaId]
def allowedMedia = characterProfile.mediaSelection == 'existing-build-flags' ? ['black-correct03','white-full04'] : [characterProfile.mediaSelection] + (characterProfile.additionalMediaSelections ?: [])
if (!characterMedia || !(characterMediaId in allowedMedia)) throw new GradleException('Profile/media selection is not authorized')
if (avatarUserNetworkActions && characterMedia.networkActionsAllowed != true) throw new GradleException('Network dance requires separate reviewed media registration')
def avatarFrameZoom = (providers.gradleProperty('avatarFrameZoom').orNull ?: '1.0').toFloat()
def avatarFrameCenterY = (providers.gradleProperty('avatarFrameCenterY').orNull ?: '0.5').toFloat()
if (!Float.isFinite(avatarFrameZoom) || avatarFrameZoom < 1f || avatarFrameZoom > 2f ||
!Float.isFinite(avatarFrameCenterY) || avatarFrameCenterY < 0.4f || avatarFrameCenterY > 0.6f) throw new GradleException('Invalid avatar framing')
if ((avatarFrameZoom != 1f || avatarFrameCenterY != 0.5f) &&
(!avatarUserAssetCandidate || characterMediaId != 'black-correct03')) throw new GradleException('Framing candidate requires exact black media')
if (emotionManifestSha && !(emotionManifestSha ==~ /[0-9a-f]{64}/)) throw new GradleException('Emotion graph requires exact external manifest SHA')
if (emotionManifestSha && (!avatarActionCandidate || !avatarMouthCandidate || !avatarNatural || actionVersionCode < 17)) throw new GradleException('Emotion candidate requires own-mouth runtime and a fresh code >=17')
if (avatarFullActionCandidate && (!emotionManifestSha || !avatarActionCandidate || actionVersionCode < 18)) throw new GradleException('Full candidate requires pinned emotion/action graph and fresh code >=18')
@@ -158,6 +164,8 @@ android {
buildConfigField 'String', 'STARTUP_ASSET_ROOT', groovy.json.JsonOutput.toJson(characterMedia.bootstrapRoot)
buildConfigField 'String', 'STARTUP_MANIFEST_SHA', groovy.json.JsonOutput.toJson(characterMedia.bootstrapSha256)
buildConfigField 'int', 'STARTUP_POSTER_RES_ID', 'com.gorios.lanvoice.R.drawable.' + characterMedia.posterResource
buildConfigField 'float', 'AVATAR_FRAME_ZOOM', avatarFrameZoom.toString() + 'f'
buildConfigField 'float', 'AVATAR_FRAME_CENTER_Y', avatarFrameCenterY.toString() + 'f'
buildConfigField 'boolean', 'CAMERA_PROBE_DIAGNOSTIC', cameraProbeDiagnostic ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', avatarStartupFix ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_ENGINEERING', (avatarEngineering || avatarNatural) ? 'true' : 'false'
@@ -173,6 +181,8 @@ android {
buildConfigField 'String', 'STARTUP_ASSET_ROOT', '"avatar/startup-white-01/"'
buildConfigField 'String', 'STARTUP_MANIFEST_SHA', '"461f5cfc10036de5f10ca3ce765fb8d9998697d3fd035aa9b1862d2ccfc3eaa2"'
buildConfigField 'int', 'STARTUP_POSTER_RES_ID', 'com.gorios.lanvoice.R.drawable.startup_poster'
buildConfigField 'float', 'AVATAR_FRAME_ZOOM', '1.0f'
buildConfigField 'float', 'AVATAR_FRAME_CENTER_Y', '0.5f'
buildConfigField 'boolean', 'CAMERA_PROBE_DIAGNOSTIC', 'false'
buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', 'false'
buildConfigField 'boolean', 'AVATAR_ENGINEERING', 'false'
@@ -13,7 +13,7 @@ import com.gorios.lanvoice.diag.DiagnosticLog
* EGL swap, and immediately returns on background/error; no decoder touches audio. */
class ContinuousAvatarView(context: Context,private val pack: AvatarPack?,private val report: (VideoPresentation)->Unit): FrameLayout(context) {
private val texture=TextureView(context).apply { isOpaque=false;alpha=0f }
private val still=ImageView(context).apply { scaleType=ImageView.ScaleType.FIT_CENTER }
private val still=FramedAvatarPoster(context)
private var renderer: ContinuousBodyRenderer?=null
private var foreground=false
private var failed=false
@@ -231,7 +231,8 @@ class ContinuousBodyRenderer(private val context: Context,private val pack: Cont
private fun draw(frame: ComposedBodyFrame) {
check(width>0 && height>0)
GLES20.glViewport(0,0,width,height);GLES20.glClearColor(1f,1f,1f,1f);GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT)
val rect=bodyFit(width,height,pack.body.width,pack.body.height)
val rect=bodyFit(width,height,pack.body.width,pack.body.height,
com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_ZOOM,com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_CENTER_Y)
val left=rect.left/width*2-1;val right=(rect.left+rect.width)/width*2-1
val top=1-rect.top/height*2;val bottom=1-(rect.top+rect.height)/height*2
positions.clear();positions.put(floatArrayOf(left,bottom,right,bottom,left,top,right,top));positions.position(0);uv.position(0)
@@ -98,11 +98,12 @@ class ContinuousFrameClock(private val frames: Int=97,
}
data class BodyFitRect(val left: Float,val top: Float,val width: Float,val height: Float)
fun bodyFit(viewW: Int,viewH: Int,mediaW: Int=480,mediaH: Int=848): BodyFitRect {
fun bodyFit(viewW: Int,viewH: Int,mediaW: Int=480,mediaH: Int=848,zoom: Float=1f,centerY: Float=0.5f): BodyFitRect {
require(viewW>0 && viewH>0 && mediaW>0 && mediaH>0)
val scale=minOf(viewW.toFloat()/mediaW,viewH.toFloat()/mediaH)
require(zoom.isFinite() && zoom in 1f..2f && centerY.isFinite() && centerY in 0.4f..0.6f)
val scale=minOf(viewW.toFloat()/mediaW,viewH.toFloat()/mediaH)*zoom
val w=mediaW*scale; val h=mediaH*scale
return BodyFitRect((viewW-w)/2,(viewH-h)/2,w,h)
return BodyFitRect((viewW-w)/2,viewH/2f-h*centerY,w,h)
}
fun patchUv(x: Float,y: Float,patch: RegisteredMouthPatch): Pair<Float,Float>? {
if(x<patch.x || y<patch.y || x>=patch.x+patch.width || y>=patch.y+patch.height) return null
@@ -20,7 +20,7 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
fun releaseStartup() { driver?.releaseInitial() }
private val main=Handler(Looper.getMainLooper())
private val textures=List(4) { TextureView(context).apply { isOpaque=false;alpha=0f } }
private val still=ImageView(context).apply { scaleType=ImageView.ScaleType.FIT_CENTER }
private val still=FramedAvatarPoster(context)
private var driver: ConversationMediaDriver?=null
private var active=false
private var released=false
@@ -8,12 +8,23 @@ import android.widget.FrameLayout
import android.widget.ImageView
import com.gorios.lanvoice.diag.StartupTrace
/** Same Fit/zoom/vertical center as the body+mouth compositor; no asset reads. */
internal class FramedAvatarPoster(context: Context): ImageView(context) {
init { scaleType=ImageView.ScaleType.FIT_CENTER }
override fun onSizeChanged(w: Int,h: Int,oldw: Int,oldh: Int) {
super.onSizeChanged(w,h,oldw,oldh)
if(w<=0 || h<=0) return
val zoom=com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_ZOOM
scaleX=zoom;scaleY=zoom
translationY=bodyFit(w,h,180,320).height*zoom*(0.5f-com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_CENTER_Y)
}
}
/** One stable host. Only real matching neutral sourceframe0 can hand off the base loop.
* Full renderer is prepared/held hidden; no TextureView output-clock inference. */
class StartupAvatarView(context: Context,private val binding: AvatarMediaBinding,
private val report: (VideoPresentation)->Unit,private val fullVisible: ()->Unit,private val failed: ()->Unit={}): FrameLayout(context) {
private val poster=ImageView(context).apply {
scaleType=ImageView.ScaleType.FIT_CENTER
private val poster=FramedAvatarPoster(context).apply {
setImageResource(com.gorios.lanvoice.BuildConfig.STARTUP_POSTER_RES_ID)
}
private val surface=TextureView(context).apply { isOpaque=false;alpha=0f }