3#include "Resources/Resources.h"
4#include "Rendering/Common.h"
5#include "Rendering/TextureData.h"
7#include "Foundation/Platform/Threads.h"
8#include "Foundation/Reflection/Name.h"
14 class IGraphicsDevice;
21 enum class TransferFunction : uint32_t {
28 enum class ColourSpace : uint32_t {
40 const unsigned char* spspps;
62 enum struct ChromaFormat :
unsigned
70 enum struct VideoDecoderPresentMode
79 const void *data =
nullptr;
81 int64_t timestamp = 0;
82 bool end_of_stream =
false;
83 bool discontinuity =
false;
84 bool end_of_picture =
false;
85 bool use_timestamp =
false;
90 uint64_t clock_rate = 10000000;
91 uint32_t error_threshold = 100;
93 uint32_t max_display_delay = 2;
96 Codec codec = Codec::H264;
101 VideoDecoderPresentMode present_mode = VideoDecoderPresentMode::Smooth;
102 uint32_t speedup_queue_count = 3;
103 float speedup_factor = 1.0f;
105 bool generateMipMaps =
true;
106 bool skip_discontinuities =
false;
107 bool recordToDisk =
false;
108 std::string recordPath;
109 VideoDecoderCallback* decodeCallback =
nullptr;
110 void* decodeCallbackData =
nullptr;
111 VideoPresentCallback* presentCallback =
nullptr;
112 void* presentCallbackData =
nullptr;
117 int64_t timestamp = -1;
122 Codec codec = Codec::H264;
123 ChromaFormat chroma_format = ChromaFormat::Chroma420;
124 uint32_t bit_depth = 8;
139 Codec getCodec()
const {
return codec; }
140 VideoDecoderPresentMode getPresentMode()
const {
return presentMode; }
141 double getDiscontinuityDuration()
const {
return discontinuityDuration; }
142 uint32_t getSpeedupQueueCount()
const {
return speedupQueueCount; }
143 float getSpeedupFactor()
const {
return speedupFactor; }
144 uint32_t getSurfaceCount()
const {
return surfaceCount; }
145 uint32_t getChromaFormatIdc()
const {
return chromaFormatIdc; }
146 uint32_t getChromaBitDepthMinus8()
const {
return chromaBitDepthMinus8; }
147 uint32_t getLumaBitDepthMinus8()
const {
return lumaBitDepthMinus8; }
148 uint32_t getCodedWidth()
const {
return codedWidth; }
149 uint32_t getCodedHeight()
const {
return codedHeight; }
150 const Rect& getDisplayArea()
const {
return displayArea; }
151 uint32_t getOutputWidth()
const {
return outputWidth; }
152 uint32_t getOutputHeight()
const {
return outputHeight; }
153 ColourSpace getColourSpace()
const {
return colourSpace; }
154 TransferFunction getTransferFunction()
const {
return transferFunction; }
155 float getGamma()
const {
return gamma; }
156 int64_t getClockRate()
const {
return clockRate; }
157 int64_t getPreviousClock()
const {
return previousClock; }
158 int64_t getClockResidual()
const {
return clockResidual; }
159 int64_t getPreviousClockResidual()
const {
return previousClockResidual; }
160 bool getCheckUnderflow()
const {
return checkUnderflow; }
161 int64_t getPresentationTime()
const {
return presentationTime; }
162 int64_t getPreviousPresentationTime()
const {
return previousPresentationTime; }
163 int64_t getPlayTime()
const {
return playTime; }
164 int64_t getPreviousPlayTime()
const {
return previousPlayTime; }
165 uint32_t getBufferUnderflowCounter()
const {
return bufferUnderflowCounter; }
166 uint32_t getBufferUnderflowMajorStutterCounter()
const {
return bufferUnderflowMajorStutterCounter; }
167 uint32_t getBufferOverflowCounter()
const {
return bufferOverflowCounter; }
168 uint32_t getDecoderRestartCounter()
const {
return decoderRestartCounter; }
169 uint32_t getDiscontinuitiesSkippedCounter()
const {
return discontinuitiesSkippedCounter; }
170 const TextureDescription& getTextureDescription()
const {
return textureDesc; }
172 RenderTexture* getRenderTexture()
const {
return renderTexture; }
174 bool& refSkipDiscontinuities() {
return skipDiscontinuities; }
175 uint32_t& refSpeedupQueueCount() {
return speedupQueueCount; }
176 float& refSpeedupFactor() {
return speedupFactor; }
178 bool shouldSkipDiscontinuities()
const {
return skipDiscontinuities; }
180 void setPresentMode(VideoDecoderPresentMode mode) { presentMode = mode; }
184 Codec codec = Codec::None;
185 VideoDecoderPresentMode presentMode = VideoDecoderPresentMode::Latest;
186 bool skipDiscontinuities =
true;
187 bool generateMipMaps =
false;
188 double discontinuityDuration = 0.5;
189 uint32_t surfaceCount = 0;
193 uint32_t speedupQueueCount = 3;
194 float speedupFactor = 1.0f;
196 VideoDecoderCallback* decodeCallback =
nullptr;
197 void* decodeCallbackData =
nullptr;
198 VideoPresentCallback* presentCallback =
nullptr;
199 void* presentCallbackData =
nullptr;
202 uint32_t chromaFormatIdc =
static_cast<uint32_t
>(-1);
203 uint32_t chromaBitDepthMinus8 =
static_cast<uint32_t
>(-1);
204 uint32_t lumaBitDepthMinus8 =
static_cast<uint32_t
>(-1);
205 uint32_t codedWidth =
static_cast<uint32_t
>(-1);
206 uint32_t codedHeight =
static_cast<uint32_t
>(-1);
208 uint32_t outputWidth = 0;
209 uint32_t outputHeight = 0;
210 ColourSpace colourSpace = ColourSpace::BT709Full;
211 TransferFunction transferFunction = TransferFunction::sRGB;
212 float gamma = 1.0f / 2.2f;
214 int64_t clockRate = 0;
215 int64_t previousClock = 0;
216 int64_t clockResidual = 0;
217 int64_t previousClockResidual = 0;
218 bool checkUnderflow =
false;
220 int64_t presentationTime = 0;
221 int64_t previousPresentationTime = 0;
223 int64_t playTime = 0;
224 int64_t previousPlayTime = 0;
227 uint32_t bufferUnderflowCounter = 0;
228 uint32_t bufferUnderflowMajorStutterCounter = 0;
229 uint32_t bufferOverflowCounter = 0;
230 uint32_t decoderRestartCounter = 0;
231 uint32_t discontinuitiesSkippedCounter = 0;
239 virtual void cleanup();
240 virtual int64_t getPresentationTime(
size_t queuePosition) = 0;
243 void createTexture();
244 int selectDisplayFrame(
size_t queueLength);
250 virtual void update() = 0;
266 std::vector<uint8_t> data;
270 payload.data = data.data();
274 using pendingDataMap = std::map<Texture*, std::vector<PendingData>>;
276 pendingDataMap pendingData;
277 Mutex pendingDataMutex;
282template<>
inline Cogs::StringView getName<Cogs::Core::Codec>() {
return "Codec"; }
A Context instance contains all the services, systems and runtime components needed to use Cogs.
std::vector< uint8_t > parameterSets
Cached VPS, SPS, and PPS data.
Provides a weakly referenced view over the contents of a string.
@ sRGB
Value is a color and is subject to gamma correction.
Contains all Cogs related functionality.
static const Handle_t NoHandle
Represents a handle to nothing.