Page 1 of 1

[Solved] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Thu Sep 29, 2022 6:33 am
by Chris Hocking
Is anyone able to provide some basic example code on how to use the
Code: Select all
IBlackmagicRawClipResolutions
Interface?

Thanks in advance!

Re: How to use IBlackmagicRawClipResolutions?

PostPosted: Thu Sep 29, 2022 9:15 am
by Chris Hocking
All good, worked it out, thanks to this thread.

Code: Select all
IBlackmagicRawClipResolutions *clipResolutions;
clip->QueryInterface(IID_IBlackmagicRawClipResolutions, (void**)&clipResolutions);


This should probably be added to the SDK Documentation?

Re: [SOLVED] How to use IBlackmagicRawClipResolutions

PostPosted: Thu Sep 29, 2022 9:57 am
by Chris Hocking
Interestingly though, that when I feed it really low width and height (i.e. 112x63), the `requestUpsideDown` isn't properly respected? For example, I expect:

Code: Select all
bool requestUpsideDown = true;
clipResolutions->GetClosestScaleForResolution(destinationWidth, destinationHeight, requestUpsideDown, &resolutionScale);


...to always return `blackmagicRawResolutionScaleFullUpsideDown`, `blackmagicRawResolutionScaleHalfUpsideDown`, `blackmagicRawResolutionScaleQuarterUpsideDown` or `blackmagicRawResolutionScaleEighthUpsideDown` - because I've set `requestUpsideDown` to `true`?

Am I misunderstanding something?

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Fri Sep 30, 2022 5:48 am
by Chris Hocking
I've modified the ProcessClipMetal sample, to explain my issue.

Specifically:

Code: Select all
IBlackmagicRawClipResolutions *clipResolutions;
clip->QueryInterface(IID_IBlackmagicRawClipResolutions, (void**)&clipResolutions);

uint32_t decodeQuality;

//
// NOTE: Feeding `GetClosestScaleForResolution` with 1920x1080 and `requestUpsideDown` as `true` gives upside down image,
//       however, feeding it 112x63 and `requestUpsideDown` as `true` gives a right-side-up image?!?
//
uint32_t destinationWidth   = 112; //1920;
uint32_t destinationHeight  = 63;  //1080;
bool requestUpsideDown      = true;

clipResolutions->GetClosestScaleForResolution(destinationWidth, destinationHeight, requestUpsideDown, &decodeQuality);


Here's the full code:

https://gist.github.com/latenitefilms/2 ... 54a5544128

Feeding it 1920x1080 and requestUpsideDown as true gives an upside down image, which is correct.

Feeding it 112x63 and requestUpsideDown as true gives a right-side-up image, which I believe is incorrect.

Am I missing something CaptainHook? Is this a bug or a misunderstanding on my part?

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Fri Sep 30, 2022 10:30 am
by antoine
Alternatively, you could maybe use GetClosestResolutionForScale to look for the best scale possible

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Fri Sep 30, 2022 10:47 am
by Chris Hocking
Thanks for the fast reply Antoine!

Dumb question... If I did use GetClosestScaleForResolution, what do I then do with the resolutionWidthPixels, and resolutionHeightPixels? I couldn't see any API for setting a specific output resolution?

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Mon Oct 03, 2022 7:38 am
by antoine
If you use GetClosestScaleForResolution you get Scale in output from Resolution in input (what you initially wanted). With GetClosestResolutionForScale you would do the opposite, you would iterate all the scales (in input) until you get a resolution (in output) that would fit best (or least worst :D ) you for what you're trying to do

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Mon Oct 03, 2022 7:43 am
by Chris Hocking
Thanks Antoine!

It sounds like this is a bug - will hopefully get confirmation tomorrow.

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Wed Oct 05, 2022 1:13 am
by Chris Hocking
For anyone playing along at home... Blackmagic has confirmed this is a bug, and will be hopefully addressed in the future. Thanks team!

Re: [BUG] GetClosestScaleForResolution & requestUpsideDown

PostPosted: Mon Apr 17, 2023 2:51 am
by Chris Hocking
This post is no longer relevant with the v3.0 SDK.

Re: [Solved] GetClosestScaleForResolution & requestUpsideDow

PostPosted: Wed Apr 19, 2023 5:06 pm
by antoine
Yeah the new SDK has plenty of new info there to get and set, it's good. Chris did you use it already and does it work for what you're trying to do ?

Re: [Solved] GetClosestScaleForResolution & requestUpsideDow

PostPosted: Mon May 29, 2023 11:35 am
by Chris Hocking
Sorry for the delayed reply - just noticed this! Yes, the new SDK solves the issues I was having.

Hope all is well in your world!