From 8d3c826ad867441cb5e77afd88098190b55d73b2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 9 Apr 2015 21:01:34 +0200 Subject: 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.) --- video/image_writer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'video') 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 -- cgit v1.2.3