[FFmpeg-devel] [PATCH] install aes.h, des.h and rc4.h

Michael Niedermayer michaelni
Sat Feb 7 13:37:13 CET 2009


On Sat, Feb 07, 2009 at 12:11:15PM +0100, Reimar D?ffinger wrote:
> On Fri, Feb 06, 2009 at 11:38:53PM +0100, Michael Niedermayer wrote:
> > On Fri, Feb 06, 2009 at 11:18:57PM +0100, Reimar D?ffinger wrote:
> > > On Fri, Feb 06, 2009 at 10:33:00PM +0100, Michael Niedermayer wrote:
> > > > On Fri, Feb 06, 2009 at 09:53:16PM +0100, Reimar D?ffinger wrote:
> > > > > But maybe we can find a better solution.
> > > > > What about a
> > > > > void *av_alloca(uint8_t *);
> > > > > Usage would be
> > > > > uint8_t buffer[size + AV_ALLOCA_PADDING];
> > > > > struct AVAES *a = av_alloca(buffer);
> > > > > 
> > > > > Does that seem like it might make a good solution or does it have
> > > > > serious issues?
> > > > 
> > > > its not particularely pretty and something should be done to make it
> > > > less error prone, also no function call should happen just a macro
> > > >  or inline function
> > > 
> > > I did intend to make the function static inline.
> > > I think it will always ugly, though maybe something like (untested)
> > > #define AV_STACK_VAR(type, name, size) \
> > >     uint8_t name ff_alloca_##name##_buffer[size + 16]; \
> > >     type name = ff_alloca_##name##_buffer + ((-(long)ff_alloca_##name##_buffer - 1)&15) + 1;
> > > 
> > > fits your idea better?
> > 
> > type name = ff_alloca_##name##_buffer + ((-(long)ff_alloca_##name##_buffer)&15);
> > and +15 should be enough
> 
> I was too tired to think about it so I just copy-and-pasted the malloc
> stuff.
> So like this (note the ugly casting is to make sure it works with C++ as
> well, and I haven't tested it yet):
> Index: libavutil/mem.h
> ===================================================================
> --- libavutil/mem.h     (revision 16989)
> +++ libavutil/mem.h     (working copy)
> @@ -41,6 +41,17 @@
>  #endif
>  
>  /**
> + * Allocate data on the stack with sufficient alignment for all operations
> + * and assign it to the given variable.
> + * @param type type of the created variable, must be a pointer type
> + * @param name name of the created variable
> + * @param size Size in bytes for the memory block to be allocated.
> + */
> +#define AV_STACK_VAR(type, name, size) \
> +    uint8_t ff_alloca_##name##_buffer[size + 15]; \
> +    type name = (type)(void *)(ff_alloca_##name##_buffer + ((-(long)ff_alloca_##name##_buffer)&15));
> +
> +/**
>   * Allocates a block of \p size bytes with alignment suitable for all
>   * memory accesses (including vectors if available on the CPU).
>   * @param size Size in bytes for the memory block to be allocated.

iam not against this, though it isnt particularely pretty ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090207/0cd58d5e/attachment.pgp>



More information about the ffmpeg-devel mailing list