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

Frame dump at raw internal resolution #12436

Merged

Conversation

Filoppi
Copy link
Contributor

@Filoppi Filoppi commented Dec 17, 2023

Allows the frame dumper to use the raw emulation output (XFB) resolution, avoiding any scaling if possible.
This should make comparisons much more reliable as pixels wouldn't be smushed together or stretched.

Currently even if bInternalResolutionFrameDumps is enabled, dumps are done after scaling to the target aspect ratio (which is almost always different from the raw emulation render), so they aren't really raw, they are scaled, but they scaling isn't done with gamma correction as the post process effects pipeline doesn't run on them.

This PR adds an enum with 3 dumping resolution choices:
image

Some possible future improvements related to this:

  • Save the target aspect ratio number in the output file name, so it could be stretched in post.
  • Remove the VIDEO_ENCODER_LCM (4) limit, or move it to the frame dumper and just make it add black pixel lines of padding on the edges instead of forcing images to stretch.

The FifoCI differences are expected.

The 2nd commit moves the adjustments to the dumping resolution into the actual dumping function, so the window output resolution isn't affected by recording anymore (previously it would snap to the closest multiple of 4 when recording, which was unnecessary).
The 4th commit allows screenshots to be taken at any resolution, without the unnecessary VIDEO_ENCODER_LCM (4) limit.

@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch 4 times, most recently from d0a2740 to 0f4eef1 Compare December 18, 2023 16:36
@JosJuice
Copy link
Member

This is okay for FifoCI, but for regular users I think this is unacceptable unless it's put behind a toggle. You say that "it's very easy to size the window to match the target aspect ratio and then set bInternalResolutionFrameDumps to false", but:

  1. Finding out the size the image is supposed to be after scaling is non-trivial
  2. Resizing the window to the right size is non-trivial (either you have to carefully drag the window edges to match exact pixel sizes, or you have to know how to navigate Qt.ini)
  3. If the game you're dumping changes the resolution/aspect ratio, each time there's a change you have to do a frame-perfect pause (without Dolphin even telling you when to pause) and do all the steps above over again (with editing Qt.ini now being impossible due to Dolphin only reloading it on restart)

This would completely break TAS dumping workflows.

@Filoppi
Copy link
Contributor Author

Filoppi commented Dec 18, 2023

@JosJuice I was indeed wondering what happens if the game changes resolution while recording. Theoretically this was already an issue before, as if bInternalResolutionFrameDumps was true (or false actually), the video/output size could be changed between frames.

Regarding the rest, we could simply make an enum with 3 choices (window resolution, XFB raw resolution, XFB aspect ratio corrected resolution).

@JosJuice
Copy link
Member

I was indeed wondering what happens if the game changes resolution while recording. Theoretically this was already an issue before, as if bInternalResolutionFrameDumps was false, the video/output size could be changed between frames.

We split the video on resolution changes.

Regarding the rest, we could simply make an enum with 3 choices (window resolution, XFB raw resolution, XFB aspect ratio corrected resolution).

Yes, that sounds fine.

@Filoppi
Copy link
Contributor Author

Filoppi commented Feb 23, 2024

image
uploaded a new version with 3 settings
Edit: screenshot outdated

@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch from 25bdb56 to d92b03c Compare February 23, 2024 02:17
Copy link
Contributor

@mbc07 mbc07 left a comment

Choose a reason for hiding this comment

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

Please don't just add a dropdown without an accompanying text label, not only it look out of place but it's also inconsistent with the other dropdowns from the Graphics config window (and from other Dolphin dialogs). Here's a suggestion for the text label:

Resolution: [dropdown with the options this PR adds]

@Filoppi
Copy link
Contributor Author

Filoppi commented Feb 23, 2024

@mbc07 it was an oversight, fixed

@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch from d92b03c to 740abfc Compare February 23, 2024 11:26
@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch 2 times, most recently from 6432dd5 to a5cba58 Compare February 29, 2024 01:48
@Filoppi
Copy link
Contributor Author

Filoppi commented Feb 29, 2024

The fifoci differences are due to the following reasons:

  • frame dumping now follows the VIDEO_ENCODER_LCM (4) size in a more streamlined way, without ever influencing the window size
  • frame dumping screenshots now ignore VIDEO_ENCODER_LCM (4), as it's only needed when dumping videos.
  • frame dumping now ignores cropping
  • frame dumping better converts from a float to int resolution, and finds the one with the closest target aspect ratio

@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch 3 times, most recently from e9cfdd4 to 6e8006f Compare March 3, 2024 13:51
@impiaaa
Copy link

impiaaa commented Mar 4, 2024

Might I also make the suggestion to tag frame dump output with the intended aspect ratio? It looks like it can be set in FFmpeg with sample_aspect_ratio in the AVCodecContext, and in PNG with the pHYs chunk. That way the actual video data can be raw XFB, but the video player or editor should still display it at the correct ratio.

@Filoppi
Copy link
Contributor Author

Filoppi commented Mar 4, 2024

@impiaaa good point. I won't do anything more surrounding these features, given I don't use them, but anybody else could do in a separate PR.

Copy link
Contributor

@MayImilae MayImilae left a comment

Choose a reason for hiding this comment

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

Mostly good to go, but a few comments.

Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp Outdated Show resolved Hide resolved
…ut resolution, avoiding any scaling if possible.

This should make comparisons much more reliable as pixels wouldn't be smushed together or stretched.
which also avoids the output window from being resized randomly to be a multiple of 4
@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch 2 times, most recently from b7fafea to 14c3b2c Compare April 3, 2024 11:41
@MayImilae
Copy link
Contributor

MayImilae commented Apr 3, 2024

image

That's better. But I have some more notes.

Having Dolphin do aspect ratio correction doesn't prevent scaling or post processing in external editing software, as is implied by this description. Raw doesn't "allow" it. Also, grammatically, it should be "at higher quality" not "with a higher quality".

I still take issue with quality being mentioned here. This option basically has Dolphin go hands off so video editors have completely control over the pixels of the footage. This could allow them to optimize the pixel clarity of their video, or they just won't apply pixel aspect ratio correction at all and get a worse result than if they had used one of our correction options (which IMO is pretty likely). The whole point of this is that we're giving the user a clean slate for them to manipulate however they so please, which can mean basically anything. So I'm not super happy with saying that this option will improve quality. Cause it may very well not.

Furthermore, I don't like the uneven presentation of these options. Window Resolution and Aspect Ratio Corrected Internal Resolution do not describe how to use them or their advantages or anything, they simply state what they are and move on. But for Raw, you continue to talk about its advantages and what users can gain from using it. That, plus positive language, are what gives is the impression that Dolphin wants you to use this and not the others. IMO, you should treat all three options the same way. If you want to matter of fact say what they are, do it for all of them. If you want to describe use cases, do it for all of them.

@Filoppi
Copy link
Contributor Author

Filoppi commented Apr 3, 2024

@MayImilae please directly write the tooltip exactly as you want :), I already gave my version and proposed some alternatives. I don't think it matters at all, but if you are looking for something very specific, please directly suggest the full edit. Thanks.

@MayImilae
Copy link
Contributor

MayImilae commented Apr 4, 2024

Ok, I'll give it a shot!

Window Resolution: Uses the output window resolution (without black bars or cropping). This is a simple dumping option that will capture the image more or less as you see it.

Aspect Ratio Corrected Internal Resolution: Uses the Internal Resolution (XFB size), and corrects it by the target aspect ratio. This option will consistently dump at the specified Internal Resolution regardless of how the image is displayed during recording.

Raw Internal Resolution: Uses the Internal Resolution (XFB size) without correcting it with the target aspect ratio. This will provide a clean dump without any aspect ratio correction so users have as raw as possible input for external editing software.

How's this? I added to the other options to even it out, and went with the one I showed earlier for Raw Internal Resolution but with some modifications. It's still not completely even between the options but by adding some details to the other ones, the details for Raw Internal Resolution now fit in better, imo.

@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch from 14c3b2c to d8d948d Compare April 7, 2024 21:44
@Filoppi
Copy link
Contributor Author

Filoppi commented Apr 7, 2024

@MayImilae re-uploaded with your text.

Copy link
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

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

Is it known why the FifoCI outputs have changed? We were previously using internal resolution frame dumps on FifoCI, and that is the new default now as far as I can tell, so I don't know why the image width has changed.

Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp Outdated Show resolved Hide resolved
// The aspect ratio corrected XFB resolution (XFB pixels might not have been square)
XFB_ASPECT_RATIO_CORRECTED_RESOLUTION,
// The raw unscaled XFB resolution (based on "internal resolution" scale)
XFB_RAW_RESOLUTION,
Copy link
Member

Choose a reason for hiding this comment

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

CamelCase is recommended for the entries of enum classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have doing all my enums like that recently. There's plenty around :).

Copy link
Member

Choose a reason for hiding this comment

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

Please change it.

@Filoppi
Copy link
Contributor Author

Filoppi commented Apr 8, 2024

@JosJuice #12436 (comment)

also polish aspect ratio related code for clarity
…ping screenshots and not videos (only videos encoders have this limit).

NOTE: this will likely trigger FIFOCI differences.
@Filoppi Filoppi force-pushed the frame-dump-raw-internal-resolution branch from d8d948d to 66592f7 Compare April 8, 2024 19:54
Copy link
Contributor

@MayImilae MayImilae left a comment

Choose a reason for hiding this comment

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

Description and UI LGTM.

@AdmiralCurtiss
Copy link
Contributor

This has been sitting here for ages, works fine, and is a useful improvement to the options.

@AdmiralCurtiss AdmiralCurtiss force-pushed the frame-dump-raw-internal-resolution branch from db619ed to 2f13be5 Compare April 13, 2024 01:22
@AdmiralCurtiss AdmiralCurtiss merged commit b393905 into dolphin-emu:master Apr 13, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants