# Path: cuburn/render.py
# class DurationEvent(cuda.Event):
# class Framebuffers(object):
# class DevSrc(object):
# class DevInfo(object):
# class Renderer(object):
# class RenderManager(ClsMod):
#     def __init__(self, prior):
#     def time(self):
#     def calc_dim(cls, width, height):
#     def __init__(self):
#     def _clear(self):
#     def free(self, stream=None):
#     def alloc(self, dim, stream=None):
#     def set_dim(self, width, height, stream=None):
#     def flip(self):
#     def flip_side(self):
#     def __init__(self):
#     def __init__(self):
#     def compile(cls, gnm, arch=None, keep=False):
#     def load(self, cubin):
#     def __init__(self, gnm, gprof, keep=False, arch=None):
#     def __init__(self):
#     def _copy(self, rdr, gnm):
#     def _interp(self, rdr, gnm, dim, ts, td):
#     def _print_interp_knots(self, rdr, tsidx=5):
#     def _iter(self, rdr, gnm, gprof, dim, tc):
#     def queue_frame(self, rdr, gnm, gprof, tc, copy=True):
#     MAX_MODREFS = 20
# 
# Path: cuburn/output.py
# def launchC(name, mod, stream, dim, fb, *args):
#     launch(name, mod, stream,
#             (32, 8, 1), (int(np.ceil(dim.w/32.)), int(np.ceil(dim.h/8.))),
#             fb.d_back, fb.d_front,
#             i32(fb.gutter), i32(dim.w), i32(dim.astride), i32(dim.h),
#             *args)
# 
# Path: cuburn/code/output.py

# 
# Path: cuburn/code/util.py
# def argset(obj, **kwargs):
# def launch(name, mod, stream, block, grid, *args, **kwargs):
# def launch2(name, mod, stream, dim, *args, **kwargs):
# def mktref(mod, n):
# def crep(s):
# def devlib(deps=(), headers='', decls='', defs=''):
# def assemble_code(*libs):
#     def go(lib):
# def compile(name, src, opts=DEFAULT_CMP_OPTIONS, save=DEFAULT_SAVE_KERNEL,
#             arch=None, keep=False):
#     def __init__(self):
#     def load(cls, name=None):
# def mkbinsearchlib(rounds):
# def fill_dptr(mod, dptr, size, stream=None, value=np.uint32(0)):
# def mkringbuflib(rb_size):
# class Template(tempita.Template):
# class ClsMod(object):
# DEFAULT_CMP_OPTIONS = ('-use_fast_math', '-lineinfo', '-ccbin', 'clang')
# DEFAULT_SAVE_KERNEL = True
# DEFAULT_SEARCH_ROUNDS = 5
# DEFAULT_RB_SIZE = 1024


import argparse
import unittest
import numpy as np
import pycuda.driver as cuda
import pycuda.autoinit
from cuburn import render
from cuburn.output import launchC
from cuburn.code import output
from cuburn.code import util
                self.fb.d_rb, self.fb.d_seeds)

        outs = np.empty((3, self.dim.h, self.dim.w), dtype='u1')
        cuda.memcpy_dtoh(outs, self.fb.d_back)
        self.assertTrue(np.all(outs[0] == 0))
        self.assertTrue(np.all(outs[1] >= 127))
        self.assertTrue(np.all(outs[1] <= 128))
        self.assertTrue(np.all(outs[2] >= 127))
        self.assertTrue(np.all(outs[2] <= 128))

    def test_clamping_above_1(self):
        ins = np.empty((self.dim.ah, self.dim.astride, 4), dtype='f4')
        ins[:] = 5
        cuda.memcpy_htod(self.fb.d_front, ins)

        launchC('f32_to_yuv444p', self.mod, None, self.dim, self.fb,
                self.fb.d_rb, self.fb.d_seeds)

        outs = np.empty((3, self.dim.h, self.dim.w), dtype='u1')
        cuda.memcpy_dtoh(outs, self.fb.d_back)
        self.assertTrue(np.all(outs[0] == 255))
        self.assertTrue(np.all(outs[1] >= 127))
        self.assertTrue(np.all(outs[1] <= 128))
        self.assertTrue(np.all(outs[2] >= 127))
        self.assertTrue(np.all(outs[2] <= 128))

    def test_yuv444p10_zero_passthru(self):
        ins = np.zeros((self.dim.ah, self.dim.astride, 4), dtype='f4')
        cuda.memcpy_htod(self.fb.d_front, ins)


# Path: cuburn/render.py
# class DurationEvent(cuda.Event):
# class Framebuffers(object):
# class DevSrc(object):
# class DevInfo(object):
# class Renderer(object):
# class RenderManager(ClsMod):
#     def __init__(self, prior):
#     def time(self):
#     def calc_dim(cls, width, height):
#     def __init__(self):
#     def _clear(self):
#     def free(self, stream=None):
#     def alloc(self, dim, stream=None):
#     def set_dim(self, width, height, stream=None):
#     def flip(self):
#     def flip_side(self):
#     def __init__(self):
#     def __init__(self):
#     def compile(cls, gnm, arch=None, keep=False):
#     def load(self, cubin):
#     def __init__(self, gnm, gprof, keep=False, arch=None):
#     def __init__(self):
#     def _copy(self, rdr, gnm):
#     def _interp(self, rdr, gnm, dim, ts, td):
#     def _print_interp_knots(self, rdr, tsidx=5):
#     def _iter(self, rdr, gnm, gprof, dim, tc):
#     def queue_frame(self, rdr, gnm, gprof, tc, copy=True):
#     MAX_MODREFS = 20
# 
# Path: cuburn/output.py
# def launchC(name, mod, stream, dim, fb, *args):
#     launch(name, mod, stream,
#             (32, 8, 1), (int(np.ceil(dim.w/32.)), int(np.ceil(dim.h/8.))),
#             fb.d_back, fb.d_front,
#             i32(fb.gutter), i32(dim.w), i32(dim.astride), i32(dim.h),
#             *args)
# 
# Path: cuburn/code/output.py

# 
# Path: cuburn/code/util.py
# def argset(obj, **kwargs):
# def launch(name, mod, stream, block, grid, *args, **kwargs):
# def launch2(name, mod, stream, dim, *args, **kwargs):
# def mktref(mod, n):
# def crep(s):
# def devlib(deps=(), headers='', decls='', defs=''):
# def assemble_code(*libs):
#     def go(lib):
# def compile(name, src, opts=DEFAULT_CMP_OPTIONS, save=DEFAULT_SAVE_KERNEL,
#             arch=None, keep=False):
#     def __init__(self):
#     def load(cls, name=None):
# def mkbinsearchlib(rounds):
# def fill_dptr(mod, dptr, size, stream=None, value=np.uint32(0)):
# def mkringbuflib(rb_size):
# class Template(tempita.Template):
# class ClsMod(object):
# DEFAULT_CMP_OPTIONS = ('-use_fast_math', '-lineinfo', '-ccbin', 'clang')
# DEFAULT_SAVE_KERNEL = True
# DEFAULT_SEARCH_ROUNDS = 5
# DEFAULT_RB_SIZE = 1024


# Path: cuburn/code/tests/test_output.py
import argparse
import unittest
import numpy as np
import pycuda.driver as cuda
import pycuda.autoinit
from cuburn import render
from cuburn.output import launchC
from cuburn.code import output
from cuburn.code import util

                self.fb.d_rb, self.fb.d_seeds)

        outs = np.empty((3, self.dim.h, self.dim.w), dtype='u1')
        cuda.memcpy_dtoh(outs, self.fb.d_back)
        self.assertTrue(np.all(outs[0] == 0))
        self.assertTrue(np.all(outs[1] >= 127))
        self.assertTrue(np.all(outs[1] <= 128))
        self.assertTrue(np.all(outs[2] >= 127))
        self.assertTrue(np.all(outs[2] <= 128))

    def test_clamping_above_1(self):
        ins = np.empty((self.dim.ah, self.dim.astride, 4), dtype='f4')
        ins[:] = 5
        cuda.memcpy_htod(self.fb.d_front, ins)

        launchC('f32_to_yuv444p', self.mod, None, self.dim, self.fb,
                self.fb.d_rb, self.fb.d_seeds)

        outs = np.empty((3, self.dim.h, self.dim.w), dtype='u1')
        cuda.memcpy_dtoh(outs, self.fb.d_back)
        self.assertTrue(np.all(outs[0] == 255))
        self.assertTrue(np.all(outs[1] >= 127))
        self.assertTrue(np.all(outs[1] <= 128))
        self.assertTrue(np.all(outs[2] >= 127))
        self.assertTrue(np.all(outs[2] <= 128))

    def test_yuv444p10_zero_passthru(self):
        ins = np.zeros((self.dim.ah, self.dim.astride, 4), dtype='f4')
        cuda.memcpy_htod(self.fb.d_front, ins)


        launchC('f32_to_yuv444p10', self.mod, None, self.dim, self.fb,