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

AEIO color bleeding

Guest
Sep 22, 2014 Sep 22, 2014

Copy link to clipboard

Copied

Hi all,

I have a basic AEIO plugin that

I'm interested in outputting the frame sequence of my composition the same as with output format to PNG frame sequence.

In the my current configuration I get ARGB pixels that carry the blending with the background.

So the pixels that are semi transparent (i.e in (0,1)) the color is the background color, which results with color bleeding.

I tried to set AEGP_SetOutSpecAlphaLabel and AEGP_SetOutSpecDepth.

alpha.alpha=AEIO_Alpha_PREMUL;
alpha.flags=AEIO_AlphaPremul;
alpha.version=AEIO_AlphaLabel_VERSION;
alpha.red=0;
alpha.green=0;
alpha.blue=0;

but there is still color bleeding in the borders.

I tried to set AEIO_Alpha_STRAIGHT but the pixels gets stretched.


a code snippet for doing that would be great.

attached is the png format example, and my format.png_format_AE.pngmyFormat_AE.png

TOPICS
SDK

Views

893

Translate

Translate

Report

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

Enthusiast , Sep 28, 2014 Sep 28, 2014

Right, you have to use rowbytes, and should not assume that the last pixel from one row will just bump into the first pixel from the next. My code typically looks like this:

char *row = worldP->data;

for(int y=0; y < worldP->height; y++)

{

    PF_Pixel8 *pix = (PF_Pixel8 *)row;

    for(int x=0; x < worldP->width; x++)

    {

          // do something here

          red = pix->red;

          green = pix->green;

          blue = pix->blue;

          alpha = pix->alpha;

          pix++;

    }

    row += worldP->r

...

Votes

Translate

Translate
Enthusiast ,
Sep 22, 2014 Sep 22, 2014

Copy link to clipboard

Copied

Yep this PNG was saved as premultipled, but PNG expect straight alpha. Seems like what you're doing would set it properly. What premultiplied state do you see in AE's output module?

What do you mean when you say the pixels get stretched when you set it to straight?

Votes

Translate

Translate

Report

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
Guest
Sep 23, 2014 Sep 23, 2014

Copy link to clipboard

Copied

fnordware wrote:

Yep this PNG was saved as premultipled, but PNG expect straight alpha. Seems like what you're doing would set it properly. What premultiplied state do you see in AE's output module?

What do you mean when you say the pixels get stretched when you set it to straight?

1)AEGP_SetOutSpecDepth (32)

2) AEGP_SetOutSpecAlphaLabel :

3)update:  I also tried to set AEGP_SetOutputChannels :AEGP_VideoChannels_RGBA during AEIO_AddFrame but it still ends up RGB

i.e

  AEGP_RQItemRefH rq_itemH = NULL;

  AEGP_OutputModuleRefH outmodH = NULL;

  err = suites.IOOutSuite()->AEGP_GetOutSpecOutputModule(outH, &rq_itemH, &outmodH);

  AEGP_VideoChannels outchannelsP = AEGP_VideoChannels_RGBA;

  err = suites.OutputModuleSuite()->AEGP_SetOutputChannels(rq_itemH, outmodH, outchannelsP);//i.e set to RGBA

  err = suites.OutputModuleSuite()->AEGP_GetOutputChannels(rq_itemH, outmodH, &outchannelsP);//return RGB!

  alpha.alpha = AEIO_Alpha_STRAIGHT;

  alpha.flags = 0;

  alpha.version = AEIO_AlphaLabel_VERSION;

  alpha.red = 0;

  alpha.green = 0;

  alpha.blue = 0;


But It will automatically change output module channels to RGB  (instead of RGB+alpha - because I chose depth to be 32!)

(I think I get the stretched buffers because in this option it will output only 24bit depth and not 32)

in fact , you can see the color output is locked when I chose RGB+alpha: I cannot change it to straight.

video_out_options.JPG

I would like to just set it to RGB+alpha , Straight Color : like in the png sequence:

png_format.JPG

Thanks!

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 23, 2014 Sep 23, 2014

Copy link to clipboard

Copied

During which AEIO callback are you doing all this? Generally I would only expect this stuff to work during AEIO_UserOptionsDialog. The idea is that the user changed some options related to bit depth or alpha and now you're changing the output module. But usually you don't do this.

What are you telling AE you support during AEIO_GetDepths?

PF_EffectWorld always holds RGBA, even when the output module is set to 24-bit. It's up to you to skip the alpha. If you're using libpng and it expects RGBRGBRGB, you'll need to make a new buffer and copy your samples into it.

Votes

Translate

Translate

Report

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
Guest
Sep 28, 2014 Sep 28, 2014

Copy link to clipboard

Copied

Thanks for the answer,

>>During which AEIO callback are you doing all this? Generally I would only expect this stuff to work during AEIO_UserOptionsDialog.

as far as I understand the UserOptionsDialog is for extra formatting options

i.e "is called when the user clicks on the Format Options"

I'm only intrested in the basic output settings :

I would like to set Video Output setting to:

Channels : RGB+alpha

Depth : Milions of colors+

color: Straight

I would prefer to have it the default , i.e probably setting it during AEIO_InitOutputSpec or AEIO_GetFlatOutputOptions.

This is what I'm trying to do today.

>>What are you telling AE you support during AEIO_GetDepths?

AEIO_SupportedDepthFlags *which = AEIO_SupportedDepthFlags_DEPTH_32;


>>PF_EffectWorld always holds RGBA, even when the output module is set to 24-bit. It's up to you to skip the alpha. If you're using libpng and it expects RGBRGBRGB,

Output Module has direct effect on the content of the pixels.

see the two examples above : in the PNG sequence I get no background color (bleeding) in the alpha channel

I'm not using libpng, and I want to achieve outputing of RGBA 32-bit, so no skipping is needed - on the contrary.

p.s

attached is the stretched results.testAE_BGRA.png

Update: I get a PF_EffectWorld with rowBytes = 2576  , while the width is 640 (640*4 = 2560)

which means there are extra 4 pixels in each row.

What is the correct way to iterate over PF_EffectWorld?

Update2:

this worked for me:

PF_Pixel8 raw[wP->height*wP->width];

memset(raw, 0, wP->height*wP->width*sizeof(PF_Pixel8));

  for (int ix=0; ix < wP->height; ++ix)

  {

       memcpy( &raw[(ix * wP->width )],

       wP->data + ix * wP->rowbytes/sizeof(PF_Pixel8) , 

       wP->width * sizeof(PF_Pixel8));

  }

Thanks!

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 28, 2014 Sep 28, 2014

Copy link to clipboard

Copied

Right, you have to use rowbytes, and should not assume that the last pixel from one row will just bump into the first pixel from the next. My code typically looks like this:

char *row = worldP->data;

for(int y=0; y < worldP->height; y++)

{

    PF_Pixel8 *pix = (PF_Pixel8 *)row;

    for(int x=0; x < worldP->width; x++)

    {

          // do something here

          red = pix->red;

          green = pix->green;

          blue = pix->blue;

          alpha = pix->alpha;

          pix++;

    }

    row += worldP->rowbytes;

}

Votes

Translate

Translate

Report

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
Enthusiast ,
Sep 28, 2014 Sep 28, 2014

Copy link to clipboard

Copied

LATEST

BTW, I have the complete source for an AEIO available here on GitHub. And it's not just any AEIO—it's actually the OpenEXR plug-in that ships with AE.

It may not be the best thing to use when learning to write an AEIO because it's fairly complicated with caching and such. But actually, the writing of files is pretty straight forward. Especially take a look at OpenEXR.cpp. Most of the AE-specific calls are in FrameSeq.cpp.

Part of the reason I made this open source was because I didn't have a real working example when I was first learning to write AEIOs, and didn't want other people to have to go through the same.

Votes

Translate

Translate

Report

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