clip.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:yuuno 作者: Irrational-Encoding-Wizardry 项目源码 文件源码
def extract_plane_r36compat(frame: VideoFrame, planeno: int, *, compat: bool=False) -> Image.Image:
    """
    Extracts the plane using the old VapourSynth API for reading a frame.

    Since we are doing raw memory operations using ctypes, this function has proven to be prone
    to SIGSEGV while developing.

    This code will subseqently be dropped from this codebase when VapourSynth r36 is officially dropped
    with the official release of R39.

    :param frame:   The frame
    :param planeno: The plane number
    :param compat:  Are we dealing with a compat format.
    :return: The extracted image.
    """
    width, height = calculate_size(frame, planeno)
    stride = frame.get_stride(planeno)
    s_plane = height * stride
    buf = (ctypes.c_byte*s_plane).from_address(frame.get_read_ptr(planeno).value)

    if not compat:
        return Image.frombuffer('L', (width, height), buf, "raw", "L", stride, -1)
    else:
        return Image.frombuffer('RGB', (width, height), buf, "raw", "BGRX", stride, -1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号