Skip to content

Commit

Permalink
Half-pixel shift in the downscaling step
Browse files Browse the repository at this point in the history
Should match chroma on most videos now, which makes the shader a little bit better.

This obviously breaks it when you have centre chroma, but hopefully this isn't a big issue.
  • Loading branch information
Artoriuz committed Oct 27, 2024
1 parent 37a449a commit 03b7f6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CfL_Prediction.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//!DESC Chroma From Luma Prediction (Downscaling Luma)

vec4 hook() {
return LUMA_texOff(0.0);
return LUMA_texOff(vec2(-0.5, 0.0));
}

//!HOOK CHROMA
Expand Down
2 changes: 1 addition & 1 deletion CfL_Prediction_Lite.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//!DESC Chroma From Luma Prediction (Downscaling Luma)

vec4 hook() {
return LUMA_texOff(0.0);
return LUMA_texOff(vec2(-0.5, 0.0));
}

//!HOOK CHROMA
Expand Down

8 comments on commit 03b7f6a

@Damole-wer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit made quality of some videos worse, even though all of them have top left chroma loc.

Example from one of them:
Screenshots were taken from this youtube video with --video-unscaled=yes. And here is the original YUV 4:4:4 image.

Before the commit:
Image

After:
Image

I also should mention that the 37a449a is slightly less saturated than previous 3fc1c1a, which deviates it farther from the original.

Before the 37a449a:
Image

After:
Image

Thank you for taking your time to read this. I hope this was helpful.

@Artoriuz
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... Anything other than left chromaloc will look wrong... I knew this would happen, I just don't know how to circumvent the issue...

@Damole-wer
Copy link

@Damole-wer Damole-wer commented on 03b7f6a Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an option to offset for chromaloc, if people see the need for it. Although, no offset 3fc1c1a, in most cases, looks the best out of all chroma upscalers, at least from my testing.

@Artoriuz
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the change on this repo, cfl does indeed seem to prefer 0 shifts.

@Damole-wer
Copy link

@Damole-wer Damole-wer commented on 03b7f6a Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for considering. I'm still kinda curious if the desaturation from 37a449a really needed. Is it to mask the artifacts, or prevent overshooting? Because i don't really see CfL producing values out of the range of the original, unlike KrigBilateral.

@Artoriuz
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly the 0.8 cap was mostly to prevent the artifacts from looking too ugly.

@Artoriuz
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I still think the shift was probably correct. Problem on this image is that downsampling with bilinear while also adding a half-pixel shift looks like absolute dogshit.

@Damole-wer
Copy link

@Damole-wer Damole-wer commented on 03b7f6a Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem on this image is that downsampling with bilinear while also adding a half-pixel shift looks like absolute dogshit.

I don't understand... Are you talking about the GitHub page downsampling? Because example images weren't downsampled at any point on my end, that's why I mentioned the --video-unscaled=yes option. There is also a video with the same source image, but at native 720p resolution.
I was merely using GitHub page as the fast example for the most obvious differences. Here is the archive
with the uploaded before images. If I'm doing my testing wrong, please let me know.

Please sign in to comment.