[Libav-user] sws_scale has weird behavior when not resizing

mxvuser max.vlasov at gmail.com
Mon Aug 17 12:25:26 CEST 2015


Hi, 
thanks to Alexandre for the fix with SWS_ACCURATE_RND flag. 
The original post dated back to 2012, I use the lib of a version close to
the end of 2014, but this issue still existed, videos might show similar
artifacts when converted without scaling and the width (or height) is not
evenly dividable by 8.  



Alexandre Millette wrote
> Hi again.
> 
> TL;DR: use the SWS_ACCURATE_RND flag.
> 
> I have solve my issue (or rather found a workaround) and thought it 
> might help some people:
> 
>  > Also I am not sure what would be the proper way to handle this 
> situation.
>  > Sure I can round the width of the frame to the nearest greater 
> multiple of
>  > 8 and add one to it, but I'm afraid that in some situation it may 
> bust the
>  > line size and cause an exception. Plus it doesn't seem right to use
> such
>  > magic numbers..
> 
> The problem only occurs when sws_scale does no resizing, that is when 
> the source and destination sizes are the same. By looking at the 
> sws_getContext source code, I have found that one flag, 
> SWS_ACCURATE_RND, among other things, force the function to not use it's 
> no-resizing algorithm. So we can prevent the issue by setting this flag.
> I am not quite sure of the exact usage of this flag, but I know VLC used 
> to have it set for quality issues (that could be related to my own 
> issue) but have since removed it from some builds (like their android's) 
> because of performance problems. I have personally seen no difference in 
> performance with the flag, but I have still decided to use it only when 
> need be, that is when the width and height are not multiples of 8.
> 
> Here's a glimpse of my code now:
> 
> ....





--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-sws-scale-has-weird-behavior-when-not-resizing-tp4655402p4661415.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list