Opened 3 months ago

Closed 7 days ago

#11239 closed defect (fixed)

Copy unscaled NV12 -> NV12 (and other format with 2 planes) broken.

Reported by: Aleksoid1978 Owned by: Niklas Haas <git@haasn.dev>
Priority: normal Component: swscale
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Aleksoid1978)

Summary of the bug:
sws_scale NV12 -> NV12 (and other format with 2 planes) unscaled result picture is broken, UV is not copy.
I think problem in planarCopyWrapper:
this line https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/swscale_unscaled.c#L1865
NV12 has only 2 plane and second plane ignored in this function.

Change History (7)

comment:1 by Aleksoid1978, 3 months ago

Description: modified (diff)
Summary: Copy unscaled NV12 -> NV12 broken.Copy unscaled NV12 -> NV12 (and other format with 2 planes) broken.

comment:2 by Balling, 3 months ago

#10716

There is also this

comment:3 by Balling, 3 months ago

Is this a regression? When unscaled was added...

in reply to:  3 comment:4 by Aleksoid1978, 2 months ago

Replying to Balling:

Is this a regression? When unscaled was added...

I don't know.

comment:5 by v0lt, 2 months ago

I tried the following command and got a similar problem as Aleksoid1978.

ffmpeg -i nv12.mkv -vf scale nv12_test.mkv

The output file has corrupted colors, everything is in green tones.

Sample: https://www.mediafire.com/file/x5c4372yqxcvcpq/NV12.mkv/file
ffmpeg version 7.1-full_build-www.gyan.dev

Last edited 2 months ago by v0lt (previous) (diff)

comment:6 by Niklas Haas, 10 days ago

There are two bugs here; one is that NV12 is not being copied correctly, the other is that this case (unspecified -> tv range) is not being correctly detected as a no-op.

comment:7 by Niklas Haas <git@haasn.dev>, 7 days ago

Owner: set to Niklas Haas <git@haasn.dev>
Resolution: fixed
Status: newclosed

In 77db7f9/ffmpeg:

swscale/unscaled: correctly copy semiplanar formats

This fixes multiple bugs with semiplanar formats like NV12. Not only do these
false positive the grayscale format checks (because dst[2] in NULL), but they
also copied an incorrect number of pixels.

Fixes conversions such as nv12 -> nv12, gray8 -> nv12, nv20le -> nv20be, etc.

Fixes: #11239
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: Sovereign Tech Fund

Note: See TracTickets for help on using tickets.