[MPlayer-users] Re: mencoder/crop => image distortion

D Richard Felker III dalias at aerifal.cx
Wed Jul 30 18:54:00 CEST 2003

On Tue, Jul 29, 2003 at 12:35:56PM -0500, Jonathan Rogers wrote:
> [Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html]
> D Richard Felker III wrote:
> >[Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html]
> >On Tue, Jul 29, 2003 at 03:45:08AM -0500, Jonathan Rogers wrote:
> >
> >>[Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html]
> >>D Richard Felker III wrote:
> >>
> >>>Lines come in pairs (because of the way chroma works, so I would
> >>>always use crop sizes and offsets that are even numbers. Otherwise you
> >>>could seriously misalign or distort the color.
> >>
> >>Isn't it the job of the scaler to deal with that? I've cropped to 
> >
> >
> >No. No scaling takes place if you just crop. And if you crop with an
> >odd offset, you WILL shift the chroma plane by one luma pixel (half a
> >chroma pixel). It may not be terribly noticable, but it will look bad
> >if you look close, and it *may* hurt compression since motion in the
> >chroma planes won't quite line up with luma.
> >
> >Note that this can be fixed by using the swscaler to shift the chroma
> >planes, but it's better not to mess them up to begin with!
> >
> >>odd dimensions several times with no problems. It's easy to test 
> >>too: just play the movie with the desired crop (and scale if you 
> >>want). If the color is distorted, something broke. If not, 
> >>there's no reason to think encoding would do any worse.
> >
> >
> >Maybe your eyes were just lazy and didn't notice.
> Have your perfect eyes been able to detect it, or is this all 
> just a thought experiment? As you've mentioned, this is lossy 
> encoding, so perfect results are not attainable anyway. I've 
> almost always scaled the frames as well as cropping, so I may not 
> have seen the problems that result from just cropping.
> You know much more about MPlayer than I do and you may be right 
> about cropping to an odd dimension, though I've tried it and not 
> been able to observe any problems. I'm genuinely curious whether 
> it's just a guess or whether it's based on direct knowledge or 
> experience.

If you have a 720x480 movie, chroma is only 360x240. There is no
offset in the chroma plane corresponding to an odd offset in luma,
so....you have to either half-pel translate chroma (which will reduce
quality) or round to the nearest chroma offset when cropping with an
odd offset. Similarly, a yv12 image inherently can't have odd width or
height since pixels come in pairs for chroma purposes (it might work
but it's very unreliable and usually the last line glitches).

As to how it looks in practice, I don't regularly try these things
myself since I'm familiar with the problems behind them. And all I can
really say is that I think you're much better off throwing away one
extra line of luma (which is probably a bit noisy anyway if it's right
by the black border) than misaligning the chroma or trying to
translate it over.


More information about the MPlayer-users mailing list