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

How to get a byte aligned memory for SSE instructions.

New Here ,
Apr 15, 2015 Apr 15, 2015

I'd like to get a aligned memory for SSE instruction on AE CS5.5

Does any one know the way to get an aligned memory in the AE memory management framework?

Very best regards.

TOPICS
SDK
691
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
Community Expert ,
Apr 15, 2015 Apr 15, 2015

AE dispenses memory chunks by size, specified in bytes.

if i understand what you mean by "aligned" and "SSE" correctly, then isn't

it an issue of compiling structures with the correct alignment, rather than

the memory allocation?

perhaps i don't understand your question fully...

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
New Here ,
Apr 15, 2015 Apr 15, 2015

Thank you for your quick reply.

I mean how to realize 16 byte memory alignment  for SSE instructions on AE.

According to the AE user manual, 16 byte memory alignment is not guaranteed .

"

The pixels in a PF_EffectWorld are not guaranteed to be 16-byte-aligned. An effect may get a subregion of a larger PF_EffectWorld. Users of Apple’s sample code for pixel processing optimization, you have been warned.

"

_aligned_malloc‌‌ can be used for this purpose but I think allocated memory is deviated from AE memory management framework.

Best regards.

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
Community Expert ,
Apr 16, 2015 Apr 16, 2015

the quote from the docs refers to the way AE handles it's buffer pixels in memory. i don't see how memory you allocate has anything to do with it.

it basically says that is you get the base address of a buffer (the address of the upper left pixel) you can't rely on the next lines to start at (base + y *  width). hence you can't transfer that that pixel's address to processes that rely on that assumption.

i don't know of a way to ask AE for the buffer data at any other way...

you'll just need to copy the buffer pixels into a new and controlled memory chunk.

am i completely off here? what exactly are you trying to do, and where did you get stuck?

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
New Here ,
Apr 16, 2015 Apr 16, 2015
LATEST

Sorry for lack of explanation.

In my plugin, I usually allocate memory by following way.

int bufferSize = imageWidth * imageHeight * 4;

AEGP_SuiteHandler suites(in_data->pica_basicP);

PH_Handle handler = (PF_Handle)suites.HandleSuite1()->host_new_handle(sizeof(float) * bufferSize);

float *p = reinterpret_cast<T*>(suites.HandleSuite1()->host_lock_handle(handler));

// The code below does not work

for(int h = 0; h < imageHeight; h++)

{

  for(int w = 0; w < imageWidth; w++)

  {

  index = imageWidth * h * 4 + w * 4;

  __m128 s = _mm_loadu_ps(p + index);

  }

}

// dispose memory

suites.HandleSuite1()->host_unlock_handle(handler);

suites.HandleSuite1()->host_dispose_handle(handler);

The allocated memory is not aligned to a 16-byte boundary, right?

I'd like to know whether we can allocate a memory (suitable for SSE) with 16-byte boundary using AE SDK or not.

Thanks a lot.

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