Skip to content

Add aligment fix for 4:2 planar video#332

Open
Fktor wants to merge 1 commit into
ValveSoftware:proton_10.0from
Fktor:proton_10.0
Open

Add aligment fix for 4:2 planar video#332
Fktor wants to merge 1 commit into
ValveSoftware:proton_10.0from
Fktor:proton_10.0

Conversation

@Fktor

@Fktor Fktor commented Jun 1, 2026

Copy link
Copy Markdown

@Fktor

Fktor commented Jun 1, 2026

Copy link
Copy Markdown
Author

Trying to fix a Resident Evil 0 video issue. The problem is that we have a video in 4:2:0 format, and the uv planes have a width that is not a multiple of 4. Gstreamer forces the stride to be aligned to 4, while the game expects the original stride. This causes visual green/red line artifacts.

I've attached the fix to a NV12 fix that was already present since they're from the same family of problems.

First time trying to fix something in Proton, so give it a hard look.

@cmccarthy-codeweavers

Copy link
Copy Markdown

Should be good after some minor fixes. This loop:

        dst = map_info.data + dst_info.offset[plane1];
        src = map_info.data + src_info.offset[plane1];
        for (i = 0; i < aligned_height; ++i)
        {
            memmove(dst, src, dst_info.stride[plane1]);
            dst += dst_info.stride[plane1];
            src += src_info.stride[plane1];
        }

The height is the same for plane 2, so instead of being duplicated for plane2, it can be inside an outer loop: for (plane = 1; plane <=2; ++plane)

else should occur on a new line instead of } else

Extra condition lines are always only double-indented (4 spaces x 2), so it would be:

                fix_yv12 = (GST_VIDEO_INFO_FORMAT(&video_info) == GST_VIDEO_FORMAT_YV12
                        || GST_VIDEO_INFO_FORMAT(&video_info) == GST_VIDEO_FORMAT_I420)
                        && (video_info.stride[1] > GST_ROUND_UP_2(video_info.width/2));

Trace messages should mention I420 too, so it doesn't look like a format snafu occurred, e.g. something like "Enabling the YV12/I420 alignment fix."

I think it should be ok to just call assert(0) instead of GST_ERROR("fix_align called for unsupported format.")

The commit message should be something like:

winegstreamer: HACK: Add alignment fix for 4:2 planar video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants