Skip to content

Cleanup CudaDeviceInterface::getCudaContext()Β #924

@scotts

Description

@scotts

The implementation of CudaDeviceInterface::getCudaContext() is unnecessarily confusing:

  1. There is a #if on the FFmpeg version directly inside the implementation to dispatch to different functions.
  2. Outside of the function, we #if on the FFmpeg version to define two different functions.
  3. The only difference between both functions is one parameter to av_hwdevice_ctx_create(), but all of the surrounding code is the same.

What we should do:

  1. Create a single function in FFMPEGCommon that internally does a #if on FFmpeg version, calling av_hwdevice_ctx_create() in the appropriate way for each version.
  2. Remove getFFMPEGContextFromExistingCudaContext(), getFFMPEGContextFromNewCudaContext() and the #if surrounding them.
  3. Call the function defined in 1 directly in getCudaContext() with the logic removed in 2 directly in getCudaContext().

There's two main principles we want to apply here:

  1. Keep FFmpeg version #if out of decoding code as much as possible. We want to abstract it into a function in FFMPEGCommon that decoding code can call.
  2. The minimum code necessary should be inside the FFmpeg version #ifs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorImproves code itself, but does not fix a bug or add new functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions