[Ffmpeg-devel] libswscale 8 bit decoding

Michael Niedermayer michaelni
Thu Nov 16 14:12:36 CET 2006


Hi

On Thu, Nov 16, 2006 at 09:03:20PM +1100, Steven Johnson wrote:
[...]
> >
> >[...]
> >  
> >>>also the downscaling of chroma is wrong (discarding 3/4 of the samples is
> >>>not ok)
> >>> 
> >>>      
> >>The code is exactly the same as the C code in rgb24toyv12, with the 
> >>exception of palette expansion.  I noticed the image quality was 
> >>significantly reduced using libswscale over imgresample, and mentioned 
> >>that in my original post, that is the probably cause.  Any pointers to a 
> >>reference for converting RGB to YV12 I can look at?
> >>    
> >
> >a simple variant is to average the 4 rgb values before rgb->yuv (or
> >do rgb->yuv on them and then average the 4 u and 4 v, the result is the
> >same) (note this is not entirely correct but its ok while the current
> >code in rgb24toyv12 and your code is not)
> >btw see bgr32ToUV and the similar functions in 
> >libswscale/swscale_template.c
> >they also still use hardcoded rgb2yuv coeffs but except that they look
> >more sane
> >  
> Is this what you are after? : (not a patch, just don't apply and test, I 
> am just showing you what I have interpreted you to be saying)

yes though the palette should be converted prior to the function like it
is done for all other cases


[...]
>            udst[i] = ((Upal[idx0]+Upal[idx1]+Upal[idx2]+Upal[idx3]) >> 2);
>            udst[i] = ((Vpal[idx0]+Vpal[idx1]+Vpal[idx2]+Vpal[idx3]) >> 2);

vdst

[...]
> >
> >  
> >>And following the thread "moving non-SIMD parts of libswscale to LGPL" I 
> >>am confused about libswscale, imgresample and the future.  As it stands, 
> >>imgresample does more than libswscale does (it handles palletised 
> >>formats), and (at least for me) produces a nicer result, but it seems is 
> >>probably slower in certain cases where the functionality overlaps.  But 
> >>is imgresample deprecated in favour of libswscale? 
> >>    
> >
> >yes
> >  
> I get a visible quality decrease using libswscale over imgresample.  
> That is concerning me some what. See: 
> ftp://ftp.sakuraindustries.com/pub/Screenshot.png
> 
> The Image on the Left is ffmpeg WITH libswscale, the image on the right 
> is the same file, played with ffmpeg using the imgresample code.  There 
> is noticeable blockiness in the image over the same picture on the 
> right.  The image is very low resolution 80x48 pixels, so is somewhat 
> blocky to begin with, but adding more blockiness results in very poor 
> image quality for this image.  This is an 8bpp source image.  How do I 
> go about getting a quality of display using libswscale equal to 
> imgresample, I must be doing something wrong, but I can't see what? 

if you want to upscale then of course you shouldnt conert pal8->yv12
as that drops 3/4 of the chroma information ...

you can also try different scalers (SWS_BICUBIC, GAUSS, LANCZOS, ...)

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list