1111from pathlib import Path
1212import numpy as np
1313from scene_equations import _scalar
14+ from quad_lines import PROFILE
15+
16+
17+ _CORE235_ENGINE = {
18+ 'commit' : 'e0b0a967f0ffd7d332106c366668ed271718472b' ,
19+ 'patches_sha256' : 'd73c955a26380a502516e6ba3a18baf753851244de4de2e5a3083930766a539a' ,
20+ }
1421
1522
1623def _colour (source ,main ,frame ,mode ,alpha ,width ,height ):
@@ -34,9 +41,20 @@ def _colour(source,main,frame,mode,alpha,width,height):
3441 return rgba .tolist ()
3542
3643
37- def source_builtin_wave (source ,scene ,audio ,* ,binary :Path ,timeout_seconds = 60 ):
44+ def source_builtin_wave (source ,scene ,audio ,* ,binary :Path ,timeout_seconds = 60 ,
45+ line_rendering_profile = 'canonical-gl-lines-v1' ):
3846 if len (scene ['frames' ])!= len (audio ['frames' ]):raise ValueError ('wave/audio frame schedule mismatch' )
3947 values = source ['values' ];width ,height = scene ['viewport' ]
48+ if line_rendering_profile not in {'canonical-gl-lines-v1' ,PROFILE }:
49+ raise ValueError ('unknown builtin wave line rendering profile' )
50+ dot = bool (_scalar (values ,'bWaveDots' ,0 ,'bool' ))
51+ scaled_dots = dot and line_rendering_profile == PROFILE
52+ if scaled_dots :
53+ engine = source .get ('parser_inputs' ,{}).get ('engine' ,{})
54+ if any (engine .get (key )!= value for key ,value in _CORE235_ENGINE .items ()):
55+ raise ValueError ('GLES builtin dot engine identity mismatch' )
56+ if width <= 0 or height <= 0 or width * height > 1024 * 768 or height > 1330 :
57+ raise ValueError ('GLES builtin dot profile requires viewport within reference area' )
4058 mode = _scalar (values ,'nWaveMode' ,0 ,'int' )
4159 request_frames = []
4260 for frame ,data in zip (scene ['frames' ],audio ['frames' ]):
@@ -56,8 +74,10 @@ def source_builtin_wave(source,scene,audio,*,binary:Path,timeout_seconds=60):
5674 native = json .loads (output .read_text ())
5775 if native .get ('render_context_time_bits' )!= 32 :
5876 raise ValueError ('prepared native waveform adapter with float32 render context required' )
59- dot = bool (_scalar (values ,'bWaveDots' ,0 ,'bool' ));thick = dot or bool (_scalar (values ,'bWaveThick' ,0 ,'bool' ))
60- offsets = [[0 ,0 ],[1 / width ,0 ],[1 / width ,- 1 / height ],[0 ,- 1 / height ]] if thick else [[0 ,0 ]]
77+ thick = dot or bool (_scalar (values ,'bWaveThick' ,0 ,'bool' ))
78+ # Waveform::Draw uses one DotStyleFor(MainWave) point when quad mode is on.
79+ # At/below the reference area LineScale=1, hence size=2 and alphaScale=1.
80+ offsets = [[0 ,0 ]] if scaled_dots or not thick else [[0 ,0 ],[1 / width ,0 ],[1 / width ,- 1 / height ],[0 ,- 1 / height ]]
6181 result = []
6282 for frame ,data ,geometry in zip (scene ['frames' ],audio ['frames' ],native ['frames' ]):
6383 waves = []
@@ -70,6 +90,7 @@ def source_builtin_wave(source,scene,audio,*,binary:Path,timeout_seconds=60):
7090 result .append ({'positions' :waves ,'clip_positions' :geometry ['vertex_waves' ],
7191 'rgba' :_colour (source ,frame ['main' ],data ,native ['mode' ],geometry ['wave_a_after_geometry' ],width ,height ),
7292 'draw_mode' :'points' if dot else 'loop' if geometry ['closed_loop' ] else 'strip' ,
93+ 'point_size' :2 if scaled_dots else 1 ,
7394 'additive' :bool (_scalar (values ,'bAdditiveWaves' ,0 ,'bool' )),'copy_offsets' :offsets })
7495 return {'basis' :native ['basis' ],'mode' :native ['mode' ],'frames' :result ,'source_hashes' :native ['source_hashes' ],
7596 'adapter_sha256' :native ['adapter_sha256' ],
0 commit comments