Bugfix correctly load non square pixels for AVF player. Closes #4937 #4949
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before the AVF player was loading a non square video as ( for example ) 1920x1080 but both the pixel data and the texture coming from AVFoundation were actually 1440x1080.
This caused a crash when accessing pixels and resulted in the texture being drawn in a strange way.
see : https://forum.openframeworks.cc/t/issues-with-pixel-ratios-in-ofvideoplayer/22120/10?u=theo
This PR loads the video at the size that represent the real pixel data and adds the ability to query what the intended stretched display size is meant to be.
For now the new calls to getDisplayWidth() / getDisplayHeight are isolated to the ofAVFoundationPlayer class - if this is something we might want to support across platforms on linux and windows we could add it to the ofVideoPlayer and potentially even make the draw calls aware of the scaling needed.
For now this seems like a conservative fix which leaves the display scaling up to the user, but provides them with the information they need to account for the non square pixels.
An example of how you would do that is: