Chroma key (green/blue screen) blending

Peter Maersk-Moller pmaersk at gmail.com
Tue Jan 14 18:23:24 PST 2014


Hi

This might be a bit off topic, but I was wondering if it would be a good
idea to enable the possibility of chroma key (green/blue screen) blending
to videoconvert? When converting to RGBA/BGRA it would be rather nifty if
videoconvert could be made to set the alpha value to values like indicated
in the following program:

// Setting alpha value high/low accoding to a chroma span
int ChromaSpan(u_int8_t *frame, u_int32_t width, u_int32_t height,
        u_int8_t red_low, u_int8_t red_high,
        u_int8_t green_low, u_int8_t green_high,
        u_int8_t blue_low, u_int8_t blue_high,
        u_int8_t alpha_low, u_int8_t alpha_high) {

        if (!frame) return -1;
        for (u_int32_t row = 0; row < height ; row++) {
                for (u_int32_t col = 0; col < width ; col++) {
                        if (frame[2] >= red_low && frame[2] <= red_high &&
                            frame[1] >= green_low && frame[1] <= green_high
&&
                            frame[0] >= blue_low && frame[0] <= blue_high)
                                frame[3] = alpha_low;
                        else frame[3] = alpha_high;
                        frame += 4;
                }
        }
        return 0;
}

The above code sets the alpha value according to a colour span rather than
a specific colour key. This is necessary because the background in real
life can vary slightly in colour.

The above code would obviously need to be implemented using Orc. However
looking at the opcodes for Orc, it seems that it is difficult to implement
a test for a variable being equal to or greater and similar equal to or
less than another variable. The reason why we need equal or greater than
and equal or less than is that we need to test for both 0 (zero) and 255.
Any suggestion on how to do this?

Obviously the variables red_low, red_high .... alpha_low and alpha_high
needs to be read/write variables settable from the command line and
changeable during runtime.

Optimization of Orc code for certain border cases where fewer checks are
necessary might off course be interesting to consider too once we first
have the general code working.

Best regards
Peter Maersk-Moller
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140115/27b38512/attachment.html>


More information about the gstreamer-devel mailing list