Intel QuickSync support for Windows (#758)

This commit is contained in:
Cameron Gutman
2023-01-14 15:23:49 -06:00
committed by GitHub
parent 5480d3d59d
commit 4fc444b5b3
7 changed files with 322 additions and 37 deletions

View File

@@ -210,6 +210,13 @@ struct hwdevice_t {
*/
virtual void init_hwframes(AVHWFramesContext *frames) {};
/**
* Implementations may make modifications required before context derivation
*/
virtual int prepare_to_derive_context(int hw_device_type) {
return 0;
};
virtual ~hwdevice_t() = default;
};

View File

@@ -406,6 +406,23 @@ public:
frames->initial_pool_size = 1;
}
int prepare_to_derive_context(int hw_device_type) override {
// QuickSync requires our device to be multithread-protected
if(hw_device_type == AV_HWDEVICE_TYPE_QSV) {
multithread_t mt;
auto status = device->QueryInterface(IID_ID3D11Multithread, (void **)&mt);
if(FAILED(status)) {
BOOST_LOG(warning) << "Failed to query ID3D11Multithread interface from device [0x"sv << util::hex(status).to_string_view() << ']';
return -1;
}
mt->SetMultithreadProtected(TRUE);
}
return 0;
}
int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) override {
this->hwframe.reset(frame);
this->frame = frame;