Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: QTMovie addImage:forDuration:withAttributes color and gamma shifts, how to get it right
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: QTMovie addImage:forDuration:withAttributes color and gamma shifts, how to get it right



On 24.01.2008, at 17:58, Tim Monroe wrote:

I'm experimenting with creating movies with QTKit. I'm creating the movie from NSImages and experimenting with different codecs: Apple Intermediate (icod), Photo-JPEG (jpeg) and Uncompressed YUV (2vuy).

Apple Intermediate and Uncompressed YUV look the same. Photo-JPEG is very different.
None matches what I see when I open the Tiff files I use to create the movies.


I see the resulting Apple Intermediate and Uncompressed YUV movies are tagged as nclc 1:1:1, meaning Rec. 709 transfer function, primaries and matrix - whereas the Photo-JPEG files have no color information tag at all. That might explain why these look different. But I do not understand why none looks like the original.

Does QTMovie's addImage:forDuration:withAttributes attempt to do any color matching (including gamma correction) or does it not? Is it perhaps just blindly tagging the movies but not actually converting to the correct color space first?

Please file a bug report with your sample images (if possible) and a clear method of reproducing your results. We have recently uncovered at least one other color space issue with QTKit, which should be fixed in a future QTKit release. I do not know of any workaround for your particular issue. Sorry about that.

Here are the problems roots and workaround:

First: the tags in the final movie mean nothing (some codec's blindly add nclc 1:1:1), it's up to YOU to set the correct tags. So to get the colors looking right you have to convert the images to one of the color space primaries supported by QuickTime, and set the nclc accordingly. QTKit will do no conversion at all.

Second: QTKit is doing something with gamma. In my experiments, for most codecs it is expecting the input images to be gamma 1.8 and then converting it to gamma 2.2 (for some codecs it is leaving it as gamma 1.8 though, notably 2vuy and jpeg). So we need to convert the input images to gamma 1.8 then pass it to QTKit; depending on which codec was used, the results need to be tagged as either gamma 1.8 or 2.2.

By the way, the resulting gamma is a simple gamma encoding and is quite different from the Rec. 709 transfer function, so using the nclc for tagging will not look correct, instead set the nclc transfer function to unknown and use the gamma extension to set gamma.

This is far from optimal as the image's gamma is possibly changed twice for no reason... this can deteriorate the image's quality.

Third: up to here we have the primaries and gamma, now, most codecs use YUV instead of RGB internally, and to get accurate colors QT needs to know which matrix to use. This makes one wonder why QTMovie's addImage:forDuration:withAttributes has no attribute for the YUV matrix... anyway, each codec will do it's own YUV conversion! And even worse, none will tag the Image Description correctly.

What this mean's is that (like with gamma) you need to test and come up with a list of which codec uses which matrix and set the movie tags accordingly. Here's the list for the codecs I tested (including the gamma used):

dvcp: matrix kQTMatrix_ITU_R_601_4
dvc : matrix kQTMatrix_ITU_R_601_4
icod: matrix kQTMatrix_ITU_R_709_2
jpeg : matrix kQTMatrix_ITU_R_601_4
2vuy: matrix kQTMatrix_SMPTE_240M_1995

What a mess!

Mark




_______________________________________________ Do not post admin requests to the list. They will be ignored. QuickTime-API mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: QTMovie addImage:forDuration:withAttributes color and gamma shifts, how to get it right (From: Tim Monroe <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.