]> git.sesse.net Git - mlt/blobdiff - src/modules/avformat/filter_avcolour_space.c
Fix YUV to RGB conversion when profile colorspace not 601.
[mlt] / src / modules / avformat / filter_avcolour_space.c
index 5733aa82ea7b5d80dabcb7e52ed37f5b0c843f68..cce62c5ea2021e62b11db5f93290c1c2136c54f2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * filter_avcolour_space.c -- Colour space filter
- * Copyright (C) 2004-2005 Ushodaya Enterprises Limited
+ * Copyright (C) 2004-2014 Ushodaya Enterprises Limited
  * Author: Charles Yates <charles.yates@pandora.be>
  *
  * This library is free software; you can redistribute it and/or
@@ -143,6 +143,9 @@ static int av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt,
                width, height, out_fmt, flags, NULL, NULL, NULL);
        if ( context )
        {
+               // libswscale wants the RGB colorspace to be SWS_CS_DEFAULT, which is = SWS_CS_ITU601.
+               if ( out_fmt == PIX_FMT_RGB24 || out_fmt == PIX_FMT_RGBA )
+                       dst_colorspace = 601;
                error = set_luma_transfer( context, src_colorspace, dst_colorspace, use_full_range );
                sws_scale( context, (const uint8_t* const*) input.data, input.linesize, 0, height,
                        output.data, output.linesize);