]> git.sesse.net Git - mlt/commitdiff
Expand colorspace support to explicit 601.
authorDan Dennedy <dan@dennedy.org>
Tue, 14 Sep 2010 05:37:46 +0000 (22:37 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 26 Sep 2010 22:20:15 +0000 (15:20 -0700)
src/modules/avformat/producer_avformat.c

index 99111f9913bc9c8faea369de4ca48eb4439b38e4..fa44ed3941e84a5a2fe78f3af32291a3479b8266 100644 (file)
@@ -704,10 +704,21 @@ static void set_luma_transfer( struct SwsContext *context, int colorspace, int n
                // Don't change these from defaults unless explicitly told to.
                if ( no_scale )
                        range = 1;
-               if ( colorspace == 709 )
-                       coefficients = sws_getCoefficients( SWS_CS_ITU709 );
-               else if ( colorspace == 240 )
+               switch ( colorspace )
+               {
+               case 170:
+               case 470:
+               case 601:
+               case 624:
+                       coefficients = sws_getCoefficients( SWS_CS_ITU601 );
+                       break;
+               case 240:
                        coefficients = sws_getCoefficients( SWS_CS_SMPTE240M );
+                       break;
+               case 709:
+                       coefficients = sws_getCoefficients( SWS_CS_ITU709 );
+                       break;
+               }
                sws_setColorspaceDetails( context, coefficients, range, coefficients, range,
                        brightness, contrast, saturation );
        }
@@ -1453,17 +1464,18 @@ static int video_codec_init( producer_avformat this, int index, mlt_properties p
                {
                        switch ( this->video_codec->colorspace )
                        {
-                       case AVCOL_SPC_BT709:
-                               this->colorspace = 709;
+                       case AVCOL_SPC_SMPTE240M:
+                               this->colorspace = 240;
                                break;
                        case AVCOL_SPC_BT470BG:
                        case AVCOL_SPC_SMPTE170M:
                                this->colorspace = 601;
                                break;
-                       case AVCOL_SPC_SMPTE240M:
-                               this->colorspace = 240;
+                       case AVCOL_SPC_BT709:
+                               this->colorspace = 709;
                                break;
                        default:
+                               // This is a heuristic Charles Poynton suggests in "Digital Video and HDTV"
                                this->colorspace = this->video_codec->width * this->video_codec->height > 750000 ? 709 : 601;
                                break;
                        }