[FFmpeg-devel] [PATCH 7/7] Add alias-safe aligned AV_[RW]N macros

Måns Rullgård mans
Mon Feb 8 12:57:41 CET 2010


Michael Niedermayer <michaelni at gmx.at> writes:

> On Sun, Feb 07, 2010 at 01:06:41PM +0000, M?ns Rullg?rd wrote:
>> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
>> 
>> > On Fri, Feb 05, 2010 at 10:51:59AM +0100, Michael Niedermayer wrote:
>> >> On Sun, Jan 31, 2010 at 02:08:29AM +0000, M?ns Rullg?rd wrote:
>> >> > Michael Niedermayer <michaelni at gmx.at> writes:
>> >> > 
>> >> > > On Fri, Jan 29, 2010 at 02:12:14AM +0000, Mans Rullgard wrote:
>> >> > >> ---
>> >> > >>  libavutil/intreadwrite.h |   32 ++++++++++++++++++++++++++++++++
>> >> > >>  1 files changed, 32 insertions(+), 0 deletions(-)
>> >> > >> 
>> >> > >> diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
>> >> > >> index 631db75..61ad488 100644
>> >> > >> --- a/libavutil/intreadwrite.h
>> >> > >> +++ b/libavutil/intreadwrite.h
>> >> > >> @@ -418,6 +418,38 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
>> >> > >>      } while(0)
>> >> > >>  #endif
>> >> > >>  
>> >> > >> +/*
>> >> > >> + * The AV_[RW]NA macros access naturally aligned data
>> >> > >> + * in a type-safe way.
>> >> > >> + */
>> >> > >> +
>> >> > >> +#define AV_RNA(s, p)    (((const ff_alias##s*)(p))->u##s)
>> >> > >> +#define AV_WNA(s, p, v) (((ff_alias##s*)(p))->u##s = (v))
>> >> > >
>> >> > > do we really need yet another set?
>> >> > 
>> >> > We need one set for aligned accesses and one for unaligned, yes.
>> >> 
>> >> yes i agree, doesnt mean i like it though
>> >
>> > What I don't particularly like is that "NA" is a bit confusing, unless
>> > you extrapolate from the other naming it might just as well mean "not aligned".
>> > No, I don't have better ideas...
>> 
>> We could rename the other ones into AV_[RW]*U...
>
> or always inlude the U / A, this would decrease the chance of people using
> AV_[RW] and expectings its alignment requirements to be different from
> what they are

That's what I meant.  I guess I wasn't clear.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list