diff options
4 files changed, 17 insertions, 8 deletions
diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc.h b/src/gallium/drivers/d3d12/d3d12_video_enc.h index 2c80acccddb..5a5018227b4 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_enc.h +++ b/src/gallium/drivers/d3d12/d3d12_video_enc.h @@ -133,6 +133,7 @@ enum d3d12_video_encoder_config_dirty_flags d3d12_video_encoder_config_dirty_flag_motion_precision_limit = 0x200, d3d12_video_encoder_config_dirty_flag_sequence_info = 0x400, d3d12_video_encoder_config_dirty_flag_intra_refresh = 0x800, + d3d12_video_encoder_config_dirty_flag_video_header = 0x1000, }; DEFINE_ENUM_FLAG_OPERATORS(d3d12_video_encoder_config_dirty_flags); @@ -280,6 +281,7 @@ struct D3D12EncodeConfiguration struct pipe_h264_enc_seq_param m_encoderCodecSpecificSequenceStateDescH264; struct pipe_h265_enc_seq_param m_encoderCodecSpecificSequenceStateDescH265; + struct pipe_h265_enc_vid_param m_encoderCodecSpecificVideoStateDescH265; }; struct EncodedBitstreamResolvedMetadata diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp b/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp index ef105f95efe..375c1a54b5e 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_enc_hevc.cpp @@ -779,6 +779,14 @@ d3d12_video_encoder_update_current_encoder_config_state_hevc(struct d3d12_video_ } pD3D12Enc->m_currentEncodeConfig.m_encoderCodecDesc = D3D12_VIDEO_ENCODER_CODEC_HEVC; + // Set VPS information + if (memcmp(&pD3D12Enc->m_currentEncodeConfig.m_encoderCodecSpecificVideoStateDescH265, + &hevcPic->vid, + sizeof(hevcPic->vid)) != 0) { + pD3D12Enc->m_currentEncodeConfig.m_ConfigDirtyFlags |= d3d12_video_encoder_config_dirty_flag_video_header; + } + pD3D12Enc->m_currentEncodeConfig.m_encoderCodecSpecificVideoStateDescH265 = hevcPic->vid; + // Set Sequence information if (memcmp(&pD3D12Enc->m_currentEncodeConfig.m_encoderCodecSpecificSequenceStateDescH265, &hevcPic->seq, @@ -1031,7 +1039,6 @@ d3d12_video_encoder_build_codec_headers_hevc(struct d3d12_video_encoder *pD3D12E auto profDesc = d3d12_video_encoder_get_current_profile_desc(pD3D12Enc); auto levelDesc = d3d12_video_encoder_get_current_level_desc(pD3D12Enc); auto codecConfigDesc = d3d12_video_encoder_get_current_codec_config_desc(pD3D12Enc); - auto MaxDPBCapacity = d3d12_video_encoder_get_current_max_dpb_capacity(pD3D12Enc); pWrittenCodecUnitsSizes.clear(); bool isFirstFrame = (pD3D12Enc->m_fenceValue == 1); @@ -1048,10 +1055,10 @@ d3d12_video_encoder_build_codec_headers_hevc(struct d3d12_video_encoder *pD3D12E size_t writtenVPSBytesCount = 0; if (writeNewVPS) { bool gopHasBFrames = (pD3D12Enc->m_currentEncodeConfig.m_encoderGOPConfigDesc.m_HEVCGroupOfPictures.PPicturePeriod > 1); - HevcVideoParameterSet vps = pHEVCBitstreamBuilder->build_vps(*profDesc.pHEVCProfile, + HevcVideoParameterSet vps = pHEVCBitstreamBuilder->build_vps(pD3D12Enc->m_currentEncodeConfig.m_encoderCodecSpecificVideoStateDescH265, + *profDesc.pHEVCProfile, *levelDesc.pHEVCLevelSetting, pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.Format, - MaxDPBCapacity, // max_num_ref_frames gopHasBFrames, active_video_parameter_set_id, pD3D12Enc->m_BitstreamHeadersBuffer, diff --git a/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.cpp b/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.cpp index 10bb7cd112d..fdaa6ecb641 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.cpp @@ -298,10 +298,10 @@ d3d12_video_encoder_convert_pixel_size_hevc_to_12tusize(const uint32_t& TUSize) } HevcVideoParameterSet -d3d12_video_bitstream_builder_hevc::build_vps(const D3D12_VIDEO_ENCODER_PROFILE_HEVC& profile, +d3d12_video_bitstream_builder_hevc::build_vps(const struct pipe_h265_enc_vid_param & vidData, + const D3D12_VIDEO_ENCODER_PROFILE_HEVC& profile, const D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC& level, const DXGI_FORMAT inputFmt, - uint8_t maxRefFrames, bool gopHasBFrames, uint8_t vps_video_parameter_set_id, std::vector<BYTE> &headerBitstream, @@ -334,7 +334,7 @@ d3d12_video_bitstream_builder_hevc::build_vps(const D3D12_VIDEO_ENCODER_PROFILE_ init_profile_tier_level(&m_latest_vps.ptl, HEVCProfileIdc, HEVCLevelIdc, isHighTier); m_latest_vps.vps_sub_layer_ordering_info_present_flag = 0u; for (int i = (m_latest_vps.vps_sub_layer_ordering_info_present_flag ? 0 : m_latest_vps.vps_max_sub_layers_minus1); i <= m_latest_vps.vps_max_sub_layers_minus1; i++) { - m_latest_vps.vps_max_dec_pic_buffering_minus1[i] = (maxRefFrames/*previous reference frames*/ + 1 /*additional current frame recon pic*/) - 1/**minus1 for header*/; + m_latest_vps.vps_max_dec_pic_buffering_minus1[i] = vidData.vps_max_dec_pic_buffering_minus1[i]; m_latest_vps.vps_max_num_reorder_pics[i] = gopHasBFrames ? m_latest_vps.vps_max_dec_pic_buffering_minus1[i] : 0; m_latest_vps.vps_max_latency_increase_plus1[i] = 0; // When vps_max_latency_increase_plus1[ i ] is equal to 0, no corresponding limit is expressed. } diff --git a/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.h b/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.h index 9c5757929e0..601dca31b08 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.h +++ b/src/gallium/drivers/d3d12/d3d12_video_encoder_bitstream_builder_hevc.h @@ -34,10 +34,10 @@ class d3d12_video_bitstream_builder_hevc : public d3d12_video_bitstream_builder_ d3d12_video_bitstream_builder_hevc() {}; ~d3d12_video_bitstream_builder_hevc() {}; - HevcVideoParameterSet build_vps(const D3D12_VIDEO_ENCODER_PROFILE_HEVC& profile, + HevcVideoParameterSet build_vps(const struct pipe_h265_enc_vid_param & vidData, + const D3D12_VIDEO_ENCODER_PROFILE_HEVC& profile, const D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC& level, const DXGI_FORMAT inputFmt, - uint8_t maxRefFrames, bool gopHasBFrames, uint8_t vps_video_parameter_set_id, std::vector<BYTE> &headerBitstream, |