]> git.sesse.net Git - mlt/blobdiff - src/modules/avformat/producer_avformat.c
Fix YUV to RGB conversion when profile colorspace not 601.
[mlt] / src / modules / avformat / producer_avformat.c
index cbdd38fd670485c9a6c8987899c6bd2d9b872d19..be1cc06e07e47b23c7fe4c0de32a437e04e89da8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * producer_avformat.c -- avformat producer
- * Copyright (C) 2003-2012 Ushodaya Enterprises Limited
+ * Copyright (C) 2003-2014 Ushodaya Enterprises Limited
  * Author: Charles Yates <charles.yates@pandora.be>
  * Author: Dan Dennedy <dan@dennedy.org>
  * Much code borrowed from ffmpeg.c: Copyright (c) 2000-2003 Fabrice Bellard
@@ -1189,7 +1189,8 @@ static int convert_image( producer_avformat self, AVFrame *frame, uint8_t *buffe
                        width, height, PIX_FMT_RGB24, flags | SWS_FULL_CHR_H_INT, NULL, NULL, NULL);
                AVPicture output;
                avpicture_fill( &output, buffer, PIX_FMT_RGB24, width, height );
-               set_luma_transfer( context, self->yuv_colorspace, profile->colorspace, self->full_luma );
+               // libswscale wants the RGB colorspace to be SWS_CS_DEFAULT, which is = SWS_CS_ITU601.
+               set_luma_transfer( context, self->yuv_colorspace, 601, self->full_luma );
                sws_scale( context, (const uint8_t* const*) frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );
@@ -1200,7 +1201,8 @@ static int convert_image( producer_avformat self, AVFrame *frame, uint8_t *buffe
                        width, height, PIX_FMT_RGBA, flags | SWS_FULL_CHR_H_INT, NULL, NULL, NULL);
                AVPicture output;
                avpicture_fill( &output, buffer, PIX_FMT_RGBA, width, height );
-               set_luma_transfer( context, self->yuv_colorspace, profile->colorspace, self->full_luma );
+               // libswscale wants the RGB colorspace to be SWS_CS_DEFAULT, which is = SWS_CS_ITU601.
+               set_luma_transfer( context, self->yuv_colorspace, 601, self->full_luma );
                sws_scale( context, (const uint8_t* const*) frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );