};
std::vector<uint8_t> m_BitstreamHeadersBuffer;
+ std::vector<uint8_t> m_StagingHeadersBuffer;
std::vector<EncodedBitstreamResolvedMetadata> m_spEncodedFrameMetadata;
struct D3D12EncodeCapabilities m_currentEncodeCapabilities = {};
*currentPicParams.pH264PicData,
currentPicParams.pH264PicData->pic_parameter_set_id,
active_seq_parameter_set_id,
- pD3D12Enc->m_BitstreamHeadersBuffer,
- pD3D12Enc->m_BitstreamHeadersBuffer.begin() + writtenSPSBytesCount,
+ pD3D12Enc->m_StagingHeadersBuffer,
+ pD3D12Enc->m_StagingHeadersBuffer.begin(),
writtenPPSBytesCount);
+ std::vector<uint8_t>& active_pps = pH264BitstreamBuilder->get_active_pps();
+ if ( (writtenPPSBytesCount != active_pps.size()) ||
+ memcmp(pD3D12Enc->m_StagingHeadersBuffer.data(), active_pps.data(), writtenPPSBytesCount)) {
+ active_pps = pD3D12Enc->m_StagingHeadersBuffer;
+ pD3D12Enc->m_BitstreamHeadersBuffer.resize(writtenSPSBytesCount + writtenPPSBytesCount);
+ memcpy(&pD3D12Enc->m_BitstreamHeadersBuffer.data()[writtenSPSBytesCount], pD3D12Enc->m_StagingHeadersBuffer.data(), writtenPPSBytesCount);
+ } else {
+ writtenPPSBytesCount = 0;
+ debug_printf("Skipping PPS (same as active PPS) for fenceValue: %" PRIu64 "\n", pD3D12Enc->m_fenceValue);
+ }
+
// Shrink buffer to fit the headers
if (pD3D12Enc->m_BitstreamHeadersBuffer.size() > (writtenPPSBytesCount + writtenSPSBytesCount)) {
pD3D12Enc->m_BitstreamHeadersBuffer.resize(writtenPPSBytesCount + writtenSPSBytesCount);
}
size_t writtenPPSBytesCount = 0;
-
+
pHEVCBitstreamBuilder->build_pps(pHEVCBitstreamBuilder->get_latest_sps(),
currentPicParams.pHEVCPicData->slice_pic_parameter_set_id,
*codecConfigDesc.pHEVCConfig,
*currentPicParams.pHEVCPicData,
- pD3D12Enc->m_BitstreamHeadersBuffer,
- pD3D12Enc->m_BitstreamHeadersBuffer.begin() + writtenSPSBytesCount + writtenVPSBytesCount,
+ pD3D12Enc->m_StagingHeadersBuffer,
+ pD3D12Enc->m_StagingHeadersBuffer.begin(),
writtenPPSBytesCount);
+ std::vector<uint8_t>& active_pps = pHEVCBitstreamBuilder->get_active_pps();
+ if ( (writtenPPSBytesCount != active_pps.size()) ||
+ memcmp(pD3D12Enc->m_StagingHeadersBuffer.data(), active_pps.data(), writtenPPSBytesCount)) {
+ active_pps = pD3D12Enc->m_StagingHeadersBuffer;
+ pD3D12Enc->m_BitstreamHeadersBuffer.resize(writtenSPSBytesCount + writtenVPSBytesCount + writtenPPSBytesCount);
+ memcpy(&pD3D12Enc->m_BitstreamHeadersBuffer.data()[(writtenSPSBytesCount + writtenVPSBytesCount)], pD3D12Enc->m_StagingHeadersBuffer.data(), writtenPPSBytesCount);
+ } else {
+ writtenPPSBytesCount = 0;
+ debug_printf("Skipping PPS (same as active PPS) for fenceValue: %" PRIu64 "\n", pD3D12Enc->m_fenceValue);
+ }
+
// Shrink buffer to fit the headers
if (pD3D12Enc->m_BitstreamHeadersBuffer.size() > (writtenPPSBytesCount + writtenSPSBytesCount + writtenVPSBytesCount)) {
pD3D12Enc->m_BitstreamHeadersBuffer.resize(writtenPPSBytesCount + writtenSPSBytesCount + writtenVPSBytesCount);
void print_pps(const H264_PPS &pps);
void print_sps(const H264_SPS &sps);
- uint32_t m_activeSPSIndex = 0;
- uint32_t m_activePPSIndex = 0;
-
uint32_t get_active_sps_id()
{
return m_activeSPSIndex;
return m_activePPSIndex;
};
+ std::vector<uint8_t>& get_active_pps()
+ {
+ return m_activePPS;
+ };
+
void set_active_sps_id(uint32_t active_sps_id)
{
m_activeSPSIndex = active_sps_id;
private:
d3d12_video_nalu_writer_h264 m_h264Encoder;
+ std::vector<uint8_t> m_activePPS;
+ uint32_t m_activeSPSIndex = 0;
+ uint32_t m_activePPSIndex = 0;
};
#endif
void print_pps(const HevcPicParameterSet& pps);
void print_rps(const HevcSeqParameterSet* sps, UINT stRpsIdx);
- uint32_t m_activeVPSIndex = 0;
- uint32_t m_activeSPSIndex = 0;
- uint32_t m_activePPSIndex = 0;
- HevcVideoParameterSet m_latest_vps = {};
- HevcSeqParameterSet m_latest_sps = {};
- HevcPicParameterSet m_latest_pps = {};
+ std::vector<uint8_t>& get_active_pps()
+ {
+ return m_activePPS;
+ };
HevcVideoParameterSet get_latest_vps()
{
private:
d3d12_video_nalu_writer_hevc m_hevcEncoder;
+ uint32_t m_activeVPSIndex = 0;
+ uint32_t m_activeSPSIndex = 0;
+ uint32_t m_activePPSIndex = 0;
+ HevcVideoParameterSet m_latest_vps = {};
+ HevcSeqParameterSet m_latest_sps = {};
+ HevcPicParameterSet m_latest_pps = {};
+ std::vector<uint8_t> m_activePPS;
void init_profile_tier_level(HEVCProfileTierLevel *ptl, uint8_t HEVCProfileIdc, uint8_t HEVCLevelIdc, bool isHighTier);
};