python_vali.PySurfaceConverter

class python_vali.PySurfaceConverter

CUDA-accelerated converter between different pixel formats.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: python_vali._python_vali.PySurfaceConverter, gpu_id: int) -> None

    Constructor for PySurfaceConverter with GPU ID.

    Creates a new instance of PySurfaceConverter that will run on the specified GPU. The CUDA stream will be automatically created and managed.

    param gpu_id:

    The ID of the GPU to use for pixel format conversion

    type gpu_id:

    int

    raises RuntimeError:

    If the specified GPU is not available

  2. __init__(self: python_vali._python_vali.PySurfaceConverter, gpu_id: int, stream: int) -> None

    Constructor for PySurfaceConverter with GPU ID and CUDA stream.

    Creates a new instance of PySurfaceConverter that will run on the specified GPU using the provided CUDA stream.

    param gpu_id:

    The ID of the GPU to use for pixel format conversion

    type gpu_id:

    int

    param stream:

    The CUDA stream to use for conversion

    type stream:

    int

    raises RuntimeError:

    If the specified GPU is not available

Methods

Conversions()

Get list of supported pixel format conversions.

Run(self, src, dst, cc_ctx)

Perform pixel format conversion synchronously.

RunAsync(self, src, dst, cc_ctx)

Perform pixel format conversion asynchronously.

__init__(*args, **kwargs)

Overloaded function.

Attributes

Stream

Get the CUDA stream associated with this instance.

static Conversions() list[tuple[python_vali._python_vali.PixelFormat, python_vali._python_vali.PixelFormat]]

Get list of supported pixel format conversions.

Returns a list of tuples containing supported input and output pixel format pairs that can be processed by the converter.

Returns:

List of tuples containing supported (input_format, output_format) pairs

Return type:

list[tuple[Pixel_Format, Pixel_Format]]

Run(self: python_vali._python_vali.PySurfaceConverter, src: VPF::Surface, dst: VPF::Surface, cc_ctx: Optional[python_vali._python_vali.ColorspaceConversionContext] = None) tuple[bool, python_vali._python_vali.TaskExecInfo]

Perform pixel format conversion synchronously.

Converts the input surface to the specified output format. This method blocks until the conversion is complete. The input surface must be in a format supported by the converter. The output surface must be in a format that can be converted to from the input format.

Parameters:
  • src (Surface) – Input surface to be converted

  • dst (Surface) – Output surface to store the converted result

  • cc_ctx (ColorspaceConversionContext, optional) – Optional colorspace conversion context that describes the color space and color range to use for conversion. If not provided, VALI will automatically select supported color conversion parameters.

Returns:

Tuple containing: - success (bool): True if conversion was successful, False otherwise - info (TaskExecInfo): Detailed execution information

Return type:

tuple[bool, TaskExecInfo]

Raises:

RuntimeError – If the conversion fails or if the formats are not compatible

RunAsync(self: python_vali._python_vali.PySurfaceConverter, src: VPF::Surface, dst: VPF::Surface, cc_ctx: Optional[python_vali._python_vali.ColorspaceConversionContext] = None) tuple[bool, python_vali._python_vali.TaskExecInfo]

Perform pixel format conversion asynchronously.

Converts the input surface to the specified output format. This method returns immediately without waiting for the conversion to complete. The input surface must be in a format supported by the converter. The output surface must be in a format that can be converted to from the input format.

Parameters:
  • src (Surface) – Input surface to be converted

  • dst (Surface) – Output surface to store the converted result

  • cc_ctx (ColorspaceConversionContext, optional) – Optional colorspace conversion context that describes the color space and color range to use for conversion. If not provided, VALI will automatically select supported color conversion parameters.

Returns:

Tuple containing: - success (bool): True if conversion was successful, False otherwise - info (TaskExecInfo): Detailed execution information

Return type:

tuple[bool, TaskExecInfo]

Raises:

RuntimeError – If the conversion fails or if the formats are not compatible

property Stream

Get the CUDA stream associated with this instance.

Returns the handle to the CUDA stream used for conversion processing.

Returns:

CUDA stream handle

Return type:

int