summaryrefslogtreecommitdiffstats
path: root/sub/sub.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-04 17:16:47 +0200
committerwm4 <wm4@nowhere>2012-10-16 07:26:32 +0200
commit3ad918bbc62449759bbf97f6a809ebdde27ad59e (patch)
tree24c3668687c5ebff37d6d1aaa0354d01310a0d8d /sub/sub.h
parentcc05910f16a5ccd8e3dca26a89e9c3835cbdb645 (diff)
downloadmpv-3ad918bbc62449759bbf97f6a809ebdde27ad59e.tar.bz2
mpv-3ad918bbc62449759bbf97f6a809ebdde27ad59e.tar.xz
sub: never decode subs to old OSD format
Instead, sd_lavc.c and spudec.c (the two image sub decoders) always output indexed/paletted images. For this purpose, add SUBBITMAP_INDEXED, and convert the subs to RGBA in img_convert.c instead. If a VO is used that supports the old OSD format only, the indexed bitmaps are converted to the old OSD format by abusing spudec.c in a similar way sd_lavc.c used to do. The main reason why spudec.c is used is because the images must not only be converted to the old format, but also properly scaled, cropped, and aligned (the asm code in libvo/osd.c requires this alignment). Remove support for the old format (packed variant) from the OpenGL VOs. (The packed formats were how the actual OSD format was handled in some GPU-driven VOs for a while.) Remove all conversions from old to new formats. Now all subtitle decoders and OSD renderers produce the new formats only. Add an evil hack to convert the new format (scaled+indexed bitmaps) to the old format. It creates a new spudec instance to convert images to grayscale and to scale them. This is temporary for VOs which don't support new OSD formats yet (vo_xv, vo_x11, vo_lavc).
Diffstat (limited to 'sub/sub.h')
-rw-r--r--sub/sub.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/sub/sub.h b/sub/sub.h
index 6a83036460..8649018029 100644
--- a/sub/sub.h
+++ b/sub/sub.h
@@ -30,13 +30,20 @@ struct sub_render_params;
enum sub_bitmap_format {
SUBBITMAP_EMPTY = 0,// no bitmaps; always has num_parts==0
SUBBITMAP_LIBASS, // A8, with a per-surface blend color (libass.color)
- SUBBITMAP_RGBA, // B8G8R8A8, can be scaled
- SUBBITMAP_OLD, // I8A8 (monochrome), premultiplied alpha
+ SUBBITMAP_RGBA, // B8G8R8A8 (MSB=A, LSB=B), can be scaled
+ SUBBITMAP_INDEXED, // scaled, bitmap points to osd_bmp_indexed
SUBBITMAP_OLD_PLANAR, // like previous, but bitmap points to old_osd_planar
SUBBITMAP_COUNT
};
+// For SUBBITMAP_INDEXED
+struct osd_bmp_indexed {
+ uint8_t *bitmap;
+ // Each entry is like a pixel in SUBBITMAP_RGBA format
+ uint32_t palette[256];
+};
+
// For SUBBITMAP_OLD_PANAR
struct old_osd_planar {
unsigned char *bitmap;
@@ -46,9 +53,10 @@ struct old_osd_planar {
struct sub_bitmap {
void *bitmap;
int stride;
+ // Note: not clipped, going outside the screen area is allowed
+ // (except for SUBBITMAP_LIBASS, which is always clipped)
int w, h;
int x, y;
- // Note: not clipped, going outside the screen area is allowed
int dw, dh;
union {
@@ -59,10 +67,14 @@ struct sub_bitmap {
};
struct sub_bitmaps {
- int render_index; // for VO cache state (limited by MAX_OSD_PARTS)
+ // For VO cache state (limited by MAX_OSD_PARTS)
+ int render_index;
enum sub_bitmap_format format;
- bool scaled; // if false, dw==w && dh==h
+
+ // If false, dw==w && dh==h.
+ // SUBBITMAP_LIBASS is never scaled.
+ bool scaled;
struct sub_bitmap *parts;
int num_parts;
@@ -120,8 +132,6 @@ struct osd_state {
double sub_offset;
double vo_sub_pts;
- bool support_rgba;
-
bool render_subs_in_filter;
struct mp_eosd_res res;