[MPlayer-dev-eng] SwScaler YV12 to BGR32 having zeroed alpha
Michael Niedermayer
michaelni at gmx.at
Sun May 29 23:02:04 CEST 2005
Hi
On Sunday 29 May 2005 15:45, Jason Tackaberry wrote:
> I'm using SwScaler to scale and convert between YV12 and BGR32
> colorspaces. I'm noticing that the alpha channel of the resulting BGR32
> image is completely zeroed, which means in order to do anything useful
> with it (when using it with code that pays attention to per-pixel alpha)
> I need to loop through the buffer and adjust every fourth byte, which
> is, I think, needless overhead.
>
> If this behaviour is hard-coded, I think it should be considered a bug.
> But I'm posting here to find out if there's an argument or other
> function I'm missing that can do what I want.
>
> I'm setting up the sws context this way:
>
> sws = sws_getContext(priv->width, priv->height, priv->outfmt, sw, sh,
> IMGFMT_BGR32, get_sws_cpuflags() | SWS_PRINT_INFO | SWS_BILINEAR, NULL,
> NULL, NULL);
>
> (Where sw and sh are the target scaled width and height.)
>
> And I'm actually scaling the image this way:
>
> uint8_t *dst[3]= {bgra_imgbuf, NULL, NULL};
> int dst_stride[3]= {scaled_width * 4, 0, 0};
> sws_scale_ordered(sws, mpi->planes, mpi->stride, 0, vf->priv->height,
> dst, dst_stride);
>
> The resulting bgra_imgbuf ends up with a zeroed alpha channel. It's
> quite simple to fix, of course:
>
> for (i=3; i < scaled_width * scaled_height * 4; i+=4)
> bgra_imgbuf[i] = 255;
>
> But this is some overhead I don't think should be needed as I feel the
> alpha bytes should be initialized to a more sane value (255) within the
> sws code. Hopefully this is possible? If not, would a patch be
> accepted to change the current behaviour?
if it would be clean, wont cause any slowdown and is preferably optional then
yes, btw just curious, what are you doing that needs the alpha values?
>
> Also, as an aside, I discovered that SWS_FAST_BILINEAR will cause a
> segfault on x86_64 architecture when using CVS from 2005-05-27. Perhaps
> this is already known, but I thought I'd mention it briefly in case
> someone wants to have a look at it.
me looks ... doesnt see gdb output ... "bugreport" closed
[...]
--
Michael
More information about the MPlayer-dev-eng
mailing list