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
+7 -5
View File
@@ -68,10 +68,10 @@ def probe_clip(path):
data=json.loads(result.stdout)
require(len(data['streams'])==1,'conversation/bridge must be silent video')
v=data['streams'][0]
require(v['codec_type']=='video' and v['codec_name']=='h264' and (v['width'],v['height'])==(480,848),'clip codec/shape')
require(v['codec_type']=='video' and v['codec_name']=='h264' and (v['width'],v['height']) in runtime_gate.SUPPORTED_SHAPES,'clip codec/shape')
us=lambda value:int((Decimal(value)*1_000_000).to_integral_value())
measured={'ptsUs':[us(f['best_effort_timestamp_time']) for f in data['frames']],
'durationUs':us(v['duration']),'fps':Fraction(v['r_frame_rate'])}
'durationUs':us(v['duration']),'fps':Fraction(v['r_frame_rate']),'shape':(v['width'],v['height'])}
subprocess.run(['/home/ubuntu/gori-bin/ffmpeg','-v','error','-xerror','-i',str(path),'-map','0:v:0','-f','null','-'],capture_output=True,check=True,timeout=60)
return measured
@@ -84,7 +84,7 @@ def probe_music_clip(path):
require(len(streams)==2 and sorted(s['codec_type'] for s in streams)==['audio','video'],
'dance requires exactly video+audio, no attached cover')
v=next(s for s in streams if s['codec_type']=='video');a=next(s for s in streams if s['codec_type']=='audio')
require(v['codec_name']=='h264' and (v['width'],v['height'])==(480,848) and
require(v['codec_name']=='h264' and (v['width'],v['height']) in runtime_gate.SUPPORTED_SHAPES and
not v.get('disposition',{}).get('attached_pic',0),'dance video codec/shape/cover')
require(a['codec_name']=='aac' and a['channels'] in (1,2) and 8000<=int(a['sample_rate'])<=96000,'dance AAC format')
us=lambda value:int((Decimal(value)*1_000_000).to_integral_value())
@@ -110,7 +110,7 @@ def probe_music_clip(path):
require(rms>0.00001 and peak<=1.001,'dance silent/out-of-range audio')
return {'ptsUs':[us(f['best_effort_timestamp_time']) for f in frames],
'durationUs':duration,'fps':Fraction(v['r_frame_rate']),'audioEndUs':audio_end,
'decodedAudioEndUs':decoded_end,'pcmFrames':len(samples)//2,'audioRms':rms,'audioPeak':peak,
'shape':(v['width'],v['height']),'decodedAudioEndUs':decoded_end,'pcmFrames':len(samples)//2,'audioRms':rms,'audioPeak':peak,
'nearFullScaleSamples':sum(abs(x)>=0.999 for x in samples),'humanListening':'not_run'}
@@ -140,7 +140,7 @@ def check_bundle(manifest,expected,output):
m=read_json(path);prefix=PurePosixPath(ref['path']).parent
for name,digest in verified.items(): add(str(prefix/name),digest,64_000_000 if name.endswith('.mp4') else 256_000)
body=m['body'];measurements[str(prefix/body['path'])]={'ptsUs':body['ptsUs'] if m['schemaVersion']==2 else [i*1_000_000//24 for i in range(body['frameCount'])],
'durationUs':body['durationUs'],'fps':Fraction(body['fpsNumerator'],body['fpsDenominator'])}
'durationUs':body['durationUs'],'fps':Fraction(body['fpsNumerator'],body['fpsDenominator']),'shape':(body['width'],body['height'])}
runtimes.append({'package_id':runtime_id,**evidence})
rgba=sum(r['rgba_cache_bytes'] for r in runtimes);require(rgba<=32_000_000,'combined runtime cache bound')
require(len(index['edges'])<=100,'edge count bound')
@@ -149,6 +149,7 @@ def check_bundle(manifest,expected,output):
require(clip['hasAudio'] is False,'conversation edge cannot have audio')
measured=measurements.get(name)
if measured is None: measured=measurements[name]=probe_clip(path)
require(measured['shape']==(clip['width'],clip['height']),'decoded clip shape mismatch: '+name)
require(len(measured['ptsUs'])==clip['frameCount'] and len(clip['ptsUs'])==clip['frameCount'],'decoded clip N mismatch: '+name)
require(all(abs(a-b)<=2 for a,b in zip(measured['ptsUs'],clip['ptsUs'])),'decoded clip PTS mismatch: '+name)
require(abs(measured['durationUs']-clip['durationUs'])<=2 and measured['fps']==Fraction(clip['fpsNumerator'],clip['fpsDenominator']),'decoded clip timing mismatch: '+name)
@@ -157,6 +158,7 @@ def check_bundle(manifest,expected,output):
clip=action['clip'];name=relative(clip['path']);path=add(name,clip['sha256'],128_000_000)
require(clip['hasAudio'] is True,'dance requires actual audio')
measured=probe_music_clip(path)
require(measured['shape']==(clip['width'],clip['height']),'decoded clip shape mismatch: '+name)
require(len(measured['ptsUs'])==clip['frameCount'] and len(clip['ptsUs'])==clip['frameCount'], 'dance decoded N mismatch: '+name)
require(all(abs(a-b)<=2 for a,b in zip(measured['ptsUs'],clip['ptsUs'])),'dance decoded PTS mismatch: '+name)
require(abs(measured['durationUs']-clip['durationUs'])<=2 and measured['fps']==Fraction(clip['fpsNumerator'],clip['fpsDenominator']),'dance decoded timing mismatch: '+name)