summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst6
-rw-r--r--Makefile4
-rw-r--r--cfg-mplayer.h1
-rw-r--r--command.c3
-rw-r--r--libmpcodecs/vf.h3
-rw-r--r--libmpcodecs/vf_ass.c31
-rw-r--r--libmpcodecs/vf_vo.c17
-rw-r--r--libmpcodecs/vfcap.h3
-rw-r--r--libvo/bitmap_packer.c73
-rw-r--r--libvo/bitmap_packer.h19
-rw-r--r--libvo/eosd_packer.c255
-rw-r--r--libvo/eosd_packer.h74
-rw-r--r--libvo/fastmemcpy.h13
-rw-r--r--libvo/gl_common.c29
-rw-r--r--libvo/gl_common.h3
-rw-r--r--libvo/gl_osd.c319
-rw-r--r--libvo/gl_osd.h42
-rw-r--r--libvo/video_out.c1
-rw-r--r--libvo/video_out.h2
-rw-r--r--libvo/vo_caca.c6
-rw-r--r--libvo/vo_corevideo.m126
-rw-r--r--libvo/vo_direct3d.c439
-rw-r--r--libvo/vo_opengl.c319
-rw-r--r--libvo/vo_opengl_old.c354
-rw-r--r--libvo/vo_opengl_shaders.glsl7
-rw-r--r--libvo/vo_vdpau.c352
-rw-r--r--mplayer.c33
-rw-r--r--sub/ass_mp.c42
-rw-r--r--sub/ass_mp.h7
-rw-r--r--sub/dec_sub.c26
-rw-r--r--sub/dec_sub.h42
-rw-r--r--sub/img_convert.c280
-rw-r--r--sub/img_convert.h18
-rw-r--r--sub/osd_dummy.c22
-rw-r--r--sub/osd_libass.c219
-rw-r--r--sub/sd.h2
-rw-r--r--sub/sd_ass.c22
-rw-r--r--sub/sd_lavc.c130
-rw-r--r--sub/spudec.c151
-rw-r--r--sub/spudec.h6
-rw-r--r--sub/sub.c460
-rw-r--r--sub/sub.h226
42 files changed, 1938 insertions, 2249 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index a8fe171601..ca245f6d32 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -163,8 +163,6 @@
:1: FreeType autohinter, light mode
:2: FreeType autohinter, normal mode
:3: font native hinter
- :0-3 + 4: The same, but hinting will only be performed if the OSD is
- rendered at screen resolution and will therefore not be scaled.
The default value is 0 (no hinting).
@@ -497,10 +495,6 @@
``--display=xtest.localdomain:0``
---double, --no-double
- Double buffering. The option to disable this exists mostly for debugging
- purposes and should not normally be used.
-
--doubleclick-time
Time in milliseconds to recognize two consecutive button presses as a
double-click (default: 300).
diff --git a/Makefile b/Makefile
index c6dc0f6090..ce1a369f77 100644
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,6 @@ SRCS_COMMON = asxparser.c \
libmpdemux/mp_taglists.c \
libmpdemux/video.c \
libvo/osd.c \
- libvo/eosd_packer.c \
libvo/bitmap_packer.c \
osdep/numcores.c \
osdep/io.c \
@@ -216,6 +215,7 @@ SRCS_COMMON = asxparser.c \
sub/sd_lavc.c \
sub/spudec.c \
sub/sub.c \
+ sub/img_convert.c \
sub/subassconvert.c \
sub/subreader.c \
sub/vobsub.c \
@@ -234,7 +234,7 @@ SRCS_MPLAYER-$(COREVIDEO) += libvo/vo_corevideo.m
SRCS_MPLAYER-$(DIRECT3D) += libvo/vo_direct3d.c libvo/w32_common.c
SRCS_MPLAYER-$(DSOUND) += libao2/ao_dsound.c
SRCS_MPLAYER-$(GL) += libvo/gl_common.c libvo/vo_opengl.c \
- libvo/vo_opengl_old.c pnm_loader.c
+ libvo/gl_osd.c libvo/vo_opengl_old.c pnm_loader.c
SRCS_MPLAYER-$(ENCODING) += libvo/vo_lavc.c libao2/ao_lavc.c encode_lavc.c
SRCS_MPLAYER-$(GL_WIN32) += libvo/w32_common.c
SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index d317f0eb32..581f363148 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -632,7 +632,6 @@ const m_option_t mplayer_opts[]={
OPT_INTRANGE("bpp", vo_dbpp, 0, 0, 32),
{"colorkey", &vo_colorkey, CONF_TYPE_INT, 0, 0, 0, NULL},
{"no-colorkey", &vo_colorkey, CONF_TYPE_FLAG, 0, 0, 0x1000000, NULL},
- {"double", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL},
// wait for v-sync (gl)
{"vsync", &vo_vsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"panscan", &vo_panscan, CONF_TYPE_FLOAT, CONF_RANGE, 0, 1.0, NULL},
diff --git a/command.c b/command.c
index 189b086b94..28625a108a 100644
--- a/command.c
+++ b/command.c
@@ -1297,7 +1297,8 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
switch (action) {
case M_PROPERTY_SET:
*pscale = *(float *) arg;
- vo_osd_resized();
+ vo_osd_changed(OSDTYPE_SUBTITLE);
+ vo_osd_changed(OSDTYPE_OSD);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
*(float *)arg = *pscale;
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h
index ec8144b22f..8b18470e62 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -104,8 +104,7 @@ struct vf_ctrl_screenshot {
#define VFCTRL_SKIP_NEXT_FRAME 12 // For encoding - drop the next frame that passes thru
#define VFCTRL_FLUSH_FRAMES 13 // For encoding - flush delayed frames
#define VFCTRL_SCREENSHOT 14 // Take screenshot, arg is vf_ctrl_screenshot
-#define VFCTRL_INIT_EOSD 15 // Select EOSD renderer
-#define VFCTRL_DRAW_EOSD 16 // Render EOSD */
+#define VFCTRL_INIT_OSD 15 // Filter OSD renderer present?
#define VFCTRL_SET_DEINTERLACE 18 // Set deinterlacing status
#define VFCTRL_GET_DEINTERLACE 19 // Get deinterlacing status
/* Hack to make the OSD state object available to vf_expand and vf_ass which
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index f0b2e6ab77..77248b49c0 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -35,6 +35,7 @@
#include "mp_image.h"
#include "vf.h"
#include "sub/sub.h"
+#include "sub/dec_sub.h"
#include "libvo/fastmemcpy.h"
@@ -355,23 +356,23 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
struct vf_priv_s *priv = vf->priv;
struct MPOpts *opts = vf->opts;
struct osd_state *osd = priv->osd;
- ASS_Image *images = 0;
+ struct sub_bitmaps imgs = (struct sub_bitmaps) {0};
if (pts != MP_NOPTS_VALUE) {
- osd->dim = (struct mp_eosd_res){ .w = vf->priv->outw,
- .h = vf->priv->outh,
- .mt = opts->ass_top_margin,
- .mb = opts->ass_bottom_margin };
- osd->normal_scale = vf->priv->aspect_correction;
- osd->vsfilter_scale = 1;
- osd->sub_pts = pts - osd->sub_offset;
- osd->support_rgba = false;
- struct sub_bitmaps b;
- sub_get_bitmaps(osd, &b);
- images = b.imgs;
+ struct sub_render_params subparams = {
+ .pts = pts,
+ .dim = { .w = vf->priv->outw,
+ .h = vf->priv->outh,
+ .mt = opts->ass_top_margin,
+ .mb = opts->ass_bottom_margin },
+ .normal_scale = vf->priv->aspect_correction,
+ .vsfilter_scale = 1,
+ };
+ bool formats[SUBBITMAP_COUNT] = {[SUBBITMAP_LIBASS] = true};
+ osd_draw_sub(osd, &imgs, &subparams, formats);
}
prepare_image(vf, mpi);
- render_frame(vf, mpi, images);
+ render_frame(vf, mpi, imgs.imgs);
return vf_next_put_image(vf, vf->dmpi, pts);
}
@@ -393,9 +394,7 @@ static int control(vf_instance_t *vf, int request, void *data)
case VFCTRL_SET_OSD_OBJ:
vf->priv->osd = data;
break;
- case VFCTRL_INIT_EOSD:
- return CONTROL_TRUE;
- case VFCTRL_DRAW_EOSD:
+ case VFCTRL_INIT_OSD:
return CONTROL_TRUE;
}
return vf_next_control(vf, request, data);
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c
index 862cd63492..998b4b6dfa 100644
--- a/libmpcodecs/vf_vo.c
+++ b/libmpcodecs/vf_vo.c
@@ -34,7 +34,6 @@
struct vf_priv_s {
struct vo *vo;
- double scale_ratio;
};
#define video_out (vf->priv->vo)
@@ -74,8 +73,6 @@ static int config(struct vf_instance *vf,
if (vo_config(video_out, width, height, d_width, d_height, flags, outfmt))
return 0;
- vf->priv->scale_ratio = (double) d_width / d_height * height / width;
-
return 1;
}
@@ -117,20 +114,6 @@ static int control(struct vf_instance *vf, int request, void *data)
};
return vo_control(video_out, VOCTRL_GET_EQUALIZER, &param) == VO_TRUE;
}
- case VFCTRL_DRAW_EOSD: {
- struct osd_state *osd = data;
- osd->support_rgba = vf->default_caps & VFCAP_EOSD_RGBA;
- osd->dim = (struct mp_eosd_res){0};
- if (!video_out->config_ok ||
- vo_control(video_out, VOCTRL_GET_EOSD_RES, &osd->dim) != true)
- return CONTROL_FALSE;
- osd->normal_scale = 1;
- osd->vsfilter_scale = vf->priv->scale_ratio;
- osd->unscaled = vf->default_caps & VFCAP_EOSD_UNSCALED;
- struct sub_bitmaps images;
- sub_get_bitmaps(osd, &images);
- return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE;
- }
}
return CONTROL_UNKNOWN;
}
diff --git a/libmpcodecs/vfcap.h b/libmpcodecs/vfcap.h
index aef75840ae..0fb73f5a51 100644
--- a/libmpcodecs/vfcap.h
+++ b/libmpcodecs/vfcap.h
@@ -42,11 +42,8 @@
#define VFCAP_POSTPROC 0x800
// filter can draw EOSD
#define VFCAP_EOSD 0x2000
-// filter will draw EOSD at screen resolution (without scaling)
-#define VFCAP_EOSD_UNSCALED 0x4000
// used by libvo and vf_vo, indicates the VO does not support draw_slice for this format
#define VOCAP_NOSLICES 0x8000
-#define VFCAP_OSD_FILTER 0x10000 // OSD is drawn in filter chain
#define VFCAP_EOSD_FILTER 0x20000 // EOSD is drawn in filter chain
#define VFCAP_EOSD_RGBA 0x40000
diff --git a/libvo/bitmap_packer.c b/libvo/bitmap_packer.c
index eedc2e2242..603a6ce410 100644
--- a/libvo/bitmap_packer.c
+++ b/libvo/bitmap_packer.c
@@ -20,6 +20,7 @@
*/
#include <stdlib.h>
+#include <assert.h>
#include <libavutil/common.h>
@@ -27,9 +28,29 @@
#include "bitmap_packer.h"
#include "mp_msg.h"
#include "mpcommon.h"
-#include "sub/ass_mp.h"
#include "sub/dec_sub.h"
+#include "fastmemcpy.h"
+#define IS_POWER_OF_2(x) (((x) > 0) && !(((x) - 1) & (x)))
+
+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)
@@ -142,6 +163,8 @@ int packer_pack(struct bitmap_packer *packer)
// No padding at edges
packer->used_width = FFMIN(used_width, packer->w);
packer->used_height = FFMIN(y, packer->h);
+ assert(packer->w == 0 || IS_POWER_OF_2(packer->w));
+ assert(packer->h == 0 || IS_POWER_OF_2(packer->h));
return packer->w != w_orig || packer->h != h_orig;
}
if (packer->w <= packer->h && packer->w != packer->w_max)
@@ -171,36 +194,34 @@ 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);
}
+
+void packer_copy_subbitmaps(struct bitmap_packer *packer, struct sub_bitmaps *b,
+ void *data, int pixel_stride, int stride)
+{
+ assert(packer->count == b->num_parts);
+ if (packer->padding) {
+ struct pos bb[2];
+ packer_get_bb(packer, bb);
+ memset_pic(data, 0, bb[1].x * pixel_stride, bb[1].y, stride);
+ }
+ for (int n = 0; n < packer->count; n++) {
+ struct sub_bitmap *s = &b->parts[n];
+ struct pos p = packer->result[n];
+
+ void *pdata = (uint8_t *)data + p.y * stride + p.x * pixel_stride;
+ memcpy_pic(pdata, s->bitmap, s->w * pixel_stride, s->h,
+ stride, s->stride);
+ }
+}
diff --git a/libvo/bitmap_packer.h b/libvo/bitmap_packer.h
index c7c377cbd0..b86c3ec4f9 100644
--- a/libvo/bitmap_packer.h
+++ b/libvo/bitmap_packer.h
@@ -26,6 +26,13 @@ struct bitmap_packer {
struct ass_image;
struct sub_bitmaps;
+// Clear all internal state. Leave the following fields: w_max, h_max
+void packer_reset(struct bitmap_packer *packer);
+
+// Get the bounding box used for bitmap data (including padding).
+// The bounding box doesn't exceed (0,0)-(packer->w,packer->h).
+void packer_get_bb(struct bitmap_packer *packer, struct pos out_bb[2]);
+
/* Reallocate packer->in for at least to desired number of items.
* Also sets packer->count to the same value.
*/
@@ -36,6 +43,7 @@ void packer_set_size(struct bitmap_packer *packer, int size);
* 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.
+ * There is a strong guarantee that w and h will be powers of 2 (or set to 0).
* 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.
*/
@@ -46,6 +54,15 @@ int packer_pack(struct bitmap_packer *packer);
* given image list.
*/
int packer_pack_from_subbitmaps(struct bitmap_packer *packer,
- struct sub_bitmaps *b, int padding_pixels);
+ struct sub_bitmaps *b);
+
+// Copy the (already packed) sub-bitmaps from b to the image in data.
+// data must point to an image that is at least (packer->w, packer->h) big.
+// The image has the given stride (bytes between (x, y) to (x, y + 1)), and the
+// pixel format used by both the sub-bitmaps and the image uses pixel_stride
+// bytes per pixel (bytes between (x, y) to (x + 1, y)).
+// If packer->padding is set, the padding borders are cleared with 0.
+void packer_copy_subbitmaps(struct bitmap_packer *packer, struct sub_bitmaps *b,
+ void *data, int pixel_stride, int stride);
#endif
diff --git a/libvo/eosd_packer.c b/libvo/eosd_packer.c
deleted file mode 100644
index 8f831d512e..0000000000
--- a/libvo/eosd_packer.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Common code for packing EOSD images into larger surfaces.
- *
- * This file is part of mplayer2.
- *
- * mplayer2 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * mplayer2 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with mplayer2; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <libavutil/common.h>
-#include "talloc.h"
-#include "mp_msg.h"
-#include "eosd_packer.h"
-
-// Initial size of EOSD surface in pixels (x*x)
-#define EOSD_SURFACE_INITIAL_SIZE 256
-
-// Allocate an eosd_packer, which can be used to layout and cache the list of
-// EOSD images contained in a mp_eosd_images_t into a flat surface.
-// It can be free'd with talloc_free().
-// Don't forget to call eosd_init() before using it.
-struct eosd_packer *eosd_packer_create(void *talloc_ctx) {
- return talloc_zero(talloc_ctx, struct eosd_packer);
-}
-
-// Call this when you need to completely reinitialize the EOSD state, e.g. when
-// when your EOSD surface was deleted.
-// max_width and max_height are the maximum surface sizes that should be
-// allowed.
-void eosd_packer_reinit(struct eosd_packer *state, uint32_t max_width,
- uint32_t max_height)
-{
- state->max_surface_width = max_width;
- state->max_surface_height = max_height;
- state->surface.w = 0;
- state->surface.h = 0;
- state->targets_count = 0;
-}
-
-#define HEIGHT_SORT_BITS 4
-static int size_index(struct eosd_target *r)
-{
- unsigned int h = r->source.y1;
- int n = av_log2_16bit(h);
- return (n << HEIGHT_SORT_BITS)
- + (- 1 - (h << HEIGHT_SORT_BITS >> n) & (1 << HEIGHT_SORT_BITS) - 1);
-}
-
-/* Pack the given rectangles into an area of size w * h.
- * The size of each rectangle is read from .source.x1/.source.y1.
- * The height of each rectangle must be at least 1 and less than 65536.
- * The .source rectangle is then set corresponding to the packed position.
- * 'scratch' must point to work memory for num_rects+16 ints.
- * Return 0 on success, -1 if the rectangles did not fit in w*h.
- *
- * The rectangles are placed in rows in order approximately sorted by
- * height (the approximate sorting is simpler than a full one would be,
- * and allows the algorithm to work in linear time). Additionally, to
- * reduce wasted space when there are a few tall rectangles, empty
- * lower-right parts of rows are filled recursively when the size of
- * rectangles in the row drops past a power-of-two threshold. So if a
- * row starts with rectangles of size 3x50, 10x40 and 5x20 then the
- * free rectangle with corners (13, 20)-(w, 50) is filled recursively.
- */
-static int pack_rectangles(struct eosd_target *rects, int num_rects,
- int w, int h, int *scratch)
-{
- int bins[16 << HEIGHT_SORT_BITS];
- int sizes[16 << HEIGHT_SORT_BITS] = {};
- for (int i = 0; i < num_rects; i++)
- sizes[size_index(rects + i)]++;
- int idx = 0;
- for (int i = 0; i < 16 << HEIGHT_SORT_BITS; i += 1 << HEIGHT_SORT_BITS) {
- for (int j = 0; j < 1 << HEIGHT_SORT_BITS; j++) {
- bins[i + j] = idx;
- idx += sizes[i + j];
- }
- scratch[idx++] = -1;
- }
- for (int i = 0; i < num_rects; i++)
- scratch[bins[size_index(rects + i)]++] = i;
- for (int i = 0; i < 16; i++)
- bins[i] = bins[i << HEIGHT_SORT_BITS] - sizes[i << HEIGHT_SORT_BITS];
- struct {
- int size, x, bottom;
- } stack[16] = {{15, 0, h}}, s = {};
- int stackpos = 1;
- int y;
- while (stackpos) {
- y = s.bottom;
- s = stack[--stackpos];
- s.size++;
- while (s.size--) {
- int maxy = -1;
- int obj;
- while ((obj = scratch[bins[s.size]]) >= 0) {
- int bottom = y + rects[obj].source.y1;
- if (bottom > s.bottom)
- break;
- int right = s.x + rects[obj].source.x1;
- if (right > w)
- break;
- bins[s.size]++;
- rects[obj].source.x0 = s.x;
- rects[obj].source.x1 += s.x;
- rects[obj].source.y0 = y;
- rects[obj].source.y1 += y;
- num_rects--;
- if (maxy <= 0)
- stack[stackpos++] = s;
- s.x = right;
- maxy = FFMAX(maxy, bottom);
- }
- if (maxy > 0)
- s.bottom = maxy;
- }
- }
- return num_rects ? -1 : 0;
-}
-
-// padding to reduce interpolation artifacts when doing scaling & filtering
-#define EOSD_PADDING 0
-
-// Release all previous images, and packs the images in imgs into state. The
-// caller must check the change variables:
-// *out_need_reposition == true: sub-image positions changed
-// *out_need_upload == true: upload all sub-images again
-// *out_need_reallocate == true: resize the EOSD texture to state->surface.w/h
-// Logical implications: need_reallocate => need_upload => need_reposition
-void eosd_packer_generate(struct eosd_packer *state, mp_eosd_images_t *imgs,
- bool *out_need_reposition, bool *out_need_upload,
- bool *out_need_reallocate)
-{
- int i;
- ASS_Image *img = imgs->imgs;
- ASS_Image *p;
- struct eosd_surface *sfc = &state->surface;
-
- *out_need_reposition = imgs->bitmap_pos_id != state->last_bitmap_pos_id;
- *out_need_upload = imgs->bitmap_id != state->last_bitmap_id;
- *out_need_reallocate = false;
-
- state->last_bitmap_pos_id = imgs->bitmap_pos_id;
- state->last_bitmap_id = imgs->bitmap_id;
-
- // eosd_reinit() was probably called, force full reupload.
- if (state->targets_count == 0 && img)
- *out_need_upload = true;
-
- if (!(*out_need_reposition) && !(*out_need_upload))
- return; // Nothing changed, no need to redraw
-
- state->targets_count = 0;
-
- *out_need_reposition = true;
-
- if (!img)
- return; // There's nothing to render!
-
- if (!(*out_need_upload))
- goto eosd_skip_upload;
-
- *out_need_upload = true;
- while (1) {
- for (p = img, i = 0; p; p = p->next) {
- if (p->w <= 0 || p->h <= 0)
- continue;
- // Allocate new space for surface/target arrays
- if (i >= state->targets_size) {
- state->targets_size = FFMAX(state->targets_size * 2, 512);
- state->targets =
- talloc_realloc_size(state, state->targets,
- state->targets_size
- * sizeof(*state->targets));
- state->scratch =
- talloc_realloc_size(state, state->scratch,
- (state->targets_size + 16)
- * sizeof(*state->scratch));
- }
- state->targets[i].source.x1 = p->w + EOSD_PADDING;
- state->targets[i].source.y1 = p->h + EOSD_PADDING;
- i++;
- }
- if (pack_rectangles(state->targets, i, sfc->w, sfc->h,
- state->scratch) >= 0)
- break;
- int w = FFMIN(FFMAX(sfc->w * 2, EOSD_SURFACE_INITIAL_SIZE),
- state->max_surface_width);
- int h = FFMIN(FFMAX(sfc->h * 2, EOSD_SURFACE_INITIAL_SIZE),
- state->max_surface_height);
- if (w == sfc->w && h == sfc->h) {
- mp_msg(MSGT_VO, MSGL_ERR, "[eosd] EOSD bitmaps do not fit on "
- "a surface with the maximum supported size\n");
- return;
- }
- sfc->w = w;
- sfc->h = h;
- *out_need_reallocate = true;
- }
- if (*out_need_reallocate) {
- mp_msg(MSGT_VO, MSGL_V, "[eosd] Allocate a %dx%d surface for "
- "EOSD bitmaps.\n", sfc->w, sfc->h);
- }
-
-eosd_skip_upload:
- for (p = img; p; p = p->next) {
- if (p->w <= 0 || p->h <= 0)
- continue;
- struct eosd_target *target = &state->targets[state->targets_count];
- target->source.x1 -= EOSD_PADDING;
- target->source.y1 -= EOSD_PADDING;
- target->dest.x0 = p->dst_x;
- target->dest.y0 = p->dst_y;
- target->dest.x1 = p->w + p->dst_x;
- target->dest.y1 = p->h + p->dst_y;
- target->color = p->color;
- target->ass_img = p;
- state->targets_count++;
- }
-}
-
-// Calculate the bounding box of all sub-rectangles in the EOSD surface that
-// will be used for EOSD rendering.
-// If the bounding box is empty, return false.
-bool eosd_packer_calculate_source_bb(struct eosd_packer *state,
- struct eosd_rect *out_bb)
-{
- struct eosd_rect bb = { state->surface.w, state->surface.h, 0, 0 };
-
- for (int n = 0; n < state->targets_count; n++) {
- struct eosd_rect s = state->targets[n].source;
- bb.x0 = FFMIN(bb.x0, s.x0);
- bb.y0 = FFMIN(bb.y0, s.y0);
- bb.x1 = FFMAX(bb.x1, s.x1);
- bb.y1 = FFMAX(bb.y1, s.y1);
- }
-
- // avoid degenerate bounding box if empty
- bb.x0 = FFMIN(bb.x0, bb.x1);
- bb.y0 = FFMIN(bb.y0, bb.y1);
-
- *out_bb = bb;
- return state->targets_count > 0;
-}
diff --git a/libvo/eosd_packer.h b/libvo/eosd_packer.h
deleted file mode 100644
index 228057d3c4..0000000000
--- a/libvo/eosd_packer.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of mplayer2.
- *
- * mplayer2 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * mplayer2 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR