summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-03 22:29:12 +0200
committerwm4 <wm4@nowhere>2016-05-03 22:29:12 +0200
commit485ae095f77a27bd3bca08b0e221dff14581e0d3 (patch)
tree01ac35ad2dc75bcc0bbbc9775d8dd8e32f7a523c /sub
parent5be40f035b03b5dbc891f463ae90575243adf301 (diff)
downloadmpv-485ae095f77a27bd3bca08b0e221dff14581e0d3.tar.bz2
mpv-485ae095f77a27bd3bca08b0e221dff14581e0d3.tar.xz
osd: make osd_ass_0/1 defines
So we can concatenate them with strings at compile time.
Diffstat (limited to 'sub')
-rw-r--r--sub/osd.h8
-rw-r--r--sub/osd_dummy.c3
-rw-r--r--sub/osd_libass.c9
3 files changed, 9 insertions, 11 deletions
diff --git a/sub/osd.h b/sub/osd.h
index 550b31e5a7..6d5b0dfe3c 100644
--- a/sub/osd.h
+++ b/sub/osd.h
@@ -107,6 +107,12 @@ enum mp_osd_font_codepoints {
OSD_PB_1 = 0x13,
};
+
+// Never valid UTF-8, so we expect it's free for use.
+// Specially interpreted by osd_libass.c, in order to allow/escape ASS tags.
+#define OSD_ASS_0 "\xFD"
+#define OSD_ASS_1 "\xFE"
+
struct osd_style_opts {
char *font;
float font_size;
@@ -200,7 +206,5 @@ void osd_set_external(struct osd_state *osd, void *id, int res_x, int res_y,
// doesn't need locking
void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function);
-extern const char *const osd_ass_0;
-extern const char *const osd_ass_1;
#endif /* MPLAYER_SUB_H */
diff --git a/sub/osd_dummy.c b/sub/osd_dummy.c
index 5c3cc76200..d9c366e1ac 100644
--- a/sub/osd_dummy.c
+++ b/sub/osd_dummy.c
@@ -6,9 +6,6 @@
#include "mpv_talloc.h"
#include "osd.h"
-const char *const osd_ass_0 = "";
-const char *const osd_ass_1 = "";
-
void osd_init_backend(struct osd_state *osd)
{
}
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index 30d404d8c6..6a2efa6603 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -179,13 +179,10 @@ static void clear_ass(struct ass_state *ass)
void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function)
{
// 0xFF is never valid UTF-8, so we can use it to escape OSD symbols.
+ // (Same trick as OSD_ASS_0/OSD_ASS_1.)
snprintf(buffer, buffer_size, "\xFF%c", osd_function);
}
-// Same trick as above: never valid UTF-8, so we expect it's free for use.
-const char *const osd_ass_0 = "\xFD";
-const char *const osd_ass_1 = "\xFE";
-
static void mangle_ass(bstr *dst, const char *in)
{
bool escape_ass = true;
@@ -198,8 +195,8 @@ static void mangle_ass(bstr *dst, const char *in)
in += 2;
continue;
}
- if (*in == '\xFD' || *in == '\xFE') {
- escape_ass = *in == '\xFE';
+ if (*in == OSD_ASS_0[0] || *in == OSD_ASS_1[0]) {
+ escape_ass = *in == OSD_ASS_1[0];
in += 1;
continue;
}