Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Question about Gamma Table example and structs

Participant ,
Oct 29, 2016 Oct 29, 2016

Hello. In the Gamma Table example there is this code:

typedef struct {

  PF_Fixed gamma_val;

  A_u_char lut[256];

} Gamma_Table;

typedef struct {

unsigned char  *lut;

} GammaInfo;

How come a struct is used to create a pointer to lut inside Gamma_Table? If there is only one data type is this pointless or does it have a reason? Thanks.

TOPICS
SDK
442
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Nov 03, 2016 Nov 03, 2016

The first struct (Gamma_Table) is used as the effect's sequence data. It contains the gamma lookup table (lut), and the gamma value. In Render, the value of gamma_val is compared against the parameter, and if they differ, the lut is re-generated.


The second struct (GammaInfo) is used as the refcon, which is passed to the iterate function to process the pixels. In this case the lut is just a pointer, which is assigned the address of the sequence data lut.

The reason for having separate structs is t

...
Translate
Engaged ,
Nov 03, 2016 Nov 03, 2016

The first struct (Gamma_Table) is used as the effect's sequence data. It contains the gamma lookup table (lut), and the gamma value. In Render, the value of gamma_val is compared against the parameter, and if they differ, the lut is re-generated.


The second struct (GammaInfo) is used as the refcon, which is passed to the iterate function to process the pixels. In this case the lut is just a pointer, which is assigned the address of the sequence data lut.

The reason for having separate structs is to keep the sequence and render data separate. In this case the only data passed to the iterate function is the lut, but in reality you may have other data that's required for rendering. You'd store that in the second struct.

Hope that makes sense!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 16, 2016 Nov 16, 2016
LATEST

Thanks Christian. I was initially confused because structs are for storing variables of different types, and in this example the second struct only contains one item. But your explanation makes sense.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines