MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / encode_generate_icc_profile

Function encode_generate_icc_profile

libavcodec/encode.c:382–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380
381#if CONFIG_LCMS2
382static int encode_generate_icc_profile(AVCodecContext *avctx, AVFrame *frame)
383{
384 enum AVColorTransferCharacteristic trc = frame->color_trc;
385 enum AVColorPrimaries prim = frame->color_primaries;
386 const FFCodec *const codec = ffcodec(avctx->codec);
387 AVCodecInternal *avci = avctx->internal;
388 cmsHPROFILE profile;
389 int ret;
390
391 /* don't generate ICC profiles if disabled or unsupported */
392 if (!(avctx->flags2 & AV_CODEC_FLAG2_ICC_PROFILES))
393 return 0;
394 if (!(codec->caps_internal & FF_CODEC_CAP_ICC_PROFILES))
395 return 0;
396
397 if (trc == AVCOL_TRC_UNSPECIFIED)
398 trc = avctx->color_trc;
399 if (prim == AVCOL_PRI_UNSPECIFIED)
400 prim = avctx->color_primaries;
401 if (trc == AVCOL_TRC_UNSPECIFIED || prim == AVCOL_PRI_UNSPECIFIED)
402 return 0; /* can't generate ICC profile with missing csp tags */
403
404 if (av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE))
405 return 0; /* don't overwrite existing ICC profile */
406
407 if (!avci->icc.avctx) {
408 ret = ff_icc_context_init(&avci->icc, avctx);
409 if (ret < 0)
410 return ret;
411 }
412
413 ret = ff_icc_profile_generate(&avci->icc, prim, trc, &profile);
414 if (ret < 0)
415 return ret;
416
417 ret = ff_icc_profile_attach(&avci->icc, profile, frame);
418 cmsCloseProfile(profile);
419 return ret;
420}
421#else /* !CONFIG_LCMS2 */
422static int encode_generate_icc_profile(av_unused AVCodecContext *c, av_unused AVFrame *f)
423{

Callers 1

Calls 5

ffcodecFunction · 0.85
av_frame_get_side_dataFunction · 0.85
ff_icc_context_initFunction · 0.85
ff_icc_profile_generateFunction · 0.85
ff_icc_profile_attachFunction · 0.85

Tested by

no test coverage detected