[FFmpeg-devel] Indeo3 replacement, part 2

Michael Niedermayer michaelni
Fri Oct 2 12:25:55 CEST 2009


On Fri, Oct 02, 2009 at 12:56:38AM +0200, Maxim wrote:
> M?ns Rullg?rd schrieb:
> > Maxim <max_pole at gmx.de> writes:
> >
> >   
> >> Reimar D?ffinger schrieb:
> >>     
> >>> On Tue, Sep 22, 2009 at 12:09:23AM +0200, Maxim wrote:
> >>>   
> >>> [...]
> >>>       
> >>>> /**
> >>>>  *  Average 4/8 pixels at once without rounding using softSIMD
> >>>>  */
> >>>> #define AVG_32(dst, src, ref)   AV_WN32((dst), ((AV_RN32(src) + AV_RN32(ref)) >> 1) & 0x7F7F7F7F)
> >>>> #define AVG_64(dst, src, ref)   AV_WN64((dst), ((AV_RN64(src) + AV_RN64(ref)) >> 1) & 0x7F7F7F7F7F7F7F7F)
> >>>>     
> >>>>         
> >>> Are all of src, dst, ref unaligned in general? If not, you should be
> >>> using casts instead of AV_RN*
> >>>   
> >>>       
> >> Could someone skilled in the art explain me the difference between a
> >> cast and an AV_RNxx?
> >> I don't see any because the AV_RNxx macros use casts as well...
> >>     
> >
> > AV_RN* support unaligned reads, simple casts do not.
> >
> >   
> >> The code above looks more readable for me when using those macros than
> >> smth like this:
> >>
> >> #define AVG_64(dst, src, ref) \
> >>         *((uint64_t *)(dst)) = ((*((uint64_t *)(src)) + *((uint64_t
> >> *)(ref))) >> 1) & 0x7F7F7F7F7F7F7F7F
> >>     
> >
> > That will not work if any of the pointers are unaligned.
> >
> >   
> 
> Thanks! All my pointers are always aligned at least on the int32_t
> boundary. Should I rework my code to use casts all the way (remove all
> AV_RNxx macros respectively)?

if alignment is sufficient then a cast is better, int64_t needs 8 byte
alignment though ...

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- 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/20091002/377e91da/attachment.pgp>



More information about the ffmpeg-devel mailing list