[FFmpeg-devel] [PATCH] make sure blending the subtitle does not write outside buffer

Michael Niedermayer michaelni
Wed Aug 8 19:04:29 CEST 2007


On Wed, Aug 08, 2007 at 03:51:26PM +0200, Reimar D?ffinger wrote:
> Hello,
> On Wed, Aug 08, 2007 at 03:50:22PM +0200, Reimar D?ffinger wrote:
> > On Sun, Aug 05, 2007 at 12:12:26PM +0200, Michael Niedermayer wrote:
> > > On Sun, Aug 05, 2007 at 11:00:04AM +0200, Reimar D?ffinger wrote:
> > > > attached patch fixes the subtitle rectangles so they do not lie outside
> > > > the video, which can cause crashes.
> > > 
> > > hmm, this seems like a hack to me
> > > shouldnt blend_subrect "skip" the parts of a rectange which are outside
> > > of the image?
> > > 
> > > that said blend_subrect() needs a cleanup, theres no need to have 9 cases
> > > handled like that, a generic and a fast one for the middle would do
> > 
> > Does something like this look okay? I can of course split it into two
> > parts, on that makes sure we do not get outside the bounds of the
> > destination image 

iam ok with the out of bounds checks if they also support x,y<0 ? well
iam even ok if they dont, its just that x,y<0 must be fixed too :)

> > and one that "scales" the x and y positions, but then
> > someone absolutely must suggest a better name for "scaledx/y/w/h" ;-)

the bitmap should be scaled if it is intended for a different display size
whichever function then does the blending would only see the scaled x/y/w/h
we of course can also support quick and dirty unscaled subs but that shouldnt
be default

> > Btw. the picture blend_subrect creates when x, y or x+w or y+h is odd is
> > still completely broken, IMO we should remove the "if (rect->x & 1) {"
> > etc. cases and just do x &= ~1; w &= ~1; etc.

x,y should have higher than 1-pixel precission, the code which scales it
to display size should also fix the sub pixel translation
that way the &1 code indeed is no longer needed, so yes you can remove
it whenever you like

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/20070808/9c3a9500/attachment.pgp>

More information about the ffmpeg-devel mailing list