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;
60 enum struct ChromaFormat :
unsigned
68 enum struct VideoDecoderPresentMode
77 const void *data =
nullptr;
79 int64_t timestamp = 0;
80 bool end_of_stream =
false;
81 bool discontinuity =
false;
82 bool end_of_picture =
false;
83 bool use_timestamp =
false;
88 uint64_t clock_rate = 10000000;
89 uint32_t error_threshold = 100;
91 uint32_t max_display_delay = 2;
94 Codec codec = Codec::H264;
99 VideoDecoderPresentMode present_mode = VideoDecoderPresentMode::Smooth;
100 uint32_t speedup_queue_count = 3;
101 float speedup_factor = 1.0f;
103 bool generateMipMaps =
true;
104 bool skip_discontinuities =
false;
105 bool recordToDisk =
false;
106 std::string recordPath;
107 VideoDecoderCallback* decodeCallback =
nullptr;
108 void* decodeCallbackData =
nullptr;
109 VideoPresentCallback* presentCallback =
nullptr;
110 void* presentCallbackData =
nullptr;
115 int64_t timestamp = -1;
120 Codec codec = Codec::H264;
121 ChromaFormat chroma_format = ChromaFormat::Chroma420;
122 uint32_t bit_depth = 8;
137 Codec getCodec()
const {
return codec; }
138 VideoDecoderPresentMode getPresentMode()
const {
return presentMode; }
139 double getDiscontinuityDuration()
const {
return discontinuityDuration; }
140 uint32_t getSpeedupQueueCount()
const {
return speedupQueueCount; }
141 float getSpeedupFactor()
const {
return speedupFactor; }
142 uint32_t getSurfaceCount()
const {
return surfaceCount; }
143 uint32_t getChromaFormatIdc()
const {
return chromaFormatIdc; }
144 uint32_t getChromaBitDepthMinus8()
const {
return chromaBitDepthMinus8; }
145 uint32_t getLumaBitDepthMinus8()
const {
return lumaBitDepthMinus8; }
146 uint32_t getCodedWidth()
const {
return codedWidth; }
147 uint32_t getCodedHeight()
const {
return codedHeight; }
148 const Rect& getDisplayArea()
const {
return displayArea; }
149 uint32_t getOutputWidth()
const {
return outputWidth; }
150 uint32_t getOutputHeight()
const {
return outputHeight; }
151 ColourSpace getColourSpace()
const {
return colourSpace; }
152 TransferFunction getTransferFunction()
const {
return transferFunction; }
153 float getGamma()
const {
return gamma; }
154 int64_t getClockRate()
const {
return clockRate; }
155 int64_t getPreviousClock()
const {
return previousClock; }
156 int64_t getClockResidual()
const {
return clockResidual; }
157 int64_t getPreviousClockResidual()
const {
return previousClockResidual; }
158 bool getCheckUnderflow()
const {
return checkUnderflow; }
159 int64_t getPresentationTime()
const {
return presentationTime; }
160 int64_t getPreviousPresentationTime()
const {
return previousPresentationTime; }
161 int64_t getPlayTime()
const {
return playTime; }
162 int64_t getPreviousPlayTime()
const {
return previousPlayTime; }
163 uint32_t getBufferUnderflowCounter()
const {
return bufferUnderflowCounter; }
164 uint32_t getBufferUnderflowMajorStutterCounter()
const {
return bufferUnderflowMajorStutterCounter; }
165 uint32_t getBufferOverflowCounter()
const {
return bufferOverflowCounter; }
166 uint32_t getDecoderRestartCounter()
const {
return decoderRestartCounter; }
167 uint32_t getDiscontinuitiesSkippedCounter()
const {
return discontinuitiesSkippedCounter; }
168 const TextureDescription& getTextureDescription()
const {
return textureDesc; }
170 RenderTexture* getRenderTexture()
const {
return renderTexture; }
172 bool& refSkipDiscontinuities() {
return skipDiscontinuities; }
173 uint32_t& refSpeedupQueueCount() {
return speedupQueueCount; }
174 float& refSpeedupFactor() {
return speedupFactor; }
176 bool shouldSkipDiscontinuities()
const {
return skipDiscontinuities; }
178 void setPresentMode(VideoDecoderPresentMode mode) { presentMode = mode; }
182 Codec codec = Codec::None;
183 VideoDecoderPresentMode presentMode = VideoDecoderPresentMode::Latest;
184 bool skipDiscontinuities =
true;
185 bool generateMipMaps =
false;
186 double discontinuityDuration = 0.5;
187 uint32_t surfaceCount = 0;
191 uint32_t speedupQueueCount = 3;
192 float speedupFactor = 1.0f;
194 VideoDecoderCallback* decodeCallback =
nullptr;
195 void* decodeCallbackData =
nullptr;
196 VideoPresentCallback* presentCallback =
nullptr;
197 void* presentCallbackData =
nullptr;
200 uint32_t chromaFormatIdc =
static_cast<uint32_t
>(-1);
201 uint32_t chromaBitDepthMinus8 =
static_cast<uint32_t
>(-1);
202 uint32_t lumaBitDepthMinus8 =
static_cast<uint32_t
>(-1);
203 uint32_t codedWidth =
static_cast<uint32_t
>(-1);
204 uint32_t codedHeight =
static_cast<uint32_t
>(-1);
206 uint32_t outputWidth = 0;
207 uint32_t outputHeight = 0;
208 ColourSpace colourSpace = ColourSpace::BT709Full;
209 TransferFunction transferFunction = TransferFunction::sRGB;
210 float gamma = 1.0f / 2.2f;
212 int64_t clockRate = 0;
213 int64_t previousClock = 0;
214 int64_t clockResidual = 0;
215 int64_t previousClockResidual = 0;
216 bool checkUnderflow =
false;
218 int64_t presentationTime = 0;
219 int64_t previousPresentationTime = 0;
221 int64_t playTime = 0;
222 int64_t previousPlayTime = 0;
225 uint32_t bufferUnderflowCounter = 0;
226 uint32_t bufferUnderflowMajorStutterCounter = 0;
227 uint32_t bufferOverflowCounter = 0;
228 uint32_t decoderRestartCounter = 0;
229 uint32_t discontinuitiesSkippedCounter = 0;
237 virtual void cleanup();
238 virtual int64_t getPresentationTime(
size_t queuePosition) = 0;
241 void createTexture();
242 int selectDisplayFrame(
size_t queueLength);
248 virtual void update() = 0;
264 std::vector<uint8_t> data;
268 payload.data = data.data();
272 using pendingDataMap = std::map<Texture*, std::vector<PendingData>>;
274 pendingDataMap pendingData;
275 Mutex pendingDataMutex;
280template<>
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.