On Tue, Apr 7, 2009 at 11:16, <[email protected]> wrote:

> Can I use AVPicture structure defined in the stack? I'm using Microsoft
> Visual Studio 2008, and I've read about stack alignment issues.
>
> This is my code:
>
> ....
> AVPicture pict;
> avpicture_fill(&pict, buffer, PIX_FMT_BGR24, c->width, c->height);
> .....
>

I been using libav* compiled in mingw from my visual-c++ project quite
extensively over the last two years.
my conclusions are:

   1. stack alignment is needed for certain MMX/SSE instructions. this
   should (and usually is) handled internally within ffmpeg, and does not
   concern visual c++ developer
   2. memory buffers usually need to be 16 byte aligned. this should be
   handled by visual-c++ developer by either
      1. using exclusively av_malloc and/or av_* functions for allocating
      memory buffers
      2. writing custom allocators or using directshow allocators for
      achieving the same functionality as av_malloc
   3. certain functions in ffmpeg allocate a lot of space *on the stack *(like
   jpeg decoding). if you have crashes of the "stack overflow" kind when
   calling ffmpeg, make sure you have decently sized stacks of at least 1MB.

so with regard to your specific question, you should worry about issue #2
and not about #1

AVPicture pict;
*uint8_t* buffer = av_malloc ( ... ) ;*
avpicture_fill(&pict, buffer, PIX_FMT_BGR24, c->width, c->height);


-- 
Aviad Rozenhek
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to