1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 17:42:17 +00:00
mpv/libvo/bitmap_packer.h
Uoti Urpala 1959ba006c subs, vo_vdpau: support RGBA color for PGS subtitles
Support passing bitmap subtitles to VOs in full RGBA color, and
implement this for libavcodec-decoded subtitle formats on decoding
side and vo_vdpau on display side. Currently this is enabled for PGS
(blu-ray) and DVB subtitles.

VDPAU seems to have sampling issues similar to known GL ones when
drawing a sub-rectangle from a larger texture with scaling, where
adjacent pixels outside the specified source rectangle affect the
result. As the bitmap subtitles may be scaled, add padding support to
the bitmap packer code.

In principle, this could be used for colored DVD subtitles too.
However, the libavcodec DVD decoder lacks parts of the resolution and
palette handling that are present in spudec.c.

Conflicts:
	libvo/vo_gl.c
	sub/dec_sub.h
	sub/sd_lavc.c
2012-09-18 21:07:30 +02:00

52 lines
1.3 KiB
C

#ifndef MPLAYER_PACK_RECTANGLES_H
#define MPLAYER_PACK_RECTANGLES_H
struct pos {
int x;
int y;
};
struct bitmap_packer {
int w;
int h;
int w_max;
int h_max;
int padding;
int count;
struct pos *in;
struct pos *result;
int used_width;
int used_height;
// internal
int *scratch;
int asize;
};
struct ass_image;
struct sub_bitmaps;
/* Reallocate packer->in for at least to desired number of items.
* Also sets packer->count to the same value.
*/
void packer_set_size(struct bitmap_packer *packer, int size);
/* To use this, set packer->count to number of rectangles, w_max and h_max
* to maximum output rectangle size, and w and h to start size (may be 0).
* Write input sizes in packer->in.
* Resulting packing will be written in packer->result.
* w and h will be increased if necessary for successful packing.
* Return value is -1 if packing failed because w and h were set to max
* values but that wasn't enough, 1 if w or h was increased, and 0 otherwise.
*/
int packer_pack(struct bitmap_packer *packer);
/* Like above, but packer->count will be automatically set and
* packer->in will be reallocated if needed and filled from the
* given image list.
*/
int packer_pack_from_subbitmaps(struct bitmap_packer *packer,
struct sub_bitmaps *b, int padding_pixels);
#endif