summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
Diffstat (limited to 'sub')
-rw-r--r--sub/ass_mp.c18
-rw-r--r--sub/ass_mp.h6
-rw-r--r--sub/dec_sub.c30
-rw-r--r--sub/dec_sub.h4
-rw-r--r--sub/osd.c10
-rw-r--r--sub/osd.h4
-rw-r--r--sub/osd_libass.c6
-rw-r--r--sub/sd.h1
-rw-r--r--sub/sd_ass.c8
-rw-r--r--sub/sd_lavc.c6
-rw-r--r--sub/sd_lavc_conv.c7
-rw-r--r--sub/sd_spu.c2
-rw-r--r--sub/sd_srt.c12
-rw-r--r--sub/spudec.c53
-rw-r--r--sub/spudec.h3
15 files changed, 95 insertions, 75 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index cdf302f959..39737824a2 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -29,7 +29,7 @@
#include <libavutil/common.h>
-#include "config.h"
+#include "common/global.h"
#include "common/msg.h"
#include "options/path.h"
#include "ass_mp.h"
@@ -150,7 +150,8 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
ass_set_line_spacing(priv, set_line_spacing);
}
-void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts)
+void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts,
+ struct mpv_global *global, struct mp_log *log)
{
char *default_font = mp_find_user_config_file("subfont.ttf");
char *config = mp_find_config_file("fonts.conf");
@@ -216,22 +217,25 @@ static int map_ass_level[] = {
static void message_callback(int level, const char *format, va_list va, void *ctx)
{
+ struct mp_log *log = ctx;
+ if (!log)
+ return;
level = map_ass_level[level];
- mp_msg_va(MSGT_ASS, level, format, va);
+ mp_msg_log_va(log, level, format, va);
// libass messages lack trailing \n
- mp_msg(MSGT_ASS, level, "\n");
+ mp_msg_log(log, level, "\n");
}
-ASS_Library *mp_ass_init(struct MPOpts *opts)
+ASS_Library *mp_ass_init(struct mpv_global *global, struct mp_log *log)
{
char *path = mp_find_user_config_file("fonts");
ASS_Library *priv = ass_library_init();
if (!priv)
abort();
- ass_set_message_cb(priv, message_callback, NULL);
+ ass_set_message_cb(priv, message_callback, log);
if (path)
ass_set_fonts_dir(priv, path);
- ass_set_extract_fonts(priv, opts->use_embedded_fonts);
+ ass_set_extract_fonts(priv, global->opts->use_embedded_fonts);
talloc_free(path);
return priv;
}
diff --git a/sub/ass_mp.h b/sub/ass_mp.h
index 987efdfe28..8fb9104662 100644
--- a/sub/ass_mp.h
+++ b/sub/ass_mp.h
@@ -41,6 +41,7 @@
#include <ass/ass_types.h>
struct MPOpts;
+struct mpv_global;
struct mp_osd_res;
struct osd_style_opts;
@@ -54,8 +55,9 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts);
struct MPOpts;
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
struct mp_osd_res *dim);
-void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts);
-ASS_Library *mp_ass_init(struct MPOpts *opts);
+void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts,
+ struct mpv_global *global, struct mp_log *log);
+ASS_Library *mp_ass_init(struct mpv_global *global, struct mp_log *log);
struct sub_bitmap;
struct sub_bitmaps;
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index 9a948cd036..d896f92315 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -27,6 +27,7 @@
#include "sd.h"
#include "dec_sub.h"
#include "options/options.h"
+#include "common/global.h"
#include "common/msg.h"
#include "misc/charset_conv.h"
@@ -56,6 +57,7 @@ static const struct sd_functions *sd_list[] = {
#define MAX_NUM_SD 3
struct dec_sub {
+ struct mp_log *log;
struct MPOpts *opts;
struct sd init_sd;
@@ -71,10 +73,11 @@ struct packet_list {
int num_packets;
};
-struct dec_sub *sub_create(struct MPOpts *opts)
+struct dec_sub *sub_create(struct mpv_global *global)
{
struct dec_sub *sub = talloc_zero(NULL, struct dec_sub);
- sub->opts = opts;
+ sub->log = mp_log_new(sub, global->log, "sub");
+ sub->opts = global->opts;
return sub;
}
@@ -133,13 +136,13 @@ void sub_set_ass_renderer(struct dec_sub *sub, struct ass_library *ass_library,
static void print_chain(struct dec_sub *sub)
{
- mp_msg(MSGT_OSD, MSGL_V, "Subtitle filter chain: ");
+ MP_VERBOSE(sub, "Subtitle filter chain: ");
for (int n = 0; n < sub->num_sd; n++) {
struct sd *sd = sub->sd[n];
- mp_msg(MSGT_OSD, MSGL_V, "%s%s (%s)", n > 0 ? " -> " : "",
+ MP_VERBOSE(sub, "%s%s (%s)", n > 0 ? " -> " : "",
sd->driver->name, sd->codec);
}
- mp_msg(MSGT_OSD, MSGL_V, "\n");
+ MP_VERBOSE(sub, "\n");
}
static int sub_init_decoder(struct dec_sub *sub, struct sd *sd)
@@ -155,6 +158,7 @@ static int sub_init_decoder(struct dec_sub *sub, struct sd *sd)
if (!sd->driver)
return -1;
+ sd->log = mp_log_new(sd, sub->log, sd->driver->name);
if (sd->driver->init(sd) < 0)
return -1;
@@ -198,7 +202,7 @@ void sub_init_from_sh(struct dec_sub *sub, struct sh_stream *sh)
}
sub_uninit(sub);
- mp_msg(MSGT_OSD, MSGL_ERR, "Could not find subtitle decoder for format '%s'.\n",
+ MP_ERR(sub, "Could not find subtitle decoder for format '%s'.\n",
sh->codec ? sh->codec : "<unknown>");
}
@@ -223,7 +227,8 @@ static void decode_chain(struct sd **sd, int num_sd, struct demux_packet *packet
}
}
-static struct demux_packet *recode_packet(struct demux_packet *in,
+static struct demux_packet *recode_packet(struct mp_log *log,
+ struct demux_packet *in,
const char *charset)
{
struct demux_packet *pkt = NULL;
@@ -249,7 +254,7 @@ static void decode_chain_recode(struct dec_sub *sub, struct sd **sd, int num_sd,
if (num_sd > 0) {
struct demux_packet *recoded = NULL;
if (sub->charset)
- recoded = recode_packet(packet, sub->charset);
+ recoded = recode_packet(sub->log, packet, sub->charset);
decode_chain(sd, num_sd, recoded ? recoded : packet);
talloc_free(recoded);
}
@@ -260,7 +265,8 @@ void sub_decode(struct dec_sub *sub, struct demux_packet *packet)
decode_chain_recode(sub, sub->sd, sub->num_sd, packet);
}
-static const char *guess_sub_cp(struct packet_list *subs, const char *usercp)
+static const char *guess_sub_cp(struct mp_log *log, struct packet_list *subs,
+ const char *usercp)
{
if (!mp_charset_requires_guess(usercp))
return usercp;
@@ -405,10 +411,10 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_stream *sh)
}
if (opts->sub_cp && !sh->sub->is_utf8)
- sub->charset = guess_sub_cp(subs, opts->sub_cp);
+ sub->charset = guess_sub_cp(sub->log, subs, opts->sub_cp);
if (sub->charset && sub->charset[0] && !mp_charset_is_utf8(sub->charset))
- mp_msg(MSGT_OSD, MSGL_INFO, "Using subtitle charset: %s\n", sub->charset);
+ MP_INFO(sub, "Using subtitle charset: %s\n", sub->charset);
double sub_speed = 1.0;
@@ -537,7 +543,7 @@ void sd_conv_add_packet(struct sd *sd, void *data, int data_len, double pts,
return;
out_of_space:
- mp_msg(MSGT_OSD, MSGL_ERR, "Subtitle too big.\n");
+ MP_ERR(sd, "Subtitle too big.\n");
}
struct demux_packet *sd_conv_def_get_converted(struct sd *sd)
diff --git a/sub/dec_sub.h b/sub/dec_sub.h
index 36b947fffa..c659458c04 100644
--- a/sub/dec_sub.h
+++ b/sub/dec_sub.h
@@ -8,7 +8,7 @@
struct sh_stream;
struct ass_track;
-struct MPOpts;
+struct mpv_global;
struct demux_packet;
struct ass_library;
struct ass_renderer;
@@ -22,7 +22,7 @@ enum sd_ctrl {
SD_CTRL_GET_RESOLUTION,
};
-struct dec_sub *sub_create(struct MPOpts *opts);
+struct dec_sub *sub_create(struct mpv_global *global);
void sub_destroy(struct dec_sub *sub);
void sub_set_video_res(struct dec_sub *sub, int w, int h);
diff --git a/sub/osd.c b/sub/osd.c
index ac2b40499a..72ae5db841 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -31,6 +31,7 @@
#include "talloc.h"
#include "options/options.h"
+#include "common/global.h"
#include "common/msg.h"
#include "osd.h"
#include "dec_sub.h"
@@ -79,11 +80,13 @@ static bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
&& a.display_par == b.display_par;
}
-struct osd_state *osd_create(struct MPOpts *opts)
+struct osd_state *osd_create(struct mpv_global *global)
{
struct osd_state *osd = talloc_zero(NULL, struct osd_state);
*osd = (struct osd_state) {
- .opts = opts,
+ .opts = global->opts,
+ .global = global,
+ .log = mp_log_new(osd, global->log, "osd"),
.osd_text = talloc_strdup(osd, ""),
.sub_text = talloc_strdup(osd, ""),
.progbar_type = -1,
@@ -246,8 +249,7 @@ void osd_draw(struct osd_state *osd, struct mp_osd_res res,
if (formats[imgs.format]) {
cb(cb_ctx, &imgs);
} else {
- mp_msg(MSGT_OSD, MSGL_ERR,
- "Can't render OSD part %d (format %d).\n",
+ MP_ERR(osd, "Can't render OSD part %d (format %d).\n",
obj->type, imgs.format);
}
}
diff --git a/sub/osd.h b/sub/osd.h
index d98d111228..9714a06c18 100644
--- a/sub/osd.h
+++ b/sub/osd.h
@@ -154,6 +154,8 @@ struct osd_state {
void *highlight_priv;
struct MPOpts *opts;
+ struct mpv_global *global;
+ struct mp_log *log;
// Internal to sub.c
struct mp_draw_sub_cache *draw_cache;
@@ -202,7 +204,7 @@ struct osd_style_opts {
extern const struct m_sub_options osd_style_conf;
-struct osd_state *osd_create(struct MPOpts *opts);
+struct osd_state *osd_create(struct mpv_global *global);
void osd_set_text(struct osd_state *osd, const char *text);
void osd_set_sub(struct osd_state *osd, const char *text);
void osd_changed(struct osd_state *osd, int new_value);
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index 3e6efe6667..48083bc71f 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -48,7 +48,8 @@ static void create_ass_renderer(struct osd_state *osd, struct osd_object *obj)
if (obj->osd_render)
return;
- obj->osd_ass_library = mp_ass_init(osd->opts);
+ struct mp_log *ass_log = mp_log_new(obj, osd->log, "libass");
+ obj->osd_ass_library = mp_ass_init(osd->global, ass_log);
ass_add_font(obj->osd_ass_library, "mpv-osd-symbols", (void *)osd_font_pfb,
sizeof(osd_font_pfb) - 1);
@@ -56,7 +57,8 @@ static void create_ass_renderer(struct osd_state *osd, struct osd_object *obj)
if (!obj->osd_render)
abort();
- mp_ass_configure_fonts(obj->osd_render, osd->opts->osd_style);
+ mp_ass_configure_fonts(obj->osd_render, osd->opts->osd_style,
+ osd->global, ass_log);
ass_set_aspect_ratio(obj->osd_render, 1.0, 1.0);
}
diff --git a/sub/sd.h b/sub/sd.h
index 0ec4bf273d..088dc166d8 100644
--- a/sub/sd.h
+++ b/sub/sd.h
@@ -5,6 +5,7 @@
#include "demux/packet.h"
struct sd {
+ struct mp_log *log;
struct MPOpts *opts;
const struct sd_functions *driver;
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 93a3c7e380..4b0c3024c8 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -102,12 +102,12 @@ static void decode(struct sd *sd, struct demux_packet *packet)
}
// plaintext subs
if (packet->pts == MP_NOPTS_VALUE) {
- mp_msg(MSGT_SUBREADER, MSGL_WARN, "Subtitle without pts, ignored\n");
+ MP_WARN(sd, "Subtitle without pts, ignored\n");
return;
}
if (packet->duration <= 0) {
- mp_msg(MSGT_SUBREADER, MSGL_WARN, "Subtitle without duration or "
- "duration set to 0 at pts %f, ignored\n", packet->pts);
+ MP_WARN(sd, "Subtitle without duration or "
+ "duration set to 0 at pts %f, ignored\n", packet->pts);
return;
}
unsigned char *text = packet->buffer;
@@ -390,7 +390,7 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
{
int msgl = basic_conv ? MSGL_V : MSGL_WARN;
ctx->last_params = params;
- mp_msg(MSGT_SUBREADER, msgl, "[sd_ass] mangling colors like vsfilter: "
+ MP_MSG(sd, msgl, "mangling colors like vsfilter: "
"RGB -> %s %s -> %s %s -> RGB\n", mp_csp_names[csp],
mp_csp_levels_names[levels], mp_csp_names[params.colorspace],
mp_csp_levels_names[params.colorlevels]);
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 1977ca3fff..dda6ac4f1c 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -111,8 +111,7 @@ static int init(struct sd *sd)
return 0;
error:
- mp_msg(MSGT_SUBREADER, MSGL_ERR,
- "Could not open libavcodec subtitle decoder\n");
+ MP_FATAL(sd, "Could not open libavcodec subtitle decoder\n");
av_free(ctx);
talloc_free(priv);
return -1;
@@ -202,8 +201,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
}
break;
default:
- mp_msg(MSGT_SUBREADER, MSGL_ERR, "sd_lavc: unsupported subtitle "
- "type from libavcodec\n");
+ MP_ERR(sd, "unsupported subtitle type from libavcodec\n");
break;
}
}
diff --git a/sub/sd_lavc_conv.c b/sub/sd_lavc_conv.c
index 0fa3986e3d..566f412cf5 100644
--- a/sub/sd_lavc_conv.c
+++ b/sub/sd_lavc_conv.c
@@ -110,8 +110,7 @@ static int init(struct sd *sd)
return 0;
error:
- mp_msg(MSGT_SUBREADER, MSGL_ERR,
- "Could not open libavcodec subtitle converter\n");
+ MP_FATAL(sd, "Could not open libavcodec subtitle converter\n");
av_free(avctx);
talloc_free(priv);
return -1;
@@ -243,7 +242,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
if (sd->codec && strcmp(sd->codec, "webvtt-webm") == 0) {
if (parse_webvtt(&pkt, &parsed_pkt) < 0) {
- mp_msg(MSGT_OSD, MSGL_ERR, "Error parsing subtitle\n");
+ MP_ERR(sd, "Error parsing subtitle\n");
goto done;
}
pkt = parsed_pkt;
@@ -251,7 +250,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
ret = avcodec_decode_subtitle2(avctx, &sub, &got_sub, &pkt);
if (ret < 0) {
- mp_msg(MSGT_OSD, MSGL_ERR, "Error decoding subtitle\n");
+ MP_ERR(sd, "Error decoding subtitle\n");
} else if (got_sub) {
for (int i = 0; i < sub.num_rects; i++) {
char *ass_line = sub.rects[i]->ass;
diff --git a/sub/sd_spu.c b/sub/sd_spu.c
index 1f815c93aa..3a7bf09127 100644
--- a/sub/sd_spu.c
+++ b/sub/sd_spu.c
@@ -42,7 +42,7 @@ static bool supports_format(const char *format)
static int init(struct sd *sd)
{
- void *spudec = spudec_new_scaled(sd->sub_video_w, sd->sub_video_h,
+ void *spudec = spudec_new_scaled(sd->log, sd->sub_video_w, sd->sub_video_h,
sd->extradata, sd->extradata_len);
if (!spudec)
return -1;
diff --git a/sub/sd_srt.c b/sub/sd_srt.c
index c08f927c4a..18ef0cce8f 100644
--- a/sub/sd_srt.c
+++ b/sub/sd_srt.c
@@ -273,7 +273,8 @@ static int read_attr(char **s, struct bstr *attr, struct bstr *val)
return 0;
}
-static void convert_subrip(const char *orig, char *dest, int dest_buffer_size)
+static void convert_subrip(struct sd *sd, const char *orig,
+ char *dest, int dest_buffer_size)
{
/* line is not const to avoid warnings with strtol, etc.
* orig content won't be changed */
@@ -392,8 +393,7 @@ static void convert_subrip(const char *orig, char *dest, int dest_buffer_size)
tag->has_color = true;
} else {
// We didn't find any matching color
- mp_msg(MSGT_SUBREADER, MSGL_WARN,
- "SubRip: unknown font color in subtitle: >%s<\n",
+ MP_WARN(sd, "unknown font color in subtitle: >%s<\n",
orig);
append_text(&new_line, "{\\c}");
}
@@ -406,8 +406,8 @@ static void convert_subrip(const char *orig, char *dest, int dest_buffer_size)
tag->has_face = true;
has_valid_attr = true;
} else
- mp_msg(MSGT_SUBREADER, MSGL_WARN,"SubRip: unrecognized "
- "attribute \"%.*s\" in font tag\n", BSTR_P(attr));
+ MP_WARN(sd, "unrecognized attribute \"%.*s\" in font tag\n",
+ BSTR_P(attr));
}
if (!has_valid_attr || *line != '>') { /* Not valid font tag */
@@ -463,7 +463,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
{
char dest[SD_MAX_LINE_LEN];
// Assume input buffer is padded with 0
- convert_subrip(packet->buffer, dest, sizeof(dest));
+ convert_subrip(sd, packet->buffer, dest, sizeof(dest));
sd_conv_add_packet(sd, dest, strlen(dest), packet->pts, packet->duration);
}
diff --git a/sub/spudec.c b/sub/spudec.c
index 79b0b2eb93..ea990553a2 100644
--- a/sub/spudec.c
+++ b/sub/spudec.c
@@ -67,6 +67,7 @@ struct spu_packet_t {
};
typedef struct {
+ struct mp_log *log;
packet_t *queue_head;
packet_t *queue_tail;
unsigned int global_palette[16];
@@ -143,12 +144,12 @@ static void next_line(packet_t *packet)
packet->deinterlace_oddness = (packet->deinterlace_oddness + 1) % 2;
}
-static inline unsigned char get_nibble(packet_t *packet)
+static inline unsigned char get_nibble(spudec_handle_t *this, packet_t *packet)
{
unsigned char nib;
unsigned int *nibblep = packet->current_nibble + packet->deinterlace_oddness;
if (*nibblep / 2 >= packet->control_start) {
- mp_msg(MSGT_SPUDEC,MSGL_WARN, "SPUdec: ERROR: get_nibble past end of packet\n");
+ MP_WARN(this, "SPUdec: ERROR: get_nibble past end of packet\n");
return 0;
}
nib = packet->packet[*nibblep / 2];
@@ -273,14 +274,14 @@ static void spudec_process_data(spudec_handle_t *this, packet_t *packet)
&& y < this->pal_height) {
unsigned int len, color;
unsigned int rle = 0;
- rle = get_nibble(packet);
+ rle = get_nibble(this, packet);
if (rle < 0x04) {
if (rle == 0) {
- rle = (rle << 4) | get_nibble(packet);
+ rle = (rle << 4) | get_nibble(this, packet);
if (rle < 0x04)
- rle = (rle << 4) | get_nibble(packet);
+ rle = (rle << 4) | get_nibble(this, packet);
}
- rle = (rle << 4) | get_nibble(packet);
+ rle = (rle << 4) | get_nibble(this, packet);
}
color = 3 - (rle & 0x3);
len = rle >> 2;
@@ -371,14 +372,14 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
start_off = next_off;
date = get_be16(this->packet + start_off) * 1024;
next_off = get_be16(this->packet + start_off + 2);
- mp_msg(MSGT_SPUDEC,MSGL_DBG2, "date=%d\n", date);
+ MP_DBG(this, "date=%d\n", date);
off = start_off + 4;
for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) {
- mp_msg(MSGT_SPUDEC,MSGL_DBG2, "cmd=%d ",type);
+ MP_DBG(this, "cmd=%d ",type);
switch(type) {
case 0x00:
/* Menu ID, 1 byte */
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n");
+ MP_DBG(this, "Menu ID\n");
/* shouldn't a Menu ID type force display start? */
start_pts = pts100 < 0 && -pts100 >= date ? 0 : pts100 + date;
end_pts = UINT_MAX;
@@ -387,7 +388,7 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
break;
case 0x01:
/* Start display */
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n");
+ MP_DBG(this, "Start display!\n");
start_pts = pts100 < 0 && -pts100 >= date ? 0 : pts100 + date;
end_pts = UINT_MAX;
display = 1;
@@ -395,7 +396,7 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
break;
case 0x02:
/* Stop display */
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n");
+ MP_DBG(this, "Stop display!\n");
end_pts = pts100 < 0 && -pts100 >= date ? 0 : pts100 + date;
break;
case 0x03:
@@ -404,7 +405,7 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
this->palette[1] = this->packet[off] & 0xf;
this->palette[2] = this->packet[off + 1] >> 4;
this->palette[3] = this->packet[off + 1] & 0xf;
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Palette %d, %d, %d, %d\n",
+ MP_DBG(this, "Palette %d, %d, %d, %d\n",
this->palette[0], this->palette[1], this->palette[2], this->palette[3]);
off+=2;
break;
@@ -426,7 +427,7 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
this->alpha[1] = b;
this->alpha[2] = c;
this->alpha[3] = d;
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Alpha %d, %d, %d, %d\n",
+ MP_DBG(this, "Alpha %d, %d, %d, %d\n",
this->alpha[0], this->alpha[1], this->alpha[2], this->alpha[3]);
off+=2;
break;
@@ -441,7 +442,7 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
start_row = b >> 12;
end_row = b & 0xfff;
height = (end_row < start_row) ? 0 : end_row - start_row /* + 1 */;
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Coords col: %d - %d row: %d - %d (%dx%d)\n",
+ MP_DBG(this, "Coords col: %d - %d row: %d - %d (%dx%d)\n",
start_col, end_col, start_row, end_row,
width, height);
off+=6;
@@ -450,12 +451,12 @@ static void spudec_process_control(spudec_handle_t *this, int pts100)
/* Graphic lines */
current_nibble[0] = 2 * get_be16(this->packet + off);
current_nibble[1] = 2 * get_be16(this->packet + off + 2);
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Graphic offset 1: %d offset 2: %d\n",
+ MP_DBG(this, "Graphic offset 1: %d offset 2: %d\n",
current_nibble[0] / 2, current_nibble[1] / 2);
off+=4;
break;
default:
- mp_msg(MSGT_SPUDEC,MSGL_WARN,"spudec: Error determining control type 0x%02x. Skipping %d bytes.\n",
+ MP_WARN(this, "spudec: Error determining control type 0x%02x. Skipping %d bytes.\n",
type, next_off - off);
goto next_control;
}
@@ -502,12 +503,13 @@ int spudec_changed(void * this)
return spu->spu_changed || spu->now_pts > spu->end_pts;
}
-void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pts100)
+void spudec_assemble(void *idontknowc, unsigned char *packet, unsigned int len, int pts100)
{
+ spudec_handle_t *this = idontknowc;
spudec_handle_t *spu = this;
// spudec_heartbeat(this, pts100);
if (len < 2) {
- mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: packet too short\n");
+ MP_WARN(this, "SPUasm: packet too short\n");
return;
}
spu->packet_pts = pts100;
@@ -522,7 +524,7 @@ void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pt
if (spu->packet != NULL) {
spu->packet_size = len2;
if (len > len2) {
- mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: invalid frag len / len2: %d / %d \n", len, len2);
+ MP_WARN(this, "SPUasm: invalid frag len / len2: %d / %d \n", len, len2);
return;
}
memcpy(spu->packet, packet, len);
@@ -532,7 +534,7 @@ void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pt
} else {
// Continue current fragment
if (spu->packet_size < spu->packet_offset + len){
- mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: invalid fragment\n");
+ MP_WARN(this, "SPUasm: invalid fragment\n");
spu->packet_size = spu->packet_offset = 0;
return;
} else {
@@ -549,16 +551,16 @@ void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pt
unsigned int x=0,y;
while(x+4<=spu->packet_offset){
y=get_be16(spu->packet+x+2); // next control pointer
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUtest: x=%d y=%d off=%d size=%d\n",x,y,spu->packet_offset,spu->packet_size);
+ MP_DBG(this, "SPUtest: x=%d y=%d off=%d size=%d\n",x,y,spu->packet_offset,spu->packet_size);
if(x>=4 && x==y){ // if it points to self - we're done!
// we got it!
- mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size);
+ MP_DBG(this, "SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size);
spudec_decode(spu, pts100);
spu->packet_offset = 0;
break;
}
if(y<=x || y>=spu->packet_size){ // invalid?
- mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x);
+ MP_WARN(this, "SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x);
spu->packet_size = spu->packet_offset = 0;
break;
}
@@ -750,10 +752,11 @@ static void spudec_parse_extradata(spudec_handle_t *this,
free(buffer);
}
-void *spudec_new_scaled(unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len)
+void *spudec_new_scaled(struct mp_log *log, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len)
{
spudec_handle_t *this = calloc(1, sizeof(spudec_handle_t));
if (this){
+ this->log = log;
this->orig_frame_height = frame_height;
this->orig_frame_width = frame_width;
// set up palette:
@@ -773,7 +776,7 @@ void *spudec_new_scaled(unsigned int frame_width, unsigned int frame_height, uin
}
}
else
- mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc");
+ MP_FATAL(this, "FATAL: spudec_init: calloc");
return this;
}
diff --git a/sub/spudec.h b/sub/spudec.h
index 55071d823e..197102b360 100644
--- a/sub/spudec.h
+++ b/sub/spudec.h
@@ -23,11 +23,12 @@
struct sub_bitmaps;
struct mp_osd_res;
+struct mp_log;
void spudec_heartbeat(void *this, unsigned int pts100);
void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pts100);
void spudec_get_indexed(void *this, struct mp_osd_res *dim, double xstretch, double ystretch, struct sub_bitmaps *res);
-void *spudec_new_scaled(unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len);
+void *spudec_new_scaled(struct mp_log *log, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len);
void spudec_free(void *this);
void spudec_reset(void *this); // called after seek
int spudec_visible(void *this); // check if spu is visible