diff options
author | wm4 <wm4@nowhere> | 2012-08-06 17:48:30 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-06 17:48:30 +0200 |
commit | 5f57d276562c18ce65c47fa60f442ea427d7033e (patch) | |
tree | 95e7820e8ed3be3a3d809feb22dd236c7f1af0fc | |
parent | 4de99d9c0c1451db8a11c4f8173352e932844f14 (diff) | |
download | mpv-5f57d276562c18ce65c47fa60f442ea427d7033e.tar.bz2 mpv-5f57d276562c18ce65c47fa60f442ea427d7033e.tar.xz |
image_writer: add option parsing
image_writer now provides its own option parsing, and screenshot.c and
the mplayer frontend use it.
-rw-r--r-- | cfg-mplayer.h | 14 | ||||
-rw-r--r-- | defaultopts.c | 2 | ||||
-rw-r--r-- | image_writer.c | 14 | ||||
-rw-r--r-- | options.h | 4 | ||||
-rw-r--r-- | screenshot.c | 9 |
5 files changed, 28 insertions, 15 deletions
diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 0f1789dec5..c250d94874 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -616,6 +616,14 @@ const m_option_t tvscan_conf[]={ }; #endif +extern const struct m_sub_options image_writer_conf; + +const m_option_t screenshot_conf[] = { + OPT_SUBSTRUCT(screenshot_image_opts, image_writer_conf, M_OPT_MERGE), + OPT_STRING("template", screenshot_template, 0), + {0}, +}; + const m_option_t mplayer_opts[]={ /* name, pointer, type, flags, min, max */ @@ -785,10 +793,8 @@ const m_option_t mplayer_opts[]={ {"tvscan", (void *) tvscan_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, #endif /* CONFIG_TV */ - OPT_INTRANGE("screenshot-jpeg-quality", screenshot_jpeg_quality, 0, 0, 100), - OPT_INTRANGE("screenshot-png-compression", screenshot_png_compression, 0, 0, 9), - OPT_STRING("screenshot-filetype", screenshot_filetype, 0), - OPT_STRING("screenshot-template", screenshot_template, 0), + {"screenshot", (void *) screenshot_conf, CONF_TYPE_SUBCONFIG, + M_OPT_PREFIXED, 0, 0, NULL}, OPT_FLAG_ON("list-properties", list_properties, CONF_GLOBAL), {"identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_FLAG, CONF_GLOBAL, 0, MSGL_V, NULL}, diff --git a/defaultopts.c b/defaultopts.c index 96768f605a..8636fe69f0 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -40,8 +40,6 @@ void set_default_mplayer_options(struct MPOpts *opts) .video_id = -1, .sub_id = -1, .extension_parsing = 1, - .screenshot_jpeg_quality = 85, - .screenshot_png_compression = 7, .audio_output_channels = 2, .audio_output_format = -1, // AF_FORMAT_UNKNOWN .playback_speed = 1., diff --git a/image_writer.c b/image_writer.c index 3aca95d963..750dd15426 100644 --- a/image_writer.c +++ b/image_writer.c @@ -51,6 +51,20 @@ const struct image_writer_opts image_writer_opts_defaults = { .jpeg_quality = 85, }; +#undef OPT_BASE_STRUCT +#define OPT_BASE_STRUCT struct image_writer_opts + +const struct m_sub_options image_writer_conf = { + .opts = (m_option_t[]) { + OPT_INTRANGE("jpeg-quality", jpeg_quality, 0, 0, 100), + OPT_INTRANGE("png-compression", png_compression, 0, 0, 9), + OPT_STRING("filetype", filetype, 0), + {0}, + }, + .size = sizeof(struct image_writer_opts), + .defaults = &image_writer_opts_defaults, +}; + struct image_writer_ctx { const struct image_writer_opts *opts; const struct img_writer *writer; @@ -85,9 +85,7 @@ typedef struct MPOpts { char *sub_demuxer_name; int extension_parsing; - int screenshot_jpeg_quality; - int screenshot_png_compression; - char *screenshot_filetype; + struct image_writer_opts *screenshot_image_opts; char *screenshot_template; int audio_output_channels; diff --git a/screenshot.c b/screenshot.c index 6c734f57b5..032fa132f4 100644 --- a/screenshot.c +++ b/screenshot.c @@ -262,15 +262,12 @@ void screenshot_save(struct MPContext *mpctx, struct mp_image *image) struct mp_csp_details colorspace; get_detected_video_colorspace(mpctx->sh_video, &colorspace); - struct image_writer_opts opts = image_writer_opts_defaults; - opts.filetype = mpctx->opts.screenshot_filetype; - opts.jpeg_quality = mpctx->opts.screenshot_jpeg_quality; - opts.png_compression = mpctx->opts.screenshot_png_compression; + struct image_writer_opts *opts = mpctx->opts.screenshot_image_opts; - char *filename = gen_fname(ctx, image_writer_file_ext(&opts)); + char *filename = gen_fname(ctx, image_writer_file_ext(opts)); if (filename) { mp_msg(MSGT_CPLAYER, MSGL_INFO, "*** screenshot '%s' ***\n", filename); - if (!write_image(image, &colorspace, &opts, filename)) + if (!write_image(image, &colorspace, opts, filename)) mp_msg(MSGT_CPLAYER, MSGL_ERR, "\nError writing screenshot!\n"); talloc_free(filename); } |