<div dir="ltr"><div><div><div><div><div><div>Hi<br><br></div>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:<br>
<br>// Setting alpha value high/low accoding to a chroma span<br>int ChromaSpan(u_int8_t *frame, u_int32_t width, u_int32_t height,<br>        u_int8_t red_low, u_int8_t red_high,<br>        u_int8_t green_low, u_int8_t green_high,<br>
        u_int8_t blue_low, u_int8_t blue_high,<br>        u_int8_t alpha_low, u_int8_t alpha_high) {<br><br>        if (!frame) return -1;<br>        for (u_int32_t row = 0; row < height ; row++) {<br>                for (u_int32_t col = 0; col < width ; col++) {<br>
                        if (frame[2] >= red_low && frame[2] <= red_high &&<br>                            frame[1] >= green_low && frame[1] <= green_high &&<br>                            frame[0] >= blue_low && frame[0] <= blue_high) <br>
                                frame[3] = alpha_low; <br>                        else frame[3] = alpha_high; <br>                        frame += 4;<br>                } <br>        } <br>        return 0;<br>}<br><br></div>
<div>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.<br></div><div><br></div>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?<br>
<br></div>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.<br><br></div>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.<br>
<br></div>Best regards<br></div>Peter Maersk-Moller<br></div>