diff options
author | wm4 <wm4@nowhere> | 2016-06-18 12:08:17 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-06-18 12:08:17 +0200 |
commit | 9215a9e59889c7a2f600c618501ace1360bf810d (patch) | |
tree | 765772f6abbde2badcf4259a2e0479dd2ebe32ec /sub/sd_lavc.c | |
parent | 689cf04571109ea12b3cddc61a6eb43ceb768c63 (diff) | |
download | mpv-9215a9e59889c7a2f600c618501ace1360bf810d.tar.bz2 mpv-9215a9e59889c7a2f600c618501ace1360bf810d.tar.xz |
sd_lavc: align sub-bitmaps for the sake of libswscale
Since there are not many sub-rectangles, this doesn't cost too much. On
the other hand, it avoids frequent warnings with vo_xv.
Also, the second copy in mp_blur_rgba_sub_bitmap() can be dropped.
Diffstat (limited to 'sub/sd_lavc.c')
-rw-r--r-- | sub/sd_lavc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index 71bb551013..6661e4fac8 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -223,6 +223,10 @@ static void read_sub_bitmaps(struct sd *sd, struct sub *sub) priv->packer->padding = padding; + // For the sake of libswscale, which in some cases takes sub-rects as + // source images, and wants 16 byte start pointer and stride alignment. + int align = 4; + for (int i = 0; i < avsub->num_rects; i++) { struct AVSubtitleRect *r = avsub->rects[i]; struct sub_bitmap *b = &sub->inbitmaps[sub->count]; @@ -238,7 +242,7 @@ static void read_sub_bitmaps(struct sd *sd, struct sub *sub) b->bitmap = r; // save for later (dumb hack to avoid more complexity) - priv->packer->in[sub->count] = (struct pos){r->w, r->h}; + priv->packer->in[sub->count] = (struct pos){r->w + (align - 1), r->h}; sub->count++; } @@ -283,6 +287,10 @@ static void read_sub_bitmaps(struct sd *sd, struct sub *sub) b->h = r->h; b->x = r->x; b->y = r->y; + + // Choose such that the extended start position is aligned. + pos.x = MP_ALIGN_UP(pos.x - extend, align * 4) + extend; + b->src_x = pos.x; b->src_y = pos.y; b->stride = sub->data->stride[0]; |