Streampunk / macadam

Async node.js interface to Blackmagic Design capture and playback devices.
Apache License 2.0
107 stars 24 forks source link

Support accelerated conversion to canvas-compatible RGBA #14

Open rezonant opened 5 years ago

rezonant commented 5 years ago

It would be useful to be able to consume frames from Macadam's Decklink Capture direct into HTML5 canvas. Canvas only supports RGBA frames, but Decklink can provide BGRA, ARGB, YUV chroma-subsample and 10-bit HDR forms of those.

I propose an additional option outputRGBA that will convert Decklink frames of any color space into RGBA when using the Capture functionality. For RGB-based formats we can do basic byte swap for a rough initial implementation, and for YUV we can use Decklink's built-in IDeckLinkVideoConversion to convert from the source YUV to BGRA, then perform the byte-swap. I don't have a plan on how to maintain the HDR in these conversions- suggestions welcome.

Ideally (eventually) the byte swap could be accelerated with SIMD I think.

Work in progress is at https://github.com/rezonant/macadam/commits/feat/color-conversion