<div dir="ltr"><div><div><div><div><div><div>Hi Sean.<br><br></div>GStreamer uses RGBA in byteorder and not in word-order. See <a href="https://en.wikipedia.org/wiki/RGBA_color_space">https://en.wikipedia.org/wiki/RGBA_color_space</a> for byte-order/word-order.<br><br></div>Your code is clearing the red component for the first half of the entire frame.<br><br></div>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<br><br></div><div>Something like below<br><br></div><div>ifr (format != RGBA && format != BGRA && format != ARGB && format != ABGRA) goto fail;<br></div><div>uint8_t *p = frame_address_start ((start_row*width)+start_col)*4 + (format == RGBA || format == BGRA) ? 3 : 0;<br></div><div>stride = (start_col + width - end_col) << 2;<br></div><div>for (j=start_row; j <= end_row; j++) {<br></div>    for (i=start_col; i <= end_col; i++) { *p = 0;  p += 4; }<br></div>    p += stride;<br>}<br><br></div>Only one byte setting and one 32 bit addition per pixel affected plus one 32 bit addition per line affected.<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 7:52 AM, Sean <span dir="ltr"><<a href="mailto:csosmo@hotmail.com" target="_blank">csosmo@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I wrote to customized element (myelement) to set partial pixels of one video<br>
frame to be transparent. My machine is little endian.<br>
<br>
<br>
This is myelement implementation, I want to make the upper half of 640x480<br>
(i.e. the upper 640x240 pixels ) invisible by setting the Alpha value to be<br>
0x0<br>
<br>
    GstMapInfo info;<br>
    if (!gst_buffer_map(buffer, &info, GST_MAP_READ)) {<br>
      return GST_FLOW_ERROR;<br>
    }<br>
    for (int i  = 0; i < 240; i++) {<br>
      for (int j = 0; j < 640; j++)<br>
      info.data[(i*640+j)*4] = 0x0;<br>
    }<br>
    GST_FLOW_OK;<br>
<br>
<br>
This is my test command:<br>
gst_launch -v videotestsrc ! video/x-raw,format=RGBA,width=<wbr>640, height=480 !<br>
videoconvert ! myelement ! x264enc ! mpegtsmux ! filesink location=test.ts<br>
<br>
 I expect the upper half of the test.ts should be transparent. However, the<br>
result is (row,col)=(0,4), (0,8) (0,12)...... become a GREEN pixel. Would<br>
anyone help to comment which part is wrong?<br>
<br>
Thanks a lot.<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/Set-partial-pixel-to-be-transparent-in-video-tp4679769.html" rel="noreferrer" target="_blank">http://gstreamer-devel.966125.<wbr>n4.nabble.com/Set-partial-<wbr>pixel-to-be-transparent-in-<wbr>video-tp4679769.html</a><br>
Sent from the GStreamer-devel mailing list archive at Nabble.com.<br>
______________________________<wbr>_________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.<wbr>freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/gstreamer-<wbr>devel</a><br>
</blockquote></div><br></div></div></div>