diff options
author | wm4 <wm4@nowhere> | 2015-04-09 21:01:34 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-04-09 21:01:34 +0200 |
commit | 8d3c826ad867441cb5e77afd88098190b55d73b2 (patch) | |
tree | 7a33435fc01339ab9c0fb963fd951828dc14a5dd | |
parent | 13a0ff8cb79473e971c2de3090616bae1905b78f (diff) | |
download | mpv-8d3c826ad867441cb5e77afd88098190b55d73b2.tar.bz2 mpv-8d3c826ad867441cb5e77afd88098190b55d73b2.tar.xz |
screenshots: write jpg files with original subsampling
A screenshot from a 4:2:0 video will use 4:2:0, RGB will use 4:4:4, and
so on. (The image data still goes through RGB conversion always.)
-rw-r--r-- | video/image_writer.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/video/image_writer.c b/video/image_writer.c index 939b435787..1da43feca6 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -77,6 +77,7 @@ struct image_writer_ctx { struct mp_log *log; const struct image_writer_opts *opts; const struct img_writer *writer; + struct mp_imgfmt_desc original_format; }; struct img_writer { @@ -200,6 +201,9 @@ static int write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) cinfo.optimize_coding = ctx->opts->jpeg_optimize; cinfo.smoothing_factor = ctx->opts->jpeg_smooth; + cinfo.comp_info[0].h_samp_factor = 1 << ctx->original_format.chroma_xs; + cinfo.comp_info[0].v_samp_factor = 1 << ctx->original_format.chroma_ys; + if (ctx->opts->jpeg_progressive) jpeg_simple_progression(&cinfo); @@ -299,7 +303,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 = { log, opts, writer }; + struct image_writer_ctx ctx = { log, opts, writer, image->fmt }; int destfmt = get_target_format(&ctx, image->imgfmt); // Caveat: no colorspace/levels conversion done if pixel formats equal |