Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior change in Greyscale #257

Closed
Reel-Deal opened this issue Jan 30, 2022 · 13 comments
Closed

Behavior change in Greyscale #257

Reel-Deal opened this issue Jan 30, 2022 · 13 comments

Comments

@Reel-Deal
Copy link
Member

Reel-Deal commented Jan 30, 2022

Should these 2 methods be identical? I was under the impression they would be, but they are not.

ColorBars(pixel_type="RGBP8").Trim(0,-1)
grey = Greyscale(matrix="Rec601")
ConvertToY(matrix="PC.601")
CombinePlanes(planes="RGB", source_planes="YYY", pixel_type="RGBP8")

Interleave(grey,last)
RGBAdjust(analyze=true)

But then I found out the behavior has changed:

  • "PC601"/"PC.601", "PC709"/"PC.709", "PC2020"/"PC.2020" are now accepted values for matrix and produce full range RGB greyscale.
  • "Rec601"/"Rec.601", "Rec709"/"Rec.709", "Rec2020"/"Rec.2020" now produce limited range RGB greyscale.
  • "Average" remains the same.

Before this change, Greyscale always produced full range RGB. This affects some scripts that use Greyscale on RGB clips since only "Rec601", "Rec709", "Rec2020" were allowed.

@pinterf
Copy link

pinterf commented Jan 30, 2022

Hi,
it was changed in greyscale.cpp in commit f2fff1e
It seems that when you specified Rec.601/Rec709/Rec2020 for Greyscale then it was using PC.601/PC.709/PC.2020 instead.
And the PC range constants were invalid matrix values.
Then I know understand why Avisynth wiki: (http://avisynth.nl/index.php/GreyScale) says:
Use Rec.601/Rec709/Rec2020 coefficients (and keeping luma range unchanged)
Then this behavior seems to be intentional and was possibly not a bug?

@Reel-Deal
Copy link
Member Author

Then this behavior seems to be intentional and was possibly not a bug?

I think it was intentional since the matrix parameter in Greyscale is only for RGB sources. The matrix only specified what coefficients to use but was always in full range.

@pinterf
Copy link

pinterf commented Jan 30, 2022

O.K. matrix is always for RGB source but the target would either be full or limited, but in this case it is always full.
I do not really understand its use case though.

@Reel-Deal
Copy link
Member Author

Reel-Deal commented Jan 30, 2022

That's the way Greyscale for RGB has always worked. Maybe since limited range RGB is rare? For YUV, the matrix does not make sense in Greyscale since all it does is set the chroma planes to neutral.

Greyscale for RGB is just a more efficient way of doing this:

# RGB source
ConvertToY(matrix="PC.601") # "PC.601", "PC.709" "PC.2020", "Average"
CombinePlanes(planes="RGB", source_planes="YYY", pixel_type="RGBPxx")

Edit: I guess if you wanted to have a full/limited option for Greyscale, the best way would be to add an extra parameter (full=true)?. I'm sure there are scripts in the wild that use Greyscale on RGB and having the "RecXXX" matrices be limited range does affect who ever is using said scripts. I would never have a need for limited ranged RGB, but just throwing it out there :)

@pinterf
Copy link

pinterf commented Jan 30, 2022

Yep, I see, it's fed back into the same RGB format. "without changing the color format."
I'm gonna revert the behavior.

@pinterf
Copy link

pinterf commented Jan 30, 2022

(gee, mentioning Fix #257 in the commit message will automatically close the issue.)

@Reel-Deal
Copy link
Member Author

Thanks for taking a look at the issue and fixing it.

Just one last thing, I think the original error message was more helpful/less confusing:

GreyScale: invalid "matrix" parameter (must be matrix="Rec601", "Rec709", "Rec2020" or "Average")

@pinterf
Copy link

pinterf commented Jan 31, 2022

I was thinking on it but a "matrix" can accept new string constants everywhere (e.g. "709", "170m", "fcc", etc.), so we are not limited to the old legacy values.

@Reel-Deal
Copy link
Member Author

Yeah, I saw that when I was updating the Convert page some days ago. I thought it was only for the convert functions. I just tried the new style matrix in Greyscale and they also work. Interesting.

Ok, so next question. From my understanding, "Rec601", "Rec709", "Rec2020" in Greyscale will always be full range (for compatibility reasons). But now that it supports the new style matrix also, e.g. "709:full", does that mean that any valid combinations can be used for Greyscale going forward? For example, if a user wants to use "709:limited", the result will be limited range RGB.

Sorry for all of the questions, I just want to make sure I understand what is going on so I can document it.

@pinterf
Copy link

pinterf commented Jan 31, 2022

Forced 'limited' range stuffed back into RGB with a mean of a special syntax? Probably not.

New style "matrix" definitions default to limited if only matrix is given, but RGB implies that the result will automatically converted back to full range before put in R, G and B planes.

Greyscale easy syntax would require only matrix. E.g. "fcc" is translated to "fcc:limited". Matrix can be spefified w/o ":l" ":limited" ":f" ":full" and that's enough for GreyScale to understand the intent.

The main question is to make this consistent; I think filter must ask for limited range syntax (as it worked so far) and it would mean a full scale Y representation in RGB. (again, as it worked traditionally).

@Reel-Deal
Copy link
Member Author

@pinterf

There's a regression, matrix="Average" returns GreyScale: only limited range matrix definition is allowed. "Average" was a valid constant before 3461d7c.

@pinterf
Copy link

pinterf commented Feb 18, 2022

Thanks, fixed. I'm waiting a bit further for other possible issues, so I'm not going to provide a build right now.

@Reel-Deal
Copy link
Member Author

No worries, I'm still busy testing other things :)

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

No branches or pull requests

2 participants