Go to the documentation of this file.
33 memset(
s, 0,
sizeof(*
s));
35 s->ctx = cmsCreateContext(
NULL,
s);
39 cmsSetLogErrorHandlerTHR(
s->ctx,
log_cb);
46 cmsFreeToneCurve(
s->curves[
i]);
47 cmsDeleteContext(
s->ctx);
48 memset(
s, 0,
sizeof(*
s));
52 cmsToneCurve **out_curve)
62 s->curves[trc] = cmsBuildGamma(
s->ctx, 1.0);
65 s->curves[trc] = cmsBuildGamma(
s->ctx, 2.2);
68 s->curves[trc] = cmsBuildGamma(
s->ctx, 2.8);
74 s->curves[trc] = cmsBuildParametricToneCurve(
s->ctx, 4, (
double[5]) {
77 1 - 1/1.099296826809442,
79 4.5 * 0.018053968510807,
83 s->curves[trc] = cmsBuildParametricToneCurve(
s->ctx, 4, (
double[5]) {
92 s->curves[trc] = cmsBuildParametricToneCurve(
s->ctx, 8, (
double[5]) {
101 s->curves[trc] = cmsBuildParametricToneCurve(
s->ctx, 8, (
double[5]) {
110 s->curves[trc] = cmsBuildParametricToneCurve(
s->ctx, 4, (
double[5]) {
119 s->curves[trc] = cmsBuildParametricToneCurve(
s->ctx, 2, (
double[3]) {
121 pow(52.37/48.0, 1/2.6),
142 *out_curve =
s->curves[trc];
149 cmsHPROFILE *out_profile)
151 cmsToneCurve *tonecurve;
160 *out_profile = cmsCreateRGBProfileTHR(
s->ctx,
161 &(cmsCIExyY) { av_q2d(prim->wp.x), av_q2d(prim->wp.y), 1.0 },
163 .Red = { av_q2d(prim->prim.r.x), av_q2d(prim->prim.r.y), 1.0 },
164 .Green = { av_q2d(prim->prim.g.x), av_q2d(prim->prim.g.y), 1.0 },
165 .Blue = { av_q2d(prim->prim.b.x), av_q2d(prim->prim.b.y), 1.0 },
167 (cmsToneCurve *[3]) { tonecurve, tonecurve, tonecurve }
175 cmsUInt32Number
size;
200 double k = 1.0 / (XYZ.X + XYZ.Y + XYZ.Z);
201 xy->
x =
av_d2q(k * XYZ.X, 100000);
202 xy->
y =
av_d2q(k * XYZ.Y, 100000);
208 static const uint8_t testprimaries[4][3] = {
212 { 0xFF, 0xFF, 0xFF },
217 cmsFloat64Number prev_adapt;
222 xyz = cmsCreateXYZProfileTHR(
s->ctx);
227 prev_adapt = cmsSetAdaptationStateTHR(
s->ctx, 0.0);
228 tf = cmsCreateTransformTHR(
s->ctx,
profile, TYPE_RGB_8, xyz, TYPE_XYZ_DBL,
229 INTENT_ABSOLUTE_COLORIMETRIC,
233 cmsFLAGS_NOOPTIMIZE |
234 cmsFLAGS_LOWRESPRECALC |
235 cmsFLAGS_GRIDPOINTS(2));
236 cmsSetAdaptationStateTHR(
s->ctx, prev_adapt);
237 cmsCloseProfile(xyz);
243 cmsDoTransform(
tf, testprimaries, dst, 4);
244 cmsDeleteTransform(
tf);
256 static const uint8_t testramp[16][3] = {
278 cmsToneCurve *tonecurve;
285 ref = cmsCreateGrayProfileTHR(
s->ctx, cmsD50_xyY(), tonecurve);
289 tf = cmsCreateTransformTHR(
s->ctx,
profile, TYPE_RGB_8,
ref, TYPE_GRAY_DBL,
290 INTENT_RELATIVE_COLORIMETRIC,
291 cmsFLAGS_NOCACHE | cmsFLAGS_NOOPTIMIZE);
292 cmsCloseProfile(
ref);
299 cmsDeleteTransform(
tf);
static void error(const char *err)
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 v...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVColorTransferCharacteristic
Color Transfer Characteristic.
AVWhitepointCoefficients wp
Struct that contains both white point location and primaries location, providing the complete descrip...
uint8_t * data
The data buffer.
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
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...
This structure describes decoded (raw) audio or video data.
@ AVCOL_TRC_NB
Not part of ABI.
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Struct defining the red, green, and blue primary locations in terms of CIE 1931 chromaticity x and y.
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
static av_always_inline void XYZ_xy(cmsCIEXYZ XYZ, AVCIExy *xy)
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
void ff_icc_context_uninit(FFIccContext *s)
static __device__ float fabs(float a)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Struct containing chromaticity x and y values for the standard CIE 1931 chromaticity definition.
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
#define AVERROR_EXTERNAL
Generic error in an external library.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
size_t size
Size of data in bytes.
@ AVCOL_TRC_BT709
also ITU-R BT1361
#define i(width, name, range_min, range_max)
int ff_icc_profile_attach(FFIccContext *s, cmsHPROFILE profile, AVFrame *frame)
Attach an ICC profile to a frame.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
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.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int ff_icc_context_init(FFIccContext *s, void *avctx)
Initializes an FFIccContext.
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
static int ref[MAX_W *MAX_W]
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
A reference to a data buffer.
AVPrimaryCoefficients prim
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
static int get_curve(FFIccContext *s, enum AVColorTransferCharacteristic trc, cmsToneCurve **out_curve)