[FFmpeg-devel] Gamma function (was Re: [PATCH] lavc/pngenc: Support writing colorspace tags.)

Michael Niedermayer michaelni at gmx.at
Mon Mar 2 13:17:29 CET 2015


On Mon, Mar 02, 2015 at 11:00:43AM +0000, Kevin Wheatley wrote:
> On Sat, Feb 28, 2015 at 1:50 AM, Niklas Haas <git at nand.wakku.to> wrote:
> 
> > +static int png_get_gama(enum AVColorTransferCharacteristic trc, uint8_t *buf)
> > +{
> > +    double gamma;
> > +    switch (trc) {
> > +        case AVCOL_TRC_BT709:
> > +        case AVCOL_TRC_SMPTE170M:
> > +        case AVCOL_TRC_SMPTE240M:
> > +        case AVCOL_TRC_BT1361_ECG:
> > +        case AVCOL_TRC_BT2020_10:
> > +        case AVCOL_TRC_BT2020_12:
> > +            /* these share a segmented TRC, but gamma 1.961 is a close
> > +              approximation, and also more correct for decoding content */
> > +            gamma = 1.961;
> > +            break;
> > +        case AVCOL_TRC_GAMMA22:
> > +        case AVCOL_TRC_IEC61966_2_1:
> > +            gamma = 2.2;
> > +            break;
> > +        case AVCOL_TRC_GAMMA28:
> > +            gamma = 2.8;
> > +            break;
> > +        case AVCOL_TRC_LINEAR:
> > +            gamma = 1.0;
> > +            break;
> > +        default:
> > +            return 0;
> > +    }
> > +
> > +    AV_WB32_PNG(buf, 1.0 / gamma);
> > +    return 1;
> > +}
> > +
> 
> 
> Co-incidentally I was thinking of submitting a patch to write the old
> QuickTime gama atom and most of this function would be useful if
> extracted to a common place (everything but the AV_WB32_PNG() as
> .mov's need a different scaling). Where should it go? libavutil?
> 
> As part of it I would also allow manually specifying a specific value
> to encode on the command line, but I wondered about how to form the
> command line options...

the various colorspace options should pass from decoder over the
video filter chain to the encoder and then muxer
its best to change them from the command line through a video
filter, this also ensures that the value reaching the encoder and
muxer matches

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150302/5fc9648a/attachment.asc>


More information about the ffmpeg-devel mailing list