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
+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('--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('--framing-zoom',type=float,default=1)
parser.add_argument('--framing-center-y',type=float,default=.5)
args=parser.parse_args()
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'
@@ -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 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:
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)
@@ -219,6 +223,19 @@ fun main(args: Array<String>) {
while(pack==null || base==null) { TestScheduler.advanceBy(0);check(System.nanoTime()<deadline);Thread.sleep(1) }
}
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(pack!!.emotionAdmission=="accepted" && pack!!.emotionAction!!.packages.size==5)
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]
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]
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
inside=(px>=0)&(px<bw)&(py>=0)&(py<bh)
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():
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)
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
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()
@@ -43,14 +45,14 @@ def main():
env=dict(os.environ,EGL_PLATFORM='surfaceless',LIBGL_ALWAYS_SOFTWARE='1')
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())
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
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))
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()}
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,'zoom':args.zoom,'centerY':args.center_y,'gl':p.stdout.strip()}
results.append(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')
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
+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)
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()
role = catalog['profiles'][profile]
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('VERSION_CODE') == str(version) and
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)
version_name = '0.7.14'+role['versionSuffix']
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']),
'assets_unchanged': len(selected['files']) if media_bundle=='black-correct03' else None,
'network_actions_allowed':media.get('networkActionsAllowed',False),
'framing_zoom':frame_zoom,'framing_center_y':frame_center_y,
'poster_resources_unchanged': 2, 'provider_authorities': authorities,
'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"
def publish(apk, report):
name = artifact_name(report['profile'], report['version_code'])
def publish(apk, report, name=None):
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
with artifact.open('xb') as out, apk.open('rb') as src:
shutil.copyfileobj(src, out)