mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
Simplify portion of NCLX color profile code
This commit is contained in:
parent
a4b8295625
commit
8845dd9818
@ -198,25 +198,8 @@ bool QAVIFHandler::decode_one_frame()
|
|||||||
qWarning("Invalid QColorSpace created from ICC!\n");
|
qWarning("Invalid QColorSpace created from ICC!\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
avifColorPrimaries primaries_to_load;
|
|
||||||
avifTransferCharacteristics trc_to_load;
|
|
||||||
|
|
||||||
if ((m_decoder->image->colorPrimaries == 2 /* AVIF_COLOR_PRIMARIES_UNSPECIFIED */) ||
|
|
||||||
(m_decoder->image->colorPrimaries == 0 /* AVIF_COLOR_PRIMARIES_UNKNOWN */)) {
|
|
||||||
primaries_to_load = (avifColorPrimaries) 1; // AVIF_COLOR_PRIMARIES_BT709
|
|
||||||
} else {
|
|
||||||
primaries_to_load = m_decoder->image->colorPrimaries;
|
|
||||||
}
|
|
||||||
if ((m_decoder->image->transferCharacteristics == 2 /* AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED */) ||
|
|
||||||
(m_decoder->image->transferCharacteristics == 0 /* AVIF_TRANSFER_CHARACTERISTICS_UNKNOWN */)) {
|
|
||||||
trc_to_load = (avifTransferCharacteristics) 13; // AVIF_TRANSFER_CHARACTERISTICS_SRGB
|
|
||||||
} else {
|
|
||||||
trc_to_load = m_decoder->image->transferCharacteristics;
|
|
||||||
}
|
|
||||||
|
|
||||||
float prim[8]; // outPrimaries: rX, rY, gX, gY, bX, bY, wX, wY
|
float prim[8]; // outPrimaries: rX, rY, gX, gY, bX, bY, wX, wY
|
||||||
avifColorPrimariesGetValues(primaries_to_load, prim);
|
avifColorPrimariesGetValues(m_decoder->image->colorPrimaries, prim);
|
||||||
|
|
||||||
QPointF redPoint(prim[0], prim[1]);
|
QPointF redPoint(prim[0], prim[1]);
|
||||||
QPointF greenPoint(prim[2], prim[3]);
|
QPointF greenPoint(prim[2], prim[3]);
|
||||||
@ -227,7 +210,7 @@ bool QAVIFHandler::decode_one_frame()
|
|||||||
QColorSpace::TransferFunction q_trc = QColorSpace::TransferFunction::Custom;
|
QColorSpace::TransferFunction q_trc = QColorSpace::TransferFunction::Custom;
|
||||||
float q_trc_gamma = 0.0f;
|
float q_trc_gamma = 0.0f;
|
||||||
|
|
||||||
switch (trc_to_load) {
|
switch (m_decoder->image->transferCharacteristics) {
|
||||||
/* AVIF_TRANSFER_CHARACTERISTICS_BT470M */
|
/* AVIF_TRANSFER_CHARACTERISTICS_BT470M */
|
||||||
case 4:
|
case 4:
|
||||||
q_trc = QColorSpace::TransferFunction::Gamma;
|
q_trc = QColorSpace::TransferFunction::Gamma;
|
||||||
@ -243,6 +226,8 @@ bool QAVIFHandler::decode_one_frame()
|
|||||||
q_trc = QColorSpace::TransferFunction::Linear;
|
q_trc = QColorSpace::TransferFunction::Linear;
|
||||||
break;
|
break;
|
||||||
/* AVIF_TRANSFER_CHARACTERISTICS_SRGB */
|
/* AVIF_TRANSFER_CHARACTERISTICS_SRGB */
|
||||||
|
case 0:
|
||||||
|
case 2: /* AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED */
|
||||||
case 13:
|
case 13:
|
||||||
q_trc = QColorSpace::TransferFunction::SRgb;
|
q_trc = QColorSpace::TransferFunction::SRgb;
|
||||||
break;
|
break;
|
||||||
@ -254,9 +239,11 @@ bool QAVIFHandler::decode_one_frame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (q_trc != QColorSpace::TransferFunction::Custom) { //we create new colorspace using Qt
|
if (q_trc != QColorSpace::TransferFunction::Custom) { //we create new colorspace using Qt
|
||||||
switch (primaries_to_load) {
|
switch (m_decoder->image->colorPrimaries) {
|
||||||
/* AVIF_COLOR_PRIMARIES_BT709 */
|
/* AVIF_COLOR_PRIMARIES_BT709 */
|
||||||
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
|
case 2: /* AVIF_COLOR_PRIMARIES_UNSPECIFIED */
|
||||||
result.setColorSpace(QColorSpace(QColorSpace::Primaries::SRgb, q_trc, q_trc_gamma));
|
result.setColorSpace(QColorSpace(QColorSpace::Primaries::SRgb, q_trc, q_trc_gamma));
|
||||||
break;
|
break;
|
||||||
/* AVIF_COLOR_PRIMARIES_SMPTE432 */
|
/* AVIF_COLOR_PRIMARIES_SMPTE432 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user