CathodeRetro::Internal::SignalDecoder

This is an internal class used by CathodeRetro::CathodeRetro to take a texture representing a set of composite or S-Video scanlines (the output of SignalGenerator) and decode it back into an RGB image.

If you are using the CathodeRetro::CathodeRetro class, you should not need to use this class directly.

For a description of what this class does, see Decoding A Fake NTSC Signal.

Public Members

Public Methods

(constructor)
                SignalDecoder(
                  IGraphicsDevice *deviceIn, 
                  const SignalProperties &signalPropsIn)
              
Description
Construct a new instance of the Internal::SignalDecoder class.
Parameters
deviceIn

Type: IGraphicsDevice *

Pointer to the graphics device instance that this instance should use for all of its drawing-related functionality. This pointer will be cached so the lifetime of deviceIn must extend past the lifetime of the Internal::SignalDecoder instance being created.

signalPropsIn

Type: const Internal::SignalProperties &

Properties of the signal being decoded (typically the output of the SignalGenerator::SignalProperties method).

SetKnobSettings
                void SetKnobSettings(
                  const TVKnobSettings &settings)
              
Description
Update the TV knob settings used by the decode process.
Parameters
settings

Type: const TVKnobSettings &

The new TV knob settings to use.

CurrentFrameRGBOutput
                const ITexture *CurrentFrameRGBOutput() const
              
Description
Return a pointer to the output of the last call to Decode.
Return Value
Type: const ITexture *

A pointer to rgbTexture, the texture containing the output of the last call to Decode.

Decode
                void Decode(
                  const ITexture *inputSignal, 
                  const ITexture *inputPhases, 
                  const SignalLevels &levels)
              
Description
Decodes a texture of scanline signals (either composite or S-Video), given the per-scanline phase information, and converts it into an RGB image.
Parameters
inputSignal

Type: const ITexture *

Pointer to the input texture containing composite or S-Video scanlines, usually the output from the SignalGenerator::SignalTexture method.

The dimensions of this texture are expected to match the scanlineWidth and scanlineCount values of the signalPropsIn parameter passed to the constructor.

inputPhases

Type: const ITexture *

Pointer to an input texture containing the per-scanline colorburst phase offset values, usually the output from the SignalGenerator::PhasesTexture method.

This texture's width should be 1, and its height should match the scanlineCount value of the signalPropsIn parameter passed to the constructor.

levels

Type: const Internal::SignalLevels &

Information about the various levels of the signal and the amount of temporal artifact reduction we should apply.

OutputTextureWidth
                uint32_t OutputTextureWidth() const
              
Description
Get the width of the decoded RGB texture that Decode will render to.
Return Value
Type: uint32_t

The width of the decoded RGB texture that Decode will render to.

Private Members

Private Structures

CompositeToSVideoConstantData
Description
This structure maps to the constant buffer input to the decoder-composite-to-svideo shader. Refer to its page for documentation of the fields.
SVideoToModulatedChromaConstantData
Description
This structure maps to the constant buffer input to the decoder-svideo-to-modulated-chroma shader. Refer to its page for documentation of the fields.
SVideoToRGBConstantData
Description
This structure maps to the constant buffer input to the decoder-svideo-to-rgb shader. Refer to its page for documentation of the fields.
FilterRGBConstantData
Description
This structure maps to the constant buffer input to the decoder-filter-rgb shader. Refer to its page for documentation of the fields.

Private Methods

CompositeToSVideo
                void CompositeToSVideo(
                  const ITexture *inputSignal, 
                  bool isDoubled)
              
Description

Run the composite-to-S-Video pass, which separates a composite signal into individual luma and chroma signals.

Called by Decode.

Parameters
inputSignal
Type: const ITexture *

The composite texture to separate.

isDoubled

Type: bool

This is set to true if the texture is doubled for temporal aliasing reduction (which changes which textures this pass writes out to to ease GPU bandwidth).

SVideoToRGB
                void SVideoToRGB(
                  const ITexture *sVideoTexture, 
                  const ITexture *inputPhases, 
                  const SignalLevels &levels)
              
Description

Does a QAM demodulation pass on an S-Video signal (with separate luma and chroma signals) to convert it into an RGB texture.

Called by Decode.

Parameters
sVideoTexture

Type: const ITexture *

A texture containing a series of S-Video scanlines (with separate luma and chroma channels) that we are going to demodulate.

inputPhases

Type: const ITexture *

Pointer to an input texture containing the per-scanline colorburst phase offset values, usually the output from the SignalGenerator::PhasesTexture method.

This texture's width should be 1, and its height should match the scanlineCount value of the signalPropsIn parameter passed to the constructor.

levels

Type: const Internal::SignalLevels &

Information about the various levels of the signal and the amount of temporal artifact reduction we should apply.

FilterRGB
                void FilterRGB()
              
Description

Runs the RGB filtering pass, which is a horizontal sharpen or blur filter based on the sharpness value of knobSettings.

Called by Decode.

Private Fields

device
                IGraphicsDevice *device
              
Type
IGraphicsDevice *
Description
Pointer to the graphics device that should be used to create graphics objects and render.
rgbTexture
                std::unique_ptr<IRenderTarget> rgbTexture
              
Type
std::unique_ptr<IRenderTarget>
Description
The RGB texture that holds the output of the entire Decode process.
scratchRGBTexture
                std::unique_ptr<IRenderTarget> scratchRGBTexture
              
Type
std::unique_ptr<IRenderTarget>
Description

A scratch RGB texture used as the output of FilterRGB.

If FilterRGB is called, this pointer is swapped with rgbTexture after running the filter, so that rgbTexture contains the final output.

signalProps
                SignalProperties signalProps
              
Type
Internal::SignalProperties
Description
The signal properties that were given to use in the constructor.
knobSettings
                TVKnobSettings knobSettings
              
Type
TVKnobSettings
Description
The TV knob settings given by the last call to SetKnobSettings.
compositeToSVideoConstantBuffer
                std::unique_ptr<IConstantBuffer> compositeToSVideoConstantBuffer
              
Type
std::unique_ptr<IConstantBuffer>
Description
The constant buffer that is used in CompositeToSVideo as an input to the decoder-composite-to-svideo shader.
decodedSVideoTextureSingle
                std::unique_ptr<IRenderTarget> decodedSVideoTextureSingle
              
Type
std::unique_ptr<IRenderTarget>
Description

The render target output of CompositeToSVideo if temporal aliasing reduction is not in use.

It is an RG texture (R is luma and G is chroma).

decodedSVideoTextureDouble
                std::unique_ptr<IRenderTarget> decodedSVideoTextureDouble
              
Type
std::unique_ptr<IRenderTarget>
Description

The render target output of CompositeToSVideo if temporal aliasing reduction is in use.

It is an RGBA texture: (R, G) is (luma, chroma) for signal 1 and (B, A) is (luma, chroma) for signal 2.

modulatedChromaTextureSingle
                std::unique_ptr<IRenderTarget> modulatedChromaTextureSingle
              
Type
std::unique_ptr<IRenderTarget>
Description

The output of the decoder-svideo-to-modulated-chroma shader used as the first step of SVideoToRGB, if temporal aliasing reduction is not in use.

This is an RG texture, where R and G are the chroma waves per scanline multiplied by the carrier sine wave and its quadrature, as part of the demodulation.

modulatedChromaTextureDouble
                std::unique_ptr<IRenderTarget> modulatedChromaTextureDouble
              
Type
std::unique_ptr<IRenderTarget>
Description

The output of the decoder-svideo-to-modulated-chroma shader used as the first step of SVideoToRGB, if temporal aliasing reduction is in use.

This is an RGBA texture, where R and G are the chroma waves per scanline multiplied by the carrier sine wave and its quadrature, as part of the demodulation. B and A are the same for the second signal.

sVideoToModulatedChromaConstantBuffer
                std::unique_ptr<IConstantBuffer> sVideoToModulatedChromaConstantBuffer
              
Type
std::unique_ptr<IConstantBuffer>
Description
The constant buffer that is used in SVideoToRGB as an input to the decoder-svideo-to-modulated-chroma shader.
sVideoToRGBConstantBuffer
                std::unique_ptr<IConstantBuffer> sVideoToRGBConstantBuffer
              
Type
std::unique_ptr<IConstantBuffer>
Description
The constant buffer that is used in SVideoToRGB as an input to the decoder-svideo-to-rgb shader.
filterRGBConstantBuffer
                std::unique_ptr<IConstantBuffer> filterRGBConstantBuffer
              
Type
std::unique_ptr<IConstantBuffer>
Description
The constant buffer that is used in FilterRGB as an input to the decoder-filter-rgb shader.