summaryrefslogtreecommitdiffstats
path: root/libvo/bitmap_packer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-28 21:19:36 +0200
committerwm4 <wm4@nowhere>2012-10-16 07:26:28 +0200
commitffb7a2fe17af204635db6694b5b49b6368be91e6 (patch)
tree2aa0814e4cf37443bb01b50a23c19b28547a99f1 /libvo/bitmap_packer.c
parent65ea69f56476aabb0755ae80b7dc565df23ab426 (diff)
downloadmpv-ffb7a2fe17af204635db6694b5b49b6368be91e6.tar.bz2
mpv-ffb7a2fe17af204635db6694b5b49b6368be91e6.tar.xz
sub: create sub_bitmap array even when using libass
One sub_bitmaps struct could contain either a libass ASS_Image list, or a mplayer native list of sub-bitmaps. This caused code duplication in vo_vdpau.c and bitmap_packer.c. Avoid this by creating such a sub_bitmap array even with libass. This basically copies the list and recreates it in mplayer's native format. It gets rid of the code duplication, and will make implementing extended subtitle and OSD rendering in other VOs easier. Also do some cosmetic changes and other preparations for the following commits.
Diffstat (limited to 'libvo/bitmap_packer.c')
-rw-r--r--libvo/bitmap_packer.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/libvo/bitmap_packer.c b/libvo/bitmap_packer.c
index eedc2e2242..5e5bafea0c 100644
--- a/libvo/bitmap_packer.c
+++ b/libvo/bitmap_packer.c
@@ -30,6 +30,24 @@
#include "sub/ass_mp.h"
#include "sub/dec_sub.h"
+void packer_reset(struct bitmap_packer *packer)
+{
+ struct bitmap_packer old = *packer;
+ *packer = (struct bitmap_packer) {
+ .w_max = old.w_max,
+ .h_max = old.h_max,
+ };
+ talloc_free_children(packer);
+}
+
+void packer_get_bb(struct bitmap_packer *packer, struct pos out_bb[2])
+{
+ out_bb[0] = (struct pos) {0};
+ out_bb[1] = (struct pos) {
+ FFMIN(packer->used_width + packer->padding, packer->w),
+ FFMIN(packer->used_height + packer->padding, packer->h),
+ };
+}
#define HEIGHT_SORT_BITS 4
static int size_index(int s)
@@ -171,36 +189,15 @@ void packer_set_size(struct bitmap_packer *packer, int size)
packer->asize + 16);
}
-static int packer_pack_from_assimg(struct bitmap_packer *packer,
- struct ass_image *imglist)
-{
- int count = 0;
- struct ass_image *img = imglist;
- while (img) {
- if (count >= packer->asize)
- packer_set_size(packer, FFMAX(packer->asize * 2, 32));
- packer->in[count].x = img->w;
- packer->in[count].y = img->h;
- img = img->next;
- count++;
- }
- packer->count = count;
- return packer_pack(packer);
-}
-
int packer_pack_from_subbitmaps(struct bitmap_packer *packer,
- struct sub_bitmaps *b, int padding_pixels)
+ struct sub_bitmaps *b)
{
- packer->padding = 0;
packer->count = 0;
- if (b->type == SUBBITMAP_EMPTY)
+ if (b->format == SUBBITMAP_EMPTY)
return 0;
- if (b->type == SUBBITMAP_LIBASS)
- return packer_pack_from_assimg(packer, b->imgs);
- packer->padding = padding_pixels;
- packer_set_size(packer, b->part_count);
+ packer_set_size(packer, b->num_parts);
int a = packer->padding;
- for (int i = 0; i < b->part_count; i++)
+ for (int i = 0; i < b->num_parts; i++)
packer->in[i] = (struct pos){b->parts[i].w + a, b->parts[i].h + a};
return packer_pack(packer);
}