Braw SDK v1.8 ISO attribute reading - observation

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Braw SDK v1.8 ISO attribute reading - observation

PostWed Jul 15, 2020 7:07 am

I made an observation in new v1.8 SDK that I'll write here just in case it isn't me being stupid again.

When decoding old .braw files, for example the original samples of wedding that were I believe from braw version 1.0 times, new v1.8 SDK does nor correctly read the ISO values list from file. It worked as expected in SDK 1.7 which I tinkered with just yesterday, today, after updating to SDK v1.8 these files show erroneous values (18, 0, 1, 0, 0 in this order for all these sample clips). Newer files do not seem to have this problem and ISO values are returned as expected.
I do stuff.
Offline

CaptainHook

Blackmagic Design

  • Posts: 2054
  • Joined: Wed Aug 22, 2012 4:50 am
  • Location: Melbourne, Australia
  • Real Name: Hook

Re: Braw SDK v1.8 ISO attribute reading - observation

PostWed Jul 15, 2020 8:53 am

Hi, can you post the code you're using to read the ISO values?
Some of this changed in 1.7 with regards to reading the analog gain value per frame and looking up the appropriate ISO list etc but nothing should have changed in regards to this for 1.8.
**Any post by me prior to Aug 2014 was before i started working for Blackmagic**
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Braw SDK v1.8 ISO attribute reading - observation

PostWed Jul 15, 2020 10:14 am

Sure, basically I do this:

Code: Select all
HRESULT result = S_OK;
BOOL isReadOnly;

BSTR cameraType;
clip->GetCameraType(&cameraType);

VARIANT variantList[30];
UINT uintISOList[30];
UINT listLen;

VARIANT analogGain;
VARIANT analogGainIsConstant;
processingAttrs->GetClipAttribute(blackmagicRawClipProcessingAttributeAnalogGain, &analogGain);
processingAttrs->GetClipAttribute(blackmagicRawClipProcessingAttributeAnalogGainIsConstant, &analogGainIsConstant);

result = constants->GetISOListForAnalogGain(cameraType, analogGain.fltVal, analogGainIsConstant.boolVal, uintISOList, &listLen, &isReadOnly);

if (result == S_OK)
{
    for (UINT i = 0; i < listLen; ++i)
    {
        VARIANT var;
        var.uintVal = uintISOList[i];
        variantList[i] = var;
    }
    attribute->updateValueList(variantList, listLen, isReadOnly);
}


But it might be something else messed in my side, I put it up just in case someone else has observed this. Otherwise I would think it is me but newer files seem to load iso list up with no problems.
Last edited by Hendrik Proosa on Wed Jul 15, 2020 10:31 am, edited 2 times in total.
I do stuff.
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Braw SDK v1.8 ISO attribute reading - observation

PostWed Jul 15, 2020 10:29 am

Just made a very strange observation which is beyond me in why it has any effect. I loop over the array and convert them to VARIANT type, which I then submit to another method that fills my processing parameter class (I use the same value list update routine for all attributes). If I add the std::cout printout there, ISO reading from old files works as expected. If I comment it out, it doesn't. Go figure... I have a feeling I have something off with handling the array but can't put my finger on it.

Code: Select all
if (result == S_OK)
{
    for (UINT i = 0; i < listLen; ++i)
    {
        VARIANT var;
        var.uintVal = uintISOList[i];
        variantList[i] = var;
        std::cout << "Iso value: " << std::to_string(uintISOList[i]) << "\n";   // if I comment this line out, it doesn't work anymore
    }
    attribute->updateValueList(variantList, listLen, isReadOnly);
}


Sorry if I'm spamming with random crap due to my incompetence with c++ :D
I do stuff.
Offline

CaptainHook

Blackmagic Design

  • Posts: 2054
  • Joined: Wed Aug 22, 2012 4:50 am
  • Location: Melbourne, Australia
  • Real Name: Hook

Re: Braw SDK v1.8 ISO attribute reading - observation

PostThu Jul 16, 2020 1:27 am

Seems like the issue is likely that you are assigning to a Variant without specifying the Variant type. Also, you're setting a fixed sized on your arrays for the ISO list where we'd recommend you dynamically resize these based on the number of entries the SDK provides (you can pass nullptr's when doing this).

Updating your code it would be something like :

Code: Select all
HRESULT result = S_OK;
BOOL isReadOnly;

BSTR cameraType;
clip->GetCameraType(&cameraType);

std::vector<VARIANT> variantList;
std::vector<UINT> uintISOList;
UINT listLen;

VARIANT analogGain;
VARIANT analogGainIsConstant;

processingAttrs->GetClipAttribute(blackmagicRawClipProcessingAttributeAnalogGain, &analogGain);
processingAttrs->GetClipAttribute(blackmagicRawClipProcessingAttributeAnalogGainIsConstant, &analogGainIsConstant);

result = constants->GetISOListForAnalogGain(cameraType, analogGain.fltVal, (BMDbool)analogGainIsConstant.boolVal, nullptr, &listLen, &isReadOnly);

if (result == S_OK)
{
    uintISOList.resize(listLen);
    result = constants->GetISOListForAnalogGain(cameraType, analogGain.fltVal, (BMDbool)analogGainIsConstant.boolVal, &uintISOList[0], &listLen, &isReadOnly);

    if (result == S_OK)
    {
        variantList.resize(listLen);
        for (UINT i = 0; i < listLen; ++i)
        {
            variantList[i].vt = blackmagicRawVariantTypeU32;
            variantList[i].uintVal = uintISOList[i];;
        }
        attribute->updateValueList(&variantList[0], listLen, isReadOnly);
    }
}


Let us know if that helps, thanks.
**Any post by me prior to Aug 2014 was before i started working for Blackmagic**
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Braw SDK v1.8 ISO attribute reading - observation

PostThu Jul 16, 2020 5:37 pm

This is super helpful, thank you! I didn't do dynamic resizing of arrays because I'm lazy :) but it didn't occur to me that I need to set the variant type, I thought it was basically an union data type.

I'll improve my code and seems that I have some new stuff to try too, from new 12K Ursa 8-)
I do stuff.
Offline

CaptainHook

Blackmagic Design

  • Posts: 2054
  • Joined: Wed Aug 22, 2012 4:50 am
  • Location: Melbourne, Australia
  • Real Name: Hook

Re: Braw SDK v1.8 ISO attribute reading - observation

PostThu Jul 16, 2020 5:46 pm

Have fun. :)
**Any post by me prior to Aug 2014 was before i started working for Blackmagic**

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 11 guests