| Message ID | 20251210005354.44726-4-bryan.odonoghue@linaro.org |
|---|---|
| State | Superseded |
| Headers | show |
| Series |
|
| Related | show |
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes: > 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(+) > > diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp > index 1554c94d5..69b7c6e59 100644 > --- a/src/apps/qcam/viewfinder_gl.cpp > +++ b/src/apps/qcam/viewfinder_gl.cpp > @@ -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: > diff --git a/src/apps/qcam/viewfinder_gl.h b/src/apps/qcam/viewfinder_gl.h > index 23c657bcf..c1b2d9d51 100644 > --- a/src/apps/qcam/viewfinder_gl.h > +++ b/src/apps/qcam/viewfinder_gl.h > @@ -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_; /* ... */ style comments (if they are needed at all here). Reviewed-by: Milan Zamazal <mzamazal@redhat.com> > + > QMutex mutex_; /* Prevent concurrent access to image_ */ > };
diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index 1554c94d5..69b7c6e59 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -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: diff --git a/src/apps/qcam/viewfinder_gl.h b/src/apps/qcam/viewfinder_gl.h index 23c657bcf..c1b2d9d51 100644 --- a/src/apps/qcam/viewfinder_gl.h +++ b/src/apps/qcam/viewfinder_gl.h @@ -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(+)