Loading...
Searching...
No Matches

Demosaics a single-channel colour-filter-array frame into RGB. More...

Inheritance diagram for score::gfx::BayerDecoder:
score::gfx::GPUVideoDecoder

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::ImageFormatdecoder
 
Phase phase {}
 
double sampleScale {1.0}
 
- Public Attributes inherited from score::gfx::GPUVideoDecoder
std::vector< Samplersamplers
 
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

Offset of the red site within the 2x2 cell, which is what distinguishes the four CFA orders from one another.

Enumerator
RGGB 

red at (0,0)

GRBG 

red at (1,0)

GBRG 

red at (0,1)

BGGR 

red at (1,1)

Member Function Documentation

◆ exec()

void score::gfx::BayerDecoder::exec ( RenderList ,
QRhiResourceUpdateBatch &  res,
AVFrame &  frame 
)
inlineoverridevirtual

Decode and upload a video frame to the GPU.

Implements score::gfx::GPUVideoDecoder.

◆ init()

std::pair< QShader, QShader > score::gfx::BayerDecoder::init ( RenderList r)
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: