diff options
author | wm4 <wm4@nowhere> | 2012-10-25 19:37:43 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-28 15:31:31 +0100 |
commit | 18d4eebedb7f80493da87f8506ff0b2db796510a (patch) | |
tree | 4f0f75a3358a52bc677a8696ec5dd8f7fe07dc4b /sub/sub.c | |
parent | 06a45265194dc7e18475de9e3531977e32d7c196 (diff) | |
download | mpv-18d4eebedb7f80493da87f8506ff0b2db796510a.tar.bz2 mpv-18d4eebedb7f80493da87f8506ff0b2db796510a.tar.xz |
draw_bmp: cosmetics, refactor
Mostly pedantic bikeshedding issues.
Move some code around, so that the sub_bitmap_to_mp_images() function
can be split into two parts. This is better than having a big function
with many input and outputs, of which only half are used in each code
path.
Also, try to make code simpler by using a mp_rect type.
Diffstat (limited to 'sub/sub.c')
-rw-r--r-- | sub/sub.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -23,7 +23,7 @@ #include <libavutil/common.h> -#include "config.h" +#include "mpcommon.h" #include "stream/stream.h" @@ -269,22 +269,22 @@ void vo_osd_changed(int new_value) osd->want_redraw = true; } -bool sub_bitmaps_bb(struct sub_bitmaps *imgs, int *x1, int *y1, - int *x2, int *y2) +bool sub_bitmaps_bb(struct sub_bitmaps *imgs, struct mp_rect *out_bb) { - *x1 = *y1 = INT_MAX; - *x2 = *y2 = INT_MIN; + struct mp_rect bb = {INT_MAX, INT_MAX, INT_MIN, INT_MIN}; for (int n = 0; n < imgs->num_parts; n++) { struct sub_bitmap *p = &imgs->parts[n]; - *x1 = FFMIN(*x1, p->x); - *y1 = FFMIN(*y1, p->y); - *x2 = FFMAX(*x2, p->x + p->dw); - *y2 = FFMAX(*y2, p->y + p->dh); + bb.x0 = FFMIN(bb.x0, p->x); + bb.y0 = FFMIN(bb.y0, p->y); + bb.x1 = FFMAX(bb.x1, p->x + p->dw); + bb.y1 = FFMAX(bb.y1, p->y + p->dh); } // avoid degenerate bounding box if empty - *x1 = FFMIN(*x1, *x2); - *y1 = FFMIN(*y1, *y2); + bb.x0 = FFMIN(bb.x0, bb.x1); + bb.y0 = FFMIN(bb.y0, bb.y1); - return *x1 < *x2 && *y1 < *y2; + *out_bb = bb; + + return bb.x0 < bb.x1 && bb.y0 < bb.y1; } |