FFmpeg
Loading...
Searching...
No Matches
fflcms2.c File Reference
#include "libavutil/csp.h"
#include "fflcms2.h"

Go to the source code of this file.

Functions

static void log_cb (cmsContext ctx, cmsUInt32Number error, const char *str)
 
int ff_icc_context_init (FFIccContext *s, void *avctx)
 Initializes an FFIccContext.
 
void ff_icc_context_uninit (FFIccContext *s)
 
static int get_curve (FFIccContext *s, enum AVColorTransferCharacteristic trc, cmsToneCurve **out_curve)
 
int ff_icc_profile_generate (FFIccContext *s, enum AVColorPrimaries color_prim, enum AVColorTransferCharacteristic color_trc, cmsHPROFILE *out_profile)
 Generate an ICC profile for a given combination of color primaries and transfer function.
 
int ff_icc_profile_attach (FFIccContext *s, cmsHPROFILE profile, AVFrame *frame)
 Attach an ICC profile to a frame.
 
static av_always_inline void XYZ_xy (cmsCIEXYZ XYZ, AVCIExy *xy)
 
static av_always_inline AVRational abs_sub_q (AVRational r1, AVRational r2)
 
int ff_icc_profile_sanitize (FFIccContext *s, cmsHPROFILE profile)
 Sanitize an ICC profile to try and fix badly broken values.
 
int ff_icc_profile_read_primaries (FFIccContext *s, cmsHPROFILE profile, AVColorPrimariesDesc *out_primaries)
 Read the color primaries and white point coefficients encoded by an ICC profile, and return the raw values in out_primaries.
 
int ff_icc_profile_detect_transfer (FFIccContext *s, cmsHPROFILE profile, enum AVColorTransferCharacteristic *out_trc)
 Attempt detecting the transfer characteristic that best approximates the transfer function encoded by an ICC profile.
 

Variables

static const AVCIExy wp_d50 = { {3457, 10000}, {3585, 10000} }
 

Function Documentation

◆ log_cb()

static void log_cb ( cmsContext ctx,
cmsUInt32Number error,
const char * str )
static

Definition at line 24 of file fflcms2.c.

Referenced by ff_icc_context_init(), libplacebo_init(), and librist_open().

◆ ff_icc_context_init()

int ff_icc_context_init ( FFIccContext * s,
void * avctx )

Initializes an FFIccContext.

This must be done prior to using it.

Returns 0 on success, or a negative error code.

Definition at line 30 of file fflcms2.c.

Referenced by iccdetect_init(), and iccgen_init().

◆ ff_icc_context_uninit()

void ff_icc_context_uninit ( FFIccContext * s)

Definition at line 42 of file fflcms2.c.

Referenced by ff_codec_close(), iccdetect_uninit(), and iccgen_uninit().

◆ get_curve()

static int get_curve ( FFIccContext * s,
enum AVColorTransferCharacteristic trc,
cmsToneCurve ** out_curve )
static

Definition at line 50 of file fflcms2.c.

Referenced by ff_icc_profile_detect_transfer(), and ff_icc_profile_generate().

◆ ff_icc_profile_generate()

int ff_icc_profile_generate ( FFIccContext * s,
enum AVColorPrimaries color_prim,
enum AVColorTransferCharacteristic color_trc,
cmsHPROFILE * out_profile )

Generate an ICC profile for a given combination of color primaries and transfer function.

Both values must be set to valid entries (not "undefined") for this function to work.

Returns 0 on success, or a negative error code.

Definition at line 143 of file fflcms2.c.

Referenced by iccgen_filter_frame().

◆ ff_icc_profile_attach()

int ff_icc_profile_attach ( FFIccContext * s,
cmsHPROFILE profile,
AVFrame * frame )

Attach an ICC profile to a frame.

Helper wrapper around cmsSaveProfileToMem and av_frame_new_side_data_from_buf.

Returns 0 on success, or a negative error code.

Definition at line 170 of file fflcms2.c.

Referenced by iccgen_filter_frame().

◆ XYZ_xy()

static av_always_inline void XYZ_xy ( cmsCIEXYZ XYZ,
AVCIExy * xy )
static

Definition at line 195 of file fflcms2.c.

Referenced by ff_icc_profile_read_primaries(), and ff_icc_profile_sanitize().

◆ abs_sub_q()

static av_always_inline AVRational abs_sub_q ( AVRational r1,
AVRational r2 )
static

Definition at line 202 of file fflcms2.c.

Referenced by ff_icc_profile_sanitize().

◆ ff_icc_profile_sanitize()

int ff_icc_profile_sanitize ( FFIccContext * s,
cmsHPROFILE profile )

Sanitize an ICC profile to try and fix badly broken values.

Returns 0 on success, or a negative error code.

Definition at line 211 of file fflcms2.c.

Referenced by iccdetect_filter_frame().

◆ ff_icc_profile_read_primaries()

int ff_icc_profile_read_primaries ( FFIccContext * s,
cmsHPROFILE profile,
AVColorPrimariesDesc * out_primaries )

Read the color primaries and white point coefficients encoded by an ICC profile, and return the raw values in out_primaries.

Returns 0 on success, or a negative error code.

Definition at line 253 of file fflcms2.c.

Referenced by iccdetect_filter_frame().

◆ ff_icc_profile_detect_transfer()

int ff_icc_profile_detect_transfer ( FFIccContext * s,
cmsHPROFILE profile,
enum AVColorTransferCharacteristic * out_trc )

Attempt detecting the transfer characteristic that best approximates the transfer function encoded by an ICC profile.

Sets out_trc to AVCOL_TRC_UNSPECIFIED if no clear match can be identified.

Returns 0 on success (including no match), or a negative error code.

Definition at line 300 of file fflcms2.c.

Referenced by iccdetect_filter_frame().

Variable Documentation

◆ wp_d50

const AVCIExy wp_d50 = { {3457, 10000}, {3585, 10000} }
static

Definition at line 209 of file fflcms2.c.

Referenced by ff_icc_profile_sanitize().