Proxies: FFmpeg proxy builder wasn't taking image quality into account at all
[blender.git] / source / blender / imbuf / intern / indexer.c
index e1481d2a08feb37fc49c5809b28916a804a733f6..eb1bfc803834d585bab987ecca5383c62f4ffd0b 100644 (file)
@@ -459,12 +459,13 @@ static int round_up(int x, int mod)
 static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
        struct anim * anim,
        AVStream * st, int proxy_size, int width, int height,
-       int UNUSED(quality))
+       int quality)
 {
        struct proxy_output_ctx * rv = MEM_callocN(
                sizeof(struct proxy_output_ctx), "alloc_proxy_output");
        
        char fname[FILE_MAX];
+       int ffmpeg_quality;
 
        // JPEG requires this
        width = round_up(width, 8);
@@ -514,6 +515,12 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg(
        rv->c->time_base.num = 1;
        rv->st->time_base = rv->c->time_base;
 
+       /* there's no  way to set JPEG quality in the same way as in AVI JPEG and image sequence,
+        * but this seems to be giving expected quality result */
+       ffmpeg_quality = 31 * (1.0f - (float)quality / 100.0f);
+       av_set_int(rv->c, "qmin", ffmpeg_quality);
+       av_set_int(rv->c, "qmax", ffmpeg_quality);
+
        if (rv->of->flags & AVFMT_GLOBALHEADER) {
                rv->c->flags |= CODEC_FLAG_GLOBAL_HEADER;
        }