Repository navigation
Add runtime VIC palette stream metadata - #871
Conversation
|
@barryw Wow, that was fast! Nice one! |
|
@chrisgleissner I have a feeling that this is just the start of the conversation ;-) Once @GideonZ gets ahold of it, I'm pretty certain I'll have some work to do lol |
|
I commented elsewhere about the format. I think you picked that up, right, @barryw ? |
@GideonZ I did. I waited until you and @chrisgleissner chimed in before I started on anything, so what's here is based on that complete conversation. I'm working with @chrisgleissner on changes he's requested on his OBS plugin and that may require changes here. I'll let you guys know if this pr has to change. |
|
@GideonZ @chrisgleissner Follow-up from the client review is in 9da3085: palette UDP now binds to the same source address as the FPGA VIC stream, and the firmware E2E enforces that source filter. The agreed 60-byte compatibility layout is unchanged. All five shipping |
|
@GideonZ @chrisgleissner Hardware validation on a dual-homed Ultimate 64 Elite found that forcing the software palette socket to the FPGA stream address breaks unicast. The FPGA VIC stream left Ethernet as Follow-up |
|
@GideonZ @chrisgleissner Final hardware validation is complete on an Ultimate 64 Elite running
This confirms the corrected routing behavior: multicast remains source-bound, while unicast permits LwIP to use the working software interface. CI is green for the final commit. |
|
Hi @barryw and @GideonZ , can this be merged? As soon as it's merged, I'd like to also merge the nice PR that Barry kindly left against C64 Stream to fully support this exciting new feature. See chrisgleissner/c64stream#131 |
I've done a rebase and am running e2e now just to make sure we're still clean. We should be good, but this is not a trivial change. |
7949843 to
b3bd458
Compare
Firmware now sends runtime palette packets from the VIC stream's interface and source port for unicast as well as multicast (GideonZ/1541ultimate#871). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
b3bd458 to
26d7af0
Compare
|
@GideonZ @chrisgleissner I rebased this branch onto current On the critical sections @GideonZ asked about in Firmware
Two changes reach beyond the palette:
E2E test
Validation Hardware: Ultimate 64 Elite, FPGA 125, core 1.50. The firmware was built from
The gate runs against the wired address because the device has Ethernet connected, and the A/V streams leave from that port. The complete default-gate log follows in the next two comments, split only because of GitHub's comment size limit.
|
|
Default E2E gate, Default gate log, part 1 of 2 |
|
Default E2E gate, Default gate log, part 2 of 2 |
|
Thanks for having added the full default E2E gate logs @barryw , and all the other changes and fixes - much appreciated! Stellar work! Did you check with @GideonZ , is he OK to have this merged, and shall this go into 3.15b or 3.16? We currently don't have the means to distinguish both - everything that currently goes into |
|
Thanks @chrisgleissner. No, I haven't had an explicit go-ahead from @GideonZ yet. His one review point (the single-variable critical sections) was addressed in 26d7af0, and he hasn't looked again since. On compatibility: existing clients see the same packets. Palette packets are only sent after That leaves two options: merge now so it ships in 3.15b, or hold it until master opens for 3.16. Either way I can split the multicast fix into its own PR if you'd rather decide on that separately. My preference is 3.15b, since the client side is compatible, but that's a judgement call. @GideonZ, your call. |
|
I hope to be up and running again within some weeks, @barryw |
26d7af0 to
30afb19
Compare
|
@chrisgleissner Rebased onto master 2c60bd8; it's now 30afb19. The only conflict was in Retested on the rebased build (Ultimate 64 Elite, FPGA 125, core 1.50): default gate 31/31, and |
|
Default E2E gate, Default gate log, part 1 of 2 |
|
Default E2E gate, Default gate log, part 2 of 2 |
|
uci-targets log |
* feat(video): accept runtime VIC palettes Refs GideonZ/1541ultimate#850 * feat(palette): follow device runtime colors Opt in through REST, recover dropped or reordered palette packets, and fall back to normal streaming when older firmware rejects the option. * fix(palette): ignore device catalog lookup * fix(palette): harden runtime updates Keep the last complete LUT through reconnects, reject malformed control packets, and document whole-frame palette application. Remove palette-only debug accounting from the receive path. * feat(palette): complete device follow mode * docs(stream): clarify palette packet routing * fix(e2e): Windows udp_replay build and palette CI coverage Winsock sendto() takes an int length, so the size_t send_size tripped C4267 under /W4 with warnings-as-errors on both Windows CI jobs. Use a platform-typed length; MAX_PACKET_SIZE bounds it. Add ntsc_palette_follow_device and ntsc_palette_follow_device_unsup to the E2E Full matrix so CI verifies both firmware that emits runtime palette metadata and firmware that rejects palette=1. Bump _POSIX_C_SOURCE to 200112L so snprintf is declared on macOS libc, allowing udp_replay to build locally before pushing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(e2e): rename palette follow-device scenarios to fit overlay Scenario names render in the top-left overlay box as at most four underscore-delimited segments of up to nine characters. The previous ntsc_palette_follow_device_unsup name had five segments, so the distinguishing "unsup" suffix was dropped from the video. Rename to ntsc_palette_device and ntsc_palette_device_legacy, mirroring ntsc_transport_legacy for the no-runtime-palette firmware case. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(palette): reset generation baseline on every video start The "already streaming" reconnect path in c64_async_retry_task resends the video start command without clearing device_palette.ordering_valid. After a firmware reboot the device restarts its palette generation from a low value, so every new palette packet was rejected as not newer and the rendered palette stayed frozen until the counter climbed past the stale one. Move the reset into c64_stream_control_to, which every start path funnels through, and drop the duplicate in c64_start_streaming_inner. Add a unit test covering video start, audio start, stop, follow mode off, and the legacy transport. Also make the palette_mapping E2E assertion detect the content region from the middle of the content range instead of five frames after the logo transition, where letterbox pixels are not yet black and the detector fell back to the full frame. This was the cause of the PaletteMapping failure logged in the last CI run. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(palette): stop get_defaults writing colour overrides as user values c64_set_property_defaults ran update_palette_color_properties, which stores the working palette colours as user values (obs_data_set_int). OBS calls get_defaults before the source is created, when the working palette is still Default, so every source started with sixteen palette_color_N user values holding Default colours. Since the per-source LUT change (#121) c64_source_apply_palette applies those overrides on top of the resolved palette, so any scene or C64Script PALETTE command that carries only the palette id rendered Default. The properties dialog masked it by rewriting the overrides on every dropdown selection. Set only default values in the defaults path. The E2E scenarios ntsc_palette_vibrant and ntsc_palette_muted now pass PaletteMapping; on main they render Default and fail it (hidden by the CI workflow not propagating e2e.sh's exit code). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs(stream): palette packets share the VIC stream's source Firmware now sends runtime palette packets from the VIC stream's interface and source port for unicast as well as multicast (GideonZ/1541ultimate#871). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Christian Gleissner <chrisgleissner@gmail.com>
|
the counterpart of this change on the C64 Stream side (thanks Barry!) is now merged, see chrisgleissner/c64stream#131 Given it is backwards compatible, shall we merge the PR here now so it a can go into 3.15b (my preference) or shall we hold off until 3.16? Thanks |
Yes! I can see the light at the end of the tunnel! 😆 |
|
I have now released C64 Stream 1.2.0 with full support for this exciting new feature, as kindly added by Barry both here and there. I'd be keen to merge this PR here soon if @GideonZ agrees. |
|
Hi @barryw, Thanks for resolving the merge conflict on this PR. |
5dd971c to
4402a80
Compare
|
Hi @barryw, thanks for resolving the merge conflict. |
|
Hi @barryw, another merge conflict appeared. Thabks for fixing it. |
Emit the active 16-color RGB palette through the software UDP stack on VIC stream start and runtime updates. Reserve line 0x7fff so the FPGA stream remains unchanged. Refs GideonZ#850
Protect legacy video receivers from short palette datagrams while allowing opted-in clients to follow runtime VIC colors. Refs GideonZ#850
Pair each generation with one atomic RGB snapshot and cap burst updates at one packet per 20 ms. Exercise 240 runtime changes while checking coalescing, packet contents, and uninterrupted video sequencing.
A conditional indefinite wait can miss a rapid stop/start transition and leave runtime palette delivery asleep. Retain the proven one-second poll while preserving notification coalescing.
Binding the palette socket to the FPGA wired address drops unicast packets when a dual-homed Ultimate routes software UDP through Wi-Fi. Keep multicast bound to the FPGA source and let LwIP select the unicast interface.
Firmware: - Resolve a stream start into a copy and commit the source, destination, enable and palette opt-in together, so a failed start leaves the running stream and its palette packets untouched. - Carry the opt-in as a mode bit instead of the command's filename, which the task menu fills with the name of the highlighted browser entry. - Validate the palette parameter before the debug stream is stopped, so a rejected request changes nothing. - Bind the palette socket to the VIC stream's interface and its source port 53248, so palette and video arrive from one address and port for unicast and multicast alike. Connect it to the destination, drain it, and close it when the stream stops, so datagrams sent to it cannot hold lwIP's netbufs. - Keep the socket across transient send failures and pace failed attempts. - Program the palette registers inside the same critical section as the shadow copy and generation, so the VIC, GET_PALETTE and the stream agree. - Treat all of 224.0.0.0/4 as multicast, not only 232-239. - Space palette packets at least 20 ms apart and leave the palette task asleep when no stream has opted in. - Document that the opt-in is device-wide and the latest start sets it. Tests: - Move the stream checks into their own palette-stream scenario after the command interface scenarios, skipping when the firmware, the link or the -H address cannot carry the stream. - Drain the stream on a thread, judge the video by stalls rather than host drops, and use video as the positive control for the no-palette checks. - Require prompt palette packets on start, change and reset, and check the repeat interval. - Start the burst fixture only on GO=1 and reset before restoring the palette when a failure leaves it parked. - Share one palette parser in streams.py and pass stream start parameters through Arming. Refs GideonZ#850
…low multicast The palette-stream scenario used the rejected palette value as its capability probe, so firmware that lost the feature reported a skip and the run stayed green. The machines that lack it are now declared in the fix table (vic-palette-stream: only the C64 Ultimate's release firmware), and everywhere else a refused palette parameter fails the scenario. Two checks cover what the scenario left out. Twenty opted-in starts and stops must each still deliver a palette packet; lwIP has eight UDP sockets, so a palette socket that is not closed runs the pool dry well within that. And a stream to 230.0.1.64 must arrive as multicast, which is the 224-231 range this PR moved from unicast.
4402a80 to
1409dba
Compare
|
Hi @GideonZ , I am happy for this to be merged into |
|
@chrisgleissner @GideonZ thank you, gentlemen! This is all I wanted for my birthday! (it was last week, but as an old fart, this is close enough!) If you guys are ever in Boston, give me a shout.. we'll celebrate this milestone! 🍻 |
VIC streams carry 4-bit color indices but no runtime palette, so clients cannot reproduce palette changes made by software such as Heartbeat. This adds an explicit
palette=1option toPUT /v1/streams/video:startand sends compact palette metadata to the active video destination without an FPGA change.Existing clients remain unchanged: palette packets are opt-in, use the agreed 60-byte video-compatible pseudo-header, and ordinary video packets retain their current format. Firmware sends an atomic RGB/generation snapshot, repeats it once per second for UDP recovery, and coalesces rapid writes to at most one packet per 25 ms (20 ms rounded up to the 5 ms tick, so at most 40 packets/s). The opt-in is device-wide: the most recent
video:startsets it.Palette packets leave through the VIC stream's interface (
SO_BINDTODEVICE) from its source port 53248, so palette and video arrive from one address and port for both unicast and multicast, including on a dual-homed Ultimate. The socket is connected to the destination, drained after each send, and closed when the stream stops.One change reaches beyond the palette: the existing multicast test in
data_streamer.ccmatched only 232-239.x.x.x and now covers 224.0.0.0/4, so video/audio streams to groups in 224-231 are sent as multicast instead of through the gateway. It can move to its own PR if preferred.Validation (Ultimate 64 Elite, FPGA 125, core 1.50):
uci-targetspalette9/9 andpalette-stream10/10 (full logs in the comments)Companion OBS plugin PR: chrisgleissner/c64stream#131
Refs #850