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 ?: []) 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 (!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') 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 && !(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 (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') 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_ASSET_ROOT', groovy.json.JsonOutput.toJson(characterMedia.bootstrapRoot)
buildConfigField 'String', 'STARTUP_MANIFEST_SHA', groovy.json.JsonOutput.toJson(characterMedia.bootstrapSha256) 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 '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', 'CAMERA_PROBE_DIAGNOSTIC', cameraProbeDiagnostic ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', avatarStartupFix ? 'true' : 'false' buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', avatarStartupFix ? 'true' : 'false'
buildConfigField 'boolean', 'AVATAR_ENGINEERING', (avatarEngineering || avatarNatural) ? '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_ASSET_ROOT', '"avatar/startup-white-01/"'
buildConfigField 'String', 'STARTUP_MANIFEST_SHA', '"461f5cfc10036de5f10ca3ce765fb8d9998697d3fd035aa9b1862d2ccfc3eaa2"' buildConfigField 'String', 'STARTUP_MANIFEST_SHA', '"461f5cfc10036de5f10ca3ce765fb8d9998697d3fd035aa9b1862d2ccfc3eaa2"'
buildConfigField 'int', 'STARTUP_POSTER_RES_ID', 'com.gorios.lanvoice.R.drawable.startup_poster' 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', 'CAMERA_PROBE_DIAGNOSTIC', 'false'
buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', 'false' buildConfigField 'boolean', 'AVATAR_STARTUP_FIX', 'false'
buildConfigField 'boolean', 'AVATAR_ENGINEERING', '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. */ * 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) { 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 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 renderer: ContinuousBodyRenderer?=null
private var foreground=false private var foreground=false
private var failed=false private var failed=false
@@ -231,7 +231,8 @@ class ContinuousBodyRenderer(private val context: Context,private val pack: Cont
private fun draw(frame: ComposedBodyFrame) { private fun draw(frame: ComposedBodyFrame) {
check(width>0 && height>0) check(width>0 && height>0)
GLES20.glViewport(0,0,width,height);GLES20.glClearColor(1f,1f,1f,1f);GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT) 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 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 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) 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) 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) 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 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>? { 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 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() } fun releaseStartup() { driver?.releaseInitial() }
private val main=Handler(Looper.getMainLooper()) private val main=Handler(Looper.getMainLooper())
private val textures=List(4) { TextureView(context).apply { isOpaque=false;alpha=0f } } 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 driver: ConversationMediaDriver?=null
private var active=false private var active=false
private var released=false private var released=false
@@ -8,12 +8,23 @@ import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import com.gorios.lanvoice.diag.StartupTrace 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. /** 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. */ * Full renderer is prepared/held hidden; no TextureView output-clock inference. */
class StartupAvatarView(context: Context,private val binding: AvatarMediaBinding, 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 report: (VideoPresentation)->Unit,private val fullVisible: ()->Unit,private val failed: ()->Unit={}): FrameLayout(context) {
private val poster=ImageView(context).apply { private val poster=FramedAvatarPoster(context).apply {
scaleType=ImageView.ScaleType.FIT_CENTER
setImageResource(com.gorios.lanvoice.BuildConfig.STARTUP_POSTER_RES_ID) setImageResource(com.gorios.lanvoice.BuildConfig.STARTUP_POSTER_RES_ID)
} }
private val surface=TextureView(context).apply { isOpaque=false;alpha=0f } private val surface=TextureView(context).apply { isOpaque=false;alpha=0f }
+57
View File
@@ -0,0 +1,57 @@
# 杨密黑裙统一构图放大测试包(code37)
2026-10-14。用户要求当前杨密资产人物占画幅接近所给全身参考,并快速交付APK。本轮从干净的 `99a03e0487c257280d67e89760613243cc29efb9` 开始,仅调整显示构图,不生成、裁剪、重编码或重做嘴层,不改gateway/persona/time/provider/TTS/相机/presence。
## 构图及范围
采用现主包 black-correct03,精确index pin仍为 `208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93`。人物原本约占9:16画面高度63%;统一Fit后1.45倍等比放大,以源画面垂直0.489处对齐屏幕中心。静止人物约92%画高,舞蹈最大伸展约96%。头、手、脚随视频自然运动,没有逐帧自动取景或不同片段突然变焦。
只读扫描全部5body、8桥、2dance共1071帧(485+200+386),使用180×320缩略图的暗色前景边界辅助检查。neutral及桥的暗色边界大致y55–258,两dance合并y50–263;统一1.5倍正中心会裁到dance01极少头发像素,因此选择1.45倍并调整中心,在最极端采样边界仍留约1.7%上下余量。该阈值扫描不是语义分割,也不能认证所有细发/半透明袖边绝不裁切;亲看neutral原图与放大对照,完整头脚保留,舞蹈真实手机观看仍待测试。
所有运行body/ownmouth桥/两段舞蹈均在同一 `ContinuousBodyRenderer` 中使用相同画面矩形。嘴层仍按原源像素坐标/actual frame/PTS合成,只把最终body+patch一起放大,避免只放大body导致嘴错位。启动poster、基础idle、完整renderer及静态fallback使用同一缩放/中心;gear与设置没有被缩放。屏幕比例变化先执行原Fit,再应用统一放大,未改贴图/decoder/mouth clock或ACTION层所有权。
新增明确构建参数 `avatarFrameZoom` / `avatarFrameCenterY`,默认1.0/0.5,因此未指定参数的主包、Lvbu、Liam构建保持原构图。非默认构图目前只允许精确授权black-correct03;release仍使用默认构图。参数必须有限且落在1–2、0.4–0.6范围,非法值拒绝。原始媒体、index、bootstrap及poster文件完全不变,不需要重新登记action pin。
## 产物
| 字段 | 实际值 |
|---|---|
| APK | lan-voice-v0714-yangmi-framing145-code37-arm64-debug.apk |
| 下载 | http://192.168.31.124:8080/lan-voice-v0714-yangmi-framing145-code37-arm64-debug.apk |
| SHA256 | e08a9fc01856b052515986801ff8e753f9729c0a240473029f5b0704e5571e5c |
| 大小 | 61,386,934 bytes |
| appId | com.gorios.lanvoice(更新现主包,独立Liam/Lvbu不受安装覆盖) |
| 版本 | 0.7.14 / versionCode37 |
| 运行配置 | persona=default,沿服务端当前默认人格与音色;网络动作仍使用已有208f…pin,不修改任何服务端登记 |
| 系统/ABI | min26、target34、arm64-v8a |
| debug证书SHA256 | b9608336bc1ed1de3269bb4594f9fe718daaa5439511c5187aa385d2b799dcf1 |
## 验证及边界
- 4051个assets和旧两个poster资源与冻结主code33逐字节一致,包内实际DEX核zoom=1.45、centerY=0.489、appId/persona/pin/版本与标志;验签、badging及HTTP字节SHA检查通过。
- 11 JVM/UI入口、全量79包装测试通过,包含非法缩放参数、三种viewport下身体/嘴源坐标一致及原默认Fit回归。
- 13 runtime ×40=520项放大后的生产shader离屏GLES pixel golden通过;验证UV、各嘴档、Fit、texture transform、透明alpha及裁剪。golden使用2D surrogate/CPU decode,不能替代Android OES/YUV和物理GPU。
- 实际APK字节的生产loader/View/renderer回放验证idle/newturn、happy/sad、两dance分别从neutral/happy进入、持续ACTION独占、实际release回调后returnA/completed。codec/music/录音确认是host doubles,非真机播放证明。
- 启动回放核poster与compositor在720×1280、360×800、800×480下变换一致;后台cold读取3425个patch、receipt读取0、主线程资产读取0,同进程不重复读。未测手机启动耗时。
- assembleDebug及compileDebugAndroidTestKotlin通过;instrumentation未运行,未安装设备,未开启mic/cam、模型或素材生成调用。
原主包code33、吕布34、Liam35/36及camera-probe产物全部保留,旧pin资产不删。该APK只更新主appId;真实主App的HAL/生命周期限制沿原实现,本轮没有把视觉放大当作相机或busy修复。
## 重建与测试
```sh
python3 scripts/package-avatar-framing.py --version-code 37 --build \
--output logs/framing145-restored/build.json
```
恢复忽略的black资产/bootstrap/poster仍按 `docs/CHARACTER_LVBU_TEST.md` 的精确pin导入脚本。新helper复用同一个profile选包/验签校验,不复制素材或源码,不覆盖已发布同名APK。发布过的code37不可再publish;后续调整需新code/文件名。
协调者核SHA后可USB升级主包。正常launcher会沿既有权限/通话流程;只看视觉使用:
```sh
adb shell am start -n com.gorios.lanvoice/com.gorios.lanvoice.MainActivity --ez avatar_offline_preview true
```
离线不联网、不启mic/cam,设置内看Idle/Talk、happy/sad和两dance;真机确认头脚余量、嘴贴合、桥接与舞蹈进出、设置开合不改变构图。正常模式再验证默认会话和已登记舞蹈。参考图是占比目标,没有把参考男性图导入App。
忽略证据:`logs/framing150-readonly.json`、`logs/framing145/{before-after.png,neutral-enlarged.png,gles/}`、`build-final.json`、`runtime.txt`、`startup.txt`、`delivery.json`及对应client/packaging日志;人物预览、媒体、APK和日志均不入Git。
+17
View File
@@ -11,6 +11,8 @@ parser.add_argument('--sha256',required=True)
parser.add_argument('--startup-loader',action='store_true',help='Production background repository over actual APK bytes, isolated private receipt, no rendering/connection') parser.add_argument('--startup-loader',action='store_true',help='Production background repository over actual APK bytes, isolated private receipt, no rendering/connection')
parser.add_argument('--user-asset-candidate',action='store_true',help='Exact user-authorized correct03 APK; this offline replay uses local media callback doubles and does not assert network admission') parser.add_argument('--user-asset-candidate',action='store_true',help='Exact user-authorized correct03 APK; this offline replay uses local media callback doubles and does not assert network admission')
parser.add_argument('--media-bundle',default='black-correct03',help='Trusted user-debug bundle, when --user-asset-candidate is set') parser.add_argument('--media-bundle',default='black-correct03',help='Trusted user-debug bundle, when --user-asset-candidate is set')
parser.add_argument('--framing-zoom',type=float,default=1)
parser.add_argument('--framing-center-y',type=float,default=.5)
args=parser.parse_args() args=parser.parse_args()
assert hashlib.sha256(args.apk.read_bytes()).hexdigest()==args.sha256, 'APK hash drift' assert hashlib.sha256(args.apk.read_bytes()).hexdigest()==args.sha256, 'APK hash drift'
ROOT=Path(__file__).resolve().parents[1];script=ROOT/'scripts/check-reply-regressions.py' ROOT=Path(__file__).resolve().parents[1];script=ROOT/'scripts/check-reply-regressions.py'
@@ -95,6 +97,8 @@ object BuildConfig { const val STARTUP_POSTER_RES_ID=1;const val AVATAR_STARTUP_
const val EMOTION_MANIFEST_SHA="987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887" const val EMOTION_MANIFEST_SHA="987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887"
const val NATURAL_MANIFEST_SHA="0a3c4918ba746019cf1df885bec66e5858a8950997dac4f64e7d37094be64dad" const val NATURAL_MANIFEST_SHA="0a3c4918ba746019cf1df885bec66e5858a8950997dac4f64e7d37094be64dad"
}''' }'''
assert 1<=args.framing_zoom<=2 and .4<=args.framing_center_y<=.6
build=build.replace('object BuildConfig {','object BuildConfig { const val AVATAR_FRAME_ZOOM='+str(args.framing_zoom)+'f;const val AVATAR_FRAME_CENTER_Y='+str(args.framing_center_y)+'f;')
if args.user_asset_candidate: if args.user_asset_candidate:
import importlib.util import importlib.util
spec=importlib.util.spec_from_file_location('user_startup',ROOT/'scripts/prepare-user-avatar-startup.py');asset_config=importlib.util.module_from_spec(spec);spec.loader.exec_module(asset_config) spec=importlib.util.spec_from_file_location('user_startup',ROOT/'scripts/prepare-user-avatar-startup.py');asset_config=importlib.util.module_from_spec(spec);spec.loader.exec_module(asset_config)
@@ -219,6 +223,19 @@ fun main(args: Array<String>) {
while(pack==null || base==null) { TestScheduler.advanceBy(0);check(System.nanoTime()<deadline);Thread.sleep(1) } while(pack==null || base==null) { TestScheduler.advanceBy(0);check(System.nanoTime()<deadline);Thread.sleep(1) }
} }
StartupAvatarRepository.request(context,{base=it},{pack=it.getOrThrow()});waitReady() StartupAvatarRepository.request(context,{base=it},{pack=it.getOrThrow()});waitReady()
if(base!!.body.width==720) {
val poster=FramedAvatarPoster(context)
for((w,h) in listOf(720 to 1280,360 to 800,800 to 480)) {
poster.onSizeChanged(w,h,0,0)
val zoom=com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_ZOOM
val center=com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_CENTER_Y
val fitted=bodyFit(w,h,180,320)
val composed=bodyFit(w,h,720,1280,zoom,center)
val displayedTop=h/2f+(fitted.top-h/2f)*poster.scaleY+poster.translationY
check(poster.scaleX==zoom && poster.scaleY==zoom && kotlin.math.abs(displayedTop-composed.top)<.001f)
}
println("POSTER_FRAMING|viewports=3|matches_compositor=true|zoom=${com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_ZOOM}|center_y=${com.gorios.lanvoice.BuildConfig.AVATAR_FRAME_CENTER_Y}|device=false")
}
check(base!!.body.frameCount==97 && base!!.patches.isEmpty() && base!!.curves.isEmpty()) check(base!!.body.frameCount==97 && base!!.patches.isEmpty() && base!!.curves.isEmpty())
check(pack!!.emotionAdmission=="accepted" && pack!!.emotionAction!!.packages.size==5) check(pack!!.emotionAdmission=="accepted" && pack!!.emotionAction!!.packages.size==5)
val patchReads=android.content.Archive.reads.count { it.contains("/patches/") } val patchReads=android.content.Archive.reads.count { it.contains("/patches/") }
+8 -6
View File
@@ -12,9 +12,9 @@ def bilinear(image,x,y):
fx=(x-ix)[...,None];fy=(y-iy)[...,None] fx=(x-ix)[...,None];fy=(y-iy)[...,None]
return (image[iy,ix]*(1-fx)+image[iy,jx]*fx)*(1-fy)+(image[jy,ix]*(1-fx)+image[jy,jx]*fx)*fy return (image[iy,ix]*(1-fx)+image[iy,jx]*fx)*(1-fy)+(image[jy,ix]*(1-fx)+image[jy,jx]*fx)*fy
def golden(body,patch,x,y,opacity,w,h,crop): def golden(body,patch,x,y,opacity,w,h,crop,zoom=1,center_y=.5):
bh,bw=body.shape[:2] bh,bw=body.shape[:2]
scale=min(w/bw,h/bh);left=(w-bw*scale)/2;top=(h-bh*scale)/2 scale=min(w/bw,h/bh)*zoom;left=(w-bw*scale)/2;top=h/2-bh*scale*center_y
yy,xx=np.mgrid[:h,:w];px=(xx+.5-left)/scale;py=(yy+.5-top)/scale yy,xx=np.mgrid[:h,:w];px=(xx+.5-left)/scale;py=(yy+.5-top)/scale
inside=(px>=0)&(px<bw)&(py>=0)&(py<bh) inside=(px>=0)&(px<bw)&(py>=0)&(py<bh)
bx=px*(.98 if crop else 1)+(bw*.01 if crop else 0)-.5 bx=px*(.98 if crop else 1)+(bw*.01 if crop else 0)-.5
@@ -29,7 +29,9 @@ def golden(body,patch,x,y,opacity,w,h,crop):
def main(): def main():
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--runtime',type=Path);parser.add_argument('--synthetic-shape',choices=['480x848','720x1280'],default='720x1280');parser.add_argument('--output',type=Path,required=True) parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--runtime',type=Path);parser.add_argument('--synthetic-shape',choices=['480x848','720x1280'],default='720x1280');parser.add_argument('--output',type=Path,required=True)
parser.add_argument('--zoom',type=float,default=1);parser.add_argument('--center-y',type=float,default=.5)
args=parser.parse_args();args.output.mkdir(parents=True,exist_ok=True) args=parser.parse_args();args.output.mkdir(parents=True,exist_ok=True)
assert 1<=args.zoom<=2 and .4<=args.center_y<=.6
m=json.loads((args.runtime/'manifest.json').read_text()) if args.runtime else None m=json.loads((args.runtime/'manifest.json').read_text()) if args.runtime else None
bw,bh=(m['body']['width'],m['body']['height']) if m else map(int,args.synthetic_shape.split('x')) bw,bh=(m['body']['width'],m['body']['height']) if m else map(int,args.synthetic_shape.split('x'))
source=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/ContinuousBodyRenderer.kt').read_text() source=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/ContinuousBodyRenderer.kt').read_text()
@@ -43,14 +45,14 @@ def main():
env=dict(os.environ,EGL_PLATFORM='surfaceless',LIBGL_ALWAYS_SOFTWARE='1') env=dict(os.environ,EGL_PLATFORM='surfaceless',LIBGL_ALWAYS_SOFTWARE='1')
def check(body,patch,x,y,opacity,w,h,label,crop=0): def check(body,patch,x,y,opacity,w,h,label,crop=0):
(tmp/'body.rgba').write_bytes(body.tobytes());(tmp/'patch.rgba').write_bytes(patch.tobytes()) (tmp/'body.rgba').write_bytes(body.tobytes());(tmp/'patch.rgba').write_bytes(patch.tobytes())
p=subprocess.run([str(tmp/'golden'),str(tmp/'vertex'),str(tmp/'fragment'),str(tmp/'body.rgba'),str(tmp/'patch.rgba'),str(tmp/'out.rgba'),str(patch.shape[1]),str(patch.shape[0]),str(x),str(y),str(opacity),str(w),str(h),str(crop),str(body.shape[1]),str(body.shape[0])],env=env,capture_output=True,text=True) p=subprocess.run([str(tmp/'golden'),str(tmp/'vertex'),str(tmp/'fragment'),str(tmp/'body.rgba'),str(tmp/'patch.rgba'),str(tmp/'out.rgba'),str(patch.shape[1]),str(patch.shape[0]),str(x),str(y),str(opacity),str(w),str(h),str(crop),str(body.shape[1]),str(body.shape[0]),str(args.zoom),str(args.center_y)],env=env,capture_output=True,text=True)
assert p.returncode==0,p.stderr assert p.returncode==0,p.stderr
actual=np.frombuffer((tmp/'out.rgba').read_bytes(),np.uint8).reshape(h,w,4)[::-1,:,:3] actual=np.frombuffer((tmp/'out.rgba').read_bytes(),np.uint8).reshape(h,w,4)[::-1,:,:3]
expected=golden(body,patch,x,y,opacity,w,h,crop);diff=np.abs(actual.astype(int)-expected.astype(int)) expected=golden(body,patch,x,y,opacity,w,h,crop,args.zoom,args.center_y);diff=np.abs(actual.astype(int)-expected.astype(int))
row={'case':label,'maxAbsRGB':int(diff.max()),'meanAbsRGB':float(diff.mean()),'viewport':[w,h],'bodyShape':[body.shape[1],body.shape[0]],'bodyTransformCrop':crop,'gl':p.stdout.strip()} row={'case':label,'maxAbsRGB':int(diff.max()),'meanAbsRGB':float(diff.mean()),'viewport':[w,h],'bodyShape':[body.shape[1],body.shape[0]],'bodyTransformCrop':crop,'zoom':args.zoom,'centerY':args.center_y,'gl':p.stdout.strip()}
results.append(row) results.append(row)
assert diff.max()<=2,row assert diff.max()<=2,row
if opacity==0 and w==body.shape[1] and h==body.shape[0] and not crop:assert np.array_equal(actual,body[:,:,:3]),'Level0 must be exact decoded body' if opacity==0 and w==body.shape[1] and h==body.shape[0] and not crop and args.zoom==1 and args.center_y==.5:assert np.array_equal(actual,body[:,:,:3]),'Level0 must be exact decoded body'
if label=='frame43-level2':Image.fromarray(actual[94:150,193:263]).resize((560,448)).save(args.output/'gles-frame43-level2-mouth.png') if label=='frame43-level2':Image.fromarray(actual[94:150,193:263]).resize((560,448)).save(args.output/'gles-frame43-level2-mouth.png')
yy,xx=np.mgrid[:bh,:bw];body=np.empty((bh,bw,4),np.uint8) yy,xx=np.mgrid[:bh,:bw];body=np.empty((bh,bw,4),np.uint8)
body[:,:,0]=xx%256;body[:,:,1]=yy%256;body[:,:,2]=((xx//16+yy//16)%2)*255;body[:,:,3]=255 body[:,:,0]=xx%256;body[:,:,1]=yy%256;body[:,:,2]=((xx//16+yy//16)%2)*255;body[:,:,3]=255
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""User-authorized Yangmi black-media framing candidate; no media/gateway changes."""
import argparse,importlib.util,json,subprocess
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
spec=importlib.util.spec_from_file_location('persona_pack',ROOT/'scripts/package-character-test.py')
pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack)
if __name__=='__main__':
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--version-code',type=int,default=37)
parser.add_argument('--build',action='store_true');parser.add_argument('--publish',action='store_true')
parser.add_argument('--output',type=Path,required=True);args=parser.parse_args()
pack.require(args.version_code>=37,'fresh framing code required')
name=f'lan-voice-v0714-yangmi-framing145-code{args.version_code}-arm64-debug.apk'
pack.require(not args.output.exists(),'new report required')
if args.publish:pack.require(not (ROOT/'artifacts'/name).exists(),'published version is immutable')
if args.build:
subprocess.run([str(ROOT/'scripts/build.sh'),':app:assembleDebug',':app:compileDebugAndroidTestKotlin',
*pack.flags('main',args.version_code),'-PavatarFrameZoom=1.45','-PavatarFrameCenterY=0.489'],cwd=ROOT,check=True)
apk=pack.build_dir('main')/'outputs/apk/debug/app-debug.apk'
report=pack.verify(apk,'main',args.version_code,frame_zoom=1.45,frame_center_y=.489)
if args.publish:report=pack.publish(apk,report,name)
args.output.parent.mkdir(parents=True,exist_ok=True)
with args.output.open('x') as out:out.write(json.dumps(report,indent=2,ensure_ascii=False)+'\n')
print(json.dumps(report,indent=2,ensure_ascii=False))
+8 -3
View File
@@ -50,7 +50,7 @@ def build_dir(profile):
return ROOT/('app/build' if profile == 'main' else 'app/build/characters/'+profile) return ROOT/('app/build' if profile == 'main' else 'app/build/characters/'+profile)
def verify(apk, profile, version, media_bundle='black-correct03'): def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,frame_center_y=.5):
catalog = select.catalog() catalog = select.catalog()
role = catalog['profiles'][profile] role = catalog['profiles'][profile]
media = catalog['mediaBundles'][media_bundle] media = catalog['mediaBundles'][media_bundle]
@@ -101,6 +101,9 @@ def verify(apk, profile, version, media_bundle='black-correct03'):
require(dex_values.get(field) == str(value).lower(), 'APK DEX boolean mismatch: '+field) require(dex_values.get(field) == str(value).lower(), 'APK DEX boolean mismatch: '+field)
require(dex_values.get('VERSION_CODE') == str(version) and require(dex_values.get('VERSION_CODE') == str(version) and
dex_values.get('VERSION_NAME') == '"0.7.14'+role['versionSuffix']+'"', 'APK DEX version mismatch') dex_values.get('VERSION_NAME') == '"0.7.14'+role['versionSuffix']+'"', 'APK DEX version mismatch')
for field,value in [('AVATAR_FRAME_ZOOM',frame_zoom),('AVATAR_FRAME_CENTER_Y',frame_center_y)]:
if field in dex_values or frame_zoom!=1 or frame_center_y!=.5:
require(abs(float(dex_values.get(field,'nan'))-value)<.000001,'APK framing mismatch: '+field)
badge = subprocess.check_output([str(TOOLS/'aapt'), 'dump', 'badging', str(apk)], text=True) badge = subprocess.check_output([str(TOOLS/'aapt'), 'dump', 'badging', str(apk)], text=True)
version_name = '0.7.14'+role['versionSuffix'] version_name = '0.7.14'+role['versionSuffix']
for value in ("name='"+role['applicationId']+"'", f"versionCode='{version}'", for value in ("name='"+role['applicationId']+"'", f"versionCode='{version}'",
@@ -123,6 +126,7 @@ def verify(apk, profile, version, media_bundle='black-correct03'):
'index_sha256': media['indexSha256'], 'media_bundle':media_bundle, 'asset_files_verified':len(selected['files']), 'index_sha256': media['indexSha256'], 'media_bundle':media_bundle, 'asset_files_verified':len(selected['files']),
'assets_unchanged': len(selected['files']) if media_bundle=='black-correct03' else None, 'assets_unchanged': len(selected['files']) if media_bundle=='black-correct03' else None,
'network_actions_allowed':media.get('networkActionsAllowed',False), 'network_actions_allowed':media.get('networkActionsAllowed',False),
'framing_zoom':frame_zoom,'framing_center_y':frame_center_y,
'poster_resources_unchanged': 2, 'provider_authorities': authorities, 'poster_resources_unchanged': 2, 'provider_authorities': authorities,
'actual_dex_verified': True, 'device': 'not_run', 'gateway_changed': False} 'actual_dex_verified': True, 'device': 'not_run', 'gateway_changed': False}
@@ -132,8 +136,9 @@ def artifact_name(profile, version):
return f"lan-voice-v0714-{profile}-code{version}-arm64-debug.apk" return f"lan-voice-v0714-{profile}-code{version}-arm64-debug.apk"
def publish(apk, report): def publish(apk, report, name=None):
name = artifact_name(report['profile'], report['version_code']) name = name or artifact_name(report['profile'], report['version_code'])
require(re.fullmatch('[a-z0-9.-]+[.]apk',name),'artifact filename shape')
artifact = ROOT/'artifacts'/name artifact = ROOT/'artifacts'/name
with artifact.open('xb') as out, apk.open('rb') as src: with artifact.open('xb') as out, apk.open('rb') as src:
shutil.copyfileobj(src, out) shutil.copyfileobj(src, out)
+4 -2
View File
@@ -22,7 +22,7 @@ static void texture(GLuint id,int w,int h,const char *path) {
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,data);free(data); glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,data);free(data);
} }
int main(int argc,char **v) { int main(int argc,char **v) {
assert(argc==16); assert(argc==16 || argc==18);
int bw=atoi(v[14]),bh=atoi(v[15]);assert(bw>0&&bh>0); int bw=atoi(v[14]),bh=atoi(v[15]);assert(bw>0&&bh>0);
int pw=atoi(v[6]),ph=atoi(v[7]),w=atoi(v[11]),h=atoi(v[12]);float x=atof(v[8]),y=atof(v[9]),opacity=atof(v[10]); int pw=atoi(v[6]),ph=atoi(v[7]),w=atoi(v[11]),h=atoi(v[12]);float x=atof(v[8]),y=atof(v[9]),opacity=atof(v[10]);
PFNEGLGETPLATFORMDISPLAYEXTPROC platform=(void*)eglGetProcAddress("eglGetPlatformDisplayEXT");assert(platform); PFNEGLGETPLATFORMDISPLAYEXTPROC platform=(void*)eglGetProcAddress("eglGetPlatformDisplayEXT");assert(platform);
@@ -38,7 +38,9 @@ int main(int argc,char **v) {
GLuint ids[2];glGenTextures(2,ids);glActiveTexture(GL_TEXTURE0);texture(ids[0],bw,bh,v[3]);glUniform1i(glGetUniformLocation(p,"uBody"),0); GLuint ids[2];glGenTextures(2,ids);glActiveTexture(GL_TEXTURE0);texture(ids[0],bw,bh,v[3]);glUniform1i(glGetUniformLocation(p,"uBody"),0);
glActiveTexture(GL_TEXTURE1);texture(ids[1],pw,ph,v[4]);glUniform1i(glGetUniformLocation(p,"uPatch"),1); glActiveTexture(GL_TEXTURE1);texture(ids[1],pw,ph,v[4]);glUniform1i(glGetUniformLocation(p,"uPatch"),1);
glUniform2f(glGetUniformLocation(p,"uBodySize"),bw,bh); glUniform2f(glGetUniformLocation(p,"uBodySize"),bw,bh);
float scale=fminf((float)w/bw,(float)h/bh),mw=bw*scale,mh=bh*scale,left=(w-mw)/2,top=(h-mh)/2; float zoom=argc==18?atof(v[16]):1,centerY=argc==18?atof(v[17]):.5f;
assert(isfinite(zoom)&&zoom>=1&&zoom<=2&&isfinite(centerY)&&centerY>=.4f&&centerY<=.6f);
float scale=fminf((float)w/bw,(float)h/bh)*zoom,mw=bw*scale,mh=bh*scale,left=(w-mw)/2,top=h/2.f-mh*centerY;
GLfloat pos[]={left/w*2-1,1-(top+mh)/h*2,(left+mw)/w*2-1,1-(top+mh)/h*2,left/w*2-1,1-top/h*2,(left+mw)/w*2-1,1-top/h*2}; GLfloat pos[]={left/w*2-1,1-(top+mh)/h*2,(left+mw)/w*2-1,1-(top+mh)/h*2,left/w*2-1,1-top/h*2,(left+mw)/w*2-1,1-top/h*2};
GLfloat uv[]={0,0,1,0,0,1,1,1}; GLfloat uv[]={0,0,1,0,0,1,1,1};
GLint a=glGetAttribLocation(p,"aPosition"),b=glGetAttribLocation(p,"aUv");glVertexAttribPointer(a,2,GL_FLOAT,GL_FALSE,0,pos);glEnableVertexAttribArray(a);glVertexAttribPointer(b,2,GL_FLOAT,GL_FALSE,0,uv);glEnableVertexAttribArray(b); GLint a=glGetAttribLocation(p,"aPosition"),b=glGetAttribLocation(p,"aUv");glVertexAttribPointer(a,2,GL_FLOAT,GL_FALSE,0,pos);glEnableVertexAttribArray(a);glVertexAttribPointer(b,2,GL_FLOAT,GL_FALSE,0,uv);glEnableVertexAttribArray(b);
+1 -1
View File
@@ -1,2 +1,2 @@
package com.gorios.lanvoice package com.gorios.lanvoice
object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=false;const val STARTUP_POSTER_RES_ID=1 } object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=false;const val STARTUP_POSTER_RES_ID=1;const val AVATAR_FRAME_ZOOM=1f;const val AVATAR_FRAME_CENTER_Y=0.5f }
+14
View File
@@ -117,6 +117,20 @@ fun dynamicBodyCheck() {
rejected(legacy+("body" to (legacy["body"] as Map<String,Any?>)+mapOf("width" to 720,"height" to 1280))) rejected(legacy+("body" to (legacy["body"] as Map<String,Any?>)+mapOf("width" to 720,"height" to 1280)))
val fit=bodyFit(360,800,720,1280) val fit=bodyFit(360,800,720,1280)
check(fit.left==0f && fit.top==80f && fit.width==360f && fit.height==640f) check(fit.left==0f && fit.top==80f && fit.width==360f && fit.height==640f)
for((w,h) in listOf(720 to 1280,360 to 800,800 to 480)) {
val original=bodyFit(w,h,720,1280)
val zoomed=bodyFit(w,h,720,1280,1.45f,.489f)
fun near(a: Float,b: Float)=kotlin.math.abs(a-b)<.001f
check(near(zoomed.width,original.width*1.45f) && near(zoomed.height,original.height*1.45f))
check(near(zoomed.left+zoomed.width/2,w/2f) && near(zoomed.top+zoomed.height*.489f,h/2f))
// The exact same source coordinates map body pixels and mouth rects.
val patch=pack.patches[0]
val displayX=zoomed.left+(patch.x+patch.width/2f)*zoomed.width/720
val sourceX=(displayX-zoomed.left)*720/zoomed.width
check(near(sourceX,patch.x+patch.width/2f))
}
for(zoom in listOf(Float.NaN,Float.POSITIVE_INFINITY,.9f,2.1f))check(runCatching { bodyFit(720,1280,720,1280,zoom) }.isFailure)
for(center in listOf(Float.NaN,.39f,.61f))check(runCatching { bodyFit(720,1280,720,1280,1.45f,center) }.isFailure)
fun render(codecW: Int,codecH: Int): Pair<List<ComposedBodyFrame>,List<String>> { fun render(codecW: Int,codecH: Int): Pair<List<ComposedBodyFrame>,List<String>> {
TestScheduler.reset();CodecFixture.reset();GLFixture.reset() TestScheduler.reset();CodecFixture.reset();GLFixture.reset()
CodecFixture.width=codecW;CodecFixture.height=codecH;CodecFixture.frames=97;CodecFixture.fps=24 CodecFixture.width=codecW;CodecFixture.height=codecH;CodecFixture.frames=97;CodecFixture.fps=24
+3 -1
View File
@@ -8,9 +8,11 @@ open class FrameLayout(val context: Context) {
fun addView(view: Any, params: LayoutParams) { children.add(view) } fun addView(view: Any, params: LayoutParams) { children.add(view) }
open fun onDetachedFromWindow() {} open fun onDetachedFromWindow() {}
} }
class ImageView(context: Context) { open class ImageView(context: Context) {
enum class ScaleType { FIT_CENTER } enum class ScaleType { FIT_CENTER }
var scaleType = ScaleType.FIT_CENTER; var alpha = 1f var scaleType = ScaleType.FIT_CENTER; var alpha = 1f
var scaleX=1f;var scaleY=1f;var translationY=0f
open fun onSizeChanged(w: Int,h: Int,oldw: Int,oldh: Int) {}
fun setImageResource(id: Int) {} fun setImageResource(id: Int) {}
fun setImageBitmap(bitmap: Any?) {} fun setImageBitmap(bitmap: Any?) {}
fun setImageDrawable(drawable: Any?) {} fun setImageDrawable(drawable: Any?) {}