[Libav-user] Scaling via sws_scale() produces wrong colourvalues

Aaron Zinghini Aaron.Zinghini at seeingmachines.com
Wed Jun 29 01:43:38 CEST 2011


Just a quick guess but I believe it is because of the filtering (SWS_FAST_BILINEAR). Filtering is used to remove aliasing effects when resizing an image and therefore you won't get a 1-1 mapping of pixels and the filtering will use neighbouring pixels to basically "blend" or smooth the image so it's not blocky after resize.

If there's an option like SWS_NONE or maybe SWS_POINT then they might produce more of a 1-1 mapping.

-----Original Message-----
From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org] On Behalf Of Johannes Ebersold
Sent: Wednesday, 29 June 2011 1:54 AM
To: libav-user at ffmpeg.org
Subject: [Libav-user] Scaling via sws_scale() produces wrong colourvalues

Hi,

I'm currently trying to scale a RGB picture using libswscale.
I tested my application by creating a complete white image, set every 
byte to 255. But in the output after the scaling every pixel got the 
value "254 251 251". I don't know what i got wrong and would be thankful 
for any advice.

My Code is part of a larger project, i will just paste a snippet here... 
So far i think, that i got something wrong initializing or using the 
swscale.

m_convert_context = sws_getCachedContext(m_convert_context, 
src_res.first, src_res.second, PIX_FMT_RGB24, m_dst_res.first, 
m_dst_res.second, PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);

//src = Pointer to a packed RGB image with
unsigned char* src_data[3] = {src, NULL, NULL};
int src_stride[3] = {3*src_res.first, 0, 0}; //RGB stride is 3*width

/use offsets to set pointers, dst is just a pointer to some memory, 
where the resulting image will be...
unsigned char* dst_data[3]= {dst, NULL, NULL};
int dst_stride[3] = {3*m_dst_res.first, 0, 0};

//convert
int ret = sws_scale(m_convert_context, src_data, src_stride, 0, 
src_res.second, dst_data, dst_stride);

Thanks for any help!
Johannes
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


More information about the Libav-user mailing list