[FFmpeg-devel] [RFC] Alpha support
Michael Niedermayer
michaelni
Mon Feb 2 20:47:02 CET 2009
On Sun, Feb 01, 2009 at 04:52:02PM +0100, C?dric Schieli wrote:
> [...]
>
> > - case PIX_FMT_RGB32:\
> > > - case PIX_FMT_BGR32:\
> > > - case PIX_FMT_RGB32_1:\
> > > - case PIX_FMT_BGR32_1:\
> > > - func(uint32_t)\
> > > - ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
> > > - ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
> > > - } \
> > > + case PIX_FMT_RGBA:\
> > > + case PIX_FMT_BGRA:\
> > > + if (!CONFIG_SMALL && c->alpPixBuf)\
> > > + {\
> > > + func(uint32_t,1)\
> > > + ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] +
> > (A1<<24);\
> > > + ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] +
> > (A2<<24);\
> > > + }\
> > > + }else{\
> > > + func(uint32_t,CONFIG_SMALL)\
> > > + ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] +
> > (CONFIG_SMALL ? (A1<<24) : 0);\
> > > + ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] +
> > (CONFIG_SMALL ? (A2<<24) : 0);\
> > > + }\
> > > + }\
> > > + break;\
> > > + case PIX_FMT_ARGB:\
> > > + case PIX_FMT_ABGR:\
> >
> > is it faster the way you wrote it compared to a table that does <<24 vs.
> > <<0 ?
> > iam asking because the table would lead to simpler and less duplicated code
> >
>
> I've tried the table approach with this :
>
> SwsContext *sws_getContext(...){
> ...
> if (c->alpPixBuf){
> int j = (c->dstFormat == PIX_FMT_RGBA || c->dstFormat ==
> PIX_FMT_BGRA) ? 24 : 0;
> for(i=0; i<256; i++)
> c->table_A[i] = (i<<j);
> }else{
> memset(c->table_A, 0, sizeof(c->table_A));
> }
> ...
> }
>
> #define YSCALE_YUV_2_ANYRGB_C(func, func2, func_g16, func_monoblack)\
> switch(c->dstFormat)\
> {\
> case PIX_FMT_RGB32:\
> case PIX_FMT_BGR32:\
> case PIX_FMT_RGB32_1:\
> case PIX_FMT_BGR32_1:\
> if (!CONFIG_SMALL && c->alpPixBuf){\
> uint32_t *a = c->table_A;\
> func(uint32_t,1)\
> START_TIMER\
> ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + a[A1];\
> ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + a[A2];\
> STOP_TIMER(__func__)\
> }\
you should not place the TIMER code inside the innermost loop as this likely
affects how the loop is compiled
anyway the speed difference appears negligible
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- 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/20090202/a5d04fae/attachment.pgp>
More information about the ffmpeg-devel
mailing list