Skip to content

LinGui: Reworked dimensions tab - #3546

Merged
jstebbins merged 1 commit into
HandBrake:masterfrom
jstebbins:lingui_dimensions2
May 2, 2021
Merged

jstebbins merged 1 commit into
HandBrake:masterfrom
jstebbins:lingui_dimensions2

Conversation

@jstebbins

@jstebbins jstebbins commented Apr 16, 2021 •

Copy link
Copy Markdown
Contributor

Also includes libhb changes to support new dimensions tab.

New libhb function hb_rotate_geometry() helper for rotating dimensions
tab settings when rotation filter settings change.

Simplified hb_set_anamorphic_size2 and added support for updating
display size and factoring pad into resolution limits.

Added new pad filter parameters top, bottom, left, right to make
interface to pad filter fit more easily with our UI.

Added preset keys for pad filter PicturePadMode, PicturePadColor,
PicturePadTop, PicturePadBottom, PicturePadLeft, PicturePadRight.

Added preset keys PictureAllowUpscaling, PictureUseMaximumSize which are
used in the new dimensions tab.

Special note for @sr55 hb_geometry_settings_t struct has changed, so if you map that in WinGui, you'll need to update it.

Test on:

  • Windows 10+ (via MinGW)
  • macOS 10.13+
  • Ubuntu Linux

Screenshots (If relevant):
Screenshot from 2021-04-16 12-20-47

@jstebbins
jstebbins force-pushed the lingui_dimensions2 branch from a614df3 to 531b752 Compare April 17, 2021 14:33
@bradleysepos bradleysepos linked an issue Apr 17, 2021 that may be closed by this pull request
@galad87

galad87 commented Apr 17, 2021 •

Copy link
Copy Markdown
Contributor

A couple of issues:

  • top and bottom crop are not flipped when rotation is set to 90 if "Horizontal Flip" is checked.
  • Scaled size can be set up to the resolution limit even if "Allow Upscaling" is not checked if crop is set.

@bradleysepos

Copy link
Copy Markdown
Contributor

Looking good. Thanks for your time and effort on this, it's great watching it all come together in a tangible way. 🚀

Here's a slight revision with some comments. Mostly alignment and label/heading improvements for clarity.

Note: I'm not entirely familiar with GNOME layout norms when it comes to controls. My intention is not to violate platform norms, of course. Just some observations and considerations, all of which are open for discussion.

Original:
Screenshot from 2021-04-16 12-20-47

Revision:
ghb

  • By reducing the horizontal spacing between Storage Size, Display Size, and Aspect Ratio, we retain enough white space to differentiate while avoiding the look of three distinct columns that appear to be out of alignment with the three distinct columns intended in the middle section.
  • Orientation seems to better encapsulate both flipping and rotation while being an accessible word (at least in English).
  • Flipping: Horizontal better follows the noun-colon-option paradigm (and improves the layout to my eyes).
  • Nested TBLR fields for cropping and borders. Horizontally aligning the top and bottom fields with the control above (so, indenting them slightly) seems to work well here, if possible.
  • I would really like Resolution Limit to be first under Resolution & Scaling, for hierarchy. Nesting Allow Upscaling and Use Maximum Size makes both cognitive sense and for good layout.
  • In my designs, upscaling is enabled via Allow Upscaling (naturally), and upscaling all the way to the resolution limit is achieved via Use Maximum Size, which sets the Scaled Size matching Maximum Size. So if Allow Upscaling means "allow me to enter values larger than the original dimensions", then Use Maximum Size means "set those values to their maximums, the storage resolution limit". In your example, Use Maximum Size seems to also be enabled when not upscaling, resulting in the Maximum Size not actually being Used anywhere (visually), which I think could cause confusion. With the addition of PAR controls, I think Use Maximum Size should set Scaled Size equal to Maximum Size and adjust PAR accordingly. Anamorphic Auto already changes storage aspect when downscaling, to make the most use of available resolution, unless something changed. There might be more to this I am not seeing.
  • We are going to have to choose between Borders and Padding, both to avoid confusion whether they are two distinct things in HandBrake (they are not), and whether we know what we're doing at all or just making stuff up 😸. My bad, pretty sure it's in all my design examples. Even though we call the filter pad, I vote for Borders in this case, as in, "crop the black borders" and "add black borders".
  • Border color following the mode (none/fill/custom) seems more correct hierarchically. Especially if we create an evil filter that places an enlarged, blurry version of the picture behind the original in full motion (like broadcast news does where displaying a low quality mobile phone video) and incorporate its controls in this section. 🙃
  • Prefixing the final Display Size with a checkbox and the word modify seems sane enough. That said, my brain seems to scan for Display Size and not Modify and clearly I do not like leading checkboxes (I've had issues with all four now... not sure if that's good design practice or a weird personal preference). One alternative way of doing this could be a lock/unlock button one must engage to permit editing (as pictured). Another could be always editable fields and a reset/refresh button, perhaps using GNOME's view-refresh icon? view-refresh

🍻

@jstebbins

Copy link
Copy Markdown
Contributor Author

In your example, Use Maximum Size seems to also be enabled when not upscaling...

When not upscaling, Use Maximum Size keeps the scale dimensions == source - crop. Otherwise, as you change crop, scale doesn't change and you have to manually adjust scale if you want the maximum possible scaling without upscaling.

@jstebbins

Copy link
Copy Markdown
Contributor Author

I don't follow your reasoning for the placement of "Allow Upscaling" and "Use Maximum Size". "Resolution limit" and "Maximum size" are intimately connected, so I don't see why you would put those options between them. It seems to me they are best either at the top or just above "Scale size" since they are unrelated to anamorphic.

@jstebbins

Copy link
Copy Markdown
Contributor Author

GTK doesn't appear to have a standard lock/unlock icon. So if we are going to do the lock toggle button thing, I'll need a couple icons to work with.

@jstebbins

Copy link
Copy Markdown
Contributor Author

An idea. Instead of repeating "Borders". Have the heading say Borders, and the popup label say "Fill" with options "None", "Surround", "Height (Letterbox)", "Width (Pillarbox)", "Custom".

A couple advantages to this. Deletes the repetition, and makes the option text short enough that it better aligns the right side of the popup box with the right side of the Top pad entry. It's still a smidgen wider, but looks better.

@jstebbins

Copy link
Copy Markdown
Contributor Author

Updated screenshot after some tweaking... Display size modification toggle button image is just a stand-in till we have a proper lock/unlock icon pair.

Screenshot from 2021-04-17 20-05-25

@bradleysepos

bradleysepos commented Apr 18, 2021 •

Copy link
Copy Markdown
Contributor

Updated screenshot after some tweaking...

Good stuff.

Fill as a label is fine; I must have been thinking there could be other types, but that seems unlikely.

In hindsight, we should probably change Fill (Surround) to Fill Height & Width, because you just know someone is going to think it has something to do with surround sound. Maybe also place it last in the list.

I need to think/sleep on the resolution section, only half-formed thoughts right now.

I can create suitable lock/unlock icon resources. I feel like we want to reset the display aspect when locking the fields, but that seems like a layer of magic atop more traditional lock behavior. Thoughts?

@jstebbins

Copy link
Copy Markdown
Contributor Author

I feel like we want to reset the display aspect when locking the fields

That's the current behavior. The button is essentially !PictureKeepAspect which is passed as a flag to hb_set_anamorphic_size2 which tells it to "keep the source display aspect". So when "locked" it will revert to the source display aspect. Maybe a lock isn't the right emblem, but I think that's the right behavior.

@jstebbins

Copy link
Copy Markdown
Contributor Author

So, I'm browsing the available icons, and gtk does have an icon with a lock on it... called "emblem-readonly".

emblem-readonly

And I'm thinking to revert we use edit-clear maybe?
edit-clear

@bradleysepos

Copy link
Copy Markdown
Contributor

Nesting Allow Upscaling and Use Maximum Size under Scaled Size seems like a good choice. Keeps them away from things they don't affect directly (or as directly) and avoids leading with checkboxes, putting Resolution Limit first in the list. I gotta have Resolution Limit first in the list.

I believe I understand the Use Maximum Size behavior you've described. It wasn't my original intention but it does make some sense. To continue with that behavior, though, something should be renamed to disassociate Maximum Size and Use Maximum Size.

ui3fillmax

If we go all the way back to one of the earliest incarnations of the Dimensions tab redesign (Aug/Sept 2016!), we had a Scaling control with Fill as one of the options. Ultimately, we decided to create Allow Upscaling to gate the whole thing, with Fill being renamed to Use Maximum Size and becoming a checkbox. This was before PAR controls were added, so it inherently was not intended to keep PAR at the time.

So that's the origin story, at least. Maybe in conjunction with moving those controls under Scaled Size, we could rename Use Maximum Size to something with OG Fill in it, or a synonym in this context. Scaled Size, Allow Upscaling, Upscale Fill? Upscale To Fill? Upscale Dr. Phil? Upscale Punxsutawney Phil? Upscale The LA Philharmonic aka LA Phil?

You could add a third checkbox, "Keep PAR" that when unchecked, sets Scaled Size == Maximum Size and adjusts PAR, basically splitting Use Maximum Size into Upscale Dr. PhilFill + Keep PAR. 😅

@bradleysepos

Copy link
Copy Markdown
Contributor

And I'm thinking to revert we use edit-clear maybe?

Is there a corresponding edit (sans clearing) icon? That seems like it would work.

@jstebbins

Copy link
Copy Markdown
Contributor Author

Is there a corresponding edit (sans clearing) icon?

Nope ☹️

@bradleysepos

Copy link
Copy Markdown
Contributor

Also, is there an online reference for your icon set? I downloaded a tarball of the GNOME 3 default icon set a few days ago, but it might not be correct as the edit-clear icon is a broom.

@jstebbins

Copy link
Copy Markdown
Contributor Author

should be renamed to disassociate Maximum Size and Use Maximum Size

LinGui has always had a checkbox to enable this behavior which was previously linked to the deprecated preset key UsesPictureSettings != 1. Checkbox says "Optimal for source" which doesn't quite fit either, but perhaps the word "Optimal" could be worked in somehow to distinguish from "Maximum".

@bradleysepos

Copy link
Copy Markdown
Contributor

Optimal For Dr Phil?

@jstebbins

Copy link
Copy Markdown
Contributor Author

Also, is there an online reference for your icon set? I downloaded a tarball of the GNOME 3 default icon set a few days ago, but it might not be correct as the edit-clear icon is a broom.

If you have a linux vm running, there's a python script that will let you browse the icons:
http://dl.0xdeadc0de.fr/misc/gtkiconview_freedesktop.py

And here's a list of the "standard" icon names
https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

@bradleysepos

bradleysepos commented Apr 18, 2021 •

Copy link
Copy Markdown
Contributor

@jstebbins

Copy link
Copy Markdown
Contributor Author

My last commit has the readonly and edit-clear icons if you want to see that combination in action.

@bradleysepos

Copy link
Copy Markdown
Contributor

Cool, just started a build on bare metal Fedora 33. 😸

@jstebbins

Copy link
Copy Markdown
Contributor Author

Current:
Screenshot from 2021-04-18 08-33-27

@jstebbins

Copy link
Copy Markdown
Contributor Author

Is keeping loose around beneficial?

Loose attempts to stay as close as possible to original source PAR. We had a discussion on IRC about that and you convinced me there's no benefit to doing that.

If you are not scaling (i.e. only crop is occuring), auto happens to result in the same PAR as the source. If you are scaling, you really want to keep as many source pixels as possible, PAR be damned.

If a specific PAR is important for some use case, you probably need to set a specific PAR with custom anamorphic anyway.

@jstebbins

Copy link
Copy Markdown
Contributor Author

One case where keeping the original PAR might be desirable is when upscaling. There's not a lot of point in taking a cropped 1920 x 800 HD video and upscaling to 1920 x 1080 if it's only going to get downscaled back to 1920 x 800 again at playback.

But we can do that automatically without the use of a special mode. Auto + upscale could trigger that behavior in hb_set_anamorphic_mode2 if desired.

@jstebbins

Copy link
Copy Markdown
Contributor Author

Thinking more about the auto + upscale use case...

I can't think of any scenario where I would personally use upscaling with auto anamorphic, which is why I'm wondering if it's behavior should be something different.

The arguments for permitting upscaling are usually either the player has a crummy scaler or the output needs to exactly match some standard. If you are upscaling a 1920x800 video to 1920x1080, you will have to rescale it on playback and it does not conform to any standard format (because PAR is nonstandard). So none of the usual arguments apply. Maybe there is some other use case for this type of upscale that I'm not thinking of? Maybe we want to allow it even though we can't think of a use case for it (file size be damned)?

I'm really just looking for ideas on what the use cases for this might be. If there are none, maybe some tweak in behavior would satisfy some use case and make this feature better.

@jstebbins

Copy link
Copy Markdown
Contributor Author

To be clear, I'm talking only about anamorphic auto + allow upscale + use max size.

@bradleysepos

Copy link
Copy Markdown
Contributor

Right, given full-screen playback, 1920x800->1920x1080 on a 1920x1080 display would basically be upscaling the height and scaling it back down on playback. That said, the additional (interpolated) resolution could be useful on a higher resolution display, on which playback could also be windowed at 2592x1080.

@bradleysepos

Copy link
Copy Markdown
Contributor

I suppose we could get clever with Optimal Size and not upscale the height where the width already equals the max width? There are probably tallscreen considerations as well; perhaps it should not upscale where the longest dimension is equal to the max (resolution limit) for that dimension?

Since we renamed Use Maximum Size to Optimal Size, that probably gives us some wiggle room to be clever in these cases. That said, it's upscaling which is advanced and not part of any preset, so we could just say "there be dragons" and leave it as-is.

@bradleysepos

bradleysepos commented Apr 22, 2021 •

Copy link
Copy Markdown
Contributor

Example:

Resolution Limit: 1920x1080
Post-crop: 1920x800
Anamorphic: Auto
Optimal Size: True
Allow Upscaling: True
Storage Size: 1920x800 (special case where largest dimension == max)
Display Size: 1920x800
Set Optimal Size to False and increase storage height to 1080 to override this behavior, yielding 2592x1080 display.

Resolution Limit: 3840x2160
Post-crop: 1920x800
Anamorphic: Auto
Optimal Size: True
Allow Upscaling: True
Storage Size: 3840x2160 (normal case where largest dimension < max)
Display Size: 5184x2160

@bradleysepos

Copy link
Copy Markdown
Contributor

Another way of thinking about this which might be an easier condition to code, is when Optimal Size is used in conjunction with Allow Upscaling, only upscale when both dimensions will increase.

@jstebbins

jstebbins commented Apr 22, 2021 •

Copy link
Copy Markdown
Contributor Author

Another way of thinking about this which might be an easier condition to code, is when Optimal Size is used in conjunction with Allow Upscaling, only upscale when both dimensions will increase.

I.e. if you increase width = W * X, also increase height = H * X (subject to maxWidth and maxHeight)? That seems reasonable. If you do the math, that results in keeping the source PAR, which would be trivial to implement as we already have a code path for setting a specific PAR in hb_set_anamorphic_size2.

Another option that has some appeal (and some complications) is to use a fixed PAR of 1:1 and only upscale if both dimensions increase. 1:1 PAR matches the PAR of most screens and most modern video standards, the appeal is more aesthetic than anything else 🤷‍♂️ . The complication is that you do have to test if it resulted in reduction of one dimension. I prefer the previous solution for it's simplicity 😉

@bradleysepos

bradleysepos commented Apr 22, 2021 •

Copy link
Copy Markdown
Contributor

Another way of thinking about this which might be an easier condition to code, is when Optimal Size is used in conjunction with Allow Upscaling, only upscale when both dimensions will increase.

I.e. if you increase width = W * X, also increase height = H * X (subject to maxWidth and maxHeight)? That seems reasonable. If you do the math, that results in keeping the source PAR, which would be trivial to implement as we already have a code path for setting a specific PAR in hb_set_anamorphic_size2.

More like:

w_max = 1920;
h_max = 1080;
w = 1920;
h = 800;

if (upscale_allowed == 1 && optimal_size == 1)
{
    if (w_max > w && h_max > h)  // nesting optional
    {
        w = w_max;
        h = h_max;
    }
}

@jstebbins

Copy link
Copy Markdown
Contributor Author

Umm, doesn't that result in the exact behavior we currently have. Output would be 1920x1080 for 1920x800 input.

@jstebbins

Copy link
Copy Markdown
Contributor Author

It's not exactly the same I suppose, but it's close enough that it's a difference without a distinction. An input of 1918 x 800 would result again in 1920 x 1080 output.

@bradleysepos

Copy link
Copy Markdown
Contributor

It results in 1920x800 output, because max width is not greater than width (we would be scaling only height to no advantage).

@bradleysepos

Copy link
Copy Markdown
Contributor

It's not exactly the same I suppose, but it's close enough that it's a difference without a distinction. An input of 1918 x 800 would result again in 1920 x 1080 output.

That's true.

@bradleysepos

Copy link
Copy Markdown
Contributor

I pretty much never want to keep PAR when scaling up or down. Perhaps we simply need a Keep PAR checkbox for people who do. Or a new anamorphic mode called Keep PAR. 😅

@jstebbins

Copy link
Copy Markdown
Contributor Author

It's not about keeping PAR. That just happens to be a side effect of not scaling one dimension more than another.

@bradleysepos

Copy link
Copy Markdown
Contributor

Perhaps a checkbox nested under Pixel Aspect, ☑️ Keep Original.

It's not about keeping PAR.

In that case, could the issue be better defined as, upscaling between zero and a very small percentage in any one dimension is not optimal?

@bradleysepos

bradleysepos commented Apr 22, 2021 •

Copy link
Copy Markdown
Contributor
if (upscale_allowed == 1 && optimal_size == 1)
{
    if (w / w_max < 0.88 && w / w_max < 0.88)  // avoid integer logic here
    {
        w = w_max;
        h = h_max;
    }
}

0.88 is just a rough idea.

@jstebbins

Copy link
Copy Markdown
Contributor Author

Perhaps a checkbox nested under Pixel Aspect, ☑️ Keep Original.

There's no point in adding such a feature to the UI. I'm not asking for that.

In that case, could the issue be better defined as, upscaling between zero and a very small percentage in any one dimension is not optimal?

Upscaling is never optimal. It is done for some specific purpose that is antithetical to optimality. My issue is that our current behavior when upscale and optimal size are checked doesn't appear to serve any purpose. I'm searching for an outcome that serves some purpose. Downscaling with optimal size checked serves a distinct purpose, it maximizes quality by keeping the most original pixels possible. Upscaling behavior with optimal checked has no equivalent purpose. I'm sounding very emo right now 👅

@bradleysepos

Copy link
Copy Markdown
Contributor

If someone wants to always upscale to fill the resolution limit, they would have to disable Optimal Size and manually match the Storage Size fields to the Maximum Size fields...

@jstebbins

Copy link
Copy Markdown
Contributor Author

If someone wants to always upscale to fill the resolution limit

The question is, why would someone want to do that? I'm just trying to come up with a behavior that might be more generally useful.

@bradleysepos

bradleysepos commented Apr 22, 2021 •

Copy link
Copy Markdown
Contributor

Downscaling with optimal size checked serves a distinct purpose, it maximizes quality by keeping the most original pixels possible.

Indeed, it explicitly conveys the user's intention to avoid downscaling, beyond the enforcing the Resolution Limit. This allows us to automatically adjust storage size as the user changes crop values, as you mentioned previously.

Upscaling behavior with optimal checked has no equivalent purpose

Likewise, it explicitly conveys the user's intention when upscaling: "just friggin' upscale it!" 😆 This again allows us to adjust storage size automatically, preventing the user from having to manually enter storage size values; i.e., they've already told us once via Resolution Limit / Maximum Size.

The main difference is, in the downscaling case, knowing the explicit intention both prevents inconvenience (user must adjust storage size values after adjusting cropping values) and potential harm (failure to do so will negatively affect picture quality). In the upscaling case, it only prevents inconvenience (user must adjust storage size values to match what they've already given us elsewhere), as there is no potential for harm.

So I'd say it's consistent and helpful in the UI, even though it's not solving an equivalent potential technical problem.

If someone wants to always upscale to fill the resolution limit

The question is, why would someone want to do that? I'm just trying to come up with a behavior that might be more generally useful.

Right. Traditionally, the answer has been Just Don't Do It™, largely because of storage considerations and the fact devices and softwares do this for you in real-time.

Up until recently, the assumption has always been we can't do much better, if any, than a TV's scaler. Why would someone want to upscale using a dumb windowing algorithm? Except in edge cases where additional restoration is warranted, it's a lot of downside for little if any benefit.

It absolutely does make sense to upscale using as much storage resolution as possible using state-of-the-art upscaling technology. AI-based upscaling can be quite impressive (I've been doing some of this manually), and I suspect it will be some time before most people's TVs have comparable capabilities (and even then, real-time constraints apply). I really doubt NLMeans+AI scaling on difficult sources will be outmatched by consumer hardware anytime soon.

Until then, it is still useful for me as a user to have a preset for tough sources that dictates, "denoise the source, upscale it to this limit, and apply a sharpening filter". Because even NLMeans+dumbscaler+dumbsharp, as it now stands, can be pretty effective if you're willing to pay with file size.

So there are good reasons to specify and record the explicit intention of using all available storage size, in any case, now and in the future.

@jstebbins

Copy link
Copy Markdown
Contributor Author

OK. I relent. I actually can see someone wanting to use as much software filtering as possible up to the resolution limits of some specific decoder hardware. That's a use case that hadn't occurred to me.

I really doubt NLMeans+AI scaling on difficult sources will be outmatched by consumer hardware anytime soon

I've not seen any denoiser, much less a good one on consumer hardware. The NVidia Shield Pro has an AI scaler, but TBH, I've not done any comparisons to see how good it is.

@sr55

sr55 commented Apr 22, 2021

Copy link
Copy Markdown
Contributor

Food for though, adding complexity to the UI for the 0.1% use case. Is it worth it?

@jstebbins

Copy link
Copy Markdown
Contributor Author

Food for though, adding complexity to the UI for the 0.1% use case. Is it worth it?

Nope. But nothing we were talking about affected UI. It's all about the under the covers behavior and what behavior would be most useful for the UI as it now stands in this PR.

@bradleysepos

Copy link
Copy Markdown
Contributor

OK. I relent.

I realize my last was a bit "thorough". 🤣 Hopefully I didn't come off as attempting to apply pressure or argue. Mostly just thinking through things "out loud".

I've not seen any denoiser, much less a good one on consumer hardware

Yeah. And probably rare that one would be exposed to the user directly.

I do have an older 1080p plasma display with a denoise filter roughly equivalent to hqdn3d on the light and medium settings, and pretty ugly on the strong setting. Definitely some sort of low pass implementation. There's an automatic mode that seems to apply the medium setting to pretty much everything, even to high quality material. So it's actually harmful to higher quality video, and naturally, I leave it disabled.

Food for though, adding complexity to the UI for the 0.1% use case. Is it worth it?

Always a good question to be asking. In this case, the control already exists and is necessary when downscaling, just trying to define/clarify how it should behave when upscaling.

@jstebbins

Copy link
Copy Markdown
Contributor Author

So, I think this PR is ready short of any additional support @sr55 might need for WinGUI. Do you need a json interface to hb_rotate_geometry()? Any other json interfaces that would be helpful?

Also includes libhb changes to support new dimensions tab.

New libhb function hb_rotate_geometry() helper for rotating dimensions
tab settings when rotation filter settings change.

Simplified hb_set_anamorphic_size2 and added support for updating
display size.

Added new pad filter parameters top, bottom, left, right to make
interface to pad filter fit more easily with our UI.

Added preset keys for pad filter PicturePadMode, PicturePadColor,
PicturePadTop, PicturePadBottom, PicturePadLeft, PicturePadRight.

Added preset keys PictureAllowUpscaling, PictureUseMaximumSize which are
used in the new dimensions tab.
@jstebbins
jstebbins force-pushed the lingui_dimensions2 branch from b7050f0 to 16f2d03 Compare May 2, 2021 15:52
@jstebbins
jstebbins merged commit 6ae34e0 into HandBrake:master May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Dimensions Tab Redesign.

4 participants