mirror of
https://github.com/mpv-player/mpv
synced 2024-12-21 22:30:22 +00:00
e9e883e3b2
Making OSD/subtitle bitmaps refcounted was planend a longer time ago, e.g. the sub_bitmaps.packed field (which refcounts the subtitle bitmap data) was added in 2016. But nothing benefited much from it, because struct sub_bitmaps was usually stack allocated, and there was this weird callback stuff through osd_draw(). Make it possible to get actually refcounted subtitle bitmaps on the OSD API level. For this, we just copy all subtitle data other than the bitmaps with sub_bitmaps_copy(). At first, I had planned some fancy refcount shit, but when that was a big mess and hard to debug and just boiled to emulating malloc(), I made it a full allocation+copy. This affects mostly the parts array. With crazy ASS subtitles, this parts array can get pretty big (thousands of elements or more), in which case the extra alloc/copy could become performance relevant. But then again this is just pure bullshit, and I see no need to care. In practice, this extra work most likely gets drowned out by libass murdering a single core (while mpv is waiting for it) anyway. So fuck it. I just wanted this so draw_bmp.c requires only a single call to render everything. VOs also can benefit from this, because the weird callback shit isn't necessary anymore (simpler code), but I haven't done anything about it yet. In general I'd hope this will work towards simplifying the OSD layer, which is prerequisite for making actual further improvements. I haven't tested some cases such as the "overlay-add" command. Maybe it crashes now? Who knows, who cares. In addition, it might be worthwhile to reduce the code duplication between all the things that output subtitle bitmaps (with repacking, image allocation, etc.), but that's orthogonal.
54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
#ifndef MPLAYER_DEC_SUB_H
|
|
#define MPLAYER_DEC_SUB_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "osd.h"
|
|
|
|
struct sh_stream;
|
|
struct mpv_global;
|
|
struct demux_packet;
|
|
struct mp_recorder_sink;
|
|
|
|
struct dec_sub;
|
|
struct sd;
|
|
|
|
enum sd_ctrl {
|
|
SD_CTRL_SUB_STEP,
|
|
SD_CTRL_SET_VIDEO_PARAMS,
|
|
SD_CTRL_SET_TOP,
|
|
SD_CTRL_SET_VIDEO_DEF_FPS,
|
|
SD_CTRL_UPDATE_OPTS,
|
|
};
|
|
|
|
struct sd_times {
|
|
double start;
|
|
double end;
|
|
};
|
|
|
|
struct attachment_list {
|
|
struct demux_attachment *entries;
|
|
int num_entries;
|
|
};
|
|
|
|
struct dec_sub *sub_create(struct mpv_global *global, struct sh_stream *sh,
|
|
struct attachment_list *attachments);
|
|
void sub_destroy(struct dec_sub *sub);
|
|
|
|
bool sub_can_preload(struct dec_sub *sub);
|
|
void sub_preload(struct dec_sub *sub);
|
|
bool sub_read_packets(struct dec_sub *sub, double video_pts);
|
|
struct sub_bitmaps *sub_get_bitmaps(struct dec_sub *sub, struct mp_osd_res dim,
|
|
int format, double pts);
|
|
char *sub_get_text(struct dec_sub *sub, double pts);
|
|
struct sd_times sub_get_times(struct dec_sub *sub, double pts);
|
|
void sub_reset(struct dec_sub *sub);
|
|
void sub_select(struct dec_sub *sub, bool selected);
|
|
void sub_set_recorder_sink(struct dec_sub *sub, struct mp_recorder_sink *sink);
|
|
void sub_set_play_dir(struct dec_sub *sub, int dir);
|
|
|
|
int sub_control(struct dec_sub *sub, enum sd_ctrl cmd, void *arg);
|
|
|
|
#endif
|