// Copyright 2022 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Gamma correction utilities.
uint32_t SharpYuvGammaToLinear(uint16_t v, int bit_depth,
SharpYuvTransferFunctionType transfer_type) { float v_float, linear; if (transfer_type == kSharpYuvTransferFunctionSrgb) { return ToLinearSrgb(v, bit_depth);
}
v_float = (float)v / ((1 << bit_depth) - 1); switch (transfer_type) { case kSharpYuvTransferFunctionBt709: case kSharpYuvTransferFunctionBt601: case kSharpYuvTransferFunctionBt2020_10Bit: case kSharpYuvTransferFunctionBt2020_12Bit:
linear = ToLinear709(v_float); break; case kSharpYuvTransferFunctionBt470M:
linear = ToLinear470M(v_float); break; case kSharpYuvTransferFunctionBt470Bg:
linear = ToLinear470Bg(v_float); break; case kSharpYuvTransferFunctionSmpte240:
linear = ToLinearSmpte240(v_float); break; case kSharpYuvTransferFunctionLinear: return v; case kSharpYuvTransferFunctionLog100:
linear = ToLinearLog100(v_float); break; case kSharpYuvTransferFunctionLog100_Sqrt10:
linear = ToLinearLog100Sqrt10(v_float); break; case kSharpYuvTransferFunctionIec61966:
linear = ToLinearIec61966(v_float); break; case kSharpYuvTransferFunctionBt1361:
linear = ToLinearBt1361(v_float); break; case kSharpYuvTransferFunctionSmpte2084:
linear = ToLinearPq(v_float); break; case kSharpYuvTransferFunctionSmpte428:
linear = ToLinearSmpte428(v_float); break; case kSharpYuvTransferFunctionHlg:
linear = ToLinearHlg(v_float); break; default:
assert(0);
linear = 0; break;
} return (uint32_t)Roundf(linear * ((1 << 16) - 1));
}
uint16_t SharpYuvLinearToGamma(uint32_t v, int bit_depth,
SharpYuvTransferFunctionType transfer_type) { float v_float, linear; if (transfer_type == kSharpYuvTransferFunctionSrgb) { return FromLinearSrgb(v, bit_depth);
}
v_float = (float)v / ((1 << 16) - 1); switch (transfer_type) { case kSharpYuvTransferFunctionBt709: case kSharpYuvTransferFunctionBt601: case kSharpYuvTransferFunctionBt2020_10Bit: case kSharpYuvTransferFunctionBt2020_12Bit:
linear = FromLinear709(v_float); break; case kSharpYuvTransferFunctionBt470M:
linear = FromLinear470M(v_float); break; case kSharpYuvTransferFunctionBt470Bg:
linear = FromLinear470Bg(v_float); break; case kSharpYuvTransferFunctionSmpte240:
linear = FromLinearSmpte240(v_float); break; case kSharpYuvTransferFunctionLinear: return v; case kSharpYuvTransferFunctionLog100:
linear = FromLinearLog100(v_float); break; case kSharpYuvTransferFunctionLog100_Sqrt10:
linear = FromLinearLog100Sqrt10(v_float); break; case kSharpYuvTransferFunctionIec61966:
linear = FromLinearIec61966(v_float); break; case kSharpYuvTransferFunctionBt1361:
linear = FromLinearBt1361(v_float); break; case kSharpYuvTransferFunctionSmpte2084:
linear = FromLinearPq(v_float); break; case kSharpYuvTransferFunctionSmpte428:
linear = FromLinearSmpte428(v_float); break; case kSharpYuvTransferFunctionHlg:
linear = FromLinearHlg(v_float); break; default:
assert(0);
linear = 0; break;
} return (uint16_t)Roundf(linear * ((1 << bit_depth) - 1));
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.