1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-17 21:27:08 +00:00
mpv/sub/osd_state.h
wm4 fd3caa264e stats: some more performance graphs
Add an infrastructure for collecting performance-related data, use it in
some places. Add rendering of them to stats.lua.

There were two main goals: minimal impact on the normal code and normal
playback. So all these stats_* function calls either happen only during
initialization, or return immediately if no stats collection is going
on. That's why it does this lazily adding of stats entries etc. (a first
iteration made each stats entry an API thing, instead of just a single
stats_ctx, but I thought that was getting too intrusive in the "normal"
code, even if everything gets worse inside of stats.c).

You could get most of this information from various profilers (including
the extremely primitive --dump-stats thing in mpv), but this makes it
easier to see the most important information at once (at least in
theory), partially because we know best about the context of various
things.

Not very happy with this. It's all pretty primitive and dumb. At this
point I just wanted to get over with it, without necessarily having to
revisit it later, but with having my stupid statistics.

Somehow the code feels terrible. There are a lot of meh decisions in
there that could be better or worse (but mostly could be better), and it
just sucks but it's also trivial and uninteresting and does the job. I
guess I hate programming. It's so tedious and the result is always shit.
Anyway, enjoy.
2020-04-09 00:33:38 +02:00

92 lines
1.9 KiB
C

#ifndef MP_OSD_STATE_H_
#define MP_OSD_STATE_H_
#include <pthread.h>
#include "osd.h"
enum mp_osdtype {
OSDTYPE_SUB,
OSDTYPE_SUB2, // IDs must be numerically successive
OSDTYPE_OSD,
OSDTYPE_EXTERNAL,
OSDTYPE_EXTERNAL2,
OSDTYPE_COUNT
};
struct ass_state {
struct mp_log *log;
struct ass_track *track;
struct ass_renderer *render;
struct ass_library *library;
int res_x, res_y;
bool changed;
struct mp_osd_res vo_res; // last known value
};
struct osd_object {
int type; // OSDTYPE_*
bool is_sub;
// OSDTYPE_OSD
bool osd_changed;
char *text;
struct osd_progbar_state progbar_state;
// OSDTYPE_SUB/OSDTYPE_SUB2
struct dec_sub *sub;
// OSDTYPE_EXTERNAL
struct osd_external **externals;
int num_externals;
// OSDTYPE_EXTERNAL2
struct sub_bitmaps *external2;
// VO cache state
int vo_change_id;
struct mp_osd_res vo_res;
// Internally used by osd_libass.c
bool changed;
struct ass_state ass;
struct mp_ass_packer *ass_packer;
struct ass_image **ass_imgs;
};
struct osd_external {
struct osd_external_ass ov;
struct ass_state ass;
};
struct osd_state {
pthread_mutex_t lock;
struct osd_object *objs[MAX_OSD_PARTS];
bool render_subs_in_filter;
double force_video_pts;
bool want_redraw;
bool want_redraw_notification;
struct m_config_cache *opts_cache;
struct mp_osd_render_opts *opts;
struct mpv_global *global;
struct mp_log *log;
struct stats_ctx *stats;
struct mp_draw_sub_cache *draw_cache;
};
// defined in osd_libass.c and osd_dummy.c
void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj,
int format, struct sub_bitmaps *out_imgs);
void osd_init_backend(struct osd_state *osd);
void osd_destroy_backend(struct osd_state *osd);
#endif