[FFmpeg-devel] [PATCH 2/2] Add hflip filter.

Frank Barchard fbarchard
Thu Aug 5 23:33:42 CEST 2010


On Wed, Aug 4, 2010 at 5:23 AM, Michael Niedermayer <michaelni at gmx.at>wrote:

> variable length memcpy on a per pixel base is slow
>

Ya, thats what I was thinking.  It supports many pixel formats, but wouldnt
be fast enough for realtime.

Check the pixel size and write a function that deals with that size, for at
least the common cases.

The ideal is something like bswap or pshufb.  pshuf can handle byte, word or
dword, but not 3 bytes (RGB) naturally... you'd have to unroll more.
in libavcodec/dsputil.c theres an endian swapping function that is close to
what you need

static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){    int i;
    for(i=0; i+8<=w; i+=8){        dst[i+0]= av_bswap32(src[i-0]);
   dst[i+1]= av_bswap32(src[i-1]);        dst[i+2]=
av_bswap32(src[i-2]);        dst[i+3]= av_bswap32(src[i-3]);
dst[i+4]= av_bswap32(src[i-4]);        dst[i+5]= av_bswap32(src[i-5]);
       dst[i+6]= av_bswap32(src[i-6]);        dst[i+7]=
av_bswap32(src[i-7]);    }    for(;i<w; i++){        dst[i+0]=
av_bswap32(src[i-0]);    }}

Then figure out how to do something like bswap but for other pixel types.

Looking at pixfmt.h your current code could handle more of the formats.



More information about the ffmpeg-devel mailing list