aboutsummaryrefslogtreecommitdiffhomepage
path: root/demux
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2013-12-21 20:24:20 +0100
committerGravatar wm4 <wm4@nowhere>2013-12-21 21:43:16 +0100
commit3dbc9007b080028f0aebbbf8b9ab1233cd70c45b (patch)
treee6e46e5dd238338c44d421ef4f9101c9898c3cbf /demux
parent9149e2af568d4cb251f8b105f360c3e6b9fd9d86 (diff)
demux: mp_msg conversions
The TV code pretends to be part of stream/, but it's actually demuxer code too. The audio_in code is shared between the TV code and stream_radio.c, so stream_radio.c needs a small hack until stream.c is converted.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c96
-rw-r--r--demux/demux.h7
-rw-r--r--demux/demux_lavf.c59
-rw-r--r--demux/demux_libass.c2
-rw-r--r--demux/demux_mf.c10
-rw-r--r--demux/demux_mkv.c297
-rw-r--r--demux/demux_raw.c5
-rw-r--r--demux/demux_subreader.c58
-rw-r--r--demux/ebml.c72
-rw-r--r--demux/ebml.h8
-rw-r--r--demux/mf.c37
-rw-r--r--demux/mf.h7
12 files changed, 316 insertions, 342 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 8d46f79391..7643b58a38 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -33,6 +33,7 @@
#include "common/av_common.h"
#include "talloc.h"
#include "common/msg.h"
+#include "common/global.h"
#include "stream/stream.h"
#include "demux.h"
@@ -225,7 +226,7 @@ struct demux_packet *demux_copy_packet(struct demux_packet *dp)
struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
{
if (demuxer->num_streams > MAX_SH_STREAMS) {
- mp_msg(MSGT_DEMUXER, MSGL_WARN, "Too many streams.");
+ MP_WARN(demuxer, "Too many streams.");
return NULL;
}
@@ -353,8 +354,7 @@ int demuxer_add_packet(demuxer_t *demuxer, struct sh_stream *stream,
if (stream->type != STREAM_VIDEO && dp->pts == MP_NOPTS_VALUE)
dp->pts = dp->dts;
- mp_msg(MSGT_DEMUXER, MSGL_DBG2,
- "DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%"PRIu64" "
+ MP_DBG(demuxer, "DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%"PRIu64" "
"[packs: A=%d V=%d S=%d]\n", stream_type_name(stream->type),
dp->len, dp->pts, dp->pos, count_packs(demuxer, STREAM_AUDIO),
count_packs(demuxer, STREAM_VIDEO), count_packs(demuxer, STREAM_SUB));
@@ -373,13 +373,13 @@ static bool demux_check_queue_full(demuxer_t *demux)
overflow:
if (!demux->warned_queue_overflow) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, "\nToo many packets in the demuxer "
- "packet queue (video: %d packets in %d bytes, audio: %d "
- "packets in %d bytes, sub: %d packets in %d bytes).\n",
- count_packs(demux, STREAM_VIDEO), count_bytes(demux, STREAM_VIDEO),
- count_packs(demux, STREAM_AUDIO), count_bytes(demux, STREAM_AUDIO),
- count_packs(demux, STREAM_SUB), count_bytes(demux, STREAM_SUB));
- mp_msg(MSGT_DEMUXER, MSGL_HINT, "Maybe you are playing a non-"
+ MP_ERR(demux, "\nToo many packets in the demuxer "
+ "packet queue (video: %d packets in %d bytes, audio: %d "
+ "packets in %d bytes, sub: %d packets in %d bytes).\n",
+ count_packs(demux, STREAM_VIDEO), count_bytes(demux, STREAM_VIDEO),
+ count_packs(demux, STREAM_AUDIO), count_bytes(demux, STREAM_AUDIO),
+ count_packs(demux, STREAM_SUB), count_bytes(demux, STREAM_SUB));
+ MP_INFO(demux, "Maybe you are playing a non-"
"interleaved stream/file or the codec failed?\n");
}
demux->warned_queue_overflow = true;
@@ -399,8 +399,8 @@ static void ds_get_packets(struct sh_stream *sh)
{
struct demux_stream *ds = sh->ds;
demuxer_t *demux = sh->demuxer;
- mp_msg(MSGT_DEMUXER, MSGL_DBG3, "ds_get_packets (%s) called\n",
- stream_type_name(sh->type));
+ MP_TRACE(demux, "ds_get_packets (%s) called\n",
+ stream_type_name(sh->type));
while (1) {
if (ds->head)
return;
@@ -411,8 +411,8 @@ static void ds_get_packets(struct sh_stream *sh)
if (!demux_fill_buffer(demux))
break; // EOF
}
- mp_msg(MSGT_DEMUXER, MSGL_V, "ds_get_packets: EOF reached (stream: %s)\n",
- stream_type_name(sh->type));
+ MP_VERBOSE(demux, "ds_get_packets: EOF reached (stream: %s)\n",
+ stream_type_name(sh->type));
ds->eof = 1;
}
@@ -476,16 +476,15 @@ bool demux_stream_eof(struct sh_stream *sh)
// ====================================================================
-void demuxer_help(void)
+void demuxer_help(struct mp_log *log)
{
int i;
- mp_msg(MSGT_DEMUXER, MSGL_INFO, "Available demuxers:\n");
- mp_msg(MSGT_DEMUXER, MSGL_INFO, " demuxer: info:\n");
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DEMUXERS\n");
+ mp_info(log, "Available demuxers:\n");
+ mp_info(log, " demuxer: info:\n");
for (i = 0; demuxer_list[i]; i++) {
- mp_msg(MSGT_DEMUXER, MSGL_INFO, "%10s %s\n",
- demuxer_list[i]->name, demuxer_list[i]->desc);
+ mp_info(log, "%10s %s\n",
+ demuxer_list[i]->name, demuxer_list[i]->desc);
}
}
@@ -500,7 +499,8 @@ static const char *d_level(enum demux_check level)
abort();
}
-static struct demuxer *open_given_type(struct MPOpts *opts,
+static struct demuxer *open_given_type(struct mpv_global *global,
+ struct mp_log *log,
const struct demuxer_desc *desc,
struct stream *stream,
struct demuxer_params *params,
@@ -516,25 +516,26 @@ static struct demuxer *open_given_type(struct MPOpts *opts,
stream->end_pos > 0,
.accurate_seek = true,
.filepos = -1,
- .opts = opts,
+ .opts = global->opts,
+ .global = global,
+ .log = mp_log_new(demuxer, log, desc->name),
.filename = talloc_strdup(demuxer, stream->url),
.metadata = talloc_zero(demuxer, struct mp_tags),
};
demuxer->params = params; // temporary during open()
stream_seek(stream, stream->start_pos);
- mp_msg(MSGT_DEMUXER, MSGL_V, "Trying demuxer: %s (force-level: %s)\n",
- desc->name, d_level(check));
+ mp_verbose(log, "Trying demuxer: %s (force-level: %s)\n",
+ desc->name, d_level(check));
int ret = demuxer->desc->open(demuxer, check);
if (ret >= 0) {
demuxer->params = NULL;
if (demuxer->filetype)
- mp_msg(MSGT_DEMUXER, MSGL_INFO, "Detected file format: %s (%s)\n",
+ mp_info(log, "Detected file format: %s (%s)\n",
demuxer->filetype, desc->desc);
else
- mp_msg(MSGT_DEMUXER, MSGL_INFO, "Detected file format: %s\n",
- desc->desc);
+ mp_info(log, "Detected file format: %s\n", desc->desc);
if (stream_manages_timeline(demuxer->stream)) {
// Incorrect, but fixes some behavior with DVD/BD
demuxer->ts_resets_possible = false;
@@ -548,8 +549,8 @@ static struct demuxer *open_given_type(struct MPOpts *opts,
demux_info_update(demuxer);
// Pretend we can seek if we can't seek, but there's a cache.
if (!demuxer->seekable && stream->uncached_stream) {
- mp_msg(MSGT_DEMUXER, MSGL_WARN,
- "File is not seekable, but there's a cache: enabling seeking.\n");
+ mp_warn(log,
+ "File is not seekable, but there's a cache: enabling seeking.\n");
demuxer->seekable = true;
}
return demuxer;
@@ -564,10 +565,13 @@ static const int d_request[] = {DEMUX_CHECK_REQUEST, -1};
static const int d_force[] = {DEMUX_CHECK_FORCE, -1};
struct demuxer *demux_open(struct stream *stream, char *force_format,
- struct demuxer_params *params, struct MPOpts *opts)
+ struct demuxer_params *params,
+ struct mpv_global *global)
{
const int *check_levels = d_normal;
const struct demuxer_desc *check_desc = NULL;
+ struct mp_log *log = mp_log_new(NULL, global->log, "!demux");
+ struct demuxer *demuxer = NULL;
if (!force_format)
force_format = stream->demuxer;
@@ -583,9 +587,8 @@ struct demuxer *demux_open(struct stream *stream, char *force_format,
check_desc = demuxer_list[n];
}
if (!check_desc) {
- mp_msg(MSGT_DEMUXER, MSGL_ERR, "Demuxer %s does not exist.\n",
- force_format);
- return NULL;
+ mp_err(log, "Demuxer %s does not exist.\n", force_format);
+ goto done;
}
}
@@ -599,15 +602,16 @@ struct demuxer *demux_open(struct stream *stream, char *force_format,
for (int n = 0; demuxer_list[n]; n++) {
const struct demuxer_desc *desc = demuxer_list[n];
if (!check_desc || desc == check_desc) {
- struct demuxer *demuxer = open_given_type(opts, desc, stream,
- params, level);
+ demuxer = open_given_type(global, log, desc, stream, params, level);
if (demuxer)
- return demuxer;
+ goto done;
}
}
}
- return NULL;
+done:
+ talloc_free(log);
+ return demuxer;
}
void demux_flush(demuxer_t *demuxer)
@@ -620,7 +624,7 @@ void demux_flush(demuxer_t *demuxer)
int demux_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
{
if (!demuxer->seekable) {
- mp_msg(MSGT_DEMUXER, MSGL_WARN, "Cannot seek in this file.\n");
+ MP_WARN(demuxer, "Cannot seek in this file.\n");
return 0;
}
@@ -716,7 +720,7 @@ int demux_info_add_bstr(demuxer_t *demuxer, struct bstr opt, struct bstr param)
if (oldval) {
if (bstrcmp0(param, oldval) == 0)
return 0;
- mp_msg(MSGT_DEMUX, MSGL_INFO, "Demuxer info %.*s changed to %.*s\n",
+ MP_INFO(demuxer, "Demuxer info %.*s changed to %.*s\n",
BSTR_P(opt), BSTR_P(param));
}
@@ -732,16 +736,16 @@ int demux_info_print(demuxer_t *demuxer)
if (!info || !info->num_keys)
return 0;
- mp_msg(MSGT_DEMUX, MSGL_INFO, "Clip info:\n");
+ MP_INFO(demuxer, "Clip info:\n");
for (n = 0; n < info->num_keys; n++) {
- mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n", info->keys[n],
- info->values[n]);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_NAME%d=%s\n", n,
- info->keys[n]);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_VALUE%d=%s\n", n,
+ MP_INFO(demuxer, " %s: %s\n", info->keys[n],
info->values[n]);
+ MP_SMODE(demuxer, "ID_CLIP_INFO_NAME%d=%s\n", n,
+ info->keys[n]);
+ MP_SMODE(demuxer, "ID_CLIP_INFO_VALUE%d=%s\n", n,
+ info->values[n]);
}
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CLIP_INFO_N=%d\n", n);
+ MP_SMODE(demuxer, "ID_CLIP_INFO_N=%d\n", n);
return 0;
}
diff --git a/demux/demux.h b/demux/demux.h
index 6d5253786f..7b25032011 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -194,6 +194,8 @@ typedef struct demuxer {
void *priv; // demuxer-specific internal data
struct MPOpts *opts;
+ struct mpv_global *global;
+ struct mp_log *log;
struct demuxer_params *params;
} demuxer_t;
@@ -227,7 +229,8 @@ bool demux_stream_eof(struct sh_stream *sh);
struct sh_stream *new_sh_stream(struct demuxer *demuxer, enum stream_type type);
struct demuxer *demux_open(struct stream *stream, char *force_format,
- struct demuxer_params *params, struct MPOpts *opts);
+ struct demuxer_params *params,
+ struct mpv_global *global);
void demux_flush(struct demuxer *demuxer);
int demux_seek(struct demuxer *demuxer, float rel_seek_secs, int flags);
@@ -247,7 +250,7 @@ void demuxer_select_track(struct demuxer *demuxer, struct sh_stream *stream,
bool selected);
void demuxer_enable_autoselect(struct demuxer *demuxer);
-void demuxer_help(void);
+void demuxer_help(struct mp_log *log);
int demuxer_add_attachment(struct demuxer *demuxer, struct bstr name,
struct bstr type, struct bstr data);
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 9057284c1e..ceef14f4d0 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -121,8 +121,7 @@ static int mp_read(void *opaque, uint8_t *buf, int size)
ret = stream_read(stream, buf, size);
- mp_msg(MSGT_HEADER, MSGL_DBG2,
- "%d=mp_read(%p, %p, %d), pos: %"PRId64", eof:%d\n",
+ MP_DBG(demuxer, "%d=mp_read(%p, %p, %d), pos: %"PRId64", eof:%d\n",
ret, stream, buf, size, stream_tell(stream), stream->eof);
return ret;
}
@@ -132,7 +131,7 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
struct demuxer *demuxer = opaque;
struct stream *stream = demuxer->stream;
int64_t current_pos;
- mp_msg(MSGT_HEADER, MSGL_DBG2, "mp_seek(%p, %"PRId64", %d)\n",
+ MP_DBG(demuxer, "mp_seek(%p, %"PRId64", %d)\n",
stream, pos, whence);
if (whence == SEEK_CUR)
pos += stream_tell(stream);
@@ -171,12 +170,12 @@ static int64_t mp_read_seek(void *opaque, int stream_idx, int64_t ts, int flags)
return ret;
}
-static void list_formats(void)
+static void list_formats(struct demuxer *demuxer)
{
- mp_msg(MSGT_DEMUX, MSGL_INFO, "Available lavf input formats:\n");
+ MP_INFO(demuxer, "Available lavf input formats:\n");
AVInputFormat *fmt = NULL;
while ((fmt = av_iformat_next(fmt)))
- mp_msg(MSGT_DEMUX, MSGL_INFO, "%15s : %s\n", fmt->name, fmt->long_name);
+ MP_INFO(demuxer, "%15s : %s\n", fmt->name, fmt->long_name);
}
static char *remove_prefix(char *s, const char **prefixes)
@@ -206,7 +205,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
priv->filename = s->url;
if (!priv->filename) {
priv->filename = "mp:unknown";
- mp_msg(MSGT_DEMUX, MSGL_WARN, "Stream url is not set!\n");
+ MP_WARN(demuxer, "Stream url is not set!\n");
}
priv->filename = remove_prefix(priv->filename, prefixes);
@@ -216,8 +215,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
// always require filename in the form "format:filename"
char *sep = strchr(priv->filename, ':');
if (!sep) {
- mp_msg(MSGT_DEMUX, MSGL_FATAL,
- "Must specify filename in 'format:filename' form\n");
+ MP_FATAL(demuxer, "Must specify filename in 'format:filename' form\n");
return -1;
}
avdevice_format = talloc_strndup(priv, priv->filename,
@@ -244,15 +242,15 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
format = avdevice_format;
if (format) {
if (strcmp(format, "help") == 0) {
- list_formats();
+ list_formats(demuxer);
return -1;
}
priv->avif = av_find_input_format(format);
if (!priv->avif) {
- mp_msg(MSGT_DEMUX, MSGL_FATAL, "Unknown lavf format %s\n", format);
+ MP_FATAL(demuxer, "Unknown lavf format %s\n", format);
return -1;
}
- mp_msg(MSGT_DEMUX, MSGL_INFO, "Forced lavf %s demuxer\n",
+ MP_INFO(demuxer, "Forced lavf %s demuxer\n",
priv->avif->long_name);
goto success;
}
@@ -284,7 +282,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
priv->avif = av_probe_input_format2(&avpd, avpd.buf_size > 0, &score);
if (priv->avif) {
- mp_msg(MSGT_HEADER, MSGL_V, "Found '%s' at score=%d size=%d.\n",
+ MP_VERBOSE(demuxer, "Found '%s' at score=%d size=%d.\n",
priv->avif->name, score, avpd.buf_size);
if (score >= min_probe)
@@ -305,7 +303,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
if (priv->avif && !format) {
for (int n = 0; format_blacklist[n]; n++) {
if (strcmp(format_blacklist[n], priv->avif->name) == 0) {
- mp_msg(MSGT_HEADER, MSGL_V, "Format blacklisted.\n");
+ MP_VERBOSE(demuxer, "Format blacklisted.\n");
priv->avif = NULL;
break;
}
@@ -313,8 +311,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
}
if (!priv->avif) {
- mp_msg(MSGT_HEADER, MSGL_V,
- "No format found, try lowering probescore or forcing the format.\n");
+ MP_VERBOSE(demuxer, "No format found, try lowering probescore or forcing the format.\n");
return -1;
}
@@ -444,7 +441,7 @@ static void handle_stream(demuxer_t *demuxer, int i)
// This also applies to vfw-muxed mkv, but we can't detect these easily.
sh_video->avi_dts = matches_avinputformat_name(priv, "avi");
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "aspect= %d*%d/(%d*%d)\n",
+ MP_DBG(demuxer, "aspect= %d*%d/(%d*%d)\n",
codec->width, codec->sample_aspect_ratio.num,
codec->height, codec->sample_aspect_ratio.den);
break;
@@ -542,8 +539,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (lavfdopts->probesize) {
if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0)
- mp_msg(MSGT_HEADER, MSGL_ERR,
- "demux_lavf, couldn't set option probesize to %u\n",
+ MP_ERR(demuxer, "demux_lavf, couldn't set option probesize to %u\n",
lavfdopts->probesize);
}
@@ -554,14 +550,13 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (analyze_duration > 0) {
if (av_opt_set_int(avfc, "analyzeduration",
analyze_duration * AV_TIME_BASE, 0) < 0)
- mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option "
+ MP_ERR(demuxer, "demux_lavf, couldn't set option "
"analyzeduration to %f\n", analyze_duration);
}
if (lavfdopts->avopt) {
if (parse_avopts(avfc, lavfdopts->avopt) < 0) {
- mp_msg(MSGT_HEADER, MSGL_ERR,
- "Your options /%s/ look like gibberish to me pal\n",
+ MP_ERR(demuxer, "Your options /%s/ look like gibberish to me pal\n",
lavfdopts->avopt);
return -1;
}
@@ -601,27 +596,25 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
}
if (avformat_open_input(&avfc, priv->filename, priv->avif, &dopts) < 0) {
- mp_msg(MSGT_HEADER, MSGL_ERR,
- "LAVF_header: avformat_open_input() failed\n");
+ MP_ERR(demuxer, "LAVF_header: avformat_open_input() failed\n");
av_dict_free(&dopts);
return -1;
}
t = NULL;
while ((t = av_dict_get(dopts, "", t, AV_DICT_IGNORE_SUFFIX))) {
- mp_msg(MSGT_OPEN, MSGL_V, "[lavf] Could not set demux option %s=%s\n",
+ MP_VERBOSE(demuxer, "[lavf] Could not set demux option %s=%s\n",
t->key, t->value);
}
av_dict_free(&dopts);
priv->avfc = avfc;
if (avformat_find_stream_info(avfc, NULL) < 0) {
- mp_msg(MSGT_HEADER, MSGL_ERR,
- "LAVF_header: av_find_stream_info() failed\n");
+ MP_ERR(demuxer, "LAVF_header: av_find_stream_info() failed\n");
return -1;
}
- mp_msg(MSGT_HEADER, MSGL_V, "demux_lavf: avformat_find_stream_info() "
+ MP_VERBOSE(demuxer, "demux_lavf: avformat_find_stream_info() "
"finished after %"PRId64" bytes.\n", stream_tell(demuxer->stream));
for (i = 0; i < avfc->nb_chapters; i++) {
@@ -658,13 +651,13 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
for (p = 0; p < avfc->nb_programs; p++) {
AVProgram *program = avfc->programs[p];
t = av_dict_get(program->metadata, "title", NULL, 0);
- mp_msg(MSGT_HEADER, MSGL_INFO, "LAVF: Program %d %s\n",
+ MP_INFO(demuxer, "LAVF: Program %d %s\n",
program->id, t ? t->value : "");
- mp_msg(MSGT_IDENTIFY, MSGL_V, "PROGRAM_ID=%d\n", program->id);
+ MP_VERBOSE(demuxer, "PROGRAM_ID=%d\n", program->id);
}
}
- mp_msg(MSGT_HEADER, MSGL_V, "LAVF: build %d\n", LIBAVFORMAT_BUILD);
+ MP_VERBOSE(demuxer, "LAVF: build %d\n", LIBAVFORMAT_BUILD);
demuxer->ts_resets_possible = priv->avif->flags & AVFMT_TS_DISCONT;
@@ -680,7 +673,7 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
{
lavf_priv_t *priv = demux->priv;
demux_packet_t *dp;
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "demux_lavf_fill_buffer()\n");
+ MP_DBG(demux, "demux_lavf_fill_buffer()\n");
AVPacket *pkt = talloc(NULL, AVPacket);
if (av_read_frame(priv->avfc, pkt) < 0) {
@@ -737,7 +730,7 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags)
{
lavf_priv_t *priv = demuxer->priv;
int avsflags = 0;
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "demux_seek_lavf(%p, %f, %d)\n",
+ MP_DBG(demuxer, "demux_seek_lavf(%p, %f, %d)\n",
demuxer, rel_seek_secs, flags);
if (flags & SEEK_ABSOLUTE)
diff --git a/demux/demux_libass.c b/demux/demux_libass.c
index f01b999d9e..15f5195cfc 100644
--- a/demux/demux_libass.c
+++ b/demux/demux_libass.c
@@ -73,7 +73,7 @@ static int d_check_file(struct demuxer *demuxer, enum demux_check check)
bstr buf = stream_read_complete(s, NULL, 100000000);
if (!buf.start) {
- mp_msg(MSGT_ASS, MSGL_ERR, "Refusing to load subtitle file "
+ MP_ERR(demuxer, "Refusing to load subtitle file "
"larger than 100 MB: %s\n", demuxer->filename);
return -1;
}
diff --git a/demux/demux_mf.c b/demux/demux_mf.c
index 876b17a025..1d80cfaa85 100644
--- a/demux/demux_mf.c
+++ b/demux/demux_mf.c
@@ -158,11 +158,9 @@ static const char *probe_format(mf_t *mf, enum demux_check check)
}
if (check == DEMUX_CHECK_REQUEST) {
if (!mf_type) {
- mp_msg(MSGT_DEMUX, MSGL_ERR,
- "[demux_mf] file type was not set! (try --mf-type=ext)\n");
+ MP_ERR(mf, "file type was not set! (try --mf-type=ext)\n");
} else {
- mp_msg(MSGT_DEMUX, MSGL_ERR,
- "[demux_mf] --mf-type set to an unknown codec!\n");
+ MP_ERR(mf, "--mf-type set to an unknown codec!\n");
}
}
return NULL;
@@ -175,9 +173,9 @@ static int demux_open_mf(demuxer_t *demuxer, enum demux_check check)
if (strncmp(demuxer->stream->url, "mf://", 5) == 0 &&
demuxer->stream->type == STREAMTYPE_MF)
- mf = open_mf_pattern(demuxer, demuxer->stream->url + 5);
+ mf = open_mf_pattern(demuxer, demuxer->log, demuxer->stream->url + 5);
else {
- mf = open_mf_single(demuxer, demuxer->stream->url);
+ mf = open_mf_single(demuxer, demuxer->log, demuxer->stream->url);
int bog = 0;
MP_TARRAY_APPEND(mf, mf->streams, bog, demuxer->stream);
}
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 52ab592eb0..8c3189b539 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -249,7 +249,8 @@ static int aac_get_sample_rate_index(uint32_t sample_rate)
return i;
}
-static bstr demux_mkv_decode(mkv_track_t *track, bstr data, uint32_t type)
+static bstr demux_mkv_decode(struct mp_log *log, mkv_track_t *track,
+ bstr data, uint32_t type)
{
uint8_t *src = data.start;
uint8_t *orig_src = src;
@@ -278,8 +279,7 @@ static bstr demux_mkv_decode(mkv_track_t *track, bstr data, uint32_t type)
zstream.zfree = (free_func) 0;
zstream.opaque = (voidpf) 0;
if (inflateInit(&zstream) != Z_OK) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] zlib initialization failed.\n");
+ mp_warn(log, "zlib initialization failed.\n");
goto error;
}
zstream.next_in = (Bytef *) src;
@@ -294,8 +294,7 @@ static bstr demux_mkv_decode(mkv_track_t *track, bstr data, uint32_t type)
zstream.next_out = (Bytef *) (dest + zstream.total_out);
result = inflate(&zstream, Z_NO_FLUSH);
if (result != Z_OK && result != Z_STREAM_END) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] zlib decompression failed.\n");
+ mp_warn(log, "zlib decompression failed.\n");
talloc_free(dest);
dest = NULL;
inflateEnd(&zstream);
@@ -323,14 +322,12 @@ static bstr demux_mkv_decode(mkv_track_t *track, bstr data, uint32_t type)
if (result == 0)
break;
if (!(result & AV_LZO_OUTPUT_FULL)) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] lzo decompression failed.\n");
+ mp_warn(log, "lzo decompression failed.\n");
talloc_free(dest);
dest = NULL;
goto error;
}
- mp_msg(MSGT_DEMUX, MSGL_DBG2,
- "[mkv] lzo decompression buffer too small.\n");
+ mp_dbg(log, "lzo decompression buffer too small.\n");
dstlen *= 2;
}
size = dstlen - out_avail;
@@ -359,17 +356,16 @@ static int demux_mkv_read_info(demuxer_t *demuxer)
mkv_d->duration = 0;
struct ebml_info info = {0};
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
if (ebml_read_element(s, &parse_ctx, &info, &ebml_info_desc) < 0)
return -1;
if (info.n_timecode_scale) {
mkv_d->tc_scale = info.timecode_scale;
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] | + timecode scale: %" PRIu64 "\n", mkv_d->tc_scale);
+ MP_VERBOSE(demuxer, "| + timecode scale: %" PRIu64 "\n", mkv_d->tc_scale);
}
if (info.n_duration) {
mkv_d->duration = info.duration * mkv_d->tc_scale / 1e9;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3fs\n",
+ MP_VERBOSE(demuxer, "| + duration: %.3fs\n",
mkv_d->duration);
}
if (info.n_title) {
@@ -378,16 +374,15 @@ static int demux_mkv_read_info(demuxer_t *demuxer)
if (info.n_segment_uid) {
int len = info.segment_uid.len;
if (len != sizeof(demuxer->matroska_data.uid.segment)) {
- mp_msg(MSGT_DEMUX, MSGL_INFO,
- "[mkv] segment uid invalid length %d\n", len);
+ MP_INFO(demuxer, "segment uid invalid length %d\n", len);
} else {
memcpy(demuxer->matroska_data.uid.segment, info.segment_uid.start,
len);
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + segment uid");
+ MP_VERBOSE(demuxer, "| + segment uid");
for (int i = 0; i < len; i++)
- mp_msg(MSGT_DEMUX, MSGL_V, " %02x",
+ MP_VERBOSE(demuxer, " %02x",
demuxer->matroska_data.uid.segment[i]);
- mp_msg(MSGT_DEMUX, MSGL_V, "\n");
+ MP_VERBOSE(demuxer, "\n");
}
}
if (demuxer->params && demuxer->params->matroska_wanted_uids) {
@@ -400,8 +395,7 @@ static int demux_mkv_read_info(demuxer_t *demuxer)
}
}
}
- mp_msg(MSGT_DEMUX, MSGL_INFO,
- "[mkv] This is not one of the wanted files. "
+ MP_INFO(demuxer, "This is not one of the wanted files. "
"Stopping attempt to open.\n");
res = -2;
}
@@ -439,29 +433,26 @@ static void parse_trackencodings(struct demuxer *demuxer,
}
if (e.type == 1) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Track "
+ MP_WARN(demuxer, "Track "
"number %u has been encrypted and "
"decryption has not yet been\n"
- "[mkv] implemented. Skipping track.\n",
+ "implemented. Skipping track.\n",
track->tnum);
} else if (e.type != 0) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] Unknown content encoding type for "
+ MP_WARN(demuxer, "Unknown content encoding type for "
"track %u. Skipping track.\n",
track->tnum);
} else if (e.comp_algo != 0 && e.comp_algo != 2 && e.comp_algo != 3) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] Track %u has been compressed with "
+ MP_WARN(demuxer, "Track %u has been compressed with "
"an unknown/unsupported compression\n"
- "[mkv] algorithm (%" PRIu64 "). Skipping track.\n",
+ "algorithm (%" PRIu64 "). Skipping track.\n",
track->tnum, e.comp_algo);
}
#if !HAVE_ZLIB
else if (e.comp_algo == 0) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] Track %u was compressed with zlib "
+ MP_WARN(demuxer, "Track %u was compressed with zlib "
"but mpv has not been compiled\n"
- "[mkv] with support for zlib compression. "
+ "with support for zlib compression. "
"Skipping track.\n",
track->tnum);
}
@@ -485,26 +476,24 @@ static void parse_trackaudio(struct demuxer *demuxer, struct mkv_track *track,
{
if (audio->n_sampling_frequency) {
track->a_sfreq = audio->sampling_frequency;
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] | + Sampling frequency: %f\n", track->a_sfreq);
+ MP_VERBOSE(demuxer, "| + Sampling frequency: %f\n", track->a_sfreq);
} else {
track->a_sfreq = 8000;
}
if (audio->n_output_sampling_frequency) {
track->a_osfreq = audio->output_sampling_frequency;
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] | + Output sampling frequency: %f\n", track->a_osfreq);
+ MP_VERBOSE(demuxer, "| + Output sampling frequency: %f\n", track->a_osfreq);
} else {
track->a_osfreq = track->a_sfreq;
}
if (audio->n_bit_depth) {
track->a_bps = audio->bit_depth;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Bit depth: %u\n",
+ MP_VERBOSE(demuxer, "| + Bit depth: %u\n",
track->a_bps);
}
if (audio->n_channels) {
track->a_channels = audio->channels;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Channels: %u\n",
+ MP_VERBOSE(demuxer, "| + Channels: %u\n",
track->a_channels);
} else {
track->a_channels = 1;
@@ -516,7 +505,7 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
{
if (video->n_frame_rate) {
track->v_frate = video->frame_rate;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n",
+ MP_VERBOSE(demuxer, "| + Frame rate: %f\n",
track->v_frate);
if (track->v_frate > 0)
track->default_duration = 1 / track->v_frate;
@@ -524,29 +513,29 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
if (video->n_display_width) {
track->v_dwidth = video->display_width;
track->v_dwidth_set = true;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display width: %u\n",
+ MP_VERBOSE(demuxer, "| + Display width: %u\n",
track->v_dwidth);
}
if (video->n_display_height) {
track->v_dheight = video->display_height;
track->v_dheight_set = true;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display height: %u\n",
+ MP_VERBOSE(demuxer, "| + Display height: %u\n",
track->v_dheight);
}
if (video->n_pixel_width) {
track->v_width = video->pixel_width;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel width: %u\n",
+ MP_VERBOSE(demuxer, "| + Pixel width: %u\n",
track->v_width);
}
if (video->n_pixel_height) {
track->v_height = video->pixel_height;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel height: %u\n",
+ MP_VERBOSE(demuxer, "| + Pixel height: %u\n",
track->v_height);
}
if (video->n_colour_space && video->colour_space.len == 4) {
uint8_t *d = (uint8_t *)&video->colour_space.start[0];
track->colorspace = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24);
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Colorspace: %#x\n",
+ MP_VERBOSE(demuxer, "| + Colorspace: %#x\n",
(unsigned int)track->colorspace);
}
}
@@ -569,43 +558,43 @@ static void parse_trackentry(struct demuxer *demuxer,
track->tnum = entry->track_number;
if (track->tnum) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Track number: %u\n",
+ MP_VERBOSE(demuxer, "| + Track number: %u\n",
track->tnum);
} else {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Missing track number!\n");
+ MP_ERR(demuxer, "Missing track number!\n");
}
if (entry->n_name) {
track->name = talloc_strndup(track, entry->name.start,
entry->name.len);
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Name: %s\n",
+ MP_VERBOSE(demuxer, "| + Name: %s\n",
track->name);
}
track->type = entry->track_type;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Track type: ");
+ MP_VERBOSE(demuxer, "| + Track type: ");
switch (track->type) {
case MATROSKA_TRACK_AUDIO:
- mp_msg(MSGT_DEMUX, MSGL_V, "Audio\n");
+ MP_VERBOSE(demuxer, "Audio\n");
break;
case MATROSKA_TRACK_VIDEO:
- mp_msg(MSGT_DEMUX, MSGL_V, "Video\n");
+ MP_VERBOSE(demuxer, "Video\n");
break;
case MATROSKA_TRACK_SUBTITLE:
- mp_msg(MSGT_DEMUX, MSGL_V, "Subtitle\n");
+ MP_VERBOSE(demuxer, "Subtitle\n");
break;
default:
- mp_msg(MSGT_DEMUX, MSGL_V, "unknown\n");
+ MP_VERBOSE(demuxer, "unknown\n");
break;
}
if (entry->n_audio) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Audio track\n");
+ MP_VERBOSE(demuxer, "| + Audio track\n");
parse_trackaudio(demuxer, track, &entry->audio);
}
if (entry->n_video) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Video track\n");
+ MP_VERBOSE(demuxer, "| + Video track\n");
parse_trackvideo(demuxer, track, &entry->video);
}
@@ -615,10 +604,10 @@ static void parse_trackentry(struct demuxer *demuxer,
if (!strcmp(track->codec_id, MKV_V_MSCOMP)
|| !strcmp(track->codec_id, MKV_A_ACM))
track->ms_compat = 1;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Codec ID: %s\n",
+ MP_VERBOSE(demuxer, "| + Codec ID: %s\n",
track->codec_id);
} else {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Missing codec ID!\n");
+ MP_ERR(demuxer, "Missing codec ID!\n");
track->codec_id = "";
}
@@ -627,14 +616,14 @@ static void parse_trackentry(struct demuxer *demuxer,
track->private_data = talloc_size(track, len + AV_LZO_INPUT_PADDING);
memcpy(track->private_data, entry->codec_private.start, len);
track->private_size = len;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + CodecPrivate, length %u\n",
+ MP_VERBOSE(demuxer, "| + CodecPrivate, length %u\n",
track->private_size);
}
if (entry->n_language) {
track->language = talloc_strndup(track, entry->language.start,
entry->language.len);
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Language: %s\n",
+ MP_VERBOSE(demuxer, "| + Language: %s\n",
track->language);
} else {
track->language = talloc_strdup(track, "eng");
@@ -642,7 +631,7 @@ static void parse_trackentry(struct demuxer *demuxer,
if (entry->n_flag_default) {
track->default_track = entry->flag_default;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Default flag: %u\n",
+ MP_VERBOSE(demuxer, "| + Default flag: %u\n",
track->default_track);
} else {
track->default_track = 1;
@@ -651,12 +640,11 @@ static void parse_trackentry(struct demuxer *demuxer,
if (entry->n_default_duration) {
track->default_duration = entry->default_duration / 1e9;
if (entry->default_duration == 0) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Default duration: 0");
+ MP_VERBOSE(demuxer, "| + Default duration: 0");
} else {
if (!track->v_frate)
track->v_frate = 1e9 / entry->default_duration;
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] | + Default duration: %.3fms ( = %.3f fps)\n",
+ MP_VERBOSE(demuxer, "| + Default duration: %.3fms ( = %.3f fps)\n",
entry->default_duration / 1000000.0, track->v_frate);
}
}
@@ -673,14 +661,14 @@ static int demux_mkv_read_tracks(demuxer_t *demuxer)
stream_t *s = demuxer->stream;
struct ebml_tracks tracks = {0};
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
if (ebml_read_element(s, &parse_ctx, &tracks, &ebml_tracks_desc) < 0)
return -1;
mkv_d->tracks = talloc_size(mkv_d,
tracks.n_track_entry * sizeof(*mkv_d->tracks));
for (int i = 0; i < tracks.n_track_entry; i++) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + a track...\n");
+ MP_VERBOSE(demuxer, "| + a track...\n");
parse_trackentry(demuxer, &tracks.track_entry[i]);
}
talloc_free(parse_ctx.talloc_ctx);
@@ -730,9 +718,9 @@ static int demux_mkv_read_cues(demuxer_t *demuxer)
return 0;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing cues ] -----------\n");
+ MP_VERBOSE(demuxer, "/---- [ parsing cues ] -----------\n");
struct ebml_cues cues = {0};
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
if (ebml_read_element(s, &parse_ctx, &cues, &ebml_cues_desc) < 0)
return -1;
@@ -741,7 +729,7 @@ static int demux_mkv_read_cues(demuxer_t *demuxer)
for (int i = 0; i < cues.n_cue_point; i++) {
struct ebml_cue_point *cuepoint = &cues.cue_point[i];
if (cuepoint->n_cue_time != 1 || !cuepoint->n_cue_track_positions) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Malformed CuePoint element\n");
+ MP_WARN(demuxer, "Malformed CuePoint element\n");
continue;
}
uint64_t time = cuepoint->cue_time;
@@ -750,8 +738,7 @@ static int demux_mkv_read_cues(demuxer_t *demuxer)
&cuepoint->cue_track_positions[c];
uint64_t pos = mkv_d->segment_start + trackpos->cue_cluster_position;
cue_index_add(demuxer, trackpos->cue_track, pos, time);
- mp_msg(MSGT_DEMUX, MSGL_DBG2,
- "[mkv] |+ found cue point for track %" PRIu64
+ MP_DBG(demuxer, "|+ found cue point for track %" PRIu64
": timecode %" PRIu64 ", filepos: %" PRIu64 "\n",
trackpos->cue_track, time, pos);
}
@@ -760,7 +747,7 @@ static int demux_mkv_read_cues(demuxer_t *demuxer)
// Do not attempt to create index on the fly.
mkv_d->index_complete = true;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing cues ] -----------\n");
+ MP_VERBOSE(demuxer, "\\---- [ parsing cues ] -----------\n");
talloc_free(parse_ctx.talloc_ctx);
return 0;
}
@@ -774,11 +761,11 @@ static void read_deferred_cues(demuxer_t *demuxer)
int64_t pos = mkv_d->deferred_cues;
mkv_d->deferred_cues = 0;
if (!stream_seek(s, pos)) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Failed to seek to cues\n");
+ MP_WARN(demuxer, "Failed to seek to cues\n");
return;
}
if (ebml_read_id(s, NULL) != MATROSKA_ID_CUES) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Expected element not found\n");
+ MP_WARN(demuxer, "Expected element not found\n");
return;
}
demux_mkv_read_cues(demuxer);
@@ -797,9 +784,9 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
if (wanted_edition_uid)
wanted_edition = -1;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing chapters ] ---------\n");
+ MP_VERBOSE(demuxer, "/---- [ parsing chapters ] ---------\n");
struct ebml_chapters file_chapters = {0};
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
if (ebml_read_element(s, &parse_ctx, &file_chapters,
&ebml_chapters_desc) < 0)
return -1;
@@ -809,7 +796,7 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
struct ebml_edition_entry *editions = file_chapters.edition_entry;
if (wanted_edition >= 0 && wanted_edition < num_editions) {
selected_edition = wanted_edition;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] User-specified edition: %d\n",
+ MP_VERBOSE(demuxer, "User-specified edition: %d\n",
selected_edition);
} else {
for (int i = 0; i < num_editions; i++) {
@@ -819,15 +806,14 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
break;
} else if (editions[i].edition_flag_default) {
selected_edition = i;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Default edition: %d\n", i);
+ MP_VERBOSE(demuxer, "Default edition: %d\n", i);
break;
}
}
}
if (selected_edition < 0) {
if (wanted_edition_uid) {
- mp_msg(MSGT_DEMUX, MSGL_ERR,
- "[mkv] Unable to find expected edition uid: %"PRIu64"\n",
+ MP_ERR(demuxer, "Unable to find expected edition uid: %"PRIu64"\n",
wanted_edition_uid);
return -1;
} else {
@@ -836,13 +822,13 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
}
for (int idx = 0; idx < num_editions; idx++) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] New edition %d\n", idx);
+ MP_VERBOSE(demuxer, "New edition %d\n", idx);
int warn_level = idx == selected_edition ? MSGL_WARN : MSGL_V;
if (editions[idx].n_edition_flag_default)
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Default edition flag: %"PRIu64
+ MP_VERBOSE(demuxer, "Default edition flag: %"PRIu64
"\n", editions[idx].edition_flag_default);
if (editions[idx].n_edition_flag_ordered)
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Ordered chapter flag: %"PRIu64
+ MP_VERBOSE(demuxer, "Ordered chapter flag: %"PRIu64
"\n", editions[idx].edition_flag_ordered);
int chapter_count = editions[idx].n_chapter_atom;
@@ -860,17 +846,17 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
struct bstr name = { "(unnamed)", 9 };
if (!ca->n_chapter_time_start)
- mp_msg(MSGT_DEMUX, warn_level,
- "[mkv] Chapter lacks start time\n");
+ MP_MSG(demuxer, warn_level,
+ "Chapter lacks start time\n");
chapter.start = ca->chapter_time_start;
chapter.end = ca->chapter_time_end;
if (ca->n_chapter_display) {
if (ca->n_chapter_display > 1)
- mp_msg(MSGT_DEMUX, warn_level, "[mkv] Multiple chapter "
+ MP_MSG(demuxer, warn_level, "Multiple chapter "
"names not supported, picking first\n");
if (!ca->chapter_display[0].n_chap_string)
- mp_msg(MSGT_DEMUX, warn_level, "[mkv] Malformed chapter "
+ MP_MSG(demuxer, warn_level, "Malformed chapter "
"name entry\n");
else
name = ca->chapter_display[0].chap_string;
@@ -880,8 +866,8 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
chapter.has_segment_uid = true;
int len = ca->chapter_segment_uid.len;
if (len != sizeof(chapter.uid.segment))
- mp_msg(MSGT_DEMUX, warn_level,
- "[mkv] Chapter segment uid bad length %d\n", len);
+ MP_MSG(demuxer, warn_level,
+ "Chapter segment uid bad length %d\n", len);
else {
memcpy(chapter.uid.segment, ca->chapter_segment_uid.start,
len);
@@ -889,16 +875,15 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
chapter.uid.edition = ca->chapter_segment_edition_uid;
else
chapter.uid.edition = 0;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Chapter segment uid ");
+ MP_VERBOSE(demuxer, "Chapter segment uid ");
for (int n = 0; n < len; n++)
- mp_msg(MSGT_DEMUX, MSGL_V, "%02x ",
+ MP_VERBOSE(demuxer, "%02x ",
chapter.uid.segment[n]);
- mp_msg(MSGT_DEMUX, MSGL_V, "\n");
+ MP_VERBOSE(demuxer, "\n");
}
}
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] Chapter %u from %02d:%02d:%02d.%03d "
+ MP_VERBOSE(demuxer, "Chapter %u from %02d:%02d:%02d.%03d "
"to %02d:%02d:%02d.%03d, %.*s\n", i,
(int) (chapter.start / 60 / 60 / 1000000000),
(int) ((chapter.start / 60 / 1000000000) % 60),
@@ -921,16 +906,14 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
}
}
if (num_editions > 1)
- mp_msg(MSGT_DEMUX, MSGL_INFO,
- "[mkv] Found %d editions, will play #%d (first is 0).\n",
+ MP_INFO(demuxer, "Found %d editions, will play #%d (first is 0).\n",
num_editions, selected_edition);
demuxer->num_editions = num_editions;
demuxer->edition = selected_edition;
talloc_free(parse_ctx.talloc_ctx);
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] \\---- [ parsing chapters ] ---------\n");
+ MP_VERBOSE(demuxer, "\\---- [ parsing chapters ] ---------\n");
return 0;
}
@@ -938,7 +921,7 @@ static int demux_mkv_read_tags(demuxer_t *demuxer)
{
stream_t *s = demuxer->stream;
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
struct ebml_tags tags = {0};
if (ebml_read_element(s, &parse_ctx, &tags, &ebml_tags_desc) < 0)
return -1;
@@ -971,11 +954,10 @@ static int demux_mkv_read_attachments(demuxer_t *demuxer)
{
stream_t *s = demuxer->stream;
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] /---- [ parsing attachments ] ---------\n");
+ MP_VERBOSE(demuxer, "/---- [ parsing attachments ] ---------\n");
struct ebml_attachments attachments = {0};
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
if (ebml_read_element(s, &parse_ctx, &attachments,
&ebml_attachments_desc) < 0)
return -1;
@@ -984,19 +966,18 @@ static int demux_mkv_read_attachments(demuxer_t *demuxer)
struct ebml_attached_file *attachment = &attachments.attached_file[i];
if (!attachment->n_file_name || !attachment->n_file_mime_type
|| !attachment->n_file_data) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Malformed attachment\n");
+ MP_WARN(demuxer, "Malformed attachment\n");
continue;
}
struct bstr name = attachment->file_name;
struct bstr mime = attachment->file_mime_type;
demuxer_add_attachment(demuxer, name, mime, attachment->file_data);
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Attachment: %.*s, %.*s, %zu bytes\n",
+ MP_VERBOSE(demuxer, "Attachment: %.*s, %.*s, %zu bytes\n",
BSTR_P(name), BSTR_P(mime), attachment->file_data.len);
}
talloc_free(parse_ctx.talloc_ctx);
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] \\---- [ parsing attachments ] ---------\n");
+ MP_VERBOSE(demuxer, "\\---- [ parsing attachments ] ---------\n");
return 0;
}
@@ -1009,10 +990,9 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer)
struct stream *s = demuxer->stream;
int res = 0;
struct ebml_seek_head seekhead = {0};
- struct ebml_parse_ctx parse_ctx = {0};
+ struct ebml_parse_ctx parse_ctx = {demuxer->log};
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] /---- [ parsing seek head ] ---------\n");
+ MP_VERBOSE(demuxer, "/---- [ parsing seek head ] ---------\n");
if (ebml_read_element(s, &parse_ctx, &seekhead, &ebml_seek_head_desc) < 0) {
res = -1;
goto out;
@@ -1022,12 +1002,12 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer)
for (int i = 0; i < seekhead.n_seek; i++) {
struct ebml_seek *seek = &seekhead.seek[i];
if (seek->n_seek_id != 1 || seek->n_seek_position != 1) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Invalid SeekHead entry\n");
+ MP_WARN(demuxer, "Invalid SeekHead entry\n");
continue;
}
uint64_t pos = seek->seek_position + mkv_d->segment_start;
if (pos >= s->end_pos) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] SeekHead position beyond "
+ MP_WARN(demuxer, "SeekHead position beyond "
"end of file - incomplete file?\n");
continue;
}
@@ -1038,25 +1018,25 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer)
}
}
if (!stream_seek(s, off)) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Couldn't seek back after "
+ MP_ERR(demuxer, "Couldn't seek back after "
"SeekHead??\n");
res = -1;
}
out:
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] \\---- [ parsing seek head ] ---------\n");
+ MP_VERBOSE(demuxer, "\\---- [ parsing seek head ] ---------\n");
talloc_free(parse_ctx.talloc_ctx);
return res;
}
-static bool seek_pos_id(struct stream *s, int64_t pos, uint32_t id)
+static bool seek_pos_id(struct demuxer *demuxer, int64_t pos, uint32_t id)
{
+ stream_t *s = demuxer->stream;
if (!stream_seek(s, pos)) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Failed to seek in file\n");
+ MP_WARN(demuxer, "Failed to seek in file\n");
return false;
}
if (ebml_read_id(s, NULL) != id) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Expected element not found\n");
+ MP_WARN(demuxer, "Expected element not found\n");
return false;
}
return true;
@@ -1074,19 +1054,19 @@ static int read_header_element(struct demuxer *demuxer, uint32_t id,
case MATROSKA_ID_INFO:
if (mkv_d->parsed_info)
break;
- if (at_filepos && !seek_pos_id(s, at_filepos, id))
+ if (at_filepos && !seek_pos_id(demuxer, at_filepos, id))
return -1;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ segment information...\n");
+ MP_VERBOSE(demuxer, "|+ segment information...\n");
mkv_d->parsed_info = true;
return demux_mkv_read_info(demuxer);
case MATROSKA_ID_TRACKS:
if (mkv_d->parsed_tracks)
break;
- if (at_filepos && !seek_pos_id(s, at_filepos, id))
+ if (at_filepos && !seek_pos_id(demuxer, at_filepos, id))
return -1;
mkv_d->parsed_tracks = true;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ segment tracks...\n");
+ MP_VERBOSE(demuxer, "|+ segment tracks...\n");
return demux_mkv_read_tracks(demuxer);
case MATROSKA_ID_CUES:
@@ -1104,7 +1084,7 @@ static int read_header_element(struct demuxer *demuxer, uint32_t id,
case MATROSKA_ID_TAGS:
if (mkv_d->parsed_tags)
break;
- if (at_filepos && !seek_pos_id(s, at_filepos, id))
+ if (at_filepos && !seek_pos_id(demuxer, at_filepos, id))
return -1;
mkv_d->parsed_tags = true;
return demux_mkv_read_tags(demuxer);
@@ -1112,14 +1092,14 @@ static int read_header_element(struct demuxer *demuxer, uint32_t id,
case MATROSKA_ID_SEEKHEAD:
if (is_parsed_header(mkv_d, pos))
break;
- if (at_filepos && !seek_pos_id(s, at_filepos, id))
+ if (at_filepos && !seek_pos_id(demuxer, at_filepos, id))
return -1;
return demux_mkv_read_seekhead(demuxer);
case MATROSKA_ID_CHAPTERS:
if (mkv_d->parsed_chapters)
break;
- if (at_filepos && !seek_pos_id(s, at_filepos, id))
+ if (at_filepos && !seek_pos_id(demuxer, at_filepos, id))
return -1;
mkv_d->parsed_chapters = true;
return demux_mkv_read_chapters(demuxer);
@@ -1127,7 +1107,7 @@ static int read_header_element(struct demuxer *demuxer, uint32_t id,
case MATROSKA_ID_ATTACHMENTS:
if (mkv_d->parsed_attachments)
break;
- if (at_filepos && !seek_pos_id(s, at_filepos, id))
+ if (at_filepos && !seek_pos_id(demuxer, at_filepos, id))
return -1;
mkv_d->parsed_attachments = true;
return demux_mkv_read_attachments(demuxer);
@@ -1171,12 +1151,11 @@ static void display_create_tracks(demuxer_t *demuxer)
break;
}
if (mkv_d->tracks[i]->name)
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] Track ID %u: %s (%s) \"%s\"\n",
+ MP_VERBOSE(demuxer, "Track ID %u: %s (%s) \"%s\"\n",
mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id,
mkv_d->tracks[i]->name);
else
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Track ID %u: %s (%s)\n",
+ MP_VERBOSE(demuxer, "Track ID %u: %s (%s)\n",
mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id);
}
}
@@ -1286,9 +1265,9 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
extradata_size = track->private_size;
}
if (!vi->id) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Unknown/unsupported "
+ MP_WARN(demuxer, "Unknown/unsupported "
"CodecID (%s) or missing/bad CodecPrivate\n"
- "[mkv] data (track %u).\n",
+ "data (track %u).\n",
track->codec_id, track->tnum);
return 1;
}
@@ -1304,7 +1283,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh->title = talloc_strdup(sh_v, track->name);
sh_v->bih = talloc_size(sh_v, sizeof(MP_BITMAPINFOHEADER) + extradata_size);
if (!sh_v->bih) {
- mp_msg(MSGT_DEMUX, MSGL_FATAL, "Memory allocation failure!\n");
+ MP_FATAL(demuxer, "Memory allocation failure!\n");
abort();
}
*sh_v->bih = *bih;
@@ -1337,7 +1316,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh_v->disp_w = track->v_dwidth;
sh_v->disp_h = track->v_dheight;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Aspect: %f\n", sh_v->aspect);
+ MP_VERBOSE(demuxer, "Aspect: %f\n", sh_v->aspect);
sh_v->avi_dts = track->ms_compat;
return 0;
@@ -1407,7 +1386,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
if (track->ms_compat) {
if (track->private_size < sizeof(*sh_a->wf))
goto error;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] track with MS compat audio.\n");
+ MP_VERBOSE(demuxer, "track with MS compat audio.\n");
MP_WAVEFORMATEX *wf = (MP_WAVEFORMATEX *) track->private_data;
sh_a->wf = talloc_zero_size(sh_a, track->private_size);
sh_a->wf->wFormatTag = le2me_16(wf->wFormatTag);
@@ -1652,8 +1631,8 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
return 0;
error:
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Unknown/unsupported audio "
- "codec ID '%s' for track %u or missing/faulty\n[mkv] "
+ MP_WARN(demuxer, "Unknown/unsupported audio "
+ "codec ID '%s' for track %u or missing/faulty\n"
"private codec data.\n", track->codec_id, track->tnum);
return 1;
}
@@ -1691,7 +1670,7 @@ static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track)
sh->demuxer_id = track->tnum;
track->sh_sub = sh_s;
sh->codec = subtitle_type;
- bstr buffer = demux_mkv_decode(track, in, 2);
+ bstr buffer = demux_mkv_decode(demuxer->log, track, in, 2);
if (buffer.start && buffer.start != track->private_data) {
talloc_free(track->private_data);
talloc_steal(track, buffer.start);
@@ -1707,8 +1686,7 @@ static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track)
sh->default_track = track->default_track;
if (!subtitle_type) {
- mp_msg(MSGT_DEMUX, MSGL_ERR,
- "[mkv] Subtitle type '%s' is not supported.\n",
+ MP_ERR(demuxer, "Subtitle type '%s' is not supported.\n",
track->codec_id);
}
@@ -1732,20 +1710,20 @@ static int read_ebml_header(demuxer_t *demuxer)
if (ebml_read_id(s, NULL) != EBML_ID_EBML)
return 0;
struct ebml_ebml ebml_master = {{0}};
- struct ebml_parse_ctx parse_ctx = { .no_error_messages = true };
+ struct ebml_parse_ctx parse_ctx = { demuxer->log, .no_error_messages = true };
if (ebml_read_element(s, &parse_ctx, &ebml_master, &ebml_ebml_desc) < 0)
return 0;
if (ebml_master.doc_type.start == NULL) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] File has EBML header but no doctype."
+ MP_VERBOSE(demuxer, "File has EBML header but no doctype."
" Assuming \"matroska\".\n");
} else if (bstrcmp(ebml_master.doc_type, bstr0("matroska")) != 0
&& bstrcmp(ebml_master.doc_type, bstr0("webm")) != 0) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] no head found\n");
+ MP_DBG(demuxer, "no head found\n");
talloc_free(parse_ctx.talloc_ctx);
return 0;
}
if (ebml_master.doc_type_read_version > 2) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] This looks like a Matroska file, "
+ MP_WARN(demuxer, "This looks like a Matroska file, "
"but we don't support format version %"PRIu64"\n",
ebml_master.doc_type_read_version);
talloc_free(parse_ctx.talloc_ctx);
@@ -1758,7 +1736,7 @@ static int read_ebml_header(demuxer_t *demuxer)
|| (ebml_master.n_ebml_max_id_length
&& ebml_master.ebml_max_id_length != 4))
{
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] This looks like a Matroska file, "
+ MP_WARN(demuxer, "This looks like a Matroska file, "
"but the header has bad parameters\n");
talloc_free(parse_ctx.talloc_ctx);
return 0;
@@ -1777,22 +1755,22 @@ static int read_mkv_segment_header(demuxer_t *demuxer)
while (!s->eof) {
if (ebml_read_id(s, NULL) != MATROSKA_ID_SEGMENT) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] segment not found\n");
+ MP_VERBOSE(demuxer, "segment not found\n");
return 0;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n");
+ MP_VERBOSE(demuxer, "+ a segment...\n");
uint64_t len = ebml_read_length(s, NULL);
if (num_skip <= 0)
return 1;
num_skip--;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] (skipping)\n");
+ MP_VERBOSE(demuxer, " (skipping)\n");
if (len == EBML_UINT_INVALID)
break;
int64_t next = stream_tell(s) + len;
if (next >= s->end_pos)
return 0;
if (!stream_seek(s, next)) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Failed to seek in file\n");
+ MP_WARN(demuxer, "Failed to seek in file\n");
return 0;
}
// Segments are like concatenated Matroska files
@@ -1800,7 +1778,7 @@ static int read_mkv_segment_header(demuxer_t *demuxer)
return 0;
}
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] End of file, no further segments.\n");
+ MP_VERBOSE(demuxer, "End of file, no further segments.\n");
return 0;
}
@@ -1813,7 +1791,7 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
if (!read_ebml_header(demuxer))
return -1;
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Found the head...\n");
+ MP_VERBOSE(demuxer, "Found the head...\n");
if (!read_mkv_segment_header(demuxer))
return -1;
@@ -1829,12 +1807,11 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
while (1) {
uint32_t id = ebml_read_id(s, NULL);
if (s->eof) {
- mp_msg(MSGT_DEMUX, MSGL_WARN,
- "[mkv] Unexpected end of file (no clusters found)\n");
+ MP_WARN(demuxer, "Unexpected end of file (no clusters found)\n");
break;
}
if (id == MATROSKA_ID_CLUSTER) {
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ found cluster, headers are "
+ MP_VERBOSE(demuxer, "|+ found cluster, headers are "
"parsed completely :)\n");
stream_seek(s, stream_tell(s) - 4);
break;
@@ -1936,7 +1913,6 @@ static int demux_mkv_read_block_lacing(bstr *buffer, int *laces,
return 0;
error:
- mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Bad input [lacing]\n");
return 1;
}
@@ -2311,8 +2287,10 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
if (!demuxer_stream_is_selected(demuxer, stream))
return 0;
- if (demux_mkv_read_block_lacing(&data, &laces, lace_size))
+ if (demux_mkv_read_block_lacing(&data, &laces, lace_size)) {
+ MP_ERR(demuxer, "Bad input [lacing]\n");
return 0;
+ }
current_pts = tc / 1e9;
@@ -2336,7 +2314,7 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
}
if (use_this_block) {
if (laces > 1) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Subtitles use Matroska "
+ MP_WARN(demuxer, "Subtitles use Matroska "
"lacing. This is abnormal and not supported.\n");
use_this_block = 0;
}
@@ -2357,7 +2335,7 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
else if (stream->type == STREAM_AUDIO && track->realmedia)
handle_realaudio(demuxer, track, block, keyframe);
else {
- bstr buffer = demux_mkv_decode(track, block, 1);
+ bstr buffer = demux_mkv_decode(demuxer->log, track, block, 1);
mkv_parse_packet(track, &buffer);
if (buffer.start) {
demux_packet_t *dp =
@@ -2426,7 +2404,7 @@ static int read_block_group(demuxer_t *demuxer, int64_t end,
goto error;
default:
- if (ebml_read_skip_or_resync_cluster(s, NULL) != 0)
+ if (ebml_read_skip_or_resync_cluster(demuxer->log, s, NULL) != 0)
goto error;
break;
}
@@ -2485,7 +2463,7 @@ static int read_next_block(demuxer_t *demuxer, struct block_info *block)
goto find_next_cluster;
default: ;
- if (ebml_read_skip_or_resync_cluster(s, NULL) != 0)
+ if (ebml_read_skip_or_resync_cluster(demuxer->log, s, NULL) != 0)
goto find_next_cluster;
break;
}
@@ -2500,7 +2478,7 @@ static int read_next_block(demuxer_t *demuxer, struct block_info *block)
break;
if (s->eof)
return -1;
- ebml_read_skip_or_resync_cluster(s, NULL);
+ ebml_read_skip_or_resync_cluster(demuxer->log, s, NULL);
}
next_cluster:
mkv_d->cluster_end = ebml_read_length(s, NULL);
@@ -2564,8 +2542,7 @@ static int create_index_until(struct demuxer *demuxer, uint64_t timecode)
uint64_t old_cluster_tc = mkv_d->cluster_tc;
if (index)
stream_seek(s, index->filepos);
- mp_msg(MSGT_DEMUX, MSGL_V,
- "[mkv] creating index until TC %" PRIu64 "\n", timecode);
+ MP_VERBOSE(demuxer, "creating index until TC %" PRIu64 "\n", timecode);
for (;;) {
int res;
struct block_info block;
@@ -2586,7 +2563,7 @@ static int create_index_until(struct demuxer *demuxer, uint64_t timecode)
mkv_d->cluster_tc = old_cluster_tc;
}
if (!mkv_d->indexes) {
- mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] no target for seek found\n");
+ MP_WARN(demuxer, "no target for seek found\n");
return -1;
}
return 0;
@@ -2707,7 +2684,7 @@ static void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
demux_mkv_fill_buffer(demuxer);
} else if (!(flags & SEEK_ABSOLUTE))
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
+ MP_VERBOSE(demuxer, "seek unsupported flags\n");
else {
stream_t *s = demuxer->stream;
uint64_t target_filepos;
@@ -2717,7 +2694,7 @@ static void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
read_deferred_cues(demuxer);
if (!mkv_d->index_complete) { /* not implemented without index */
- mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
+ MP_VERBOSE(demuxer, "seek unsupported flags\n");
stream_seek(s, old_pos);
return;
}
diff --git a/demux/demux_raw.c b/demux/demux_raw.c
index 12fa1741a8..63674cea0c 100644
--- a/demux/demux_raw.c
+++ b/demux/demux_raw.c
@@ -120,7 +120,7 @@ static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
return -1;
if (!width || !height) {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "rawvideo: width or height not specified!\n");
+ MP_ERR(demuxer, "rawvideo: width or height not specified!\n");
return -1;
}
@@ -166,8 +166,7 @@ static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
break;
}
if (!bpp) {
- mp_msg(MSGT_DEMUX, MSGL_ERR,
- "rawvideo: img size not specified and unknown format!\n");
+ MP_ERR(demuxer, "rawvideo: img size not specified and unknown format!\n");
return -1;
}
imgsize = width * height * bpp / 8;
diff --git a/demux/demux_subreader.c b/demux/demux_subreader.c
index e2b4c1cac4..fa029655fc 100644
--- a/demux/demux_subreader.c
+++ b/demux/demux_subreader.c
@@ -90,6 +90,7 @@ typedef struct sub_data {
// Parameter struct for the format-specific readline functions
struct readline_args {
+ struct mp_log *log;
int utf16;
struct MPOpts *opts;
@@ -319,14 +320,15 @@ static const char *sub_readtext(const char *source, char **dest) {
else return NULL; // last text field
}
-static subtitle *set_multiline_text(subtitle *current, const char *text, int start)
+static subtitle *set_multiline_text(struct readline_args *arg, subtitle *current,
+ const char *text, int start)
{
int i = start;
while ((text = sub_readtext(text, current->text + i))) {
if (current->text[i] == ERR) return ERR;
i++;
if (i >= SUB_MAX_TEXT) {
- mp_msg(MSGT_SUBREADER, MSGL_WARN, "Too many lines in a subtitle\n");
+ MP_WARN(arg, "Too many lines in a subtitle\n");
current->lines = i;
return current;
}
@@ -351,7 +353,7 @@ static subtitle *sub_read_line_microdvd(stream_t *st,subtitle *current,
"{%ld}{%ld}%[^\r\n]",
&(current->start), &(current->end), line2) < 3));
- return set_multiline_text(current, line2, 0);
+ return set_multiline_text(args, current, line2, 0);
}
static subtitle *sub_read_line_mpl2(stream_t *st,subtitle *current,
@@ -369,7 +371,7 @@ static subtitle *sub_read_line_mpl2(stream_t *st,subtitle *current,
current->start *= 10;
current->end *= 10;
- return set_multiline_text(current, line2, 0);
+ return set_multiline_text(args, current, line2, 0);
}
static subtitle *sub_read_line_subrip(stream_t* st, subtitle *current,
@@ -521,7 +523,7 @@ static subtitle *sub_read_line_vplayer(stream_t *st,subtitle *current,
++p;
}
if (p==NULL) {
- printf("SUB: Skipping incorrect subtitle line!\n");
+ printf("Skipping incorrect subtitle line!\n");
continue;
}
*/
@@ -532,7 +534,7 @@ static subtitle *sub_read_line_vplayer(stream_t *st,subtitle *current,
if (*p!='|') {
//
- return set_multiline_text(current, p, 0);
+ return set_multiline_text(args, current, p, 0);
}
}
return current;
@@ -581,7 +583,7 @@ static subtitle *sub_read_line_rt(stream_t *st,subtitle *current,
next = strstr(line,"<clear/>");
if(next && strlen(next)>8){
next+=8;
- return set_multiline_text(current, next, 0);
+ return set_multiline_text(args, current, next, 0);
}
}
return current;
@@ -770,7 +772,7 @@ retry:
if (!stream_read_line (st, line, LINE_LEN, utf16))
return current;
- if (set_multiline_text(current, line, 1) == ERR)
+ if (set_multiline_text(args, current, line, 1) == ERR)
return ERR;
if (!strlen(current->text[0]) && !strlen(current->text[1]))
@@ -806,7 +808,7 @@ retry:
current->text[0]=""; // just to be sure that string is clear
- if (set_multiline_text(current, line, 0) == ERR)
+ if (set_multiline_text(args, current, line, 0) == ERR)
return ERR;
if (!strlen(current->text[0]) && current->lines <= 1)
@@ -1061,7 +1063,17 @@ static int sub_autodetect (stream_t* st, int *uses_time, int utf16) {
return SUB_INVALID; // too many bad lines
}
-static void adjust_subs_time(subtitle* sub, float subtime, float fps,
+struct subreader {
+ subtitle * (*read)(stream_t *st, subtitle *dest,
+ struct readline_args *args);
+ void (*post)(subtitle *dest);
+ const char *name;
+ const char *codec_name;
+ struct readline_args args;
+};
+
+static void adjust_subs_time(struct subreader *srp, subtitle* sub,
+ float subtime, float fps,
float sub_fps, int block,
int sub_num, int sub_uses_time) {
int n,m;
@@ -1091,20 +1103,11 @@ static void adjust_subs_time(subtitle* sub, float subtime, float fps,
sub = nextsub;
m = 0;
}
- if (n) mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: Adjusted %d subtitle(s).\n", n);
+ if (n) MP_VERBOSE(&srp->args, "Adjusted %d subtitle(s).\n", n);
}
-struct subreader {
- subtitle * (*read)(stream_t *st, subtitle *dest,
- struct readline_args *args);
- void (*post)(subtitle *dest);
- const char *name;
- const char *codec_name;
- struct readline_args args;
-};
-
static bool subreader_autodetect(stream_t *fd, struct MPOpts *opts,
- struct subreader *out)
+ struct mp_log *log, struct subreader *out)
{
static const struct subreader sr[]=
{
@@ -1135,14 +1138,15 @@ static bool subreader_autodetect(stream_t *fd, struct MPOpts *opts,
utf16--;
if (sub_format==SUB_INVALID) {
- mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: Could not determine file format\n");
+ mp_verbose(log, "Could not determine file format\n");
return false;
}
srp=sr+sub_format;
- mp_msg(MSGT_SUBREADER, MSGL_V, "SUB: Detected subtitle file format: %s\n", srp->name);
+ mp_verbose(log, "Detected subtitle file format: %s\n", srp->name);
*out = *srp;
out->args = (struct readline_args) {
+ .log = log,
.utf16 = utf16,
.opts = opts,
.sub_slacktime = 20000, //20 sec
@@ -1233,8 +1237,8 @@ static sub_data* sub_read_file(stream_t *fd, struct subreader *srp)
free(alloced_sub);
-// printf ("SUB: Subtitle format %s time.\n", uses_time?"uses":"doesn't use");
- mp_msg(MSGT_SUBREADER, MSGL_V,"SUB: Read %i subtitles, %i bad line(s).\n",
+// printf ("Subtitle format %s time.\n", uses_time?"uses":"doesn't use");
+ MP_VERBOSE(&srp->args, "Read %i subtitles, %i bad line(s).\n",
sub_num, sub_errs);
if(sub_num<=0){
@@ -1242,7 +1246,7 @@ static sub_data* sub_read_file(stream_t *fd, struct subreader *srp)
return NULL;
}
- adjust_subs_time(first, 6.0, fps, opts->sub_fps, 1, sub_num, args.uses_time);/*~6 secs AST*/
+ adjust_subs_time(srp, first, 6.0, fps, opts->sub_fps, 1, sub_num, args.uses_time);/*~6 secs AST*/
return_sub = first;
if (return_sub == NULL) return NULL;
@@ -1334,7 +1338,7 @@ static int d_open_file(struct demuxer *demuxer, enum demux_check check)
struct stream *ps = read_probe_stream(demuxer->stream, PROBE_SIZE);
struct subreader sr;
- bool res = subreader_autodetect(ps, demuxer->opts, &sr);
+ bool res = subreader_autodetect(ps, demuxer->opts, demuxer->log, &sr);
free_stream(ps);
diff --git a/demux/ebml.c b/demux/ebml.c
index dabdebb9ea..6565b9c3a9 100644
--- a/demux/ebml.c
+++ b/demux/ebml.c
@@ -272,17 +272,16 @@ int ebml_read_skip(stream_t *s, uint64_t *length)
/*
* Skip to (probable) next cluster (MATROSKA_ID_CLUSTER) element start position.
*/
-int ebml_resync_cluster(stream_t *s)
+int ebml_resync_cluster(struct mp_log *log, stream_t *s)
{
int64_t pos = stream_tell(s);
uint32_t last_4_bytes = 0;
- mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Corrupt file detected. "
+ mp_err(log, "Corrupt file detected. "
"Trying to resync starting from position %"PRId64"...\n", pos);
while (!s->eof) {
// Assumes MATROSKA_ID_CLUSTER is 4 bytes, with no 0 bytes.
if (last_4_bytes == MATROSKA_ID_CLUSTER) {
- mp_msg(MSGT_DEMUX, MSGL_ERR,
- "[mkv] Cluster found at %"PRId64".\n", pos - 4);
+ mp_err(log, "Cluster found at %"PRId64".\n", pos - 4);
stream_seek(s, pos - 4);
return 0;
}
@@ -295,7 +294,8 @@ int ebml_resync_cluster(stream_t *s)
/*
* Skip the current element, or on error, call ebml_resync_cluster().
*/
-int ebml_read_skip_or_resync_cluster(stream_t *s, uint64_t *length)
+int ebml_read_skip_or_resync_cluster(struct mp_log *log, stream_t *s,
+ uint64_t *length)
{
uint64_t len;
int l;
@@ -319,7 +319,7 @@ int ebml_read_skip_or_resync_cluster(stream_t *s, uint64_t *length)
return 0;
resync:
- return ebml_resync_cluster(s) < 0 ? -1 : 1;
+ return ebml_resync_cluster(log, s) < 0 ? -1 : 1;
}
/*
@@ -455,8 +455,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
{
assert(type->type == EBML_TYPE_SUBELEMENTS);
assert(level < 8);
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "%.*s[mkv] Parsing element %s\n",
- level, " ", type->name);
+ MP_DBG(ctx, "%.*sParsing element %s\n", level, " ", type->name);
char *s = target;
uint8_t *end = data + size;
@@ -469,8 +468,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
if (len > end - p)
goto past_end_error;
if (len < 0) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Error parsing subelement "
- "id\n");
+ MP_DBG(ctx, "Error parsing subelement id\n");
goto other_error;
}
p += len;
@@ -478,8 +476,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
if (len > end - p)
goto past_end_error;
if (len < 0) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Error parsing subelement "
- "length\n");
+ MP_DBG(ctx, "Error parsing subelement length\n");
goto other_error;
}
p += len;
@@ -495,7 +492,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
if (length > end - p) {
if (field_idx >= 0 && type->fields[field_idx].desc->type
!= EBML_TYPE_SUBELEMENTS) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Subelement content goes "
+ MP_DBG(ctx, "Subelement content goes "
"past end of containing element\n");
goto other_error;
}
@@ -508,7 +505,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
continue;
past_end_error:
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Subelement headers go "
+ MP_DBG(ctx, "Subelement headers go "
"past end of containing element\n");
other_error:
ctx->has_errors = true;
@@ -564,7 +561,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
if (length > end - data) {
// Try to parse what is possible from inside this partial element
length = end - data;
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Next subelement content goes "
+ MP_DBG(ctx, "Next subelement content goes "
"past end of containing element, will be truncated\n");
}
int field_idx = -1;
@@ -575,14 +572,14 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
}
if (field_idx < 0) {
if (id == 0xec)
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "%.*s[mkv] Ignoring Void element "
+ MP_DBG(ctx, "%.*sIgnoring Void element "
"size: %"PRIu64"\n", level+1, " ", length);
else if (id == 0xbf)
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "%.*s[mkv] Ignoring CRC-32 "
+ MP_DBG(ctx, "%.*sIgnoring CRC-32 "
"element size: %"PRIu64"\n", level+1, " ",
length);
else
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Ignoring unrecognized "
+ MP_DBG(ctx, "Ignoring unrecognized "
"subelement. ID: %x size: %"PRIu64"\n", id, length);
data += length;
continue;
@@ -593,26 +590,26 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
int *countptr = (int *) (s + fd->count_offset);
if (*countptr >= num_elems[field_idx]) {
// Shouldn't happen with on any sane file without bugs
- mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Too many subelems?\n");
+ MP_ERR(ctx, "Too many subelems?\n");
ctx->has_errors = true;
data += length;
continue;
}
if (*countptr > 0 && !multiple) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Another subelement of type "
+ MP_DBG(ctx, "Another subelement of type "
"%x %s (size: %"PRIu64"). Only one allowed. Ignoring.\n",
id, ed->name, length);
ctx->has_errors = true;
data += length;
continue;
}
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "%.*s[mkv] Parsing %x %s size: %"PRIu64
+ MP_DBG(ctx, "%.*sParsing %x %s size: %"PRIu64
" value: ", level+1, " ", id, ed->name, length);
char *fieldptr = s + fd->offset;
switch (ed->type) {
case EBML_TYPE_SUBELEMENTS:
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "subelements\n");
+ MP_DBG(ctx, "subelements\n");
char *subelptr;
if (multiple) {
char *array_start = (char *) *(generic_struct **) fieldptr;
@@ -631,36 +628,36 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
subelptr = (fieldtype *) fieldptr
GETPTR(uintptr, uint64_t);
if (length < 1 || length > 8) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "uint invalid length %"PRIu64
+ MP_DBG(ctx, "uint invalid length %"PRIu64
"\n", length);
goto error;
}
*uintptr = ebml_parse_uint(data, length);
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "uint %"PRIu64"\n", *uintptr);
+ MP_DBG(ctx, "uint %"PRIu64"\n", *uintptr);
break;
case EBML_TYPE_SINT:;
int64_t *sintptr;
GETPTR(sintptr, int64_t);
if (length < 1 || length > 8) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "sint invalid length %"PRIu64
+ MP_DBG(ctx, "sint invalid length %"PRIu64
"\n", length);
goto error;
}
*sintptr = ebml_parse_sint(data, length);
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "sint %"PRId64"\n", *sintptr);
+ MP_DBG(ctx, "sint %"PRId64"\n", *sintptr);
break;
case EBML_TYPE_FLOAT:;
double *floatptr;
GETPTR(floatptr, double);
if (length != 4 && length != 8) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "float invalid length %"PRIu64
+ MP_DBG(ctx, "float invalid length %"PRIu64
"\n", length);
goto error;
}
*floatptr = ebml_parse_float(data, length);
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "float %f\n", *floatptr);
+ MP_DBG(ctx, "float %f\n", *floatptr);
break;
case EBML_TYPE_STR:
@@ -670,10 +667,10 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
strptr->start = data;
strptr->len = length;
if (ed->type == EBML_TYPE_STR)
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "string \"%.*s\"\n",
+ MP_DBG(ctx, "string \"%.*s\"\n",
BSTR_P(*strptr));
else
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "binary %zd bytes\n",
+ MP_DBG(ctx, "binary %zd bytes\n",
strptr->len);
break;
@@ -682,10 +679,10 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
GETPTR(idptr, uint32_t);
*idptr = ebml_parse_id(data, &len);
if (len != length) {
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "ebml_id broken value\n");
+ MP_DBG(ctx, "ebml_id broken value\n");
goto error;
}
- mp_msg(MSGT_DEMUX, MSGL_DBG2, "ebml_id %x\n", (unsigned)*idptr);
+ MP_DBG(ctx, "ebml_id %x\n", (unsigned)*idptr);
break;
default:
abort();
@@ -704,24 +701,21 @@ int ebml_read_element(struct stream *s, struct ebml_parse_ctx *ctx,
int msglevel = ctx->no_error_messages ? MSGL_DBG2 : MSGL_WARN;
uint64_t length = ebml_read_length(s, &ctx->bytes_read);
if (s->eof) {
- mp_msg(MSGT_DEMUX, msglevel, "[mkv] Unexpected end of file "
+ MP_MSG(ctx, msglevel, "Unexpected end of file "
"- partial or corrupt file?\n");
return -1;
}
if (length > 1000000000) {
- mp_msg(MSGT_DEMUX, msglevel, "[mkv] Refusing to read element over "
- "100 MB in size\n");
+ MP_MSG(ctx, msglevel, "Refusing to read element over 100 MB in size\n");
return -1;
}
ctx->talloc_ctx = talloc_size(NULL, length + 8);
int read_len = stream_read(s, ctx->talloc_ctx, length);
ctx->bytes_read += read_len;
if (read_len < length)
- mp_msg(MSGT_DEMUX, msglevel, "[mkv] Unexpected end of file "
- "- partial or corrupt file?\n");
+ MP_MSG(ctx, msglevel, "Unexpected end of file - partial or corrupt file?\n");
ebml_parse_element(ctx, target, ctx->talloc_ctx, read_len, desc, 0);
if (ctx->has_errors)
- mp_msg(MSGT_DEMUX, msglevel, "[mkv] Error parsing element %s\n",
- desc->name);
+ MP_MSG(ctx, msglevel, "Error parsing element %s\n", desc->name);
return 0;
}
diff --git a/demux/ebml.h b/demux/ebml.h
index 8652746e48..9bfea7a8a6 100644
--- a/demux/ebml.h
+++ b/demux/ebml.h
@@ -26,6 +26,8 @@
#include "stream/stream.h"
#include "bstr/bstr.h"
+struct mp_log;
+
/* EBML version supported */
#define EBML_VERSION 1
@@ -57,6 +59,7 @@ struct ebml_elem_desc {
};
struct ebml_parse_ctx {
+ struct mp_log *log;
void *talloc_ctx;
int bytes_read;
bool has_errors;
@@ -99,8 +102,9 @@ double ebml_read_float (stream_t *s, uint64_t *length);
char *ebml_read_ascii (stream_t *s, uint64_t *length);
char *ebml_read_utf8 (stream_t *s, uint64_t *length);
int ebml_read_skip (stream_t *s, uint64_t *length);
-int ebml_read_skip_or_resync_cluster(stream_t *s, uint64_t *length);
-int ebml_resync_cluster(stream_t *s);
+int ebml_read_skip_or_resync_cluster(struct mp_log *log, stream_t *s,
+ uint64_t *length);
+int ebml_resync_cluster(struct mp_log *log, stream_t *s);
uint32_t ebml_read_master (stream_t *s, uint64_t *length);
int ebml_read_element(struct stream *s, struct ebml_parse_ctx *ctx,
diff --git a/demux/mf.c b/demux/mf.c
index 02a576c51d..0aabd46bb8 100644
--- a/demux/mf.c
+++ b/demux/mf.c
@@ -52,13 +52,14 @@ static void mf_add(mf_t *mf, const char *fname)
MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry);
}
-mf_t *open_mf_pattern(void *talloc_ctx, char *filename)
+mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename)
{
#if defined(HAVE_GLOB) || defined(__MINGW32__)
int error_count = 0;
int count = 0;
mf_t *mf = talloc_zero(talloc_ctx, mf_t);
+ mf->log = log;
if (filename[0] == '@') {
FILE *lst_f = fopen(filename + 1, "r");
@@ -70,24 +71,21 @@ mf_t *open_mf_pattern(void *talloc_ctx, char *filename)
while (t > fname && isspace(*t))
*(t--) = 0;
if (!mp_path_exists(fname)) {
- mp_msg(MSGT_STREAM, MSGL_V, "[mf] file not found: '%s'\n",
- fname);
+ mp_verbose(log, "file not found: '%s'\n", fname);
} else {
mf_add(mf, fname);
}
}
fclose(lst_f);
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] number of files: %d\n",
- mf->nr_of_files);
+ mp_info(log, "number of files: %d\n", mf->nr_of_files);
goto exit_mf;
}
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] %s is not indirect filelist\n",
- filename + 1);
+ mp_info(log, "%s is not indirect filelist\n", filename + 1);
}
if (strchr(filename, ',')) {
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] filelist: %s\n", filename);
+ mp_info(log, "filelist: %s\n", filename);
bstr bfilename = bstr0(filename);
while (bfilename.len) {
@@ -96,15 +94,13 @@ mf_t *open_mf_pattern(void *talloc_ctx, char *filename)
char *fname2 = bstrdup0(mf, bfname);
if (!mp_path_exists(fname2))
- mp_msg(MSGT_STREAM, MSGL_V, "[mf] file not found: '%s'\n",
- fname2);
+ mp_verbose(log, "file not found: '%s'\n", fname2);
else {
mf_add(mf, fname2);
}
talloc_free(fname2);
}
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] number of files: %d\n",
- mf->nr_of_files);
+ mp_info(log, "number of files: %d\n", mf->nr_of_files);
goto exit_mf;
}
@@ -116,7 +112,7 @@ mf_t *open_mf_pattern(void *talloc_ctx, char *filename)
if (!strchr(filename, '*'))
strcat(fname, "*");
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] search expr: %s\n", fname);
+ mp_info(log, "search expr: %s\n", fname);
glob_t gg;
if (glob(fname, 0, NULL, &gg)) {
@@ -129,38 +125,37 @@ mf_t *open_mf_pattern(void *talloc_ctx, char *filename)
continue;
mf_add(mf, gg.gl_pathv[i]);
}
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] number of files: %d\n",
- mf->nr_of_files);
+ mp_info(log, "number of files: %d\n", mf->nr_of_files);
globfree(&gg);
goto exit_mf;
}
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] search expr: %s\n", filename);
+ mp_info(log, "search expr: %s\n", filename);
while (error_count < 5) {
sprintf(fname, filename, count++);
if (!mp_path_exists(fname)) {
error_count++;
- mp_msg(MSGT_STREAM, MSGL_V, "[mf] file not found: '%s'\n", fname);
+ mp_verbose(log, "file not found: '%s'\n", fname);
} else {
mf_add(mf, fname);
}
}
- mp_msg(MSGT_STREAM, MSGL_INFO, "[mf] number of files: %d\n",
- mf->nr_of_files);
+ mp_info(log, "number of files: %d\n", mf->nr_of_files);
exit_mf:
return mf;
#else
- mp_msg(MSGT_STREAM, MSGL_FATAL, "[mf] mf support is disabled on your os\n");
+ mp_fatal(log, "mf support is disabled on your os\n");
return 0;
#endif
}
-mf_t *open_mf_single(void *talloc_ctx, char *filename)
+mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename)
{
mf_t *mf = talloc_zero(talloc_ctx, mf_t);
+ mf->log = log;
mf_add(mf, filename);
return mf;
}
diff --git a/demux/mf.h b/demux/mf.h
index 5511e3188b..09f6e03b4f 100644
--- a/demux/mf.h
+++ b/demux/mf.h
@@ -19,10 +19,13 @@
#ifndef MPLAYER_MF_H
#define MPLAYER_MF_H
+struct mp_log;
+
extern double mf_fps;
extern char * mf_type;
typedef struct mf {
+ struct mp_log *log;
struct sh_video *sh;
int curr_frame;
int nr_of_files;
@@ -31,7 +34,7 @@ typedef struct mf {
struct stream **streams;
} mf_t;
-mf_t *open_mf_pattern(void *talloc_ctx, char *filename);
-mf_t *open_mf_single(void *talloc_ctx, char *filename);
+mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename);
+mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename);
#endif /* MPLAYER_MF_H */