]> git.sesse.net Git - mlt/commitdiff
Rename variables and properties around luma range for clarity.
authorDan Dennedy <dan@dennedy.org>
Sun, 26 Sep 2010 22:47:35 +0000 (15:47 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 26 Sep 2010 22:47:35 +0000 (15:47 -0700)
Frame property "force_full_luma" controls this and can be set via
producer property "set.force_full_luma." However, it is not really ready
for use until libswscale can respect its full_range parameter in a RGB
to YUV conversion.

src/modules/avformat/filter_avcolour_space.c
src/modules/avformat/producer_avformat.c

index d3a0d5439ccf341f8bbc63ff7147b220a7f470e4..cd019016a014c56469a5072471fcd7067aa595a0 100644 (file)
@@ -73,18 +73,18 @@ static int convert_mlt_to_av_cs( mlt_image_format format )
        return value;
 }
 
-static void set_luma_transfer( struct SwsContext *context, int colorspace, int no_scale )
+static void set_luma_transfer( struct SwsContext *context, int colorspace, int use_full_range )
 {
        int *coefficients;
-       int range;
+       int full_range;
        int brightness, contrast, saturation;
 
-       if ( sws_getColorspaceDetails( context, &coefficients, &range, &coefficients, &range,
+       if ( sws_getColorspaceDetails( context, &coefficients, &full_range, &coefficients, &full_range,
                        &brightness, &contrast, &saturation ) != -1 )
        {
                // Don't change these from defaults unless explicitly told to.
-               if ( no_scale )
-                       range = 1;
+               if ( use_full_range )
+                       full_range = 1;
                switch ( colorspace )
                {
                case 170:
@@ -100,13 +100,13 @@ static void set_luma_transfer( struct SwsContext *context, int colorspace, int n
                        coefficients = sws_getCoefficients( SWS_CS_ITU709 );
                        break;
                }
-               sws_setColorspaceDetails( context, coefficients, range, coefficients, range,
+               sws_setColorspaceDetails( context, coefficients, full_range, coefficients, full_range,
                        brightness, contrast, saturation );
        }
 }
 
 static void av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt,
-       int width, int height, int colorspace, int no_scale )
+       int width, int height, int colorspace, int use_full_range )
 {
        AVPicture input;
        AVPicture output;
@@ -128,7 +128,7 @@ static void av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt
 #ifdef SWSCALE
        struct SwsContext *context = sws_getContext( width, height, in_fmt,
                width, height, out_fmt, flags, NULL, NULL, NULL);
-       set_luma_transfer( context, colorspace, no_scale );
+       set_luma_transfer( context, colorspace, use_full_range );
        sws_scale( context, input.data, input.linesize, 0, height,
                output.data, output.linesize);
        sws_freeContext( context );
@@ -190,14 +190,11 @@ static int convert_image( mlt_frame frame, uint8_t **image, mlt_image_format *fo
 
                // Update the output
                int colorspace = mlt_properties_get_int( properties, "colorspace" );
-               int no_scale_luma = 0;
-               if ( *format == mlt_image_yuv422 && mlt_properties_get_int( properties, "skip_luma_scale" )
+               int force_full_luma = mlt_properties_get_int( properties, "force_full_luma" );
+               if ( *format == mlt_image_yuv422 && force_full_luma
                         && ( output_format == mlt_image_rgb24 || output_format == mlt_image_rgb24a ) )
-               {
-                       no_scale_luma = 1;
-                       mlt_properties_set( properties, "skip_luma_scale", NULL );
-               }
-               av_convert_image( output, *image, out_fmt, in_fmt, width, height, colorspace, no_scale_luma );
+                       mlt_properties_set( properties, "force_full_luma", NULL );
+               av_convert_image( output, *image, out_fmt, in_fmt, width, height, colorspace, force_full_luma );
                *image = output;
                *format = output_format;
                mlt_properties_set_data( properties, "image", output, size, mlt_pool_release, NULL );
@@ -276,7 +273,7 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
 static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
 {
        frame->convert_image = convert_image;
-       mlt_frame_push_get_image( frame, mlt_service_profile( MLT_FILTER_SERVICE( filter ) ) );
+       mlt_frame_push_service( frame, mlt_service_profile( MLT_FILTER_SERVICE( filter ) ) );
        mlt_frame_push_get_image( frame, get_image );
        return frame;
 }
index fa44ed3941e84a5a2fe78f3af32291a3479b8266..cd4b097a2f1ce97379dd6ed0f4c17ad2b0061764 100644 (file)
@@ -692,18 +692,18 @@ static void get_audio_streams_info( producer_avformat this )
        this->resample_factor = 1.0;
 }
 
-static void set_luma_transfer( struct SwsContext *context, int colorspace, int no_scale )
+static void set_luma_transfer( struct SwsContext *context, int colorspace, int use_full_range )
 {
        int *coefficients;
-       int range;
+       int full_range;
        int brightness, contrast, saturation;
 
-       if ( sws_getColorspaceDetails( context, &coefficients, &range, &coefficients, &range,
+       if ( sws_getColorspaceDetails( context, &coefficients, &full_range, &coefficients, &full_range,
                        &brightness, &contrast, &saturation ) != -1 )
        {
                // Don't change these from defaults unless explicitly told to.
-               if ( no_scale )
-                       range = 1;
+               if ( use_full_range )
+                       full_range = 1;
                switch ( colorspace )
                {
                case 170:
@@ -719,7 +719,7 @@ static void set_luma_transfer( struct SwsContext *context, int colorspace, int n
                        coefficients = sws_getCoefficients( SWS_CS_ITU709 );
                        break;
                }
-               sws_setColorspaceDetails( context, coefficients, range, coefficients, range,
+               sws_setColorspaceDetails( context, coefficients, full_range, coefficients, full_range,
                        brightness, contrast, saturation );
        }
 }
@@ -728,7 +728,7 @@ static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
        mlt_image_format *format, int width, int height, int colorspace )
 {
 #ifdef SWSCALE
-       int luma = 0;
+       int full_range = 0;
        int flags = SWS_BILINEAR | SWS_ACCURATE_RND;
 
 #ifdef USE_MMX
@@ -745,7 +745,7 @@ static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
                        width, height, PIX_FMT_RGBA, flags, NULL, NULL, NULL);
                AVPicture output;
                avpicture_fill( &output, buffer, PIX_FMT_RGBA, width, height );
-               set_luma_transfer( context, colorspace, luma );
+               set_luma_transfer( context, colorspace, full_range );
                sws_scale( context, frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );
@@ -761,7 +761,7 @@ static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
                output.linesize[0] = width;
                output.linesize[1] = width >> 1;
                output.linesize[2] = width >> 1;
-               set_luma_transfer( context, colorspace, luma );
+               set_luma_transfer( context, colorspace, full_range );
                sws_scale( context, frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );
@@ -772,7 +772,7 @@ static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
                        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, colorspace, luma );
+               set_luma_transfer( context, colorspace, full_range );
                sws_scale( context, frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );
@@ -783,7 +783,7 @@ static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
                        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, colorspace, luma );
+               set_luma_transfer( context, colorspace, full_range );
                sws_scale( context, frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );
@@ -794,7 +794,7 @@ static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt,
                        width, height, PIX_FMT_YUYV422, flags | SWS_FULL_CHR_H_INP, NULL, NULL, NULL);
                AVPicture output;
                avpicture_fill( &output, buffer, PIX_FMT_YUYV422, width, height );
-               set_luma_transfer( context, colorspace, luma );
+               set_luma_transfer( context, colorspace, full_range );
                sws_scale( context, frame->data, frame->linesize, 0, height,
                        output.data, output.linesize);
                sws_freeContext( context );