[FFmpeg-devel] [PATCH] swscale alpha channel support
Cédric Schieli
cschieli
Mon Feb 23 17:07:02 CET 2009
2009/2/23 Kostya <kostya.shishkov at gmail.com>
> On Mon, Feb 23, 2009 at 04:22:23PM +0100, Michael Niedermayer wrote:
> > On Mon, Feb 23, 2009 at 04:16:44PM +0100, C?dric Schieli wrote:
> [...]
> > > Index: ffmpeg/libswscale/yuv2rgb2.c
> > > ===================================================================
> > > --- ffmpeg.orig/libswscale/yuv2rgb2.c 2009-02-23
> 15:14:39.409161445 +0100
> > > +++ ffmpeg/libswscale/yuv2rgb2.c 2009-02-23 15:17:36.861446441 +0100
> > > @@ -83,11 +83,11 @@
> > > g = (void *)(c->table_gU[U] + c->table_gV[V]); \
> > > b = (void *)c->table_bU[U];
> > >
> > > -#define PUTRGB(dst,src,i,o) \
> > > - Y = src[2*i+o]; \
> > > - dst[2*i ] = r[Y] + g[Y] + b[Y]; \
> > > - Y = src[2*i+1-o]; \
> > > - dst[2*i+1] = r[Y] + g[Y] + b[Y];
> > > +#define PUTRGB(dst,src,i,o,a) \
> > > + Y = src[2*i+o]; \
> > > + dst[2*i ] = r[Y] + g[Y] + b[Y] + (a); \
> > > + Y = src[2*i+1-o]; \
> > > + dst[2*i+1] = r[Y] + g[Y] + b[Y] + (a);
> > >
> > > #define PUTRGB24(dst,src,i) \
> > > Y = src[2*i]; \
> >
> > alpha can be merged in the table i think which avoids that 1 add per
> pixel
>
> I don't think so - it's independent channel that is copied between
> different
> formats (YUV, RGB, whatever).
>
With something like that ?
--- ffmpeg.orig/libswscale/yuv2rgb2.c 2009-02-23 15:14:39.409161445 +0100
+++ ffmpeg/libswscale/yuv2rgb2.c 2009-02-23 16:58:45.009146149 +0100
@@ -533,7 +533,7 @@
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
- int i, base, rbase, gbase, bbase;
+ int i, base, rbase, gbase, bbase, abase;
const int yoffs = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
@@ -659,12 +659,13 @@
rbase = base + (isRgb ? 16 : 0);
gbase = base + 8;
bbase = base + (isRgb ? 0 : 16);
+ abase = (c->dstFormat == PIX_FMT_RGBA || c->dstFormat ==
PIX_FMT_BGRA) ? 24 : 0;
c->yuvTable = av_malloc(1024*3*4);
y_table32 = c->yuvTable;
yb = -(384<<16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
- y_table32[i ] = yval << rbase;
+ y_table32[i ] = (yval << rbase) + (255 << abase);
y_table32[i+1024] = yval << gbase;
y_table32[i+2048] = yval << bbase;
yb += cy;
It works, but I find it a little bit hackish. And that will complicate
further the yuva2rgb case.
Regards,
C?dric Schieli
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list