[FFmpeg-devel] [PATCH] avfilter/vf_scale: fix interlaced chroma for other formats

Niklas Haas ffmpeg at haasn.xyz
Sat Oct 14 02:00:50 EEST 2023


On Sat, 14 Oct 2023 00:52:23 +0200 Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Fri, Oct 13, 2023 at 04:22:05PM +0200, Niklas Haas wrote:
> > From: Niklas Haas <git at haasn.dev>
> > 
> > This logic only covers the case of yuv420p. Extend this logic to cover
> > *all* vertically subsampled YUV formats, which require the same
> > interlaced scaling logic.
> > 
> > Fortunately, we can get away with re-using the same code for both JPEG
> > and MPEG range YUV, because the only difference here is the horizontal
> > alignment. (To be fixed in a separate commit)
> > ---
> >  libavfilter/vf_scale.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> the patches from H4JO.txt
> cause several fate tests to worsen in their stddev. like:

I investigated these regressions and came to the conclusion that the raw
input to those tests use mpeg1/jpeg/center-aligned chroma, but the
rawvideo demuxer does not tag them as such.

So this change in logic (i.e. treating unspecified yuv as mpeg2/mpeg4
chroma loc instead of mpeg1/jpeg chroma loc) regresses those tests by
design.

A solution would either to continue treating unspecified yuv as
mpeg1/jpeg chroma loc (status quo), or change the FATE test to
explicitly mark the rawvideo source as center chroma.

That said, if the status quo for the past decades is to for vf_scale
treat unspecified chroma loc as center-aligned, I am no longer sure if
suddenly changing this behavior is a good idea. At the same time, this
is also terribly inconsistent across implementations. For example, VLC
treats all chroma as center-aligned (ignoring tags), mpv treats untagged
*limited range* yuv as mpeg2/left-aligned (and full range as
mpeg1/jpeg/center), while libplacebo treats all untagged yuv as
mpeg2/left-aligned. There really is no consistent standard here across
software, and I haven't even looked at what proprietary players do.


More information about the ffmpeg-devel mailing list