summaryrefslogtreecommitdiffstats
path: root/video/image_writer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 17:59:38 +0100
committerwm4 <wm4@nowhere>2013-12-21 20:50:10 +0100
commit5beedf1967f93ad4edfb6d1dd2edf9f4660a5afe (patch)
treeebe5c9826ad5537c36ce0f8f096581078327e2de /video/image_writer.c
parent38342436cd59afd345595d83b329bc7c6ac3616f (diff)
downloadmpv-5beedf1967f93ad4edfb6d1dd2edf9f4660a5afe.tar.bz2
mpv-5beedf1967f93ad4edfb6d1dd2edf9f4660a5afe.tar.xz
image_writer: mp_msg conversions
Adds an awkward mp_log argument for error messages.
Diffstat (limited to 'video/image_writer.c')
-rw-r--r--video/image_writer.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/video/image_writer.c b/video/image_writer.c
index 98a691d51d..7e725fe729 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -74,6 +74,7 @@ const struct m_sub_options image_writer_conf = {
};
struct image_writer_ctx {
+ struct mp_log *log;
const struct image_writer_opts *opts;
const struct img_writer *writer;
};
@@ -113,8 +114,7 @@ static int write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp)
if (avcodec_open2(avctx, codec, NULL) < 0) {
print_open_fail:
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "Could not open libavcodec encoder"
- " for saving images\n");
+ MP_ERR(ctx, "Could not open libavcodec encoder for saving images\n");
goto error_exit;
}
@@ -256,7 +256,7 @@ const char *image_writer_file_ext(const struct image_writer_opts *opts)
}
int write_image(struct mp_image *image, const struct image_writer_opts *opts,
- const char *filename)
+ const char *filename, struct mp_log *log)
{
struct mp_image *allocated_image = NULL;
struct image_writer_opts defs = image_writer_opts_defaults;
@@ -268,7 +268,7 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
opts = &defs;
const struct img_writer *writer = get_writer(opts);
- struct image_writer_ctx ctx = { opts, writer };
+ struct image_writer_ctx ctx = { log, opts, writer };
int destfmt = IMGFMT_RGB24;
if (writer->pixfmts) {
@@ -296,14 +296,12 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
FILE *fp = fopen(filename, "wb");
int success = 0;
if (fp == NULL) {
- mp_msg(MSGT_CPLAYER, MSGL_ERR,
- "Error opening '%s' for writing!\n", filename);
+ mp_err(log, "Error opening '%s' for writing!\n", filename);
} else {
success = writer->write(&ctx, image, fp);
success = !fclose(fp) && success;
if (!success)
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "Error writing file '%s'!\n",
- filename);
+ mp_err(log, "Error writing file '%s'!\n", filename);
}
talloc_free(allocated_image);
@@ -311,9 +309,9 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
return success;
}
-void dump_png(struct mp_image *image, const char *filename)
+void dump_png(struct mp_image *image, const char *filename, struct mp_log *log)
{
struct image_writer_opts opts = image_writer_opts_defaults;
opts.format = "png";
- write_image(image, &opts, filename);
+ write_image(image, &opts, filename, log);
}