[MPlayer-users] lanczos or bicubic spline or..?

* afe0108 at yahoo.com
Wed Feb 4 22:21:21 CET 2004


--- D Richard Felker III <dalias at aerifal.cx> wrote:
> On Tue, Feb 03, 2004 at 10:56:52PM -0800, * wrote:
> > --- D Richard Felker III <dalias at aerifal.cx> wrote:
> > > On Sun, Feb 01, 2004 at 11:11:05PM -0800, * wrote:
> > > > Thanks (again) Rich!  I think I'm a little less confused now.  I don't
> > > > know if this is complete nonsense or not, but I ran a test upscaling 10
> > > > times in a row to compare:
> > > >
> > > > mplayer movie.vob -nosound -vo png -vf crop=716:452:0:12,
> > > > scale=720:384,scale=736:400,scale=768:416,scale=800:432,scale=832:448,
> > > > scale=864:464,scale=896:480,scale=912:496,scale=944:512,scale=976:528
> > > > -sws #
> > >
> > > IMO this is not a legitimate test. When encoding a movie you don't
> > > scale 8 times, and you especially should never upscale. Try it with
> > > just _one_ scale filter, to the size you'll actually be encoding, and
> > > compare the results.
> > >
> > > Also, compare the results _after_ encoding to mpeg4, since that's what
> > > will ultimately matter.
> > >
> > Okay, thanks for walking me through this.  With one scale filter there
> > are the following PSNR:
> >
> > mencoder movie.vob -nosound -ovc lavc -lavcopts psnr:mbd=2:mv0:trell:
> > cbp:precmp=2:cmp=2:subcmp=2:vmax_b_frames=1:predia=2:dia=2:preme=2:
> > vme=4:v4mv:vbitrate=875 -vf scale=976:528 -ss 360 -frames 360 -sws #
>
> Why on earth are you upscaling your movie to encode it?? This will
> only hurt the quality. Either leave the size alone and encode aspect
> (but broken players won't support this), or scale it down to a
> reasonable size. There's no way you'll get remotely tolerable quality
> at 875 kbit/sec for 976x528 video. You'd need at least 2mbit. The only
> reason the first few frames look ok is that the rate control hasn't
> had time to kick in yet.
>
Sorry that was just to make the difference more visible.  For the movie
above I would have used:

-vf crop=716:452:0:12,scale=720:384

But in fact I have never been sure what the proper scale should be.
Whether I should always scale x/y so BOTH are smaller than the cropped
x/y, or whether I should pick a value of y close to the cropped value
and scale x accordingly.

It seems like the latter would preserve the most detail.  But then the
bits will be spread out over a larger area.  I wish there was an
objective way to find the optimum scaling.  I'm pretty sure I can't rely
on PSNR (from lavc)- when I try scaling to 320x192 the PSNR reported is
always higher than 720x384.

> > 0 PSNR: Y:41.37, Cb:44.15, Cr:44.26, All:42.13
> > 1 PSNR: Y:41.37, Cb:44.11, Cr:44.25, All:42.12
> > 2 PSNR: Y:40.27, Cb:43.15, Cr:43.30, All:41.05
> > 3 PSNR: Y:40.69, Cb:43.67, Cr:43.80, All:41.49
> > 4 PSNR: Y:38.18, Cb:41.84, Cr:41.95, All:39.10
> > 5 PSNR: Y:41.37, Cb:44.11, Cr:44.25, All:42.12
> > 6 PSNR: Y:40.31, Cb:43.66, Cr:43.79, All:41.18
> > 7 PSNR: Y:41.96, Cb:44.56, Cr:44.70, All:42.68
> > 8 PSNR: Y:39.76, Cb:42.68, Cr:42.84, All:40.55
> > 9 PSNR: Y:39.98, Cb:42.85, Cr:42.99, All:40.75
> > 10 PSNR: Y:40.12, Cb:43.01, Cr:43.16, All:40.90
>
> These come from using the psnr option to lavc?? Or...??
>
Correct.


> > And extracting 1 frame:
> >
> > mplayer test.avi -nosound -vo png -frames 1
> >
> > http://box.dnsalias.net/mexico/0.png
> > http://box.dnsalias.net/mexico/1.png
> > http://box.dnsalias.net/mexico/2.png
> > http://box.dnsalias.net/mexico/3.png
> > http://box.dnsalias.net/mexico/4.png
> > http://box.dnsalias.net/mexico/5.png
> > http://box.dnsalias.net/mexico/6.png
> > http://box.dnsalias.net/mexico/7.png
> > http://box.dnsalias.net/mexico/8.png
> > http://box.dnsalias.net/mexico/9.png
> > http://box.dnsalias.net/mexico/10.png
> >
> > This seems to be pretty consistent.  Gaussian (7) gets highest PSNR and
> > nearest-neighbor (4) lowest.
> >
> > It is impossible for me to tell the difference between (2) and (6).  But
>
> (2) and (6) behave identically on the luma, but treat the chroma
> differently. (2) uses bicubic scaling for both while (6) uses simple
> bilinear scaling for chroma. This is both faster and makes more sense
> usually, since chroma samples are too far apart for bicubic
> interpolation to be reasonable.
>
Interesting.  Who knew?  I guess I should look for a simple book about
this.

> > I have to say that (9) looks a tiny bit sharper.  Don't you think?  Like
> > there is more texture in the skin.
>
> I don't notice any difference. Certainly not from a viewing distance.
>
> > > The PSNR I'm talking about is not from the scale filters, but from the
> > > mpeg4-encoder after the scaling takes place. What I said is that if
> > > you give the mpeg4 encoder a sharper image, your resulting movie file
> > > will have worse (lower) PSNR relative to the input it gets, than if
> > > you give the mpeg4 encoder a more blurred image.
> > >
> > Okay.  So basically PSNR is completely useless for telling which of the
> > -sws settings have a higher quality?  I don't want either (7) or (4).
>
> There are many ways to measure "quality", which is a very subjective
> term. One of them is by how much information is lost, i.e. how closely
> you can recover the original image by inverting the scale operation.
> Sinc will naturally win for this measure, but from a perceptual
> standpoint, it looks very bad.
>
> A second, more reasonable way to measure quality would be according to
> how good it looks to you, but this is very hard to measure without
> double-blind (or multi-blind) testing.
>
Argh, this is not what I wanted to hear but thanks.  What if I am going
blind and still want to encode movies for other people?  It seems like
there should be some metric for measuring how much detail is preserved,
or something like that.  I think I prefer a little bit of blockiness and
more detail over a smoother picture with less detail.

> Finally, you need to take into account the quality _after_ encoding to
> mpeg4. If you're going to keep increasing your bitrate until you're
> happy with the quality, or use constant-qscale, then this doesn't
> really matter much. But if you want the output to fit in a fixed size,
> then keeping more fine detail will necessarily result in more ringing
> and blocking artefacts.
>
I want the output to fit in a fixed size.  Usually 700M for movies under
about 100mins or 1400M for longer or if I really like them.

> If you're getting your PSNR's from lavc, they're measuring exactly one
> thing: how close the encoded video matches the (already scaled) video
> you're passing into it. They tell you how lossy the mpeg4 encoding is
> when done after your scaling, not how lossy the scaling is.
>
Okay, perhaps I finally understand.  Thanks for the very verbose (and
lucid) explanations!  Hopefully this will preempt some similar questions
on the list for awhile.

> > > IMO you should pick between 2 and 6. 6 probably makes more sense for
> > > 4:2:0-sampled sources.
> > >
> > I am ashamed to say I do not know what is 4:2:0-sampled source?  You
> > mean with hqdn3d?
>
> Anything mpeg-type will be 4:2:0. It just refers to the way chroma
> subsampling is done (half resolution in both horizontal and vertical
> directions).
>
> Rich
>
>




__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/




More information about the MPlayer-users mailing list