Set partial pixel to be transparent in video
Peter Maersk-Moller
pmaersk at gmail.com
Mon Sep 26 09:10:10 UTC 2016
Hi Sean.
GStreamer uses RGBA in byteorder and not in word-order. See
https://en.wikipedia.org/wiki/RGBA_color_space for byte-order/word-order.
Your code is clearing the red component for the first half of the entire
frame.
BTW you code should be more efficient. Find the beginning of the first
pixel address, add 3 for RGBA and BGRA (0 for ARGB/ABGR) and then
Something like below
ifr (format != RGBA && format != BGRA && format != ARGB && format != ABGRA)
goto fail;
uint8_t *p = frame_address_start ((start_row*width)+start_col)*4 + (format
== RGBA || format == BGRA) ? 3 : 0;
stride = (start_col + width - end_col) << 2;
for (j=start_row; j <= end_row; j++) {
for (i=start_col; i <= end_col; i++) { *p = 0; p += 4; }
p += stride;
}
Only one byte setting and one 32 bit addition per pixel affected plus one
32 bit addition per line affected.
On Mon, Sep 26, 2016 at 7:52 AM, Sean <csosmo at hotmail.com> wrote:
> Hi,
>
> I wrote to customized element (myelement) to set partial pixels of one
> video
> frame to be transparent. My machine is little endian.
>
>
> This is myelement implementation, I want to make the upper half of 640x480
> (i.e. the upper 640x240 pixels ) invisible by setting the Alpha value to be
> 0x0
>
> GstMapInfo info;
> if (!gst_buffer_map(buffer, &info, GST_MAP_READ)) {
> return GST_FLOW_ERROR;
> }
> for (int i = 0; i < 240; i++) {
> for (int j = 0; j < 640; j++)
> info.data[(i*640+j)*4] = 0x0;
> }
> GST_FLOW_OK;
>
>
> This is my test command:
> gst_launch -v videotestsrc ! video/x-raw,format=RGBA,width=640,
> height=480 !
> videoconvert ! myelement ! x264enc ! mpegtsmux ! filesink location=test.ts
>
> I expect the upper half of the test.ts should be transparent. However, the
> result is (row,col)=(0,4), (0,8) (0,12)...... become a GREEN pixel. Would
> anyone help to comment which part is wrong?
>
> Thanks a lot.
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.
> n4.nabble.com/Set-partial-pixel-to-be-transparent-in-video-tp4679769.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160926/cb13c215/attachment.html>
More information about the gstreamer-devel
mailing list