Demosaics a single-channel colour-filter-array frame into RGB. More...
Detailed Description
Demosaics a single-channel colour-filter-array frame into RGB.
The mosaic arrives as one sample per pixel in an R8 or R16 texture and is expanded by bilinear interpolation: at a site carrying its own colour the sample is kept, and the two missing channels are averaged from the four orthogonal and four diagonal neighbours (or, on a green site, from the two horizontal and two vertical ones).
The CFA order is a constructor parameter rather than a baked assumption: a capture that crops to an odd origin flips the phase, and a wrong phase does not look broken – it looks like a colour cast, which is easy to mistake for white balance.
sampleScale accounts for a mosaic that does not fill its container. Ten bits right-aligned in a 16-bit lane – what V4L2 specifies for SRGGB10 and friends – normalise to 1/64 of full scale and need 65535/1023, exactly as Mono10 does. A producer that instead replicates the high bits down into the low ones already spans the full range and needs 1.0.
Black level, white balance, exposure and the transfer curve are applied after the reconstruction, from the material block rather than baked in – see CaptureAdjustGLSL.hpp. They are per-sensor corrections, not part of turning a mosaic into RGB, and every one of them is the identity by default. Lens shading is still absent.
Public Types | |
| enum class | Phase { RGGB , GRBG , GBRG , BGGR } |
Public Member Functions | |
| BayerDecoder (QRhiTexture::Format fmt, int bytesPerSample, Video::ImageFormat &d, Phase phase, double sampleScale=1.0) | |
| std::pair< QShader, QShader > | init (RenderList &r) override |
| Initialize a GPUVideoDecoder. | |
| void | exec (RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override |
| Decode and upload a video frame to the GPU. | |
Public Member Functions inherited from score::gfx::GPUVideoDecoder | |
| virtual void | release (RenderList &) |
| This method will release all the created samplers and textures. | |
Public Attributes | |
| QRhiTexture::Format | format |
| int | bytesPerSample {} |
| Video::ImageFormat & | decoder |
| Phase | phase {} |
| double | sampleScale {1.0} |
Public Attributes inherited from score::gfx::GPUVideoDecoder | |
| std::vector< Sampler > | samplers |
| bool | hasFrame {} |
| bool | failed {} |
| bool | formatChanged {} |
Static Public Attributes | |
| static const constexpr auto | frag |
Additional Inherited Members | |
Static Public Member Functions inherited from score::gfx::GPUVideoDecoder | |
| static QRhiTextureSubresourceUploadDescription | createTextureUpload (uint8_t *pixels, int w, int h, int bytesPerPixel, int stride) |
| Utility method to create a QRhiTextureSubresourceUploadDescription. | |
| static QString | vertexShader (bool invertY=false) noexcept |
Member Enumeration Documentation
◆ Phase
|
strong |
Member Function Documentation
◆ exec()
|
inlineoverridevirtual |
Decode and upload a video frame to the GPU.
Implements score::gfx::GPUVideoDecoder.
◆ init()
|
inlineoverridevirtual |
Initialize a GPUVideoDecoder.
This method must :
- Create samplers and textures for the video format.
- Create shaders that will render the data put into these textures.
It returns a {vertex, fragment} shader pair.
Implements score::gfx::GPUVideoDecoder.
The documentation for this struct was generated from the following file:
Public Member Functions inherited from