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

Rework the aspect ratio calculation (Fixes 240p mode) #3472

Merged
merged 2 commits into from Jan 9, 2016

Conversation

phire
Copy link
Member

@phire phire commented Jan 8, 2016

Calculations are now based on signal timings rather than pixels, as it didn't make a lot of sense to do things with pixels.

Now handles all 240i/240p/480i/480p modes without any special casing. Will even handle modes like 960i or 243@59.74hz

Despite the changes in equations, the resulting aspect ratios are identical.

Video Interface simply isn't aware about widescreen.
Instead, the render class can multiply by 1.3333333 to get
the 16:9 aspect ratio.
@phire phire force-pushed the TVs_dont_have_pixels branch 2 times, most recently from cf372b1 to b658331 Compare January 8, 2016 09:12
@phire
Copy link
Member Author

phire commented Jan 8, 2016

@mirrorbender could you take a look at this? It should have the exact same aspect ratios as your old code.

@phire phire changed the title [WIP] Rework the aspect ratio calculation (Fixes 240p mode) Rework the aspect ratio calculation (Fixes 240p mode) Jan 8, 2016
@phire
Copy link
Member Author

phire commented Jan 8, 2016

This is ready for review/merging now. Replaces #3346

@JMC47
Copy link
Contributor

JMC47 commented Jan 8, 2016

lgtm in basic testing of various games and aspect ratios.


// 5. Calculate the final ratio and scale to 4:3
float ratio = horizontal_active_ratio / vertical_active_ratio;
if(std::isnormal(ratio)) // Check we have a sane ratio and haven't propagated any infs/nans/zeros

This comment was marked as off-topic.

@delroth
Copy link
Member

delroth commented Jan 8, 2016

@phire: This comment grants you the permission to merge this pull request whenever you think it is ready. After addressing the remaining comments, click this link to merge.


Other than these two nits, code LGTM. @dolphin-emu-bot allowmerge

@mirrorbender
Copy link
Contributor

@phire I looked over it quickly. The numbers are correct (as much as that is possible here). I can go over the code more closely if you want me to, but I trust that you and the others who have reviewed and tested it have already done a fine job of that, and at a glance it looks fine to me. So I'd say go ahead and merge it.

@phire
Copy link
Member Author

phire commented Jan 9, 2016

@mirrorbender Now that I've separated the vertical and horizontal calculations and moved away from pixels, I can see that the vertical timings are wrong by half a line per field. The NTSC timings should be 262.5 / 242.5 which works out to 525 / 485 (instead of the current 525 / 486)

You can confirm this by looking Figure 7 on page 11 of SMPTE 170M-2004.
Actually it goes a step further and defines the vertical blanking per field as 20 lines + 1.5us in Detail Y-Y and Table 3 on page 13.

Half a line makes no sense in pixels, but it makes perfect sense for a CRT where the horizontal and vertical timings aren't directly connected and the image is rotated slightly anyway.

I'll submit a second PR in the future to address this.

@mirrorbender
Copy link
Contributor

I'm having trouble following the diagrams in terms of where the half lines go in the picture (half line at the end of field 1 and beginning of field 2?), but my reasoning for 486 was that two fields of 242.5 resulted in 484 full lines plus 2 separate half lines, which meant 486 was a better number if those half-lines were scanned to it's own vertical space within the active frame. However, assuming a slight tilt, I can see how 485 lines would be a better approximation of the appropriate height of the screen in a CRT TV.

@phire
Copy link
Member Author

phire commented Jan 9, 2016

The half lines are at the start and end of the frame. The standard doesn't say it, but Field 1 is the even/lower field and Field 2 is the upper/odd field.
With the tilt, the start of line 1 is the same height on the screen as the start of line 2, except line 1 starts half-way along the screen. It's the scan pattern which is tilted, I suspect TVs were build with a slight rotation of the coils in the opposite direction, so the tilt would be canceled out.

For a digital video format which can't do half-lines, padding it to 486 lines (or discarding both half-lines and dropping down to 484 lines) make sense, but 485 lines is completely nonsensical.

They are now based on signal timings rather than pixels, as it
didn't make a lot of sense to do things with pixels.

Now handles all 240i/240p/480i/480p modes without any special
casing.

Despite the diffrent equaions, this should result in the exact same aspect
ratio as the previous code.
@phire
Copy link
Member Author

phire commented Jan 9, 2016

Comments have been updated to fix typos and add some details from the BT-470-6 standard.

delroth added a commit that referenced this pull request Jan 9, 2016
Rework the aspect ratio calculation (Fixes 240p mode)
@delroth delroth merged commit 39971ec into dolphin-emu:master Jan 9, 2016
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • aeon-charge-attack on ogl-lin-nouveau: diff
  • chibi-robo-zfighting on ogl-lin-nouveau: diff
  • fortune-street-white-box on ogl-lin-nouveau: diff
  • mtennis-zfreeze on ogl-lin-nouveau: failed to render
  • thps4-shadow on ogl-lin-nouveau: failed to render
  • chibi-robo-zfighting on ogl-lin-radeon: diff
  • monkeyball-fuse on ogl-lin-radeon: diff
  • rs2-zfreeze on ogl-lin-radeon: diff
  • sms-bubbles on ogl-lin-radeon: diff
  • sw3-dt on ogl-lin-radeon: diff

automated-fifoci-reporter

@fallaha56
Copy link

hi, aspect ratios still broken on N64 VC games -> going 16:9 when 4:3, bug report filed

@phire
Copy link
Member Author

phire commented Jan 10, 2016

Technically that's correct emulation, as on a real Wii/TV you are required
to manually switch between 16:9 and 4:3 modes for virtual console games.

But we really should add .ini files for all virtual console games to
override that.


Scott Mansell

On 10 January 2016 at 23:03, fallaha56 notifications@github.com wrote:

hi, aspect ratios still broken on N64 VC games -> going 16:9 when 4:3, bug
report filed


Reply to this email directly or view it on GitHub
#3472 (comment).

@JMC47
Copy link
Contributor

JMC47 commented Jan 10, 2016

Yes, any issue made is invalid.

On Sun, Jan 10, 2016, 5:11 AM Scott Mansell notifications@github.com
wrote:

Technically that's correct emulation, as on a real Wii/TV you are required
to manually switch between 16:9 and 4:3 modes for virtual console games.

But we really should add .ini files for all virtual console games to
override that.


Scott Mansell

On 10 January 2016 at 23:03, fallaha56 notifications@github.com wrote:

hi, aspect ratios still broken on N64 VC games -> going 16:9 when 4:3,
bug
report filed


Reply to this email directly or view it on GitHub
<#3472 (comment)
.


Reply to this email directly or view it on GitHub
#3472 (comment).

@fallaha56
Copy link

thanks @phire i did wonder if you guys were simply being too accurate ;-)

but yeah some form of override would be cool thanks

@JMC47 i wouldn't describe it as invalid! it makes using VC a massive pain...

@JMC47
Copy link
Contributor

JMC47 commented Jan 10, 2016

Hehehe! It is accurate to the Wii, though. That's why it's not valid.

On Sun, Jan 10, 2016, 5:14 AM fallaha56 notifications@github.com wrote:

thanks @phire https://github.com/phire i did wonder if you guys were
simply being too accurate ;-)

but yeah some form of override would be cool

@JMC47 https://github.com/JMC47 wouldn't describe it as invalid! it
makes using VC a massive pain...


Reply to this email directly or view it on GitHub
#3472 (comment).

@JMC47
Copy link
Contributor

JMC47 commented Jan 10, 2016

I am okay with ini overrides, though.

On Sun, Jan 10, 2016, 5:17 AM Justin C jmc4789@gmail.com wrote:

Hehehe! It is accurate to the Wii, though. That's why it's not valid.

On Sun, Jan 10, 2016, 5:14 AM fallaha56 notifications@github.com wrote:

thanks @phire https://github.com/phire i did wonder if you guys were
simply being too accurate ;-)

but yeah some form of override would be cool

@JMC47 https://github.com/JMC47 wouldn't describe it as invalid! it
makes using VC a massive pain...


Reply to this email directly or view it on GitHub
#3472 (comment)
.

@fallaha56
Copy link

thanks @JMC47...fingers hurting from the added mouseclicks resetting ratios ;) can refile issue as 'finger injury' if that's better lol ;))

@phire phire deleted the TVs_dont_have_pixels branch February 2, 2016 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants