MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / dxgi_init_avcodec_hardware_input_buffer

Function dxgi_init_avcodec_hardware_input_buffer

src/video.cpp:2950–2974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2948
2949namespace video {
2950 util::Either<avcodec_buffer_t, int> dxgi_init_avcodec_hardware_input_buffer(platf::avcodec_encode_device_t *encode_device) {
2951 avcodec_buffer_t ctx_buf {av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_D3D11VA)};
2952 auto ctx = (AVD3D11VADeviceContext *) ((AVHWDeviceContext *) ctx_buf->data)->hwctx;
2953
2954 std::fill_n((std::uint8_t *) ctx, sizeof(AVD3D11VADeviceContext), 0);
2955
2956 auto device = (ID3D11Device *) encode_device->data;
2957
2958 device->AddRef();
2959 ctx->device = device;
2960
2961 ctx->lock_ctx = (void *) 1;
2962 ctx->lock = do_nothing;
2963 ctx->unlock = do_nothing;
2964
2965 auto err = av_hwdevice_ctx_init(ctx_buf.get());
2966 if (err) {
2967 char err_str[AV_ERROR_MAX_STRING_SIZE] {0};
2968 BOOST_LOG(error) << "Failed to create FFMpeg hardware device context: "sv << av_make_error_string(err_str, AV_ERROR_MAX_STRING_SIZE, err);
2969
2970 return err;
2971 }
2972
2973 return ctx_buf;
2974 }
2975#endif
2976
2977 int start_capture_async(capture_thread_async_ctx_t &capture_thread_ctx) {

Callers

nothing calls this directly

Calls 2

AddRefMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected