Add HDR and colorspace fields to DECODE_UNIT

This commit is contained in:
Cameron Gutman 2023-03-11 11:36:21 -06:00
parent 02f12e4448
commit c9426a6a71
2 changed files with 19 additions and 0 deletions

View File

@ -172,6 +172,18 @@ typedef struct _DECODE_UNIT {
// Head of the buffer chain (never NULL)
PLENTRY bufferList;
// Determines if this frame is SDR or HDR
//
// Note: This is not currently parsed from the actual bitstream, so if your
// client has access to a bitstream parser, prefer that over this field.
bool hdrActive;
// Provides the colorspace of this frame (see COLORSPACE_* defines above)
//
// Note: This is not currently parsed from the actual bitstream, so if your
// client has access to a bitstream parser, prefer that over this field.
uint8_t colorspace;
} DECODE_UNIT, *PDECODE_UNIT;
// Specifies that the audio stream should be encoded in stereo (default)

View File

@ -453,6 +453,13 @@ static void reassembleFrame(int frameNumber) {
qdu->decodeUnit.presentationTimeMs = firstPacketPresentationTime;
qdu->decodeUnit.enqueueTimeMs = LiGetMillis();
// These might be wrong for a few frames during a transition between SDR and HDR,
// but the effects shouldn't very noticable since that's an infrequent operation.
//
// If we start sending this state in the frame header, we can make it 100% accurate.
qdu->decodeUnit.hdrActive = LiGetCurrentHostDisplayHdrMode();
qdu->decodeUnit.colorspace = (uint8_t)(qdu->decodeUnit.hdrActive ? COLORSPACE_REC_2020 : StreamConfig.colorSpace);
// IDR frames will have leading CSD buffers
if (nalChainHead->bufferType != BUFFER_TYPE_PICDATA) {
qdu->decodeUnit.frameType = FRAME_TYPE_IDR;