[FFmpeg-devel] [PATCH] Add drawtext filter from the libavfilter soc repo.
Nicolas George
nicolas.george
Fri Feb 18 16:04:22 CET 2011
Le decadi 30 pluvi?se, an CCXIX, M?ns Rullg?rd a ?crit?:
> > + alpha = (yuv_color[3] * (val)) >> 8; \
> > + picref->data[0][luma_pos ] = (alpha * yuv_color[0] + (255 - alpha) * picref->data[0][luma_pos ]) >> 8; \
> > + picref->data[1][chroma_pos1] = (alpha * yuv_color[1] + (255 - alpha) * picref->data[1][chroma_pos1]) >> 8; \
> > + picref->data[2][chroma_pos2] = (alpha * yuv_color[2] + (255 - alpha) * picref->data[2][chroma_pos2]) >> 8; \
> > +}
> Strictly speaking, the >>8 is wrong, but I guess the difference is small
> enough that it doesn't matter.
Since there are multiplications anyway, it might probably be possible to use
the same trick used in mplayer's vf_ass, which is that x/255 is very near to
(257*x)>>16:
opacity = (0x10203 * opacity + 0x80) >> 8; /* 0x10203 = (1<<32)/(255*255) */
/* 0 <= opacity <= 0x10101 */
k *= opacity; /* 0 <= k <= 0xFFFFFF */
dsty[j] = (k * y + (0xFFFFFF - k) * dsty[j] + 0x800000) >> 24;
(in this particular case, we had two alpha coefficients, and therefore
divided by 255*255)
This is both faster than a division and more accurate than just a shift.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110218/637b7ad0/attachment.pgp>
More information about the ffmpeg-devel
mailing list