@@ -473,6 +473,10 @@ bool ViewFinderGL::createFragmentShader()
textureUniformSize_ = shaderProgram_.uniformLocation("tex_size");
textureUniformStrideFactor_ = shaderProgram_.uniformLocation("stride_factor");
textureUniformBayerFirstRed_ = shaderProgram_.uniformLocation("tex_bayer_first_red");
+ ccmUniformDataIn_ = shaderProgram_.uniformLocation("ccm");
+ blackLevelUniformDataIn_ = shaderProgram_.uniformLocation("blacklevel");
+ gammaUniformDataIn_ = shaderProgram_.uniformLocation("gamma");
+ contrastUniformDataIn_ = shaderProgram_.uniformLocation("contrast");
/* Create the textures. */
for (std::unique_ptr<QOpenGLTexture> &texture : textures_) {
@@ -542,6 +546,15 @@ void ViewFinderGL::doRender()
/* Stride of the first plane, in pixels. */
unsigned int stridePixels;
+ /* Identity CCM */
+ float ccm[] = {1.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f };
+ QMatrix3x3 qCcmMat(ccm);
+
+ /* Black Level */
+ QVector3D qBlackLevelVec(0.0f, 0.0f, 0.0f);
+
switch (format_) {
case libcamera::formats::NV12:
case libcamera::formats::NV21:
@@ -788,6 +801,18 @@ void ViewFinderGL::doRender()
* the generic stride factor to 1.0.
*/
stridePixels = size_.width();
+
+ /* Colour Correction Matrix */
+ shaderProgram_.setUniformValue(ccmUniformDataIn_, qCcmMat);
+
+ /* Black Level */
+ shaderProgram_.setUniformValue(blackLevelUniformDataIn_, qBlackLevelVec);
+
+ /* Gamma */
+ shaderProgram_.setUniformValue(gammaUniformDataIn_, 1.0f);
+
+ /* Contrast */
+ shaderProgram_.setUniformValue(contrastUniformDataIn_, 1.0f);
break;
default:
@@ -103,5 +103,17 @@ private:
GLuint textureUniformBayerFirstRed_;
QPointF firstRed_;
+ // Represent per-frame CCM as a uniform vector of floats 3 x 3
+ GLint ccmUniformDataIn_;
+
+ // Black Level compensation
+ GLint blackLevelUniformDataIn_;
+
+ // Gamma
+ GLint gammaUniformDataIn_;
+
+ // Contrast
+ GLint contrastUniformDataIn_;
+
QMutex mutex_; /* Prevent concurrent access to image_ */
};
Populate qcam viewfinder_gl to set default Bayer values so that the shaders can be used in their original mode without conditional compilation. Set an identity CCM, identity Black Level and set Gamma and Contrast to 1.0f respectively. Once this change is made we can use the Bayer shaders in their original format in qcam with raw streams. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> --- src/apps/qcam/viewfinder_gl.cpp | 25 +++++++++++++++++++++++++ src/apps/qcam/viewfinder_gl.h | 12 ++++++++++++ 2 files changed, 37 insertions(+)