mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 00:42:57 +00:00
385febe276
Each subtitle track gets its own decoder instance (sd_ass). But they use a shared ASS_Renderer. This is done mainly because of fontconfig. Initializing fontconfig is very slow when using it with memory fonts, so there's a practical need to cache this memory font state, which is done by not creating separate ASS_Renderers. This is very dirty and very evil, but we probably can't get rid of it any time soon. The shared ASS_Renderer was not properly synchronized. While the program logic guarantees that only one sd_ass instance is visible at a time, there are other interactions that require synchronization. In particular, I suspect concurrent execution of mp_ass_configure_fonts() and sd_ass.get_bitmaps cause issues in a newer libass development branch. So here's a shitty hack that hopefully fixes things, hopefully only until libass becomes less dependent on fontconfig.
53 lines
1.5 KiB
C
53 lines
1.5 KiB
C
#ifndef MPLAYER_DEC_SUB_H
|
|
#define MPLAYER_DEC_SUB_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <pthread.h>
|
|
|
|
#include "osd.h"
|
|
|
|
struct sh_stream;
|
|
struct ass_track;
|
|
struct mpv_global;
|
|
struct demux_packet;
|
|
struct ass_library;
|
|
struct ass_renderer;
|
|
|
|
struct dec_sub;
|
|
struct sd;
|
|
|
|
enum sd_ctrl {
|
|
SD_CTRL_SUB_STEP,
|
|
SD_CTRL_SET_VIDEO_PARAMS,
|
|
SD_CTRL_GET_RESOLUTION,
|
|
};
|
|
|
|
struct dec_sub *sub_create(struct mpv_global *global);
|
|
void sub_destroy(struct dec_sub *sub);
|
|
void sub_lock(struct dec_sub *sub);
|
|
void sub_unlock(struct dec_sub *sub);
|
|
|
|
void sub_set_video_res(struct dec_sub *sub, int w, int h);
|
|
void sub_set_video_fps(struct dec_sub *sub, double fps);
|
|
void sub_set_extradata(struct dec_sub *sub, void *data, int data_len);
|
|
void sub_set_ass_renderer(struct dec_sub *sub, struct ass_library *ass_library,
|
|
struct ass_renderer *ass_renderer,
|
|
pthread_mutex_t *ass_lock);
|
|
void sub_init_from_sh(struct dec_sub *sub, struct sh_stream *sh);
|
|
|
|
bool sub_is_initialized(struct dec_sub *sub);
|
|
|
|
bool sub_read_all_packets(struct dec_sub *sub, struct sh_stream *sh);
|
|
bool sub_accept_packets_in_advance(struct dec_sub *sub);
|
|
void sub_decode(struct dec_sub *sub, struct demux_packet *packet);
|
|
void sub_get_bitmaps(struct dec_sub *sub, struct mp_osd_res dim, double pts,
|
|
struct sub_bitmaps *res);
|
|
bool sub_has_get_text(struct dec_sub *sub);
|
|
char *sub_get_text(struct dec_sub *sub, double pts);
|
|
void sub_reset(struct dec_sub *sub);
|
|
|
|
int sub_control(struct dec_sub *sub, enum sd_ctrl cmd, void *arg);
|
|
|
|
#endif
|