Generated by Cython 0.27.3
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: encoder.c
0001: # This file is part of Xpra.
0002: # Copyright (C) 2013-2017 Antoine Martin <antoine@devloop.org.uk>
0003: # Xpra is released under the terms of the GNU GPL v2, or, at your option, any
0004: # later version. See the file COPYING for details.
0005:
0006: #cython: auto_pickle=False, cdivision=True
0007: from __future__ import absolute_import
0008:
+0009: import binascii
__pyx_t_2 = __Pyx_Import(__pyx_n_s_binascii, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_binascii, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0010: import os
__pyx_t_2 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0011: import sys
__pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0012: import numpy
__pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0013: import array
__pyx_t_2 = __Pyx_Import(__pyx_n_s_array, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0014: from collections import deque
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_deque); __Pyx_GIVEREF(__pyx_n_s_deque); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_deque); __pyx_t_3 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_deque); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_deque, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0015:
+0016: from pycuda import driver
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_driver); __Pyx_GIVEREF(__pyx_n_s_driver); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_driver); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pycuda, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_driver); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_driver, __pyx_t_3) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0017:
+0018: from xpra.os_util import WIN32, OSX, LINUX, PYTHON3, bytestostr
__pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_WIN32); __Pyx_GIVEREF(__pyx_n_s_WIN32); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_WIN32); __Pyx_INCREF(__pyx_n_s_OSX); __Pyx_GIVEREF(__pyx_n_s_OSX); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_OSX); __Pyx_INCREF(__pyx_n_s_LINUX); __Pyx_GIVEREF(__pyx_n_s_LINUX); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_LINUX); __Pyx_INCREF(__pyx_n_s_PYTHON3); __Pyx_GIVEREF(__pyx_n_s_PYTHON3); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_PYTHON3); __Pyx_INCREF(__pyx_n_s_bytestostr); __Pyx_GIVEREF(__pyx_n_s_bytestostr); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_bytestostr); __pyx_t_3 = __Pyx_Import(__pyx_n_s_xpra_os_util, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_WIN32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_WIN32, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_OSX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_OSX, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_LINUX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_LINUX, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PYTHON3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PYTHON3, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_bytestostr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_bytestostr, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0019: from xpra.util import AtomicInteger, engs, csv, pver, envint, envbool
__pyx_t_3 = PyList_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_AtomicInteger); __Pyx_GIVEREF(__pyx_n_s_AtomicInteger); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_AtomicInteger); __Pyx_INCREF(__pyx_n_s_engs); __Pyx_GIVEREF(__pyx_n_s_engs); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_engs); __Pyx_INCREF(__pyx_n_s_csv); __Pyx_GIVEREF(__pyx_n_s_csv); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_csv); __Pyx_INCREF(__pyx_n_s_pver); __Pyx_GIVEREF(__pyx_n_s_pver); PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_pver); __Pyx_INCREF(__pyx_n_s_envint); __Pyx_GIVEREF(__pyx_n_s_envint); PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_envint); __Pyx_INCREF(__pyx_n_s_envbool); __Pyx_GIVEREF(__pyx_n_s_envbool); PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_envbool); __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_util, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_AtomicInteger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_AtomicInteger, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_engs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_engs, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_csv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_csv, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pver); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pver, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_envint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_envint, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_envbool); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_envbool, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0020: from xpra.codecs.cuda_common.cuda_context import init_all_devices, get_devices, select_device, \
__pyx_t_2 = PyList_New(11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_init_all_devices); __Pyx_GIVEREF(__pyx_n_s_init_all_devices); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_init_all_devices); __Pyx_INCREF(__pyx_n_s_get_devices); __Pyx_GIVEREF(__pyx_n_s_get_devices); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_get_devices); __Pyx_INCREF(__pyx_n_s_select_device); __Pyx_GIVEREF(__pyx_n_s_select_device); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_select_device); __Pyx_INCREF(__pyx_n_s_get_cuda_info); __Pyx_GIVEREF(__pyx_n_s_get_cuda_info); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_get_cuda_info); __Pyx_INCREF(__pyx_n_s_get_pycuda_info); __Pyx_GIVEREF(__pyx_n_s_get_pycuda_info); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_get_pycuda_info); __Pyx_INCREF(__pyx_n_s_device_info); __Pyx_GIVEREF(__pyx_n_s_device_info); PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_device_info); __Pyx_INCREF(__pyx_n_s_reset_state); __Pyx_GIVEREF(__pyx_n_s_reset_state); PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_reset_state); __Pyx_INCREF(__pyx_n_s_get_CUDA_function); __Pyx_GIVEREF(__pyx_n_s_get_CUDA_function); PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_get_CUDA_function); __Pyx_INCREF(__pyx_n_s_record_device_failure); __Pyx_GIVEREF(__pyx_n_s_record_device_failure); PyList_SET_ITEM(__pyx_t_2, 8, __pyx_n_s_record_device_failure); __Pyx_INCREF(__pyx_n_s_record_device_success); __Pyx_GIVEREF(__pyx_n_s_record_device_success); PyList_SET_ITEM(__pyx_t_2, 9, __pyx_n_s_record_device_success); __Pyx_INCREF(__pyx_n_s_CUDA_ERRORS_INFO); __Pyx_GIVEREF(__pyx_n_s_CUDA_ERRORS_INFO); PyList_SET_ITEM(__pyx_t_2, 10, __pyx_n_s_CUDA_ERRORS_INFO); __pyx_t_3 = __Pyx_Import(__pyx_n_s_xpra_codecs_cuda_common_cuda_con, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_init_all_devices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_all_devices, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_get_devices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_devices, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_select_device); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_select_device, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_get_cuda_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_cuda_info, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_get_pycuda_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_pycuda_info, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_device_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_device_info, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_reset_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reset_state, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_get_CUDA_function); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_CUDA_function, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_record_device_failure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_record_device_failure, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_record_device_success); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_record_device_success, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_CUDA_ERRORS_INFO); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUDA_ERRORS_INFO, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0021: get_cuda_info, get_pycuda_info, device_info, reset_state, \
0022: get_CUDA_function, record_device_failure, record_device_success, CUDA_ERRORS_INFO
+0023: from xpra.codecs.codec_constants import video_spec, TransientCodecException
__pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_video_spec); __Pyx_GIVEREF(__pyx_n_s_video_spec); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_video_spec); __Pyx_INCREF(__pyx_n_s_TransientCodecException); __Pyx_GIVEREF(__pyx_n_s_TransientCodecException); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_TransientCodecException); __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_codecs_codec_constants, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_video_spec); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_video_spec, __pyx_t_3) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_TransientCodecException); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_TransientCodecException, __pyx_t_3) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0024: from xpra.codecs.image_wrapper import ImageWrapper
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_ImageWrapper); __Pyx_GIVEREF(__pyx_n_s_ImageWrapper); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ImageWrapper); __pyx_t_3 = __Pyx_Import(__pyx_n_s_xpra_codecs_image_wrapper, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ImageWrapper); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ImageWrapper, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0025: from xpra.codecs.nv_util import get_nvidia_module_version, get_license_keys, validate_driver_yuv444lossless, get_cards
__pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_get_nvidia_module_version); __Pyx_GIVEREF(__pyx_n_s_get_nvidia_module_version); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_get_nvidia_module_version); __Pyx_INCREF(__pyx_n_s_get_license_keys); __Pyx_GIVEREF(__pyx_n_s_get_license_keys); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_get_license_keys); __Pyx_INCREF(__pyx_n_s_validate_driver_yuv444lossless); __Pyx_GIVEREF(__pyx_n_s_validate_driver_yuv444lossless); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_validate_driver_yuv444lossless); __Pyx_INCREF(__pyx_n_s_get_cards); __Pyx_GIVEREF(__pyx_n_s_get_cards); PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_get_cards); __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_codecs_nv_util, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_nvidia_module_version); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_nvidia_module_version, __pyx_t_3) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_license_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_license_keys, __pyx_t_3) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_validate_driver_yuv444lossless); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_driver_yuv444lossless, __pyx_t_3) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_cards); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_cards, __pyx_t_3) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0026:
+0027: from xpra.log import Logger
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Logger); __Pyx_GIVEREF(__pyx_n_s_Logger); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Logger); __pyx_t_3 = __Pyx_Import(__pyx_n_s_xpra_log, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0028: log = Logger("encoder", "nvenc")
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__45 = PyTuple_Pack(2, __pyx_n_s_encoder, __pyx_n_s_nvenc); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__45); __Pyx_GIVEREF(__pyx_tuple__45);
0029:
+0030: import ctypes
__pyx_t_2 = __Pyx_Import(__pyx_n_s_ctypes, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ctypes, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0031: from ctypes import cdll as loader, POINTER
__pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_cdll); __Pyx_GIVEREF(__pyx_n_s_cdll); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_cdll); __Pyx_INCREF(__pyx_n_s_POINTER); __Pyx_GIVEREF(__pyx_n_s_POINTER); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_POINTER); __pyx_t_3 = __Pyx_Import(__pyx_n_s_ctypes, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_cdll); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_loader, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_POINTER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_POINTER, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0032:
0033: from libc.stdint cimport uintptr_t, uint8_t, uint16_t, uint32_t, int32_t, uint64_t
0034: from xpra.monotonic_time cimport monotonic_time
0035:
+0036: CLIENT_KEYS_STR = get_license_keys(NVENCAPI_MAJOR_VERSION) + get_license_keys()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_license_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(NVENCAPI_MAJOR_VERSION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_license_keys); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CLIENT_KEYS_STR, __pyx_t_6) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0037: DESIRED_PRESET = os.environ.get("XPRA_NVENC_PRESET", "")
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_environ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_DESIRED_PRESET, __pyx_t_2) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__46 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_PRESET, __pyx_kp_s__18); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46);
0038: #NVENC requires compute capability value 0x30 or above:
+0039: cdef int MIN_COMPUTE = 0x30
__pyx_v_4xpra_6codecs_5nvenc_7encoder_MIN_COMPUTE = 0x30;
0040:
+0041: cdef int YUV444_THRESHOLD = envint("XPRA_NVENC_YUV444_THRESHOLD", 85)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_envint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_THRESHOLD = __pyx_t_7; /* … */ __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_YUV444_THRESHOLD, __pyx_int_85); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__47); __Pyx_GIVEREF(__pyx_tuple__47);
+0042: cdef int LOSSLESS_THRESHOLD = envint("XPRA_NVENC_LOSSLESS_THRESHOLD", 100)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_envint); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_THRESHOLD = __pyx_t_7; /* … */ __pyx_tuple__48 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_LOSSLESS_THRESHOLD, __pyx_int_100); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__48); __Pyx_GIVEREF(__pyx_tuple__48);
+0043: cdef int NATIVE_RGB = envbool("XPRA_NVENC_NATIVE_RGB", not WIN32)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_WIN32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyBool_FromLong((!__pyx_t_8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_n_s_XPRA_NVENC_NATIVE_RGB, __pyx_t_3}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_n_s_XPRA_NVENC_NATIVE_RGB, __pyx_t_3}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_n_s_XPRA_NVENC_NATIVE_RGB); __Pyx_GIVEREF(__pyx_n_s_XPRA_NVENC_NATIVE_RGB); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_n_s_XPRA_NVENC_NATIVE_RGB); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_NATIVE_RGB = __pyx_t_7;
+0044: cdef int LOSSLESS_ENABLED = envbool("XPRA_NVENC_LOSSLESS", True)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED = __pyx_t_7; /* … */ __pyx_tuple__49 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_LOSSLESS, Py_True); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__49); __Pyx_GIVEREF(__pyx_tuple__49);
+0045: cdef int YUV420_ENABLED = envbool("XPRA_NVENC_YUV420P", True)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV420_ENABLED = __pyx_t_7; /* … */ __pyx_tuple__50 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_YUV420P, Py_True); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__50); __Pyx_GIVEREF(__pyx_tuple__50);
+0046: cdef int YUV444_ENABLED = envbool("XPRA_NVENC_YUV444P", True)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED = __pyx_t_7; /* … */ __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_YUV444P, Py_True); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__51); __Pyx_GIVEREF(__pyx_tuple__51);
+0047: cdef int DEBUG_API = envbool("XPRA_NVENC_DEBUG_API", False)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API = __pyx_t_7; /* … */ __pyx_tuple__52 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_DEBUG_API, Py_False); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__52); __Pyx_GIVEREF(__pyx_tuple__52);
0048:
+0049: cdef int QP_MAX_VALUE = 51 #newer versions of ffmpeg can decode up to 63
__pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE = 51;
0050:
+0051: YUV444_CODEC_SUPPORT = {}
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_YUV444_CODEC_SUPPORT, __pyx_t_2) < 0) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0052: LOSSLESS_CODEC_SUPPORT = {}
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_LOSSLESS_CODEC_SUPPORT, __pyx_t_2) < 0) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0053:
0054:
+0055: cdef inline int MIN(int a, int b):
static CYTHON_INLINE int __pyx_f_4xpra_6codecs_5nvenc_7encoder_MIN(int __pyx_v_a, int __pyx_v_b) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("MIN", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0056: if a<=b:
__pyx_t_1 = ((__pyx_v_a <= __pyx_v_b) != 0); if (__pyx_t_1) { /* … */ }
+0057: return a
__pyx_r = __pyx_v_a; goto __pyx_L0;
+0058: return b
__pyx_r = __pyx_v_b; goto __pyx_L0;
+0059: cdef inline int MAX(int a, int b):
static CYTHON_INLINE int __pyx_f_4xpra_6codecs_5nvenc_7encoder_MAX(int __pyx_v_a, int __pyx_v_b) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("MAX", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0060: if a>=b:
__pyx_t_1 = ((__pyx_v_a >= __pyx_v_b) != 0); if (__pyx_t_1) { /* … */ }
+0061: return a
__pyx_r = __pyx_v_a; goto __pyx_L0;
+0062: return b
__pyx_r = __pyx_v_b; goto __pyx_L0;
0063:
0064:
0065: cdef extern from "string.h":
0066: void* memset(void * ptr, int value, size_t num)
0067: void* memcpy(void * destination, void * source, size_t num)
0068:
0069: cdef extern from "stdlib.h":
0070: void* malloc(size_t __size)
0071: void free(void* mem)
0072:
0073:
+0074: CUresult = ctypes.c_int
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_c_int); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUresult, __pyx_t_6) < 0) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0075: CUcontext = ctypes.c_void_p
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CUcontext, __pyx_t_2) < 0) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0076:
0077:
0078: cdef extern from "nvEncodeAPI.h":
0079: ctypedef int NVENCSTATUS
0080: ctypedef void* NV_ENC_INPUT_PTR
0081: ctypedef void* NV_ENC_OUTPUT_PTR
0082: ctypedef void* NV_ENC_REGISTERED_PTR
0083:
0084: #not available with driver version 367.35
0085: #NVENCSTATUS NvEncodeAPIGetMaxSupportedVersion(uint32_t* version)
0086:
0087: ctypedef enum NV_ENC_CAPS:
0088: NV_ENC_CAPS_NUM_MAX_BFRAMES
0089: NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES
0090: NV_ENC_CAPS_SUPPORT_FIELD_ENCODING
0091: NV_ENC_CAPS_SUPPORT_MONOCHROME
0092: NV_ENC_CAPS_SUPPORT_FMO
0093: NV_ENC_CAPS_SUPPORT_QPELMV
0094: NV_ENC_CAPS_SUPPORT_BDIRECT_MODE
0095: NV_ENC_CAPS_SUPPORT_CABAC
0096: NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM
0097: NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS
0098: NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES
0099: NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES
0100: NV_ENC_CAPS_LEVEL_MAX
0101: NV_ENC_CAPS_LEVEL_MIN
0102: NV_ENC_CAPS_SEPARATE_COLOUR_PLANE
0103: NV_ENC_CAPS_WIDTH_MAX
0104: NV_ENC_CAPS_HEIGHT_MAX
0105: NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC
0106: NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE
0107: NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE
0108: NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP
0109: NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE
0110: NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK
0111: NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING
0112: NV_ENC_CAPS_SUPPORT_INTRA_REFRESH
0113: NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE
0114: NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE
0115: NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION
0116: NV_ENC_CAPS_PREPROC_SUPPORT
0117: NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT
0118: NV_ENC_CAPS_MB_NUM_MAX
0119: NV_ENC_CAPS_EXPOSED_COUNT
0120: NV_ENC_CAPS_SUPPORT_YUV444_ENCODE
0121: NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE
0122: NV_ENC_CAPS_SUPPORT_SAO
0123: NV_ENC_CAPS_SUPPORT_MEONLY_MODE
0124: NV_ENC_CAPS_SUPPORT_LOOKAHEAD
0125: NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ
0126: NV_ENC_CAPS_SUPPORT_10BIT_ENCODE
0127: #SDK 8:
0128: #NV_ENC_CAPS_NUM_MAX_LTR_FRAMES
0129:
0130: ctypedef enum NV_ENC_DEVICE_TYPE:
0131: NV_ENC_DEVICE_TYPE_DIRECTX
0132: NV_ENC_DEVICE_TYPE_CUDA
0133: #SDK 8:
0134: #NV_ENC_DEVICE_TYPE_OPENGL
0135:
0136: ctypedef enum NV_ENC_INPUT_RESOURCE_TYPE:
0137: NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX
0138: NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR
0139: NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY
0140: #SDK 8:
0141: #NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX
0142:
0143: ctypedef enum NV_ENC_MEMORY_HEAP:
0144: NV_ENC_MEMORY_HEAP_AUTOSELECT
0145: NV_ENC_MEMORY_HEAP_VID
0146: NV_ENC_MEMORY_HEAP_SYSMEM_CACHED
0147: NV_ENC_MEMORY_HEAP_SYSMEM_UNCACHED
0148:
0149: ctypedef enum NV_ENC_H264_ENTROPY_CODING_MODE:
0150: NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT
0151: NV_ENC_H264_ENTROPY_CODING_MODE_CABAC
0152: NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC
0153:
0154: ctypedef enum NV_ENC_STEREO_PACKING_MODE:
0155: NV_ENC_STEREO_PACKING_MODE_NONE
0156: NV_ENC_STEREO_PACKING_MODE_CHECKERBOARD
0157: NV_ENC_STEREO_PACKING_MODE_COLINTERLEAVE
0158: NV_ENC_STEREO_PACKING_MODE_ROWINTERLEAVE
0159: NV_ENC_STEREO_PACKING_MODE_SIDEBYSIDE
0160: NV_ENC_STEREO_PACKING_MODE_TOPBOTTOM
0161: NV_ENC_STEREO_PACKING_MODE_FRAMESEQ
0162:
0163: ctypedef enum NV_ENC_H264_FMO_MODE:
0164: NV_ENC_H264_FMO_AUTOSELECT
0165: NV_ENC_H264_FMO_ENABLE
0166: NV_ENC_H264_FMO_DISABLE
0167:
0168: ctypedef enum NV_ENC_H264_BDIRECT_MODE:
0169: NV_ENC_H264_BDIRECT_MODE_AUTOSELECT
0170: NV_ENC_H264_BDIRECT_MODE_DISABLE
0171: NV_ENC_H264_BDIRECT_MODE_TEMPORAL
0172: NV_ENC_H264_BDIRECT_MODE_SPATIAL
0173:
0174: ctypedef enum NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE:
0175: NV_ENC_H264_ADAPTIVE_TRANSFORM_AUTOSELECT
0176: NV_ENC_H264_ADAPTIVE_TRANSFORM_DISABLE
0177: NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE
0178:
0179: ctypedef enum NV_ENC_PARAMS_FRAME_FIELD_MODE:
0180: NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME
0181: NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD
0182: NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF
0183:
0184: ctypedef enum NV_ENC_BUFFER_FORMAT:
0185: NV_ENC_BUFFER_FORMAT_UNDEFINED
0186: NV_ENC_BUFFER_FORMAT_NV12
0187: NV_ENC_BUFFER_FORMAT_YV12
0188: NV_ENC_BUFFER_FORMAT_IYUV
0189: NV_ENC_BUFFER_FORMAT_YUV444
0190: NV_ENC_BUFFER_FORMAT_YUV420_10BIT
0191: NV_ENC_BUFFER_FORMAT_YUV444_10BIT
0192: NV_ENC_BUFFER_FORMAT_ARGB
0193: NV_ENC_BUFFER_FORMAT_ARGB10
0194: NV_ENC_BUFFER_FORMAT_AYUV
0195: NV_ENC_BUFFER_FORMAT_ABGR
0196: NV_ENC_BUFFER_FORMAT_ABGR10
0197:
0198: ctypedef enum NV_ENC_PIC_FLAGS:
0199: NV_ENC_PIC_FLAG_FORCEINTRA
0200: NV_ENC_PIC_FLAG_FORCEIDR
0201: NV_ENC_PIC_FLAG_OUTPUT_SPSPPS
0202: NV_ENC_PIC_FLAG_EOS
0203:
0204: ctypedef enum NV_ENC_PIC_STRUCT:
0205: NV_ENC_PIC_STRUCT_FRAME
0206: NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM
0207: NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP
0208:
0209: ctypedef enum NV_ENC_PIC_TYPE:
0210: NV_ENC_PIC_TYPE_P
0211: NV_ENC_PIC_TYPE_B
0212: NV_ENC_PIC_TYPE_I
0213: NV_ENC_PIC_TYPE_IDR
0214: NV_ENC_PIC_TYPE_BI
0215: NV_ENC_PIC_TYPE_SKIPPED
0216: NV_ENC_PIC_TYPE_INTRA_REFRESH
0217: NV_ENC_PIC_TYPE_UNKNOWN
0218:
0219: ctypedef enum NV_ENC_SLICE_TYPE:
0220: NV_ENC_SLICE_TYPE_DEFAULT
0221: NV_ENC_SLICE_TYPE_I
0222: NV_ENC_SLICE_TYPE_UNKNOWN
0223:
0224: ctypedef enum NV_ENC_MV_PRECISION:
0225: NV_ENC_MV_PRECISION_FULL_PEL
0226: NV_ENC_MV_PRECISION_HALF_PEL
0227: NV_ENC_MV_PRECISION_QUARTER_PEL
0228:
0229: ctypedef enum NV_ENC_LEVEL:
0230: NV_ENC_LEVEL_AUTOSELECT
0231: NV_ENC_LEVEL_H264_1
0232: NV_ENC_LEVEL_H264_1b
0233: NV_ENC_LEVEL_H264_11
0234: NV_ENC_LEVEL_H264_12
0235: NV_ENC_LEVEL_H264_13
0236: NV_ENC_LEVEL_H264_2
0237: NV_ENC_LEVEL_H264_21
0238: NV_ENC_LEVEL_H264_22
0239: NV_ENC_LEVEL_H264_3
0240: NV_ENC_LEVEL_H264_31
0241: NV_ENC_LEVEL_H264_32
0242: NV_ENC_LEVEL_H264_4
0243: NV_ENC_LEVEL_H264_41
0244: NV_ENC_LEVEL_H264_42
0245: NV_ENC_LEVEL_H264_5
0246: NV_ENC_LEVEL_H264_51
0247: NV_ENC_LEVEL_H264_52
0248: NV_ENC_LEVEL_HEVC_1
0249: NV_ENC_LEVEL_HEVC_2
0250: NV_ENC_LEVEL_HEVC_21
0251: NV_ENC_LEVEL_HEVC_3
0252: NV_ENC_LEVEL_HEVC_31
0253: NV_ENC_LEVEL_HEVC_4
0254: NV_ENC_LEVEL_HEVC_41
0255: NV_ENC_LEVEL_HEVC_5
0256: NV_ENC_LEVEL_HEVC_51
0257: NV_ENC_LEVEL_HEVC_52
0258: NV_ENC_LEVEL_HEVC_6
0259: NV_ENC_LEVEL_HEVC_61
0260: NV_ENC_LEVEL_HEVC_62
0261:
0262: ctypedef enum NV_ENC_PARAMS_RC_MODE:
0263: NV_ENC_PARAMS_RC_CONSTQP #Constant QP mode
0264: NV_ENC_PARAMS_RC_VBR #Variable bitrate mode
0265: NV_ENC_PARAMS_RC_CBR #Constant bitrate mode
0266: NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ #low-delay CBR, high quality
0267: NV_ENC_PARAMS_RC_CBR_HQ #CBR, high quality (slower)
0268: NV_ENC_PARAMS_RC_VBR_HQ
0269: #SDK 7 names (deprecated):
0270: NV_ENC_PARAMS_RC_VBR_MINQP #Variable bitrate mode with MinQP
0271: NV_ENC_PARAMS_RC_2_PASS_QUALITY #Multi pass encoding optimized for image quality and works only with low latency mode
0272: NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP #Multi pass encoding optimized for maintaining frame size and works only with low latency mode
0273: NV_ENC_PARAMS_RC_2_PASS_VBR #Multi pass VBR
0274: NV_ENC_PARAMS_RC_CBR2 #(deprecated)
0275:
0276: ctypedef enum NV_ENC_HEVC_CUSIZE:
0277: NV_ENC_HEVC_CUSIZE_AUTOSELECT
0278: NV_ENC_HEVC_CUSIZE_8x8
0279: NV_ENC_HEVC_CUSIZE_16x16
0280: NV_ENC_HEVC_CUSIZE_32x32
0281: NV_ENC_HEVC_CUSIZE_64x64
0282:
0283:
0284: ctypedef struct NV_ENC_LOCK_BITSTREAM:
0285: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER.
0286: uint32_t doNotWait #[in]: If this flag is set, the NvEncodeAPI interface will return buffer pointer even if operation is not completed. If not set, the call will block until operation completes.
0287: uint32_t ltrFrame #[out]: Flag indicating this frame is marked as LTR frame
0288: uint32_t reservedBitFields #[in]: Reserved bit fields and must be set to 0
0289: void* outputBitstream #[in]: Pointer to the bitstream buffer being locked.
0290: uint32_t* sliceOffsets #[in,out]: Array which receives the slice offsets. Currently used only when NV_ENC_CONFIG_H264::sliceMode == 3. Array size must be equal to NV_ENC_CONFIG_H264::sliceModeData.
0291: uint32_t frameIdx #[out]: Frame no. for which the bitstream is being retrieved.
0292: uint32_t hwEncodeStatus #[out]: The NvEncodeAPI interface status for the locked picture.
0293: uint32_t numSlices #[out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1.
0294: uint32_t bitstreamSizeInBytes#[out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr.
0295: uint64_t outputTimeStamp #[out]: Presentation timestamp associated with the encoded output.
0296: uint64_t outputDuration #[out]: Presentation duration associates with the encoded output.
0297: void* bitstreamBufferPtr #[out]: Pointer to the generated output bitstream. Client should allocate sufficiently large buffer to hold the encoded output. Client is responsible for managing this memory.
0298: NV_ENC_PIC_TYPE pictureType #[out]: Picture type of the encoded picture.
0299: NV_ENC_PIC_STRUCT pictureStruct #[out]: Structure of the generated output picture.
0300: uint32_t frameAvgQP #[out]: Average QP of the frame.
0301: uint32_t frameSatd #[out]: Total SATD cost for whole frame.
0302: uint32_t ltrFrameIdx #[out]: Frame index associated with this LTR frame.
0303: uint32_t ltrFrameBitmap #[out]: Bitmap of LTR frames indices which were used for encoding this frame. Value of 0 if no LTR frames were used.
0304: uint32_t reserved[236] #[in]: Reserved and must be set to 0
0305: void* reserved2[64] #[in]: Reserved and must be set to NULL
0306:
0307: ctypedef struct NV_ENC_LOCK_INPUT_BUFFER:
0308: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER.
0309: uint32_t doNotWait #[in]: Set to 1 to make ::NvEncLockInputBuffer() a unblocking call. If the encoding is not completed, driver will return ::NV_ENC_ERR_ENCODER_BUSY error code.
0310: uint32_t reservedBitFields #[in]: Reserved bitfields and must be set to 0
0311: NV_ENC_INPUT_PTR inputBuffer #[in]: Pointer to the input buffer to be locked, client should pass the pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource API.
0312: void* bufferDataPtr #[out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr.
0313: uint32_t pitch #[out]: Pitch of the locked input buffer.
0314: uint32_t reserved1[251] #[in]: Reserved and must be set to 0
0315: void* reserved2[64] #[in]: Reserved and must be set to NULL
0316:
0317: ctypedef struct NV_ENC_STAT:
0318: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_STAT_VER.
0319: uint32_t reserved #[in]: Reserved and must be set to 0
0320: NV_ENC_OUTPUT_PTR outputBitStream #[out]: Specifies the pointer to output bitstream.
0321: uint32_t bitStreamSize #[out]: Size of generated bitstream in bytes.
0322: uint32_t picType #[out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE.
0323: uint32_t lastValidByteOffset #[out]: Offset of last valid bytes of completed bitstream
0324: uint32_t sliceOffsets[16] #[out]: Offsets of each slice
0325: uint32_t picIdx #[out]: Picture number
0326: uint32_t reserved1[233] #[in]: Reserved and must be set to 0
0327: void* reserved2[64] #[in]: Reserved and must be set to NULL
0328:
0329: ctypedef struct NV_ENC_SEQUENCE_PARAM_PAYLOAD:
0330: pass
0331: ctypedef struct NV_ENC_EVENT_PARAMS:
0332: pass
0333: ctypedef struct NV_ENC_MAP_INPUT_RESOURCE:
0334: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER.
0335: uint32_t subResourceIndex #[in]: Deprecated. Do not use.
0336: void* inputResource #[in]: Deprecated. Do not use.
0337: NV_ENC_REGISTERED_PTR registeredResource #[in]: The Registered resource handle obtained by calling NvEncRegisterInputResource.
0338: NV_ENC_INPUT_PTR mappedResource #[out]: Mapped pointer corresponding to the registeredResource. This pointer must be used in NV_ENC_PIC_PARAMS::inputBuffer parameter in ::NvEncEncodePicture() API.
0339: NV_ENC_BUFFER_FORMAT mappedBufferFmt #[out]: Buffer format of the outputResource. This buffer format must be used in NV_ENC_PIC_PARAMS::bufferFmt if client using the above mapped resource pointer.
0340: uint32_t reserved1[251] #[in]: Reserved and must be set to 0.
0341: void* reserved2[63] #[in]: Reserved and must be set to NULL
0342: ctypedef struct NV_ENC_REGISTER_RESOURCE:
0343: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER.
0344: NV_ENC_INPUT_RESOURCE_TYPE resourceType #[in]: Specifies the type of resource to be registered. Supported values are ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX, ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR.
0345: uint32_t width #[in]: Input buffer Width.
0346: uint32_t height #[in]: Input buffer Height.
0347: uint32_t pitch #[in]: Input buffer Pitch.
0348: uint32_t subResourceIndex #[in]: Subresource Index of the DirectX resource to be registered. Should eb set to 0 for other interfaces.
0349: void* resourceToRegister #[in]: Handle to the resource that is being registered.
0350: NV_ENC_REGISTERED_PTR registeredResource #[out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface.
0351: NV_ENC_BUFFER_FORMAT bufferFormat #[in]: Buffer format of resource to be registered.
0352: uint32_t reserved1[248] #[in]: Reserved and must be set to 0.
0353: void* reserved2[62] #[in]: Reserved and must be set to NULL.
0354:
0355: ctypedef struct GUID:
0356: uint32_t Data1
0357: uint16_t Data2
0358: uint16_t Data3
0359: uint8_t Data4[8]
0360:
0361: int NVENC_INFINITE_GOPLENGTH
0362:
0363: #Encode Codec GUIDS supported by the NvEncodeAPI interface.
0364: GUID NV_ENC_CODEC_H264_GUID
0365: GUID NV_ENC_CODEC_HEVC_GUID
0366:
0367: #Profiles:
0368: GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID
0369: GUID NV_ENC_H264_PROFILE_BASELINE_GUID
0370: GUID NV_ENC_H264_PROFILE_MAIN_GUID
0371: GUID NV_ENC_H264_PROFILE_HIGH_GUID
0372: GUID NV_ENC_H264_PROFILE_HIGH_444_GUID
0373: GUID NV_ENC_H264_PROFILE_STEREO_GUID
0374: GUID NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY
0375: GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID
0376: GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID
0377:
0378: GUID NV_ENC_HEVC_PROFILE_MAIN_GUID
0379: GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID
0380: GUID NV_ENC_HEVC_PROFILE_FREXT_GUID
0381:
0382: #Presets:
0383: GUID NV_ENC_PRESET_DEFAULT_GUID
0384: GUID NV_ENC_PRESET_HP_GUID
0385: GUID NV_ENC_PRESET_HQ_GUID
0386: GUID NV_ENC_PRESET_BD_GUID
0387: #V3 ONLY PRESETS:
0388: GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID
0389: GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID
0390: GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID
0391: #V4 ONLY PRESETS:
0392: GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID
0393: GUID NV_ENC_PRESET_LOSSLESS_HP_GUID
0394:
0395: ctypedef struct NV_ENC_CAPS_PARAM:
0396: uint32_t version
0397: uint32_t capsToQuery
0398: uint32_t reserved[62]
0399:
0400: ctypedef struct NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS:
0401: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER.
0402: NV_ENC_DEVICE_TYPE deviceType #[in]: (NV_ENC_DEVICE_TYPE) Specified the device Type
0403: void *device #[in]: Pointer to client device.
0404: GUID *reserved #[in]: Pointer to a GUID key issued to the client.
0405: uint32_t apiVersion #[in]: API version. Should be set to NVENCAPI_VERSION.
0406: uint32_t reserved1[253] #[in]: Reserved and must be set to 0
0407: void *reserved2[64] #[in]: Reserved and must be set to NULL
0408:
0409: ctypedef struct NV_ENC_CREATE_INPUT_BUFFER:
0410: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_CREATE_INPUT_BUFFER_VER
0411: uint32_t width #[in]: Input buffer width
0412: uint32_t height #[in]: Input buffer width
0413: NV_ENC_MEMORY_HEAP memoryHeap #[in]: Input buffer memory heap
0414: NV_ENC_BUFFER_FORMAT bufferFmt #[in]: Input buffer format
0415: uint32_t reserved #[in]: Reserved and must be set to 0
0416: void *inputBuffer #[out]: Pointer to input buffer
0417: void *pSysMemBuffer #[in]: Pointer to existing sysmem buffer
0418: uint32_t reserved1[57] #[in]: Reserved and must be set to 0
0419: void *reserved2[63] #[in]: Reserved and must be set to NULL
0420:
0421: ctypedef struct NV_ENC_CREATE_BITSTREAM_BUFFER:
0422: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_CREATE_BITSTREAM_BUFFER_VER
0423: uint32_t size #[in]: Size of the bitstream buffer to be created
0424: NV_ENC_MEMORY_HEAP memoryHeap #[in]: Output buffer memory heap
0425: uint32_t reserved #[in]: Reserved and must be set to 0
0426: void *bitstreamBuffer#[out]: Pointer to the output bitstream buffer
0427: void *bitstreamBufferPtr #[out]: Reserved and should not be used
0428: uint32_t reserved1[58] #[in]: Reserved and should be set to 0
0429: void* reserved2[64] #[in]: Reserved and should be set to NULL
0430:
0431: ctypedef struct NV_ENC_QP:
0432: uint32_t qpInterP
0433: uint32_t qpInterB
0434: uint32_t qpIntra
0435:
0436: ctypedef struct NV_ENC_CONFIG_HEVC_VUI_PARAMETERS:
0437: uint32_t overscanInfoPresentFlag #[in]: if set to 1 , it specifies that the overscanInfo is present
0438: uint32_t overscanInfo #[in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification).
0439: uint32_t videoSignalTypePresentFlag #[in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */
0440: uint32_t videoFormat #[in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/
0441: uint32_t videoFullRangeFlag #[in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */
0442: uint32_t colourDescriptionPresentFlag #[in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */
0443: uint32_t colourPrimaries #[in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */
0444: uint32_t transferCharacteristics #[in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */
0445: uint32_t colourMatrix #[in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (as defined in Annex E of the ITU-T Specification). */
0446: uint32_t chromaSampleLocationFlag #[in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/
0447: uint32_t chromaSampleLocationTop #[in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */
0448: uint32_t chromaSampleLocationBot #[in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */
0449: uint32_t bitstreamRestrictionFlag #[in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/
0450: uint32_t reserved[15]
0451:
0452: ctypedef struct NV_ENC_CONFIG_H264_VUI_PARAMETERS:
0453: uint32_t overscanInfoPresentFlag #[in]: if set to 1 , it specifies that the overscanInfo is present
0454: uint32_t overscanInfo #[in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification).
0455: uint32_t videoSignalTypePresentFlag #[in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present.
0456: uint32_t videoFormat #[in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).
0457: uint32_t videoFullRangeFlag #[in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification).
0458: uint32_t colourDescriptionPresentFlag #[in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present.
0459: uint32_t colourPrimaries #[in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification)
0460: uint32_t transferCharacteristics #[in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification)
0461: uint32_t colourMatrix #[in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (as defined in Annex E of the ITU-T Specification).
0462: uint32_t chromaSampleLocationFlag #[in]: if set to 1 , it specifies that thechromaSampleLocationTop and chromaSampleLocationBot are present.
0463: uint32_t chromaSampleLocationTop #[in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification)
0464: uint32_t chromaSampleLocationBot #[in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification)
0465: uint32_t bitstreamRestrictionFlag #[in]: if set to 1, it speficies the bitstream restriction parameters are present in the bitstream.
0466: uint32_t reserved[15]
0467:
0468: ctypedef struct NV_ENC_CONFIG_H264:
0469: uint32_t enableTemporalSVC #[in]: Set to 1 to enable SVC temporal
0470: uint32_t enableStereoMVC #[in]: Set to 1 to enable stereo MVC
0471: uint32_t hierarchicalPFrames #[in]: Set to 1 to enable hierarchical PFrames
0472: uint32_t hierarchicalBFrames #[in]: Set to 1 to enable hierarchical BFrames
0473: uint32_t outputBufferingPeriodSEI #[in]: Set to 1 to write SEI buffering period syntax in the bitstream
0474: uint32_t outputPictureTimingSEI #[in]: Set to 1 to write SEI picture timing syntax in the bitstream
0475: uint32_t outputAUD #[in]: Set to 1 to write access unit delimiter syntax in bitstream
0476: uint32_t disableSPSPPS #[in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream
0477: uint32_t outputFramePackingSEI #[in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream
0478: uint32_t outputRecoveryPointSEI #[in]: Set to 1 to enable writing of recovery point SEI message
0479: uint32_t enableIntraRefresh #[in]: Set to 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored
0480: uint32_t enableConstrainedEncoding #[in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constarined picture is independent of other slices
0481: #Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps.
0482: uint32_t repeatSPSPPS #[in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame
0483: uint32_t enableVFR #[in]: Set to 1 to enable variable frame rate.
0484: uint32_t enableLTR #[in]: Currently this feature is not available and must be set to 0. Set to 1 to enable LTR support and auto-mark the first
0485: uint32_t qpPrimeYZeroTransformBypassFlag #[in] To enable lossless encode set this to 1, set QP to 0 and RC_mode to NV_ENC_PARAMS_RC_CONSTQP and profile to HIGH_444_PREDICTIVE_PROFILE
0486: #Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps.
0487: uint32_t useConstrainedIntraPred #[in]: Set 1 to enable constrained intra prediction.
0488: uint32_t reservedBitFields[15] #[in]: Reserved bitfields and must be set to 0
0489: uint32_t level #[in]: Specifies the encoding level. Client is recommended to set this to NV_ENC_LEVEL_AUTOSELECT in order to enable the NvEncodeAPI interface to select the correct level.
0490: uint32_t idrPeriod #[in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically.
0491: uint32_t separateColourPlaneFlag #[in]: Set to 1 to enable 4:4:4 separate colour planes
0492: uint32_t disableDeblockingFilterIDC #[in]: Specifies the deblocking filter mode. Permissible value range: [0,2]
0493: uint32_t numTemporalLayers #[in]: Specifies max temporal layers to be used for hierarchical coding. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS]
0494: uint32_t spsId #[in]: Specifies the SPS id of the sequence header. Currently reserved and must be set to 0.
0495: uint32_t ppsId #[in]: Specifies the PPS id of the picture header. Currently reserved and must be set to 0.
0496: NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE adaptiveTransformMode #[in]: Specifies the AdaptiveTransform Mode. Check support for AdaptiveTransform mode using ::NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM caps.
0497: NV_ENC_H264_FMO_MODE fmoMode #[in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps.
0498: NV_ENC_H264_BDIRECT_MODE bdirectMode #[in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.
0499: NV_ENC_H264_ENTROPY_CODING_MODE entropyCodingMode #[in]: Specifies the entropy coding mode. Check support for CABAC mode using ::NV_ENC_CAPS_SUPPORT_CABAC caps.
0500: NV_ENC_STEREO_PACKING_MODE stereoMode #[in]: Specifies the stereo frame packing mode which is to be signalled in frame packing arrangement SEI
0501: uint32_t intraRefreshPeriod #[in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
0502: #Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH.
0503: uint32_t intraRefreshCnt #[in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod
0504: uint32_t maxNumRefFrames #[in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default dpb size.
0505: #The low latency application which wants to invalidate reference frame as an error resilience tool
0506: #is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
0507: #frames are invalidated.
0508: uint32_t sliceMode #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
0509: #sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
0510: #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
0511: #When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice
0512: uint32_t sliceModeData #[in]: Specifies the parameter needed for sliceMode. For:
0513: #sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
0514: #sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
0515: #sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
0516: #sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally
0517: NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters #[in]: Specifies the H264 video usability info pamameters
0518: uint32_t ltrNumFrames #[in]: Specifies the number of LTR frames used. Additionally, encoder will mark the first numLTRFrames base layer reference frames within each IDR interval as LTR
0519: uint32_t ltrTrustMode #[in]: Specifies the LTR operating mode. Set to 0 to disallow encoding using LTR frames until later specified. Set to 1 to allow encoding using LTR frames unless later invalidated.
0520: uint32_t chromaFormatIDC #[in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
0521: #Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.
0522: uint32_t maxTemporalLayers #[in]: Specifies the max temporal layer used for hierarchical coding.
0523: uint32_t reserved1[270] #[in]: Reserved and must be set to 0
0524: void *reserved2[64] #[in]: Reserved and must be set to NULL
0525:
0526: ctypedef struct NV_ENC_CONFIG_HEVC:
0527: uint32_t level #[in]: Specifies the level of the encoded bitstream.
0528: uint32_t tier #[in]: Specifies the level tier of the encoded bitstream.
0529: NV_ENC_HEVC_CUSIZE minCUSize #[in]: Specifies the minimum size of luma coding unit.
0530: NV_ENC_HEVC_CUSIZE maxCUSize #[in]: Specifies the maximum size of luma coding unit. Currently NVENC SDK only supports maxCUSize equal to NV_ENC_HEVC_CUSIZE_32x32.
0531: uint32_t useConstrainedIntraPred #[in]: Set 1 to enable constrained intra prediction.
0532: uint32_t disableDeblockAcrossSliceBoundary #[in]: Set 1 to disable in loop filtering across slice boundary.
0533: uint32_t outputBufferingPeriodSEI #[in]: Set 1 to write SEI buffering period syntax in the bitstream
0534: uint32_t outputPictureTimingSEI #[in]: Set 1 to write SEI picture timing syntax in the bitstream
0535: uint32_t outputAUD #[in]: Set 1 to write Access Unit Delimiter syntax.
0536: uint32_t enableLTR #[in]: Set 1 to enable use of long term reference pictures for inter prediction.
0537: uint32_t disableSPSPPS #[in]: Set 1 to disable VPS,SPS and PPS signalling in the bitstream.
0538: uint32_t repeatSPSPPS #[in]: Set 1 to output VPS,SPS and PPS for every IDR frame.
0539: uint32_t enableIntraRefresh #[in]: Set 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored
0540: uint32_t chromaFormatIDC #[in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
0541: uint32_t pixelBitDepthMinus8 #[in]: Specifies pixel bit depth minus 8. Should be set to 0 for 8 bit input, 2 for 10 bit input.
0542: uint32_t reserved #[in]: Reserved bitfields.
0543: uint32_t idrPeriod #[in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically.
0544: uint32_t intraRefreshPeriod #[in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
0545: #Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH.
0546: uint32_t intraRefreshCnt #[in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod
0547: uint32_t maxNumRefFramesInDPB #[in]: Specifies the maximum number of references frames in the DPB.
0548: uint32_t ltrNumFrames #[in]: Specifies the maximum number of long term references can be used for prediction
0549: uint32_t vpsId #[in]: Specifies the VPS id of the video parameter set. Currently reserved and must be set to 0.
0550: uint32_t spsId #[in]: Specifies the SPS id of the sequence header. Currently reserved and must be set to 0.
0551: uint32_t ppsId #[in]: Specifies the PPS id of the picture header. Currently reserved and must be set to 0.
0552: uint32_t sliceMode #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
0553: #sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
0554: #When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice
0555: uint32_t sliceModeData #[in]: Specifies the parameter needed for sliceMode. For:
0556: #sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
0557: #sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
0558: #sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
0559: #sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally
0560: uint32_t maxTemporalLayersMinus1 #[in]: Specifies the max temporal layer used for hierarchical coding.
0561: NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters #Specifies the HEVC video usability info pamameters
0562: uint32_t reserved1[218] #[in]: Reserved and must be set to 0.
0563: void* reserved2[64] #[in]: Reserved and must be set to NULL
0564:
0565: ctypedef struct NV_ENC_CODEC_CONFIG:
0566: NV_ENC_CONFIG_H264 h264Config #[in]: Specifies the H.264-specific encoder configuration
0567: NV_ENC_CONFIG_HEVC hevcConfig #[in]: Specifies the HEVC-specific encoder configuration. Currently unsupported and must not to be used.
0568: uint32_t reserved[256] #[in]: Reserved and must be set to 0
0569:
0570: ctypedef struct NV_ENC_RC_PARAMS:
0571: uint32_t version
0572: NV_ENC_PARAMS_RC_MODE rateControlMode #[in]: Specifies the rate control mode. Check support for various rate control modes using ::NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES caps.
0573: NV_ENC_QP constQP #[in]: Specifies the initial QP to be used for encoding, these values would be used for all frames if in Constant QP mode.
0574: uint32_t averageBitRate #[in]: Specifies the average bitrate(in bits/sec) used for encoding.
0575: uint32_t maxBitRate #[in]: Specifies the maximum bitrate for the encoded output. This is used for VBR and ignored for CBR mode.
0576: uint32_t vbvBufferSize #[in]: Specifies the VBV(HRD) buffer size. in bits. Set 0 to use the default VBV buffer size.
0577: uint32_t vbvInitialDelay #[in]: Specifies the VBV(HRD) initial delay in bits. Set 0 to use the default VBV initial delay
0578: uint32_t enableMinQP #[in]: Set this to 1 if minimum QP used for rate control.
0579: uint32_t enableMaxQP #[in]: Set this to 1 if maximum QP used for rate control.
0580: uint32_t enableInitialRCQP #[in]: Set this to 1 if user suppplied initial QP is used for rate control.
0581: uint32_t enableAQ #[in]: Set this to 1 to enable adaptive quantization.
0582: uint32_t enableExtQPDeltaMap #[in]: Set this to 1 to enable additional QP modifier for each MB supplied by client though signed byte array pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap
0583: uint32_t reservedBitFields[27] #[in]: Reserved bitfields and must be set to 0
0584: NV_ENC_QP minQP #[in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1.
0585: NV_ENC_QP maxQP #[in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1.
0586: NV_ENC_QP initialRCQP #[in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1.
0587: uint32_t temporallayerIdxMask#[in]: Specifies the temporal layers (as a bitmask) whose QPs have changed. Valid max bitmask is [2^NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS - 1]
0588: uint8_t temporalLayerQP[8] #[in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as as the array index
0589: #SDK 8:
0590: #uint8_t targetQuality #[in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic)
0591: #uint8_t targetQualityLSB #[in]: Fractional part of target quality (as 8.8 fixed point format)
0592: #uint16_t lookaheadDepth #[in]: Maximum depth of lookahead with range 0-32 (only used if enableLookahead=1)
0593: uint32_t reserved[9]
0594:
0595: ctypedef struct NV_ENC_CONFIG:
0596: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER.
0597: GUID profileGUID #[in]: Specifies the codec profile guid. If client specifies \p NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID the NvEncodeAPI interface will select the appropriate codec profile.
0598: uint32_t gopLength #[in]: Specifies the number of pictures in one GOP. Low latency application client can set goplength to NVENC_INFINITE_GOPLENGTH so that keyframes are not inserted automatically.
0599: int32_t frameIntervalP #[in]: Specifies the GOP pattern as follows: \p frameIntervalP = 0: I, 1: IPP, 2: IBP, 3: IBBP If goplength is set to NVENC_INFINITE_GOPLENGTH \p frameIntervalP should be set to 1.
0600: uint32_t monoChromeEncoding #[in]: Set this to 1 to enable monochrome encoding for this session.
0601: NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode #[in]: Specifies the frame/field mode. Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps.
0602: NV_ENC_MV_PRECISION mvPrecision #[in]: Specifies the desired motion vector prediction precision.
0603: NV_ENC_RC_PARAMS rcParams #[in]: Specifies the rate control parameters for the current encoding session.
0604: NV_ENC_CODEC_CONFIG encodeCodecConfig #[in]: Specifies the codec specific config parameters through this union.
0605: uint32_t reserved[278] #[in]: Reserved and must be set to 0
0606: void *reserved2[64] #[in]: Reserved and must be set to NULL
0607:
0608:
0609: ctypedef struct NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE:
0610: uint32_t numCandsPerBlk16x16 #[in]: Specifies the number of candidates per 16x16 block.
0611: uint32_t numCandsPerBlk16x8 #[in]: Specifies the number of candidates per 16x8 block.
0612: uint32_t numCandsPerBlk8x16 #[in]: Specifies the number of candidates per 8x16 block.
0613: uint32_t numCandsPerBlk8x8 #[in]: Specifies the number of candidates per 8x8 block.
0614: uint32_t reserved #[in]: Reserved for padding.
0615: uint32_t reserved1[3] #[in]: Reserved for future use.
0616:
0617: ctypedef struct NV_ENC_INITIALIZE_PARAMS:
0618: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER.
0619: GUID encodeGUID #[in]: Specifies the Encode GUID for which the encoder is being created. ::NvEncInitializeEncoder() API will fail if this is not set, or set to unsupported value.
0620: GUID presetGUID #[in]: Specifies the preset for encoding. If the preset GUID is set then , the preset configuration will be applied before any other parameter.
0621: uint32_t encodeWidth #[in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail.
0622: uint32_t encodeHeight #[in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail.
0623: uint32_t darWidth #[in]: Specifies the display aspect ratio Width.
0624: uint32_t darHeight #[in]: Specifies the display aspect ratio height.
0625: uint32_t frameRateNum #[in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ).
0626: uint32_t frameRateDen #[in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ).
0627: uint32_t enableEncodeAsync #[in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification.
0628: uint32_t enablePTD #[in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface.
0629: uint32_t reportSliceOffsets #[in]: Set this to 1 to enable reporting slice offsets in ::_NV_ENC_LOCK_BITSTREAM. Currently supported only for H264. Client must set this to 0 if NV_ENC_CONFIG_H264::sliceMode is 1
0630: uint32_t enableSubFrameWrite #[in]: Set this to 1 to write out available bitstream to memory at subframe intervals
0631: uint32_t enableExternalMEHints #[in]: Set to 1 to enable external ME hints for the current frame. Currently this feature is supported only if NV_ENC_INITIALIZE_PARAMS::enablePTD to 0 or\p frameIntervalP = 1 (i.e no B frames).
0632: uint32_t enableMEOnlyMode #[in] Set to 1 to enable ME Only Mode
0633: uint32_t reservedBitFields[28] #[in]: Reserved bitfields and must be set to 0
0634: uint32_t privDataSize #[in]: Reserved private data buffer size and must be set to 0
0635: void *privData #[in]: Reserved private data buffer and must be set to NULL
0636: NV_ENC_CONFIG *encodeConfig #[in]: Specifies the advanced codec specific structure. If client has sent a valid codec config structure, it will override parameters set by the NV_ENC_INITIALIZE_PARAMS::presetGUID parameter. If set to NULL the NvEncodeAPI interface will use the NV_ENC_INITIALIZE_PARAMS::presetGUID to set the codec specific parameters.
0637: #Client can also optionally query the NvEncodeAPI interface to get codec specific parameters for a presetGUID using ::NvEncGetEncodePresetConfig() API. It can then modify (if required) some of the codec config parameters and send down a custom config structure as part of ::_NV_ENC_INITIALIZE_PARAMS.
0638: #Even in this case client is recommended to pass the same preset guid it has used in ::NvEncGetEncodePresetConfig() API to query the config structure; as NV_ENC_INITIALIZE_PARAMS::presetGUID. This will not override the custom config structure but will be used to determine other Encoder HW specific parameters not exposed in the API.
0639: uint32_t maxEncodeWidth #[in]: Maximum encode width to be used for current Encode session.
0640: #Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change.
0641: uint32_t maxEncodeHeight #[in]: Maximum encode height to be allowed for current Encode session.
0642: #Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change.
0643: NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE maxMEHintCountsPerBlock[2] #[in]: If Client wants to pass external motion vectors in NV_ENC_PIC_PARAMS::meExternalHints buffer it must specify the maximum number of hint candidates per block per direction for the encode session.
0644: #The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors.
0645: #This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1.
0646: uint32_t reserved[289] #[in]: Reserved and must be set to 0
0647: void *reserved2[64] #[in]: Reserved and must be set to NULL
0648:
0649: ctypedef struct NV_ENC_RECONFIGURE_PARAMS:
0650: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER.
0651: NV_ENC_INITIALIZE_PARAMS reInitEncodeParams
0652: uint32_t resetEncoder #[in]: This resets the rate control states and other internal encoder states. This should be used only with an IDR frame.
0653: #If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR
0654: uint32_t forceIDR #[in]: Encode the current picture as an IDR picture. This flag is only valid when Picture type decision is taken by the Encoder
0655: #[_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1].
0656: uint32_t reserved
0657:
0658: ctypedef struct NV_ENC_PRESET_CONFIG:
0659: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER.
0660: NV_ENC_CONFIG presetCfg #[out]: preset config returned by the Nvidia Video Encoder interface.
0661: uint32_t reserved1[255] #[in]: Reserved and must be set to 0
0662: void* reserved2[64] #[in]: Reserved and must be set to NULL
0663:
0664: ctypedef struct NV_ENC_H264_SEI_PAYLOAD:
0665: uint32_t payloadSize #[in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D
0666: uint32_t payloadType #[in] SEI payload types and syntax can be found in Annex D of the H.264 Specification.
0667: uint8_t *payload #[in] pointer to user data
0668: ctypedef NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD
0669:
0670: ctypedef struct NV_ENC_PIC_PARAMS_H264:
0671: uint32_t displayPOCSyntax #[in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision.
0672: uint32_t reserved3 #[in]: Reserved and must be set to 0
0673: uint32_t refPicFlag #[in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1.
0674: uint32_t colourPlaneId #[in]: Specifies the colour plane ID associated with the current input.
0675: uint32_t forceIntraRefreshWithFrameCnt #[in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
0676: #When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
0677: #forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified
0678: uint32_t constrainedFrame #[in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame.
0679: #NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1
0680: uint32_t sliceModeDataUpdate #[in]: Set to 1 if client wants to change the sliceModeData field to speficy new sliceSize Parameter
0681: #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
0682: uint32_t ltrMarkFrame #[in]: Set to 1 if client wants to mark this frame as LTR
0683: uint32_t ltrUseFrames #[in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap
0684: uint32_t reservedBitFields #[in]: Reserved bit fields and must be set to 0
0685: uint8_t* sliceTypeData #[in]: Array which specifies the slice type used to force intra slice for a particular slice. Currently supported only for NV_ENC_CONFIG_H264::sliceMode == 3.
0686: #Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
0687: #Array element with index n corresponds to nth slice. To force a particular slice to intra client should set corresponding array element to NV_ENC_SLICE_TYPE_I
0688: #all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT
0689: uint32_t sliceTypeArrayCnt #[in]: Client should set this to the number of elements allocated in sliceTypeData array. If sliceTypeData is NULL then this should be set to 0
0690: uint32_t seiPayloadArrayCnt #[in]: Specifies the number of elements allocated in seiPayloadArray array.
0691: NV_ENC_SEI_PAYLOAD *seiPayloadArray #[in]: Array of SEI payloads which will be inserted for this frame.
0692: uint32_t sliceMode #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
0693: #sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
0694: #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
0695: #When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice
0696: uint32_t sliceModeData #[in]: Specifies the parameter needed for sliceMode. For:
0697: #sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
0698: #sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
0699: #sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
0700: #sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally
0701: uint32_t ltrMarkFrameIdx #[in]: Specifies the long term referenceframe index to use for marking this frame as LTR.
0702: uint32_t ltrUseFrameBitmap #[in]: Specifies the the associated bitmap of LTR frame indices when encoding this frame.
0703: uint32_t ltrUsageMode #[in]: Specifies additional usage constraints for encoding using LTR frames from this point further. 0: no constraints, 1: no short term refs older than current, no previous LTR frames.
0704: uint32_t reserved[243] #[in]: Reserved and must be set to 0.
0705: void* reserved2[62] #[in]: Reserved and must be set to NULL.
0706:
0707: ctypedef struct NV_ENC_PIC_PARAMS_HEVC:
0708: uint32_t displayPOCSyntax #[in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision.
0709: uint32_t refPicFlag #[in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1.
0710: uint32_t temporalId #[in]: Specifies the temporal id of the picture
0711: uint32_t forceIntraRefreshWithFrameCnt #[in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
0712: #When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
0713: #forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified
0714: uint32_t constrainedFrame #[in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame
0715: #NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1
0716: uint32_t sliceModeDataUpdate #[in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
0717: #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
0718: uint32_t ltrMarkFrame #[in]: Set to 1 if client wants to mark this frame as LTR
0719: uint32_t ltrUseFrames #[in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap
0720: uint32_t reservedBitFields #[in]: Reserved bit fields and must be set to 0
0721: uint8_t* sliceTypeData #[in]: Array which specifies the slice type used to force intra slice for a particular slice. Currently supported only for NV_ENC_CONFIG_H264::sliceMode == 3.
0722: #Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
0723: #Array element with index n corresponds to nth slice. To force a particular slice to intra client should set corresponding array element to NV_ENC_SLICE_TYPE_I
0724: #all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT
0725: uint32_t sliceTypeArrayCnt #[in]: Client should set this to the number of elements allocated in sliceTypeData array. If sliceTypeData is NULL then this should be set to 0
0726: uint32_t sliceMode #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
0727: #sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
0728: #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
0729: #When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice
0730: uint32_t sliceModeData #[in]: Specifies the parameter needed for sliceMode. For:
0731: #sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
0732: #sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
0733: #sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
0734: #sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally
0735: uint32_t ltrMarkFrameIdx #[in]: Specifies the long term reference frame index to use for marking this frame as LTR.
0736: uint32_t ltrUseFrameBitmap #[in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame.
0737: uint32_t ltrUsageMode #[in]: Not supported. Reserved for future use and must be set to 0.
0738: uint32_t seiPayloadArrayCnt #[in]: Specifies the number of elements allocated in seiPayloadArray array.
0739: uint32_t reserved #[in]: Reserved and must be set to 0.
0740: NV_ENC_SEI_PAYLOAD* seiPayloadArray #[in]: Array of SEI payloads which will be inserted for this frame.
0741: uint32_t reserved2 [244] #[in]: Reserved and must be set to 0.
0742: void* reserved3[61] #[in]: Reserved and must be set to NULL.
0743:
0744: ctypedef union NV_ENC_CODEC_PIC_PARAMS:
0745: NV_ENC_PIC_PARAMS_H264 h264PicParams #[in]: H264 encode picture params.
0746: NV_ENC_PIC_PARAMS_HEVC hevcPicParams #[in]: HEVC encode picture params.
0747: uint32_t reserved[256] #[in]: Reserved and must be set to 0.
0748:
0749: ctypedef struct NV_ENC_MEONLY_PARAMS:
0750: uint32_t version #[in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.
0751: uint32_t inputWidth #[in]: Specifies the input buffer width
0752: uint32_t inputHeight #[in]: Specifies the input buffer height
0753: NV_ENC_INPUT_PTR inputBuffer #[in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs.
0754: NV_ENC_INPUT_PTR referenceFrame #[in]: Specifies the reference frame pointer
0755: NV_ENC_OUTPUT_PTR outputMV #[in,out]: Specifies the pointer to output motion vector data buffer allocated by NvEncCreateMVBuffer.
0756: NV_ENC_BUFFER_FORMAT bufferFmt #[in]: Specifies the input buffer format.
0757: uint32_t reserved1[252] #[in]: Reserved and must be set to 0
0758: void* reserved2[61] #[in]: Reserved and must be set to NULL
0759:
0760: ctypedef struct NVENC_EXTERNAL_ME_HINT:
0761: int32_t mvx #[in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0.
0762: int32_t mvy #[in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0
0763: int32_t refidx #[in]: Specifies the reference index (31=invalid). Current we support only 1 reference frame per direction for external hints, so \p refidx must be 0.
0764: int32_t dir #[in]: Specifies the direction of motion estimation . 0=L0 1=L1.
0765: int32_t partType #[in]: Specifies the bloack partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).
0766: int32_t lastofPart #[in]: Set to 1 for the last MV of (sub) partition
0767: int32_t lastOfMB #[in]: Set to 1 for the last MV of macroblock.
0768:
0769: ctypedef struct NV_ENC_PIC_PARAMS:
0770: uint32_t version #[in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER.
0771: uint32_t inputWidth #[in]: Specifies the input buffer width
0772: uint32_t inputHeight #[in]: Specifies the input buffer height
0773: uint32_t inputPitch #[in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth.
0774: uint32_t encodePicFlags #[in]: Specifies bit-wise OR`ed encode pic flags. See ::NV_ENC_PIC_FLAGS enum.
0775: uint32_t frameIdx #[in]: Specifies the frame index associated with the input frame [optional].
0776: uint64_t inputTimeStamp #[in]: Specifies presentation timestamp associated with the input picture.
0777: uint64_t inputDuration #[in]: Specifies duration of the input picture
0778: NV_ENC_INPUT_PTR inputBuffer #[in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.
0779: NV_ENC_OUTPUT_PTR outputBitstream #[in]: Specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API.
0780: void* completionEvent #[in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer.
0781: NV_ENC_BUFFER_FORMAT bufferFmt #[in]: Specifies the input buffer format.
0782: NV_ENC_PIC_STRUCT pictureStruct #[in]: Specifies structure of the input picture.
0783: NV_ENC_PIC_TYPE pictureType #[in]: Specifies input picture type. Client required to be set explicitly by the client if the client has not set NV_ENC_INITALIZE_PARAMS::enablePTD to 1 while calling NvInitializeEncoder.
0784: NV_ENC_CODEC_PIC_PARAMS codecPicParams #[in]: Specifies the codec specific per-picture encoding parameters.
0785: uint32_t newEncodeWidth #[in]: Specifies the new output width for current Encoding session, in case of dynamic resolution change. Client should only set this in combination with NV_ENC_PIC_FLAGS::NV_ENC_PIC_FLAG_DYN_RES_CHANGE.
0786: #Additionally, if Picture Type decision is handled by the Client [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 0], the client should set the _NV_ENC_PIC_PARAMS::pictureType as ::NV_ENC_PIC_TYPE_IDR.
0787: #If _NV_ENC_INITIALIZE_PARAMS::enablePTD == 1, then the Encoder will generate an IDR frame corresponding to this input.
0788: uint32_t newEncodeHeight #[in]: Specifies the new output width for current Encoding session, in case of dynamic resolution change. Client should only set this in combination with NV_ENC_PIC_FLAGS::NV_ENC_PIC_FLAG_DYN_RES_CHANGE.
0789: #Additionally, if Picture Type decision is handled by the Client [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 0], the client should set the _NV_ENC_PIC_PARAMS::pictureType as ::NV_ENC_PIC_TYPE_IDR.
0790: #If _NV_ENC_INITIALIZE_PARAMS::enablePTD == 1, then the Encoder will generate an IDR frame corresponding to this input.
0791: NV_ENC_RC_PARAMS rcParams #[in]: Specifies the rate control parameters for the current encoding session.
0792: NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2] #[in]: Specifies the number of hint candidates per block per direction for the current frame. meHintCountsPerBlock[0] is for L0 predictors and meHintCountsPerBlock[1] is for L1 predictors.
0793: #The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization.
0794: NVENC_EXTERNAL_ME_HINT *meExternalHints #[in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks multiplied by the total number of candidates per macroblock.
0795: #The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
0796: # + 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1)
0797: uint32_t newDarWidth #[in]: Specifies the new disalay aspect ratio width for current Encoding session, in case of dynamic resolution change. Client should only set this in combination with NV_ENC_PIC_FLAGS::NV_ENC_PIC_FLAG_DYN_RES_CHANGE.
0798: #Additionally, if Picture Type decision is handled by the Client [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 0], the client should set the _NV_ENC_PIC_PARAMS::pictureType as ::NV_ENC_PIC_TYPE_IDR.
0799: #If _NV_ENC_INITIALIZE_PARAMS::enablePTD == 1, then the Encoder will generate an IDR frame corresponding to this input.
0800: uint32_t newDarHeight #[in]: Specifies the new disalay aspect ratio height for current Encoding session, in case of dynamic resolution change. Client should only set this in combination with NV_ENC_PIC_FLAGS::NV_ENC_PIC_FLAG_DYN_RES_CHANGE.
0801: #If _NV_ENC_INITIALIZE_PARAMS::enablePTD == 1, then the Encoder will generate an IDR frame corresponding to this input.
0802: uint32_t reserved1[259] #[in]: Reserved and must be set to 0
0803: void* reserved2[63] #[in]: Reserved and must be set to NULL
0804:
0805: #NVENCSTATUS NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList)
0806:
0807: ctypedef NVENCSTATUS (*PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder) nogil
0808: ctypedef NVENCSTATUS (*PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount) nogil
0809: ctypedef NVENCSTATUS (*PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount) nogil
0810: ctypedef NVENCSTATUS (*PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount) nogil
0811: ctypedef NVENCSTATUS (*PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount) nogil
0812: ctypedef NVENCSTATUS (*PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount) nogil
0813: ctypedef NVENCSTATUS (*PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount) nogil
0814: ctypedef NVENCSTATUS (*PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal) nogil
0815: ctypedef NVENCSTATUS (*PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount) nogil
0816: ctypedef NVENCSTATUS (*PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount) nogil
0817: ctypedef NVENCSTATUS (*PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig) nogil
0818: ctypedef NVENCSTATUS (*PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams) nogil
0819: ctypedef NVENCSTATUS (*PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams) nogil
0820: ctypedef NVENCSTATUS (*PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer) nogil
0821: ctypedef NVENCSTATUS (*PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams) nogil
0822: ctypedef NVENCSTATUS (*PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer) nogil
0823: ctypedef NVENCSTATUS (*PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams) nogil
0824: ctypedef NVENCSTATUS (*PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams) nogil
0825: ctypedef NVENCSTATUS (*PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer) nogil
0826: ctypedef NVENCSTATUS (*PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams) nogil
0827: ctypedef NVENCSTATUS (*PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer) nogil
0828: ctypedef NVENCSTATUS (*PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats) nogil
0829: ctypedef NVENCSTATUS (*PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload) nogil
0830: ctypedef NVENCSTATUS (*PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams) nogil
0831: ctypedef NVENCSTATUS (*PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams) nogil
0832: ctypedef NVENCSTATUS (*PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams) nogil
0833: ctypedef NVENCSTATUS (*PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer) nogil
0834: ctypedef NVENCSTATUS (*PNVENCDESTROYENCODER) (void* encoder) nogil
0835: ctypedef NVENCSTATUS (*PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp) nogil
0836: ctypedef NVENCSTATUS (*PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder) nogil
0837: ctypedef NVENCSTATUS (*PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams) nogil
0838: ctypedef NVENCSTATUS (*PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes) nogil
0839: ctypedef NVENCSTATUS (*PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams) nogil
0840:
0841: ctypedef struct NV_ENCODE_API_FUNCTION_LIST:
0842: uint32_t version #[in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER.
0843: uint32_t reserved #[in]: Reserved and should be set to 0.
0844: PNVENCOPENENCODESESSION nvEncOpenEncodeSession
0845: PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount
0846: PNVENCGETENCODEPROFILEGUIDCOUNT nvEncGetEncodeProfileGUIDCount
0847: PNVENCGETENCODEPROFILEGUIDS nvEncGetEncodeProfileGUIDs
0848: PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs
0849: PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount
0850: PNVENCGETINPUTFORMATS nvEncGetInputFormats
0851: PNVENCGETENCODECAPS nvEncGetEncodeCaps
0852: PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount
0853: PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs
0854: PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig
0855: PNVENCINITIALIZEENCODER nvEncInitializeEncoder
0856: PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer
0857: PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer
0858: PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer
0859: PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer
0860: PNVENCENCODEPICTURE nvEncEncodePicture
0861: PNVENCLOCKBITSTREAM nvEncLockBitstream
0862: PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream
0863: PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer
0864: PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer
0865: PNVENCGETENCODESTATS nvEncGetEncodeStats
0866: PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams
0867: PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent
0868: PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent
0869: PNVENCMAPINPUTRESOURCE nvEncMapInputResource
0870: PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource
0871: PNVENCDESTROYENCODER nvEncDestroyEncoder
0872: PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames
0873: PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx
0874: PNVENCREGISTERRESOURCE nvEncRegisterResource
0875: PNVENCUNREGISTERRESOURCE nvEncUnregisterResource
0876: PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder
0877: void* reserved2[285] #[in]: Reserved and must be set to NULL
0878:
0879: #constants:
0880: unsigned int NVENCAPI_MAJOR_VERSION
0881: unsigned int NVENCAPI_MINOR_VERSION
0882: uint32_t NVENCAPI_VERSION
0883: unsigned int NV_ENCODE_API_FUNCTION_LIST_VER
0884: unsigned int NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER
0885: unsigned int NV_ENC_INITIALIZE_PARAMS_VER
0886: unsigned int NV_ENC_PRESET_CONFIG_VER
0887: unsigned int NV_ENC_CONFIG_VER
0888: unsigned int NV_ENC_CREATE_INPUT_BUFFER_VER
0889: unsigned int NV_ENC_CREATE_BITSTREAM_BUFFER_VER
0890: unsigned int NV_ENC_CAPS_PARAM_VER
0891: unsigned int NV_ENC_LOCK_INPUT_BUFFER_VER
0892: unsigned int NV_ENC_LOCK_BITSTREAM_VER
0893: unsigned int NV_ENC_PIC_PARAMS_VER
0894: unsigned int NV_ENC_RC_PARAMS_VER
0895: unsigned int NV_ENC_REGISTER_RESOURCE_VER
0896: unsigned int NV_ENC_MAP_INPUT_RESOURCE_VER
0897: unsigned int NVENC_INFINITE_GOPLENGTH
0898: unsigned int NV_ENC_SUCCESS
0899: unsigned int NV_ENC_ERR_NO_ENCODE_DEVICE
0900: unsigned int NV_ENC_ERR_UNSUPPORTED_DEVICE
0901: unsigned int NV_ENC_ERR_INVALID_ENCODERDEVICE
0902: unsigned int NV_ENC_ERR_INVALID_DEVICE
0903: unsigned int NV_ENC_ERR_DEVICE_NOT_EXIST
0904: unsigned int NV_ENC_ERR_INVALID_PTR
0905: unsigned int NV_ENC_ERR_INVALID_EVENT
0906: unsigned int NV_ENC_ERR_INVALID_PARAM
0907: unsigned int NV_ENC_ERR_INVALID_CALL
0908: unsigned int NV_ENC_ERR_OUT_OF_MEMORY
0909: unsigned int NV_ENC_ERR_ENCODER_NOT_INITIALIZED
0910: unsigned int NV_ENC_ERR_UNSUPPORTED_PARAM
0911: unsigned int NV_ENC_ERR_LOCK_BUSY
0912: unsigned int NV_ENC_ERR_NOT_ENOUGH_BUFFER
0913: unsigned int NV_ENC_ERR_INVALID_VERSION
0914: unsigned int NV_ENC_ERR_MAP_FAILED
0915: unsigned int NV_ENC_ERR_NEED_MORE_INPUT
0916: unsigned int NV_ENC_ERR_ENCODER_BUSY
0917: unsigned int NV_ENC_ERR_EVENT_NOT_REGISTERD
0918: unsigned int NV_ENC_ERR_GENERIC
0919: unsigned int NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY
0920: unsigned int NV_ENC_ERR_UNIMPLEMENTED
0921: unsigned int NV_ENC_ERR_RESOURCE_REGISTER_FAILED
0922: unsigned int NV_ENC_ERR_RESOURCE_NOT_REGISTERED
0923: unsigned int NV_ENC_ERR_RESOURCE_NOT_MAPPED
0924:
0925: unsigned int NV_ENC_CAPS_MB_PER_SEC_MAX
0926: unsigned int NV_ENC_CAPS_SUPPORT_YUV444_ENCODE
0927: unsigned int NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE
0928: unsigned int NV_ENC_RECONFIGURE_PARAMS_VER
0929:
0930:
0931: NV_ENC_STATUS_TXT = {
+0932: NV_ENC_SUCCESS : "This indicates that API call returned with no errors.",
__pyx_t_2 = __Pyx_PyDict_NewPresized(26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_SUCCESS); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_API_call_ret) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0933: NV_ENC_ERR_NO_ENCODE_DEVICE : "This indicates that no encode capable devices were detected",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_NO_ENCODE_DEVICE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_no_encode_ca) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0934: NV_ENC_ERR_UNSUPPORTED_DEVICE : "This indicates that devices pass by the client is not supported.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_UNSUPPORTED_DEVICE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 934, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_devices_pass) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0935: NV_ENC_ERR_INVALID_ENCODERDEVICE : "This indicates that the encoder device supplied by the client is not valid.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_ENCODERDEVICE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_encoder) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0936: NV_ENC_ERR_INVALID_DEVICE : "This indicates that device passed to the API call is invalid.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_DEVICE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 936, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_device_passe) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0937: NV_ENC_ERR_DEVICE_NOT_EXIST : """This indicates that device passed to the API call is no longer available and
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_DEVICE_NOT_EXIST); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_device_passe_2) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0938: needs to be reinitialized. The clients need to destroy the current encoder
0939: session by freeing the allocated input output buffers and destroying the device
0940: and create a new encoding session.""",
+0941: NV_ENC_ERR_INVALID_PTR : "This indicates that one or more of the pointers passed to the API call is invalid.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_PTR); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_one_or_more) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0942: NV_ENC_ERR_INVALID_EVENT : "This indicates that completion event passed in ::NvEncEncodePicture() call is invalid.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_EVENT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_completion_e) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0943: NV_ENC_ERR_INVALID_PARAM : "This indicates that one or more of the parameter passed to the API call is invalid.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_PARAM); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_one_or_more_2) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0944: NV_ENC_ERR_INVALID_CALL : "This indicates that an API call was made in wrong sequence/order.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_CALL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 944, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_an_API_call) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0945: NV_ENC_ERR_OUT_OF_MEMORY : "This indicates that the API call failed because it was unable to allocate enough memory to perform the requested operation.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_OUT_OF_MEMORY); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 945, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_API_call) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0946: NV_ENC_ERR_ENCODER_NOT_INITIALIZED: """This indicates that the encoder has not been initialized with
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_ENCODER_NOT_INITIALIZED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_encoder_2) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0947: ::NvEncInitializeEncoder() or that initialization has failed.
0948: The client cannot allocate input or output buffers or do any encoding
0949: related operation before successfully initializing the encoder.""",
+0950: NV_ENC_ERR_UNSUPPORTED_PARAM : "This indicates that an unsupported parameter was passed by the client.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_UNSUPPORTED_PARAM); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_an_unsupport) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0951: NV_ENC_ERR_LOCK_BUSY : """This indicates that the ::NvEncLockBitstream() failed to lock the output
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_LOCK_BUSY); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_NvEncLoc) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0952: buffer. This happens when the client makes a non blocking lock call to
0953: access the output bitstream by passing NV_ENC_LOCK_BITSTREAM::doNotWait flag.
0954: This is not a fatal error and client should retry the same operation after
0955: few milliseconds.""",
+0956: NV_ENC_ERR_NOT_ENOUGH_BUFFER : "This indicates that the size of the user buffer passed by the client is insufficient for the requested operation.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_NOT_ENOUGH_BUFFER); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_size_of) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0957: NV_ENC_ERR_INVALID_VERSION : "This indicates that an invalid struct version was used by the client.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_VERSION); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 957, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_an_invalid_s) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0958: NV_ENC_ERR_MAP_FAILED : "This indicates that ::NvEncMapInputResource() API failed to map the client provided input resource.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_MAP_FAILED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_NvEncMapInpu) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0959: NV_ENC_ERR_NEED_MORE_INPUT : """
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_NEED_MORE_INPUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_encode_driver_re) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0960: This indicates encode driver requires more input buffers to produce an output
0961: bitstream. If this error is returned from ::NvEncEncodePicture() API, this
0962: is not a fatal error. If the client is encoding with B frames then,
0963: ::NvEncEncodePicture() API might be buffering the input frame for re-ordering.
0964: A client operating in synchronous mode cannot call ::NvEncLockBitstream()
0965: API on the output bitstream buffer if ::NvEncEncodePicture() returned the
0966: ::NV_ENC_ERR_NEED_MORE_INPUT error code.
0967: The client must continue providing input frames until encode driver returns
0968: ::NV_ENC_SUCCESS. After receiving ::NV_ENC_SUCCESS status the client can call
0969: ::NvEncLockBitstream() API on the output buffers in the same order in which
0970: it has called ::NvEncEncodePicture().
0971: """,
+0972: NV_ENC_ERR_ENCODER_BUSY : """This indicates that the HW encoder is busy encoding and is unable to encode
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_ENCODER_BUSY); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_HW_encod) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0973: the input. The client should call ::NvEncEncodePicture() again after few milliseconds.""",
+0974: NV_ENC_ERR_EVENT_NOT_REGISTERD : """This indicates that the completion event passed in ::NvEncEncodePicture()
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_EVENT_NOT_REGISTERD); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_completi) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0975: API has not been registered with encoder driver using ::NvEncRegisterAsyncEvent().""",
+0976: NV_ENC_ERR_GENERIC : "This indicates that an unknown internal error has occurred.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_GENERIC); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 976, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_an_unknown_i) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0977: NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY : "This indicates that the client is attempting to use a feature that is not available for the license type for the current system.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_client_i) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0978: NV_ENC_ERR_UNIMPLEMENTED : "This indicates that the client is attempting to use a feature that is not implemented for the current version.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_UNIMPLEMENTED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_client_i_2) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0979: NV_ENC_ERR_RESOURCE_REGISTER_FAILED : "This indicates that the ::NvEncRegisterResource API failed to register the resource.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_RESOURCE_REGISTER_FAILED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_NvEncReg) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0980: NV_ENC_ERR_RESOURCE_NOT_REGISTERED : "This indicates that the client is attempting to unregister a resource that has not been successfuly registered.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_RESOURCE_NOT_REGISTERED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_client_i_3) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0981: NV_ENC_ERR_RESOURCE_NOT_MAPPED : "This indicates that the client is attempting to unmap a resource that has not been successfuly mapped.",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_RESOURCE_NOT_MAPPED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_kp_s_This_indicates_that_the_client_i_4) < 0) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_NV_ENC_STATUS_TXT, __pyx_t_2) < 0) __PYX_ERR(0, 931, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0982: }
0983:
0984: CAPS_NAMES = {
+0985: NV_ENC_CAPS_NUM_MAX_BFRAMES : "NUM_MAX_BFRAMES",
__pyx_t_2 = __Pyx_PyDict_NewPresized(39); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_NUM_MAX_BFRAMES); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_NUM_MAX_BFRAMES) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0986: NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES : "SUPPORTED_RATECONTROL_MODES",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 986, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORTED_RATECONTROL_MODES) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0987: NV_ENC_CAPS_SUPPORT_FIELD_ENCODING : "SUPPORT_FIELD_ENCODING",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_FIELD_ENCODING); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 987, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_FIELD_ENCODING) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0988: NV_ENC_CAPS_SUPPORT_MONOCHROME : "SUPPORT_MONOCHROME",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_MONOCHROME); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 988, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_MONOCHROME) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0989: NV_ENC_CAPS_SUPPORT_FMO : "SUPPORT_FMO",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_FMO); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_FMO) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0990: NV_ENC_CAPS_SUPPORT_QPELMV : "SUPPORT_QPELMV",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_QPELMV); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_QPELMV) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0991: NV_ENC_CAPS_SUPPORT_BDIRECT_MODE : "SUPPORT_BDIRECT_MODE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_BDIRECT_MODE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_BDIRECT_MODE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0992: NV_ENC_CAPS_SUPPORT_CABAC : "SUPPORT_CABAC",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_CABAC); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 992, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_CABAC) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0993: NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM : "SUPPORT_ADAPTIVE_TRANSFORM",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 993, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_ADAPTIVE_TRANSFORM) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0994: NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS : "NUM_MAX_TEMPORAL_LAYERS",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_NUM_MAX_TEMPORAL_LAYERS) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0995: NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES: "SUPPORT_HIERARCHICAL_PFRAMES",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_HIERARCHICAL_PFRAMES) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0996: NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES: "SUPPORT_HIERARCHICAL_BFRAMES",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_HIERARCHICAL_BFRAMES) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0997: NV_ENC_CAPS_LEVEL_MAX : "LEVEL_MAX",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_LEVEL_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_LEVEL_MAX) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0998: NV_ENC_CAPS_LEVEL_MIN : "LEVEL_MIN",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_LEVEL_MIN); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_LEVEL_MIN) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0999: NV_ENC_CAPS_SEPARATE_COLOUR_PLANE : "SEPARATE_COLOUR_PLANE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SEPARATE_COLOUR_PLANE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SEPARATE_COLOUR_PLANE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1000: NV_ENC_CAPS_WIDTH_MAX : "WIDTH_MAX",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_WIDTH_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_WIDTH_MAX) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1001: NV_ENC_CAPS_HEIGHT_MAX : "HEIGHT_MAX",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_HEIGHT_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_HEIGHT_MAX) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1002: NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC : "SUPPORT_TEMPORAL_SVC",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_TEMPORAL_SVC) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1003: NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE : "SUPPORT_DYN_RES_CHANGE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1003, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_DYN_RES_CHANGE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1004: NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE : "SUPPORT_DYN_BITRATE_CHANGE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1004, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_DYN_BITRATE_CHANGE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1005: NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP : "SUPPORT_DYN_FORCE_CONSTQP",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_DYN_FORCE_CONSTQP) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1006: NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE : "SUPPORT_DYN_RCMODE_CHANGE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_DYN_RCMODE_CHANGE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1007: NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK : "SUPPORT_SUBFRAME_READBACK",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_SUBFRAME_READBACK) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1008: NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING: "SUPPORT_CONSTRAINED_ENCODING",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_CONSTRAINED_ENCODING) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1009: NV_ENC_CAPS_SUPPORT_INTRA_REFRESH : "SUPPORT_INTRA_REFRESH",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_INTRA_REFRESH); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_INTRA_REFRESH) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1010: NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE : "SUPPORT_CUSTOM_VBV_BUF_SIZE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_CUSTOM_VBV_BUF_SIZE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1011: NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE : "SUPPORT_DYNAMIC_SLICE_MODE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_DYNAMIC_SLICE_MODE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1012: NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION: "SUPPORT_REF_PIC_INVALIDATION",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_REF_PIC_INVALIDATION) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1013: NV_ENC_CAPS_PREPROC_SUPPORT : "PREPROC_SUPPORT",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_PREPROC_SUPPORT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_PREPROC_SUPPORT) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1014: NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT : "ASYNC_ENCODE_SUPPORT",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_ASYNC_ENCODE_SUPPORT) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1015: NV_ENC_CAPS_MB_NUM_MAX : "MB_NUM_MAX",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_MB_NUM_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_MB_NUM_MAX) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1016: NV_ENC_CAPS_EXPOSED_COUNT : "EXPOSED_COUNT",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_EXPOSED_COUNT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1016, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_EXPOSED_COUNT) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1017: NV_ENC_CAPS_SUPPORT_YUV444_ENCODE : "SUPPORT_YUV444_ENCODE",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_CAPS_SUPPORT_YUV444_ENCODE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1017, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_YUV444_ENCODE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1018: NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE : "SUPPORT_LOSSLESS_ENCODE",
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1018, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_LOSSLESS_ENCODE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1019: NV_ENC_CAPS_SUPPORT_SAO : "SUPPORT_SAO",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_SAO); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1019, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_SAO) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1020: NV_ENC_CAPS_SUPPORT_MEONLY_MODE : "SUPPORT_MEONLY_MODE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_MEONLY_MODE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1020, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_MEONLY_MODE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1021: NV_ENC_CAPS_SUPPORT_LOOKAHEAD : "SUPPORT_LOOKAHEAD",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_LOOKAHEAD); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1021, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_LOOKAHEAD) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1022: NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ : "SUPPORT_TEMPORAL_AQ",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_TEMPORAL_AQ) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1023: NV_ENC_CAPS_SUPPORT_10BIT_ENCODE : "SUPPORT_10BIT_ENCODE",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_SUPPORT_10BIT_ENCODE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1023, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SUPPORT_10BIT_ENCODE) < 0) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CAPS_NAMES, __pyx_t_2) < 0) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1024: #SDK 8:
1025: #NV_ENC_CAPS_NUM_MAX_LTR_FRAMES : "NUM_MAX_LTR_FRAMES",
1026: }
1027:
1028: PIC_TYPES = {
+1029: NV_ENC_PIC_TYPE_P : "P",
__pyx_t_2 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_P); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_P) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1030: NV_ENC_PIC_TYPE_B : "B",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_B); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1030, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_B) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1031: NV_ENC_PIC_TYPE_I : "I",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_I); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1031, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_I) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1032: NV_ENC_PIC_TYPE_IDR : "IDR",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_IDR); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_IDR) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1033: NV_ENC_PIC_TYPE_BI : "BI",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_BI); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_BI) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1034: NV_ENC_PIC_TYPE_SKIPPED : "SKIPPED",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_SKIPPED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1034, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_SKIPPED) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1035: NV_ENC_PIC_TYPE_INTRA_REFRESH : "INTRA_REFRESH",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_INTRA_REFRESH); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_INTRA_REFRESH) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1036: NV_ENC_PIC_TYPE_UNKNOWN : "UNKNOWN",
__pyx_t_6 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(NV_ENC_PIC_TYPE_UNKNOWN); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_t_6, __pyx_n_s_UNKNOWN) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_PIC_TYPES, __pyx_t_2) < 0) __PYX_ERR(0, 1028, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1037: }
1038:
+1039: NvEncodeAPICreateInstance = None
if (PyDict_SetItem(__pyx_d, __pyx_n_s_NvEncodeAPICreateInstance, Py_None) < 0) __PYX_ERR(0, 1039, __pyx_L1_error)
+1040: cuCtxGetCurrent = None
if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuCtxGetCurrent, Py_None) < 0) __PYX_ERR(0, 1040, __pyx_L1_error)
1041:
+1042: def init_nvencode_library():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_1init_nvencode_library(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_1init_nvencode_library = {"init_nvencode_library", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_1init_nvencode_library, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_1init_nvencode_library(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_nvencode_library (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_init_nvencode_library(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_init_nvencode_library(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_v_load = NULL; PyObject *__pyx_v_nvenc_libname = NULL; PyObject *__pyx_v_cuda_libname = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_nvencode_library", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.init_nvencode_library", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_load); __Pyx_XDECREF(__pyx_v_nvenc_libname); __Pyx_XDECREF(__pyx_v_cuda_libname); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__53 = PyTuple_Pack(5, __pyx_n_s_load, __pyx_n_s_nvenc_libname, __pyx_n_s_cuda_libname, __pyx_n_s_x_2, __pyx_n_s_e); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1042, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__53); __Pyx_GIVEREF(__pyx_tuple__53); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_1init_nvencode_library, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1042, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_nvencode_library, __pyx_t_2) < 0) __PYX_ERR(0, 1042, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_init_nvencode_library, 1042, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 1042, __pyx_L1_error)
1043: global NvEncodeAPICreateInstance, cuCtxGetCurrent
+1044: if WIN32:
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_WIN32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1044, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1044, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L3; }
+1045: load = ctypes.WinDLL
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_WinDLL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_load = __pyx_t_3; __pyx_t_3 = 0;
+1046: nvenc_libname = "nvencodeapi64.dll"
__Pyx_INCREF(__pyx_kp_s_nvencodeapi64_dll);
__pyx_v_nvenc_libname = __pyx_kp_s_nvencodeapi64_dll;
+1047: cuda_libname = "nvcuda.dll"
__Pyx_INCREF(__pyx_kp_s_nvcuda_dll);
__pyx_v_cuda_libname = __pyx_kp_s_nvcuda_dll;
1048: else:
1049: #assert os.name=="posix"
+1050: load = ctypes.cdll.LoadLibrary
/*else*/ { __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cdll); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_LoadLibrary); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_load = __pyx_t_3; __pyx_t_3 = 0;
+1051: nvenc_libname = "libnvidia-encode.so"
__Pyx_INCREF(__pyx_kp_s_libnvidia_encode_so);
__pyx_v_nvenc_libname = __pyx_kp_s_libnvidia_encode_so;
+1052: cuda_libname = "libcuda.so"
__Pyx_INCREF(__pyx_kp_s_libcuda_so);
__pyx_v_cuda_libname = __pyx_kp_s_libcuda_so;
}
__pyx_L3:;
1053: #CUDA:
+1054: log("init_nvencode_library() will try to load %s", cuda_libname)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_init_nvencode_library_will_try_t, __pyx_v_cuda_libname}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1054, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_init_nvencode_library_will_try_t, __pyx_v_cuda_libname}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1054, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_nvencode_library_will_try_t); __Pyx_GIVEREF(__pyx_kp_s_init_nvencode_library_will_try_t); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_init_nvencode_library_will_try_t); __Pyx_INCREF(__pyx_v_cuda_libname); __Pyx_GIVEREF(__pyx_v_cuda_libname); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_cuda_libname); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1055: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L9_try_end:; }
+1056: x = load(cuda_libname)
__Pyx_INCREF(__pyx_v_load); __pyx_t_1 = __pyx_v_load; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_6) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_cuda_libname); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1056, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_cuda_libname}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1056, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_cuda_libname}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1056, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1056, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(__pyx_v_cuda_libname); __Pyx_GIVEREF(__pyx_v_cuda_libname); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_cuda_libname); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1056, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_x = __pyx_t_3; __pyx_t_3 = 0;
+1057: log("init_nvencode_library() %s(%s)=%s", load, cuda_libname, x)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_kp_s_init_nvencode_library_s_s_s, __pyx_v_load, __pyx_v_cuda_libname, __pyx_v_x}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_kp_s_init_nvencode_library_s_s_s, __pyx_v_load, __pyx_v_cuda_libname, __pyx_v_x}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_nvencode_library_s_s_s); __Pyx_GIVEREF(__pyx_kp_s_init_nvencode_library_s_s_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_init_nvencode_library_s_s_s); __Pyx_INCREF(__pyx_v_load); __Pyx_GIVEREF(__pyx_v_load); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_load); __Pyx_INCREF(__pyx_v_cuda_libname); __Pyx_GIVEREF(__pyx_v_cuda_libname); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_cuda_libname); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_x); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1058: except Exception as e:
__pyx_t_5 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_5) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.init_nvencode_library", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_6) < 0) __PYX_ERR(0, 1058, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1;
+1059: log("failed to load '%s'", cuda_libname, exc_info=True)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_kp_s_failed_to_load_s); __Pyx_GIVEREF(__pyx_kp_s_failed_to_load_s); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_s_failed_to_load_s); __Pyx_INCREF(__pyx_v_cuda_libname); __Pyx_GIVEREF(__pyx_v_cuda_libname); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_cuda_libname); __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_11); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_exc_info, Py_True) < 0) __PYX_ERR(0, 1059, __pyx_L6_except_error) __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1060: raise ImportError("nvenc: the required library %s cannot be loaded: %s" % (cuda_libname, e))
__pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_v_cuda_libname); __Pyx_GIVEREF(__pyx_v_cuda_libname); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_cuda_libname); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_e); __pyx_t_11 = __Pyx_PyString_Format(__pyx_kp_s_nvenc_the_required_library_s_can, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 1060, __pyx_L6_except_error) } goto __pyx_L6_except_error; __pyx_L6_except_error:;
+1061: cuCtxGetCurrent = x.cuCtxGetCurrent
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_cuCtxGetCurrent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1061, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuCtxGetCurrent, __pyx_t_6) < 0) __PYX_ERR(0, 1061, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1062: cuCtxGetCurrent.restype = ctypes.c_int # CUresult == int
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_c_int); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuCtxGetCurrent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__Pyx_PyObject_SetAttrStr(__pyx_t_6, __pyx_n_s_restype, __pyx_t_1) < 0) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1063: cuCtxGetCurrent.argtypes = [POINTER(CUcontext)] # CUcontext *pctx
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_POINTER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_CUcontext); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_11) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_6); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_3}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_3}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuCtxGetCurrent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__Pyx_PyObject_SetAttrStr(__pyx_t_6, __pyx_n_s_argtypes, __pyx_t_1) < 0) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1064: log("init_nvencode_library() %s.cuCtxGetCurrent=%s", os.path.splitext(cuda_libname)[0], cuCtxGetCurrent)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_splitext); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_11) { __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_cuda_libname); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_cuda_libname}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_12); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_cuda_libname}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_12); } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL; __Pyx_INCREF(__pyx_v_cuda_libname); __Pyx_GIVEREF(__pyx_v_cuda_libname); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_cuda_libname); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_12, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuCtxGetCurrent); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_init_nvencode_library_s_cuCtxGet, __pyx_t_3, __pyx_t_12}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_init_nvencode_library_s_cuCtxGet, __pyx_t_3, __pyx_t_12}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_11 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_nvencode_library_s_cuCtxGet); __Pyx_GIVEREF(__pyx_kp_s_init_nvencode_library_s_cuCtxGet); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_kp_s_init_nvencode_library_s_cuCtxGet); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_12); __pyx_t_3 = 0; __pyx_t_12 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1065: #nvidia-encode:
+1066: log("init_nvencode_library() will try to load %s", nvenc_libname)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_kp_s_init_nvencode_library_will_try_t, __pyx_v_nvenc_libname}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_kp_s_init_nvencode_library_will_try_t, __pyx_v_nvenc_libname}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_nvencode_library_will_try_t); __Pyx_GIVEREF(__pyx_kp_s_init_nvencode_library_will_try_t); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_kp_s_init_nvencode_library_will_try_t); __Pyx_INCREF(__pyx_v_nvenc_libname); __Pyx_GIVEREF(__pyx_v_nvenc_libname); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_v_nvenc_libname); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1067: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L17_try_end; __pyx_L12_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L1_error; __pyx_L17_try_end:; }
+1068: x = load(nvenc_libname)
__Pyx_INCREF(__pyx_v_load); __pyx_t_1 = __pyx_v_load; __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_12) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_nvenc_libname); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1068, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_6); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_nvenc_libname}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1068, __pyx_L12_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_nvenc_libname}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1068, __pyx_L12_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1068, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_INCREF(__pyx_v_nvenc_libname); __Pyx_GIVEREF(__pyx_v_nvenc_libname); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_nvenc_libname); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1068, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_6); __pyx_t_6 = 0;
+1069: log("init_nvencode_library() %s(%s)=%s", load, nvenc_libname, x)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1069, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_kp_s_init_nvencode_library_s_s_s, __pyx_v_load, __pyx_v_nvenc_libname, __pyx_v_x}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1069, __pyx_L12_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_kp_s_init_nvencode_library_s_s_s, __pyx_v_load, __pyx_v_nvenc_libname, __pyx_v_x}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1069, __pyx_L12_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_12 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1069, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_nvencode_library_s_s_s); __Pyx_GIVEREF(__pyx_kp_s_init_nvencode_library_s_s_s); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_kp_s_init_nvencode_library_s_s_s); __Pyx_INCREF(__pyx_v_load); __Pyx_GIVEREF(__pyx_v_load); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_v_load); __Pyx_INCREF(__pyx_v_nvenc_libname); __Pyx_GIVEREF(__pyx_v_nvenc_libname); PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_5, __pyx_v_nvenc_libname); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_5, __pyx_v_x); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1069, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1070: except Exception as e:
__pyx_t_5 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_5) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.init_nvencode_library", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_12) < 0) __PYX_ERR(0, 1070, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1;
+1071: log("failed to load '%s'", nvenc_libname, exc_info=True)
__pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1071, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1071, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_s_failed_to_load_s); __Pyx_GIVEREF(__pyx_kp_s_failed_to_load_s); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_failed_to_load_s); __Pyx_INCREF(__pyx_v_nvenc_libname); __Pyx_GIVEREF(__pyx_v_nvenc_libname); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_nvenc_libname); __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1071, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_exc_info, Py_True) < 0) __PYX_ERR(0, 1071, __pyx_L14_except_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1071, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1072: raise ImportError("nvenc: the required library %s cannot be loaded: %s" % (nvenc_libname, e))
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1072, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_nvenc_libname); __Pyx_GIVEREF(__pyx_v_nvenc_libname); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_nvenc_libname); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_e); __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_nvenc_the_required_library_s_can, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1072, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1072, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1072, __pyx_L14_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 1072, __pyx_L14_except_error) } goto __pyx_L14_except_error; __pyx_L14_except_error:;
+1073: NvEncodeAPICreateInstance = x.NvEncodeAPICreateInstance
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_NvEncodeAPICreateInstance); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NvEncodeAPICreateInstance, __pyx_t_12) < 0) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1074: NvEncodeAPICreateInstance.restype = ctypes.c_int
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_c_int); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_NvEncodeAPICreateInstance); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__Pyx_PyObject_SetAttrStr(__pyx_t_12, __pyx_n_s_restype, __pyx_t_1) < 0) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1075: NvEncodeAPICreateInstance.argtypes = [ctypes.c_void_p]
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyList_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NvEncodeAPICreateInstance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_n_s_argtypes, __pyx_t_12) < 0) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1076: log("init_nvencode_library() NvEncodeAPICreateInstance=%s", NvEncodeAPICreateInstance)
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_NvEncodeAPICreateInstance); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_init_nvencode_library_NvEncodeAP, __pyx_t_6}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1076, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_init_nvencode_library_NvEncodeAP, __pyx_t_6}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1076, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_nvencode_library_NvEncodeAP); __Pyx_GIVEREF(__pyx_kp_s_init_nvencode_library_NvEncodeAP); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_kp_s_init_nvencode_library_NvEncodeAP); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1077: #NVENCSTATUS NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList)
1078:
+1079: def atob(a):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_3atob(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_3atob = {"atob", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_3atob, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_3atob(PyObject *__pyx_self, PyObject *__pyx_v_a) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("atob (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_2atob(__pyx_self, ((PyObject *)__pyx_v_a)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_2atob(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("atob", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.atob", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_4xpra_6codecs_5nvenc_7encoder_7guidstr_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_a); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1079, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__55); __Pyx_GIVEREF(__pyx_tuple__55); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_3atob, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_atob, __pyx_t_2) < 0) __PYX_ERR(0, 1079, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_atob, 1079, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 1079, __pyx_L1_error)
+1080: if PYTHON3:
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PYTHON3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1080, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+1081: return a.tobytes()
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1082: return a.tostring()
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_tostring); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1082, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1082, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1082, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1083:
+1084: cdef guidstr(GUID guid):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(GUID __pyx_v_guid) { struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr *__pyx_cur_scope; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_s = NULL; PyObject *__pyx_v_b = NULL; PyObject *__pyx_v_j = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("guidstr", 0); __pyx_cur_scope = (struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr *)__pyx_tp_new_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_ptype_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1084, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.guidstr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_s); __Pyx_XDECREF(__pyx_v_b); __Pyx_XDECREF(__pyx_v_j); __Pyx_XDECREF(__pyx_v__); __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr { PyObject_HEAD PyObject *__pyx_v_parts; };
1085: #really ugly! (surely there's a way using struct.unpack ?)
1086: #is this even endian safe? do we care? (always on the same system)
+1087: parts = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_parts = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1088: for v, s in ((guid.Data1, 4), (guid.Data2, 2), (guid.Data3, 2)):
__pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_guid.Data1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_uint16_t(__pyx_v_guid.Data2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_uint16_t(__pyx_v_guid.Data3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_2); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (__pyx_t_5 >= 3) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1088, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1088, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1088, __pyx_L1_error) } __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_2); __pyx_t_2 = 0; /* … */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1089: b = array.array('B', [0 for _ in range(s)])
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_s); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_6 = __pyx_t_7; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1089, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_6))) { if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1089, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1089, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1089, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_int_0))) __PYX_ERR(0, 1089, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_s_B, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_n_s_B, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_n_s_B); __Pyx_GIVEREF(__pyx_n_s_B); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_10, __pyx_n_s_B); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_10, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_b, __pyx_t_1); __pyx_t_1 = 0;
+1090: for j in range(s):
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1090, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1090, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1090, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1090, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1091: b[s-j-1] = v % 256
__pyx_t_3 = __Pyx_PyInt_RemainderObjC(__pyx_v_v, __pyx_int_256, 0x100, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = PyNumber_Subtract(__pyx_v_s, __pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_7, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(PyObject_SetItem(__pyx_v_b, __pyx_t_2, __pyx_t_3) < 0)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1092: v = v // 256
__pyx_t_3 = __Pyx_PyInt_FloorDivideObjC(__pyx_v_v, __pyx_int_256, 0x100, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0;
+1093: parts.append(atob(b))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_atob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_b); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_b}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_b}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(__pyx_v_b); __Pyx_GIVEREF(__pyx_v_b); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_b); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_parts, __pyx_t_1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1094: parts.append(atob(array.array('B', guid.get("Data4")[:2])))
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_atob); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __pyx_convert__to_py_GUID(__pyx_v_guid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_Data4); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_7, 0, 2, NULL, NULL, &__pyx_slice__2, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_n_s_B, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_n_s_B, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_12 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_n_s_B); __Pyx_GIVEREF(__pyx_n_s_B); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_10, __pyx_n_s_B); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_10, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_2) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_3}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_3}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_parts, __pyx_t_4); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_slice__2 = PySlice_New(Py_None, __pyx_int_2, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2);
+1095: parts.append(atob(array.array('B', guid.get("Data4")[2:8])))
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_atob); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_convert__to_py_GUID(__pyx_v_guid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_Data4); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_3, 2, 8, NULL, NULL, &__pyx_slice__4, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_n_s_B, __pyx_t_6}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_n_s_B, __pyx_t_6}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_n_s_B); __Pyx_GIVEREF(__pyx_n_s_B); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_10, __pyx_n_s_B); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_10, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_2) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_12}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_12}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_parts, __pyx_t_4); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_slice__4 = PySlice_New(__pyx_int_2, __pyx_int_8, Py_None); if (unlikely(!__pyx_slice__4)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__4); __Pyx_GIVEREF(__pyx_slice__4);
+1096: s = b"-".join(binascii.hexlify(b).upper() for b in parts)
static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7guidstr_genexpr(PyObject *__pyx_self) { struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_1_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_cur_scope = (struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_1_genexpr *)__pyx_tp_new_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_1_genexpr(__pyx_ptype_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_1_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1096, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr *) __pyx_self; __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4xpra_6codecs_5nvenc_7encoder_7guidstr_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_guidstr_locals_genexpr, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!gen)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.guidstr.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_4xpra_6codecs_5nvenc_7encoder_7guidstr_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1096, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_parts)) { __Pyx_RaiseClosureNameError("parts"); __PYX_ERR(0, 1096, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_parts == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1096, __pyx_L1_error) } __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_parts; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1096, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_b); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_b, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_binascii); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_hexlify); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_5) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_cur_scope->__pyx_v_b); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_b}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_b}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_b); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_b); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_cur_scope->__pyx_v_b); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_upper); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1096, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1096, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; __Pyx_Coroutine_ResetAndClearException(__pyx_generator); __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_4 = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7guidstr_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyBytes_Join(__pyx_kp_b__5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1); __pyx_t_1 = 0; /* … */ struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_1_genexpr { PyObject_HEAD struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct____pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr *__pyx_outer_scope; PyObject *__pyx_v_b; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; };
1097: #log.info("guidstr(%s)=%s", guid, s)
+1098: return bytestostr(s)
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_bytestostr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_7) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_s}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_s}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_s); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1099:
+1100: cdef GUID c_parseguid(src) except *:
static GUID __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(PyObject *__pyx_v_src) { PyObject *__pyx_v_sample_guid = NULL; int __pyx_v_i; int __pyx_v_s; PyObject *__pyx_v_c = NULL; PyObject *__pyx_v_parts = NULL; PyObject *__pyx_v_nparts = NULL; PyObject *__pyx_v_b = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_j = NULL; GUID __pyx_v_guid; GUID __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("c_parseguid", 0); __Pyx_INCREF(__pyx_v_src); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.c_parseguid", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_XDECREF(__pyx_v_sample_guid); __Pyx_XDECREF(__pyx_v_c); __Pyx_XDECREF(__pyx_v_parts); __Pyx_XDECREF(__pyx_v_nparts); __Pyx_XDECREF(__pyx_v_b); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_j); __Pyx_XDECREF(__pyx_v_src); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1101: #just as ugly as above - shoot me now
1102: #only this format is allowed:
+1103: sample_guid = "CE788D20-AAA9-4318-92BB-AC7E858C8D36"
__Pyx_INCREF(__pyx_kp_s_CE788D20_AAA9_4318_92BB_AC7E858C);
__pyx_v_sample_guid = __pyx_kp_s_CE788D20_AAA9_4318_92BB_AC7E858C;
+1104: if len(src)!=len(sample_guid):
__pyx_t_1 = PyObject_Length(__pyx_v_src); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1104, __pyx_L1_error) __pyx_t_2 = PyObject_Length(__pyx_v_sample_guid); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1104, __pyx_L1_error) __pyx_t_3 = ((__pyx_t_1 != __pyx_t_2) != 0); if (__pyx_t_3) { /* … */ }
+1105: raise Exception("invalid GUID format: expected %s characters but got %s" % (len(sample_guid), len(src)))
__pyx_t_2 = PyObject_Length(__pyx_v_sample_guid); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1105, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyObject_Length(__pyx_v_src); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1105, __pyx_L1_error) __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_invalid_GUID_format_expected_s_c, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 1105, __pyx_L1_error)
1106: cdef int i, s
+1107: src = bytestostr(src)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_bytestostr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_4) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_src); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_src}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1107, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_src}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1107, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_src); __Pyx_GIVEREF(__pyx_v_src); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_src); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_src, __pyx_t_5); __pyx_t_5 = 0;
+1108: for i in range(len(sample_guid)):
__pyx_t_2 = PyObject_Length(__pyx_v_sample_guid); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1108, __pyx_L1_error) for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_2; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+1109: if sample_guid[i]=="-":
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_sample_guid, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_kp_s__5, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1109, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L6; }
1110: #dash must be in the same place:
+1111: if src[i]!="-":
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_src, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_kp_s__5, Py_NE)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_3) { /* … */ }
+1112: raise Exception("invalid GUID format: character at position %s is not '-': %s" % (i, src[i]))
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_src, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_invalid_GUID_format_character_at, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1112, __pyx_L1_error)
1113: else:
1114: #must be an hex number:
+1115: c = src.upper()[i]
/*else*/ { __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_upper); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (__pyx_t_5) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1115, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1115, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_6, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_7); __pyx_t_7 = 0;
+1116: if c not in (u"0123456789ABCDEF"):
__pyx_t_3 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_c, __pyx_kp_u_0123456789ABCDEF, Py_NE)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1116, __pyx_L1_error) __pyx_t_9 = (__pyx_t_3 != 0); if (__pyx_t_9) { /* … */ } } __pyx_L6:; }
+1117: raise Exception("invalid GUID format: character at position %s is not in hex: %s" % (i, c))
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __Pyx_INCREF(__pyx_v_c); __Pyx_GIVEREF(__pyx_v_c); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_c); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_invalid_GUID_format_character_at_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 1117, __pyx_L1_error)
+1118: parts = src.split("-") #ie: ["CE788D20", "AAA9", ...]
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_split); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_parts = __pyx_t_6; __pyx_t_6 = 0; /* … */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s__5); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 1118, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6);
+1119: nparts = []
__pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_nparts = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0;
+1120: for i, s in (0, 4), (1, 2), (2, 2), (3, 2), (4, 6):
__pyx_tuple__7 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_4); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __pyx_tuple__8 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_2); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); __pyx_tuple__9 = PyTuple_Pack(2, __pyx_int_2, __pyx_int_2); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); __pyx_tuple__10 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_2); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); __pyx_tuple__11 = PyTuple_Pack(2, __pyx_int_4, __pyx_int_6); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); /* … */ __pyx_t_6 = __pyx_tuple__12; __Pyx_INCREF(__pyx_t_6); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= 5) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_7); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1120, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif if (likely(__pyx_t_7 != Py_None)) { PyObject* sequence = __pyx_t_7; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1120, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1120, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_i = __pyx_t_8; __pyx_v_s = __pyx_t_10; /* … */ } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_tuple__12 = PyTuple_Pack(5, __pyx_tuple__7, __pyx_tuple__8, __pyx_tuple__9, __pyx_tuple__10, __pyx_tuple__11); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 1120, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); /* … */ struct __pyx_ctuple_long__and_long { long f0; long f1; };
+1121: b = atob(array.array('B', binascii.unhexlify(parts[i])))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_atob); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_array); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_binascii); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_unhexlify); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_parts, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_15 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); } } if (!__pyx_t_15) { __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_14)) { PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_13}; __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) { PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_13}; __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL; __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_16, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_n_s_B, __pyx_t_11}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_n_s_B, __pyx_t_11}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_14) { __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __pyx_t_14 = NULL; } __Pyx_INCREF(__pyx_n_s_B); __Pyx_GIVEREF(__pyx_n_s_B); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_10, __pyx_n_s_B); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_10, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_12) { __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_7); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_5}; __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_5}; __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_16, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_b, __pyx_t_7); __pyx_t_7 = 0;
+1122: v = 0
__Pyx_INCREF(__pyx_int_0); __Pyx_XDECREF_SET(__pyx_v_v, __pyx_int_0);
+1123: for j in range(s):
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_4 = __pyx_t_7; __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0; __pyx_t_17 = NULL; } else { __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1123, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_17)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 1123, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 1123, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_17(__pyx_t_4); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1123, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_7); __pyx_t_7 = 0; /* … */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1124: c = b[j]
__pyx_t_7 = PyObject_GetItem(__pyx_v_b, __pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_7); __pyx_t_7 = 0;
+1125: if not PYTHON3:
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_PYTHON3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_3 = ((!__pyx_t_9) != 0); if (__pyx_t_3) { /* … */ }
+1126: c = ord(c)
__pyx_t_18 = __Pyx_PyObject_Ord(__pyx_v_c); if (unlikely(__pyx_t_18 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 1126, __pyx_L1_error) __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_t_18); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_c, __pyx_t_7); __pyx_t_7 = 0;
+1127: v += c<<((s-j-1)*8)
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_16 = PyNumber_Subtract(__pyx_t_7, __pyx_v_j); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_SubtractObjC(__pyx_t_16, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = PyNumber_Multiply(__pyx_t_7, __pyx_int_8); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Lshift(__pyx_v_c, __pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = PyNumber_InPlaceAdd(__pyx_v_v, __pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_16); __pyx_t_16 = 0;
+1128: nparts.append(v)
__pyx_t_19 = __Pyx_PyList_Append(__pyx_v_nparts, __pyx_v_v); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 1128, __pyx_L1_error)
1129: cdef GUID guid
+1130: guid.Data1 = nparts[0]
__pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_nparts, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_20 = __Pyx_PyInt_As_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_20 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1130, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_guid.Data1 = __pyx_t_20;
+1131: guid.Data2 = nparts[1]
__pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_nparts, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_21 = __Pyx_PyInt_As_uint16_t(__pyx_t_6); if (unlikely((__pyx_t_21 == ((uint16_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1131, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_guid.Data2 = __pyx_t_21;
+1132: guid.Data3 = nparts[2]
__pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_nparts, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_21 = __Pyx_PyInt_As_uint16_t(__pyx_t_6); if (unlikely((__pyx_t_21 == ((uint16_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1132, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_guid.Data3 = __pyx_t_21;
+1133: v = (nparts[3]<<48) + nparts[4]
__pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_nparts, 3, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyInt_LshiftObjC(__pyx_t_6, __pyx_int_48, 48, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_nparts, 4, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_16 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_16); __pyx_t_16 = 0;
+1134: for i in range(8):
for (__pyx_t_10 = 0; __pyx_t_10 < 8; __pyx_t_10+=1) { __pyx_v_i = __pyx_t_10;
+1135: guid.Data4[i] = (v>>((7-i)*8)) % 256
__pyx_t_16 = __Pyx_PyInt_From_long(((7 - __pyx_v_i) * 8)); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_6 = PyNumber_Rshift(__pyx_v_v, __pyx_t_16); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyInt_RemainderObjC(__pyx_t_6, __pyx_int_256, 0x100, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_22 = __Pyx_PyInt_As_uint8_t(__pyx_t_16); if (unlikely((__pyx_t_22 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1135, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; (__pyx_v_guid.Data4[__pyx_v_i]) = __pyx_t_22; }
+1136: return guid
__pyx_r = __pyx_v_guid; goto __pyx_L0;
1137:
+1138: def parseguid(s):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_5parseguid(PyObject *__pyx_self, PyObject *__pyx_v_s); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_5parseguid = {"parseguid", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_5parseguid, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_5parseguid(PyObject *__pyx_self, PyObject *__pyx_v_s) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("parseguid (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_4parseguid(__pyx_self, ((PyObject *)__pyx_v_s)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_4parseguid(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("parseguid", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.parseguid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__57 = PyTuple_Pack(1, __pyx_n_s_s); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1138, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__57); __Pyx_GIVEREF(__pyx_tuple__57); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_5parseguid, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parseguid, __pyx_t_2) < 0) __PYX_ERR(0, 1138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_parseguid, 1138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 1138, __pyx_L1_error)
+1139: return c_parseguid(s)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_v_s); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1139, __pyx_L1_error) __pyx_t_2 = __pyx_convert__to_py_GUID(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
1140:
+1141: def test_parse():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7test_parse(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_7test_parse = {"test_parse", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7test_parse, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7test_parse(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("test_parse (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_6test_parse(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_6test_parse(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_v_sample_guid = NULL; GUID __pyx_v_x; PyObject *__pyx_v_v = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("test_parse", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.test_parse", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_sample_guid); __Pyx_XDECREF(__pyx_v_v); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__59 = PyTuple_Pack(3, __pyx_n_s_sample_guid, __pyx_n_s_x_2, __pyx_n_s_v); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1141, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__59); __Pyx_GIVEREF(__pyx_tuple__59); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_7test_parse, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_parse, __pyx_t_2) < 0) __PYX_ERR(0, 1141, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_test_parse, 1141, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 1141, __pyx_L1_error)
+1142: sample_guid = u"CE788D20-AAA9-4318-92BB-AC7E858C8D36"
__Pyx_INCREF(__pyx_kp_u_CE788D20_AAA9_4318_92BB_AC7E858C);
__pyx_v_sample_guid = __pyx_kp_u_CE788D20_AAA9_4318_92BB_AC7E858C;
+1143: x = c_parseguid(sample_guid)
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_v_sample_guid); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1143, __pyx_L1_error)
__pyx_v_x = __pyx_t_1;
+1144: v = guidstr(x)
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_v = __pyx_t_2; __pyx_t_2 = 0;
+1145: assert v==sample_guid, "expected %s but got %s" % (sample_guid, v)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_v, __pyx_v_sample_guid, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1145, __pyx_L1_error) if (unlikely(!__pyx_t_3)) { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_sample_guid); __Pyx_GIVEREF(__pyx_v_sample_guid); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_sample_guid); __Pyx_INCREF(__pyx_v_v); __Pyx_GIVEREF(__pyx_v_v); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_v); __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_expected_s_but_got_s, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1145, __pyx_L1_error) } } #endif
+1146: test_parse()
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_test_parse); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_5) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1147:
1148:
1149: cdef GUID CLIENT_KEY_GUID
+1150: memset(&CLIENT_KEY_GUID, 0, sizeof(GUID))
memset((&__pyx_v_4xpra_6codecs_5nvenc_7encoder_CLIENT_KEY_GUID), 0, (sizeof(GUID)));
+1151: if CLIENT_KEYS_STR:
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CLIENT_KEYS_STR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_8) { /* … */ }
1152: #if we have client keys, parse them and keep the ones that look valid
+1153: validated = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validated, __pyx_t_2) < 0) __PYX_ERR(0, 1153, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1154: for x in CLIENT_KEYS_STR:
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CLIENT_KEYS_STR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_9 = 0; __pyx_t_10 = NULL; } else { __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1154, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_6))) { if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1154, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1154, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1154, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } if (PyDict_SetItem(__pyx_d, __pyx_n_s_x_2, __pyx_t_2) < 0) __PYX_ERR(0, 1154, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1155: if x:
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_x_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1155, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_8) { /* … */ }
+1156: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L13_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L1_error; __pyx_L7_exception_handled:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); __pyx_L13_try_end:; }
+1157: CLIENT_KEY_GUID = c_parseguid(x)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_x_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1157, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1157, __pyx_L6_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_4xpra_6codecs_5nvenc_7encoder_CLIENT_KEY_GUID = __pyx_t_14;
+1158: validated.append(x)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_validated); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_x_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1158, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_15 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_t_5); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1158, __pyx_L6_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1159: except Exception as e:
__pyx_t_7 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_7) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 1159, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_e, __pyx_t_2) < 0) __PYX_ERR(0, 1159, __pyx_L8_except_error)
+1160: log.error("invalid nvenc client key specified: '%s' (%s)", x, e)
__pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_x_2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_18 = __Pyx_GetModuleGlobalName(__pyx_n_s_e); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_17); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_17, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_17)) { PyObject *__pyx_temp[4] = {__pyx_t_19, __pyx_kp_s_invalid_nvenc_client_key_specifi, __pyx_t_16, __pyx_t_18}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) { PyObject *__pyx_temp[4] = {__pyx_t_19, __pyx_kp_s_invalid_nvenc_client_key_specifi, __pyx_t_16, __pyx_t_18}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } else #endif { __pyx_t_20 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_20); if (__pyx_t_19) { __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19); __pyx_t_19 = NULL; } __Pyx_INCREF(__pyx_kp_s_invalid_nvenc_client_key_specifi); __Pyx_GIVEREF(__pyx_kp_s_invalid_nvenc_client_key_specifi); PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_7, __pyx_kp_s_invalid_nvenc_client_key_specifi); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_7, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_7, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_18 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_20, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1160, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; } __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1161: del e
if (__Pyx_PyObject_DelAttrStr(__pyx_m, __pyx_n_s_e) < 0) __PYX_ERR(0, 1161, __pyx_L8_except_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L7_exception_handled; } goto __pyx_L8_except_error; __pyx_L8_except_error:;
+1162: CLIENT_KEYS_STR = validated
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_validated); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_CLIENT_KEYS_STR, __pyx_t_6) < 0) __PYX_ERR(0, 1162, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1163:
1164: CODEC_GUIDS = {
+1165: guidstr(NV_ENC_CODEC_H264_GUID) : "H264",
__pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_CODEC_H264_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_H264) < 0) __PYX_ERR(0, 1165, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1166: guidstr(NV_ENC_CODEC_HEVC_GUID) : "HEVC",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_CODEC_HEVC_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_HEVC) < 0) __PYX_ERR(0, 1165, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CODEC_GUIDS, __pyx_t_6) < 0) __PYX_ERR(0, 1164, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1167: }
1168:
+1169: cdef codecstr(GUID guid):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(GUID __pyx_v_guid) { PyObject *__pyx_v_s = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("codecstr", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.codecstr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1170: s = guidstr(guid)
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_guid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_s = __pyx_t_1; __pyx_t_1 = 0;
+1171: return CODEC_GUIDS.get(s, s)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CODEC_GUIDS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_s, __pyx_v_s}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_s, __pyx_v_s}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_s); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_s); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1172:
1173:
1174: CODEC_PROFILES_GUIDS = {
+1175: guidstr(NV_ENC_CODEC_H264_GUID) : {
__pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_CODEC_H264_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3);
+1176: guidstr(NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID) : "auto",
__pyx_t_2 = __Pyx_PyDict_NewPresized(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_n_s_auto) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1177: guidstr(NV_ENC_H264_PROFILE_BASELINE_GUID) : "baseline",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_BASELINE_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1177, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_n_s_baseline) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1178: guidstr(NV_ENC_H264_PROFILE_MAIN_GUID) : "main",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_MAIN_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_n_s_main_2) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1179: guidstr(NV_ENC_H264_PROFILE_HIGH_GUID) : "high",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_HIGH_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_n_s_high) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1180: guidstr(NV_ENC_H264_PROFILE_STEREO_GUID) : "stereo",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_STEREO_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_n_s_stereo) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1181: guidstr(NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY): "temporal",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_n_s_temporal) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1182: guidstr(NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID) : "progressive-high",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_kp_s_progressive_high) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1183: guidstr(NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID) : "constrained-high",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_kp_s_constrained_high) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1184: #new in SDK v4:
+1185: guidstr(NV_ENC_H264_PROFILE_HIGH_444_GUID) : "high-444",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_H264_PROFILE_HIGH_444_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_2, __pyx_t_5, __pyx_kp_s_high_444) < 0) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 1175, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1186: },
+1187: guidstr(NV_ENC_CODEC_HEVC_GUID) : {
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_CODEC_HEVC_GUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+1188: guidstr(NV_ENC_HEVC_PROFILE_MAIN_GUID) : "main",
__pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_HEVC_PROFILE_MAIN_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_3, __pyx_t_5, __pyx_n_s_main_2) < 0) __PYX_ERR(0, 1188, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1189: guidstr(NV_ENC_HEVC_PROFILE_MAIN10_GUID) : "main10",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_HEVC_PROFILE_MAIN10_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_3, __pyx_t_5, __pyx_n_s_main10) < 0) __PYX_ERR(0, 1188, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1190: guidstr(NV_ENC_HEVC_PROFILE_FREXT_GUID) : "frext",
__pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_HEVC_PROFILE_FREXT_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_3, __pyx_t_5, __pyx_n_s_frext) < 0) __PYX_ERR(0, 1188, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 1175, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CODEC_PROFILES_GUIDS, __pyx_t_6) < 0) __PYX_ERR(0, 1174, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1191: },
1192: }
1193:
1194: #this one is not defined anywhere but in the OBS source
1195: #(I think they have access to information we do not have):
1196: #GUID NV_ENC_PRESET_STREAMING = c_parseguid("7ADD423D-D035-4F6F-AEA5-50885658643C")
1197:
1198: CODEC_PRESETS_GUIDS = {
+1199: guidstr(NV_ENC_PRESET_DEFAULT_GUID) : "default",
__pyx_t_6 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_DEFAULT_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_default) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1200: guidstr(NV_ENC_PRESET_HP_GUID) : "hp",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_HP_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_hp) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1201: guidstr(NV_ENC_PRESET_HQ_GUID) : "hq",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_HQ_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_hq) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1202: guidstr(NV_ENC_PRESET_BD_GUID) : "bd",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_BD_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_bd) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1203: guidstr(NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID) : "low-latency",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_kp_s_low_latency) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1204: guidstr(NV_ENC_PRESET_LOW_LATENCY_HQ_GUID) : "low-latency-hq",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_LOW_LATENCY_HQ_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_kp_s_low_latency_hq) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1205: guidstr(NV_ENC_PRESET_LOW_LATENCY_HP_GUID) : "low-latency-hp",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_LOW_LATENCY_HP_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_kp_s_low_latency_hp) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1206: #new in SDK4:
+1207: guidstr(NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID) : "lossless",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_lossless) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1208: guidstr(NV_ENC_PRESET_LOSSLESS_HP_GUID) : "lossless-hp",
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(NV_ENC_PRESET_LOSSLESS_HP_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_kp_s_lossless_hp) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_7ADD423D_D035_4F6F_AEA5_50885658, __pyx_n_s_streaming) < 0) __PYX_ERR(0, 1199, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_CODEC_PRESETS_GUIDS, __pyx_t_6) < 0) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1209: "7ADD423D-D035-4F6F-AEA5-50885658643C" : "streaming",
1210: }
1211:
+1212: YUV444_PRESETS = ("high-444", "lossless", "lossless-hp",)
if (PyDict_SetItem(__pyx_d, __pyx_n_s_YUV444_PRESETS, __pyx_tuple__61) < 0) __PYX_ERR(0, 1212, __pyx_L1_error) /* … */ __pyx_tuple__61 = PyTuple_Pack(3, __pyx_kp_s_high_444, __pyx_n_s_lossless, __pyx_kp_s_lossless_hp); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 1212, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__61); __Pyx_GIVEREF(__pyx_tuple__61);
+1213: LOSSLESS_PRESETS = ("lossless", "lossless-hp",)
if (PyDict_SetItem(__pyx_d, __pyx_n_s_LOSSLESS_PRESETS, __pyx_tuple__62) < 0) __PYX_ERR(0, 1213, __pyx_L1_error) /* … */ __pyx_tuple__62 = PyTuple_Pack(2, __pyx_n_s_lossless, __pyx_kp_s_lossless_hp); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 1213, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__62); __Pyx_GIVEREF(__pyx_tuple__62);
1214:
+1215: cdef presetstr(GUID preset):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_presetstr(GUID __pyx_v_preset) { PyObject *__pyx_v_s = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("presetstr", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.presetstr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1216: s = guidstr(preset)
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_s = __pyx_t_1; __pyx_t_1 = 0;
+1217: return CODEC_PRESETS_GUIDS.get(s, s)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CODEC_PRESETS_GUIDS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_s, __pyx_v_s}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1217, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_s, __pyx_v_s}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1217, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_s); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_s); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1218:
1219:
1220: #try to map preset names to a "speed" value:
1221: PRESET_SPEED = {
+1222: "lossless" : 0,
__pyx_t_6 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_lossless, __pyx_int_0) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_lossless_hp, __pyx_int_30) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_bd, __pyx_int_40) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_hq, __pyx_int_50) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_default, __pyx_int_50) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_hp, __pyx_int_60) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_low_latency_hq, __pyx_int_70) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_low_latency, __pyx_int_80) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_low_latency_hp, __pyx_int_100) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_streaming, __pyx_int_neg_1000) < 0) __PYX_ERR(0, 1222, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_PRESET_SPEED, __pyx_t_6) < 0) __PYX_ERR(0, 1221, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1223: "lossless-hp" : 30,
1224: "bd" : 40,
1225: "hq" : 50,
1226: "default" : 50,
1227: "hp" : 60,
1228: "low-latency-hq": 70,
1229: "low-latency" : 80,
1230: "low-latency-hp": 100,
1231: "streaming" : -1000, #disabled for now
1232: }
1233: PRESET_QUALITY = {
+1234: "lossless" : 100,
__pyx_t_6 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_lossless, __pyx_int_100) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_lossless_hp, __pyx_int_100) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_bd, __pyx_int_80) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_hq, __pyx_int_70) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_low_latency_hq, __pyx_int_60) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_default, __pyx_int_50) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_hp, __pyx_int_40) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_low_latency, __pyx_int_20) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_kp_s_low_latency_hp, __pyx_int_0) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_streaming, __pyx_int_neg_1000) < 0) __PYX_ERR(0, 1234, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_PRESET_QUALITY, __pyx_t_6) < 0) __PYX_ERR(0, 1233, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1235: "lossless-hp" : 100,
1236: "bd" : 80,
1237: "hq" : 70,
1238: "low-latency-hq": 60,
1239: "default" : 50,
1240: "hp" : 40,
1241: "low-latency" : 20,
1242: "low-latency-hp": 0,
1243: "streaming" : -1000, #disabled for now
1244: }
1245:
1246:
1247:
1248: BUFFER_FORMAT = {
+1249: NV_ENC_BUFFER_FORMAT_UNDEFINED : "undefined",
__pyx_t_6 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_UNDEFINED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_undefined) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1250: NV_ENC_BUFFER_FORMAT_NV12 : "NV12_PL",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_NV12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_NV12_PL) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1251: NV_ENC_BUFFER_FORMAT_YV12 : "YV12_PL",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_YV12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_YV12_PL) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1252: NV_ENC_BUFFER_FORMAT_IYUV : "IYUV_PL",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_IYUV); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_IYUV_PL) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1253: NV_ENC_BUFFER_FORMAT_YUV444 : "YUV444_PL",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_YUV444); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_YUV444_PL) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1254: NV_ENC_BUFFER_FORMAT_YUV420_10BIT : "YUV420_10BIT",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_YUV420_10BIT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_YUV420_10BIT) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1255: NV_ENC_BUFFER_FORMAT_YUV444_10BIT : "YUV444_10BIT",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_YUV444_10BIT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_YUV444_10BIT) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1256: NV_ENC_BUFFER_FORMAT_ARGB : "ARGB",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_ARGB); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_ARGB) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1257: NV_ENC_BUFFER_FORMAT_ARGB10 : "ARGB10",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_ARGB10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_ARGB10) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1258: NV_ENC_BUFFER_FORMAT_AYUV : "AYUV",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_AYUV); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_AYUV) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1259: NV_ENC_BUFFER_FORMAT_ABGR : "ABGR",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_ABGR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_ABGR) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1260: NV_ENC_BUFFER_FORMAT_ABGR10 : "ABGR10",
__pyx_t_3 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(NV_ENC_BUFFER_FORMAT_ABGR10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_6, __pyx_t_3, __pyx_n_s_ABGR10) < 0) __PYX_ERR(0, 1249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_BUFFER_FORMAT, __pyx_t_6) < 0) __PYX_ERR(0, 1248, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1261: }
1262:
1263:
+1264: def get_COLORSPACES(encoding):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_9get_COLORSPACES(PyObject *__pyx_self, PyObject *__pyx_v_encoding); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_9get_COLORSPACES = {"get_COLORSPACES", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_9get_COLORSPACES, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_9get_COLORSPACES(PyObject *__pyx_self, PyObject *__pyx_v_encoding) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_COLORSPACES (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_8get_COLORSPACES(__pyx_self, ((PyObject *)__pyx_v_encoding)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_8get_COLORSPACES(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_encoding) { PyObject *__pyx_v_out_cs = NULL; PyObject *__pyx_v_COLORSPACES = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_COLORSPACES", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_COLORSPACES", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_out_cs); __Pyx_XDECREF(__pyx_v_COLORSPACES); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__63 = PyTuple_Pack(3, __pyx_n_s_encoding, __pyx_n_s_out_cs, __pyx_n_s_COLORSPACES); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__63); __Pyx_GIVEREF(__pyx_tuple__63); /* … */ __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_9get_COLORSPACES, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_COLORSPACES, __pyx_t_6) < 0) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_COLORSPACES, 1264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 1264, __pyx_L1_error)
1265: global YUV420_ENABLED, YUV444_ENABLED, YUV444_CODEC_SUPPORT
+1266: out_cs = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_out_cs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1267: if YUV420_ENABLED:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV420_ENABLED != 0); if (__pyx_t_2) { /* … */ }
+1268: out_cs.append("YUV420P")
__pyx_t_3 = __Pyx_PyList_Append(__pyx_v_out_cs, __pyx_n_s_YUV420P); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1268, __pyx_L1_error)
+1269: if YUV444_CODEC_SUPPORT.get(encoding.lower(), YUV444_ENABLED) or NATIVE_RGB:
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_encoding, __pyx_n_s_lower); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_7) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1269, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_t_6}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_t_6}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L5_bool_binop_done; } __pyx_t_10 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_NATIVE_RGB != 0); __pyx_t_2 = __pyx_t_10; __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1270: out_cs.append("YUV444P")
__pyx_t_3 = __Pyx_PyList_Append(__pyx_v_out_cs, __pyx_n_s_YUV444P); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1270, __pyx_L1_error)
1271: COLORSPACES = {
+1272: "BGRX" : out_cs,
__pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_BGRX, __pyx_v_out_cs) < 0) __PYX_ERR(0, 1272, __pyx_L1_error)
+1273: "BGRA" : out_cs,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_BGRA, __pyx_v_out_cs) < 0) __PYX_ERR(0, 1272, __pyx_L1_error)
+1274: "XRGB" : out_cs,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_XRGB, __pyx_v_out_cs) < 0) __PYX_ERR(0, 1272, __pyx_L1_error)
+1275: "ARGB" : out_cs,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ARGB, __pyx_v_out_cs) < 0) __PYX_ERR(0, 1272, __pyx_L1_error) __pyx_v_COLORSPACES = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1276: }
+1277: return COLORSPACES
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_COLORSPACES); __pyx_r = __pyx_v_COLORSPACES; goto __pyx_L0;
1278:
+1279: def get_input_colorspaces(encoding):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_11get_input_colorspaces(PyObject *__pyx_self, PyObject *__pyx_v_encoding); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_11get_input_colorspaces = {"get_input_colorspaces", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_11get_input_colorspaces, METH_O, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_11get_input_colorspaces(PyObject *__pyx_self, PyObject *__pyx_v_encoding) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_input_colorspaces (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_10get_input_colorspaces(__pyx_self, ((PyObject *)__pyx_v_encoding)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_10get_input_colorspaces(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_encoding) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_input_colorspaces", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_input_colorspaces", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__65 = PyTuple_Pack(1, __pyx_n_s_encoding); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 1279, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__65); __Pyx_GIVEREF(__pyx_tuple__65); /* … */ __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_11get_input_colorspaces, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_input_colorspaces, __pyx_t_6) < 0) __PYX_ERR(0, 1279, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_input_colorspaces, 1279, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 1279, __pyx_L1_error)
+1280: return list(get_COLORSPACES(encoding).keys())
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_COLORSPACES); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_encoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_encoding}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_encoding}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_encoding); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1280, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1281:
+1282: def get_output_colorspaces(encoding, input_colorspace):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_13get_output_colorspaces(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_13get_output_colorspaces = {"get_output_colorspaces", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_13get_output_colorspaces, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_13get_output_colorspaces(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_input_colorspace = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_output_colorspaces (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_encoding,&__pyx_n_s_input_colorspace,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoding)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input_colorspace)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_output_colorspaces", 1, 2, 2, 1); __PYX_ERR(0, 1282, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_output_colorspaces") < 0)) __PYX_ERR(0, 1282, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_encoding = values[0]; __pyx_v_input_colorspace = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_output_colorspaces", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1282, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_output_colorspaces", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_12get_output_colorspaces(__pyx_self, __pyx_v_encoding, __pyx_v_input_colorspace); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_12get_output_colorspaces(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_encoding, PyObject *__pyx_v_input_colorspace) { PyObject *__pyx_v_cs = NULL; PyObject *__pyx_v_out = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_output_colorspaces", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_output_colorspaces", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cs); __Pyx_XDECREF(__pyx_v_out); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__67 = PyTuple_Pack(4, __pyx_n_s_encoding, __pyx_n_s_input_colorspace, __pyx_n_s_cs, __pyx_n_s_out); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 1282, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__67); __Pyx_GIVEREF(__pyx_tuple__67); /* … */ __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_13get_output_colorspaces, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_output_colorspaces, __pyx_t_6) < 0) __PYX_ERR(0, 1282, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_output_colorspaces, 1282, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 1282, __pyx_L1_error)
+1283: cs = get_COLORSPACES(encoding)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_COLORSPACES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_encoding}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1283, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_encoding}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1283, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_encoding); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_cs = __pyx_t_1; __pyx_t_1 = 0;
+1284: out = cs.get(input_colorspace)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_cs, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_input_colorspace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_input_colorspace}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1284, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_input_colorspace}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1284, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_input_colorspace); __Pyx_GIVEREF(__pyx_v_input_colorspace); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_input_colorspace); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_out = __pyx_t_1; __pyx_t_1 = 0;
+1285: assert out, "invalid input colorspace %s for encoding %s (must be one of: %s)" % (input_colorspace, encoding, out)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_out); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1285, __pyx_L1_error) if (unlikely(!__pyx_t_5)) { __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_input_colorspace); __Pyx_GIVEREF(__pyx_v_input_colorspace); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_input_colorspace); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_encoding); __Pyx_INCREF(__pyx_v_out); __Pyx_GIVEREF(__pyx_v_out); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_out); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_input_colorspace_s_for_e, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1285, __pyx_L1_error) } } #endif
1286: #the output will actually be in one of those two formats once decoded
1287: #because internally that's what we convert to before encoding
1288: #(well, NV12... which is equivallent to YUV420P here...)
+1289: return out
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_out); __pyx_r = __pyx_v_out; goto __pyx_L0;
1290:
1291:
+1292: WIDTH_MASK = 0xFFFE
if (PyDict_SetItem(__pyx_d, __pyx_n_s_WIDTH_MASK, __pyx_int_65534) < 0) __PYX_ERR(0, 1292, __pyx_L1_error)
+1293: HEIGHT_MASK = 0xFFFE
if (PyDict_SetItem(__pyx_d, __pyx_n_s_HEIGHT_MASK, __pyx_int_65534) < 0) __PYX_ERR(0, 1293, __pyx_L1_error)
1294:
1295: #Note: these counters should be per-device, but
1296: #when we call get_runtime_factor(), we don't know which device is going to get used!
1297: #since we have load balancing, using an overall factor isn't too bad
+1298: context_counter = AtomicInteger()
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AtomicInteger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_2) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1298, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1298, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_context_counter, __pyx_t_6) < 0) __PYX_ERR(0, 1298, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1299: context_gen_counter = AtomicInteger()
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_AtomicInteger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_2) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1299, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_context_gen_counter, __pyx_t_6) < 0) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1300: cdef double last_context_failure = 0
__pyx_v_4xpra_6codecs_5nvenc_7encoder_last_context_failure = 0.0;
1301:
+1302: def get_runtime_factor():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_15get_runtime_factor(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_15get_runtime_factor = {"get_runtime_factor", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_15get_runtime_factor, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_15get_runtime_factor(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_runtime_factor (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_14get_runtime_factor(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_14get_runtime_factor(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_v_device_count = NULL; PyObject *__pyx_v_max_contexts = NULL; PyObject *__pyx_v_cc = NULL; PyObject *__pyx_v_low_limit = NULL; PyObject *__pyx_v_f = NULL; double __pyx_v_failure_elapsed; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_runtime_factor", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_runtime_factor", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_device_count); __Pyx_XDECREF(__pyx_v_max_contexts); __Pyx_XDECREF(__pyx_v_cc); __Pyx_XDECREF(__pyx_v_low_limit); __Pyx_XDECREF(__pyx_v_f); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__69 = PyTuple_Pack(6, __pyx_n_s_device_count, __pyx_n_s_max_contexts, __pyx_n_s_cc, __pyx_n_s_low_limit, __pyx_n_s_f, __pyx_n_s_failure_elapsed); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__69); __Pyx_GIVEREF(__pyx_tuple__69); /* … */ __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_15get_runtime_factor, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_runtime_factor, __pyx_t_6) < 0) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_runtime_factor, 1302, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 1302, __pyx_L1_error)
1303: global last_context_failure, context_counter
+1304: device_count = len(init_all_devices())
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_all_devices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_device_count = __pyx_t_1; __pyx_t_1 = 0;
+1305: max_contexts = 32 * device_count
__pyx_t_1 = PyNumber_Multiply(__pyx_int_32, __pyx_v_device_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_max_contexts = __pyx_t_1; __pyx_t_1 = 0;
+1306: cc = context_counter.get()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1306, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_cc = __pyx_t_1; __pyx_t_1 = 0;
1307: #try to avoid using too many contexts
1308: #(usually, we can have up to 32 contexts per card)
+1309: low_limit = 16
__Pyx_INCREF(__pyx_int_16);
__pyx_v_low_limit = __pyx_int_16;
+1310: f = max(0, 1.0 - (max(0, cc-low_limit)/max(1, max_contexts-low_limit)))
__pyx_t_1 = PyNumber_Subtract(__pyx_v_cc, __pyx_v_low_limit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_7) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; } else { __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Subtract(__pyx_v_max_contexts, __pyx_v_low_limit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = 1; __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_7) { __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = __pyx_t_1; } else { __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = __pyx_t_8; __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyFloat_SubtractCObj(__pyx_float_1_0, __pyx_t_1, 1.0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = PyObject_RichCompare(__pyx_t_6, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_7) { __Pyx_INCREF(__pyx_t_6); __pyx_t_1 = __pyx_t_6; } else { __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __pyx_t_8; __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_f = __pyx_t_6; __pyx_t_6 = 0;
1311: #if we have had errors recently, lower our chances further:
+1312: cdef double failure_elapsed = monotonic_time()-last_context_failure
__pyx_v_failure_elapsed = (__pyx_f_4xpra_14monotonic_time_monotonic_time() - __pyx_v_4xpra_6codecs_5nvenc_7encoder_last_context_failure);
1313: #discount factor gradually for 1 minute:
+1314: f /= 61-min(60, failure_elapsed)
__pyx_t_9 = __pyx_v_failure_elapsed; __pyx_t_5 = 60; if (((__pyx_t_9 < __pyx_t_5) != 0)) { __pyx_t_10 = __pyx_t_9; } else { __pyx_t_10 = __pyx_t_5; } __pyx_t_6 = PyFloat_FromDouble((61.0 - __pyx_t_10)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyNumber_InPlaceDivide(__pyx_v_f, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_f, __pyx_t_1); __pyx_t_1 = 0;
+1315: log("nvenc.get_runtime_factor()=%s", f)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_nvenc_get_runtime_factor_s, __pyx_v_f}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1315, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_nvenc_get_runtime_factor_s, __pyx_v_f}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1315, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvenc_get_runtime_factor_s); __Pyx_GIVEREF(__pyx_kp_s_nvenc_get_runtime_factor_s); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_kp_s_nvenc_get_runtime_factor_s); __Pyx_INCREF(__pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_f); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1316: return f
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_f); __pyx_r = __pyx_v_f; goto __pyx_L0;
1317:
1318:
+1319: MAX_SIZE = {}
__pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_SIZE, __pyx_t_6) < 0) __PYX_ERR(0, 1319, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1320:
+1321: def get_spec(encoding, colorspace):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_17get_spec(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_17get_spec = {"get_spec", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_17get_spec, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_17get_spec(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_colorspace = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_spec (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_encoding,&__pyx_n_s_colorspace,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoding)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_colorspace)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_spec", 1, 2, 2, 1); __PYX_ERR(0, 1321, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_spec") < 0)) __PYX_ERR(0, 1321, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_encoding = values[0]; __pyx_v_colorspace = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_spec", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1321, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_spec", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_16get_spec(__pyx_self, __pyx_v_encoding, __pyx_v_colorspace); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_16get_spec(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_encoding, PyObject *__pyx_v_colorspace) { long __pyx_v_min_w; long __pyx_v_min_h; PyObject *__pyx_v_max_w = NULL; PyObject *__pyx_v_max_h = NULL; PyObject *__pyx_v_has_lossless_mode = NULL; PyObject *__pyx_v_cs = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_spec", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_spec", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_max_w); __Pyx_XDECREF(__pyx_v_max_h); __Pyx_XDECREF(__pyx_v_has_lossless_mode); __Pyx_XDECREF(__pyx_v_cs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__71 = PyTuple_Pack(8, __pyx_n_s_encoding, __pyx_n_s_colorspace, __pyx_n_s_min_w, __pyx_n_s_min_h, __pyx_n_s_max_w, __pyx_n_s_max_h, __pyx_n_s_has_lossless_mode, __pyx_n_s_cs); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 1321, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__71); __Pyx_GIVEREF(__pyx_tuple__71); /* … */ __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_17get_spec, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_spec, __pyx_t_6) < 0) __PYX_ERR(0, 1321, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_spec, 1321, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 1321, __pyx_L1_error)
+1322: assert encoding in get_encodings(), "invalid format: %s (must be one of %s" % (encoding, get_encodings())
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_encodings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_encoding, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_4 != 0))) { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_encodings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_invalid_format_s_must_be_one_of, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1322, __pyx_L1_error) } } #endif
+1323: assert colorspace in get_COLORSPACES(encoding), "invalid colorspace: %s (must be one of %s)" % (colorspace, get_COLORSPACES(encoding))
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_COLORSPACES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_encoding}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_encoding}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_encoding); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_colorspace, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_4 != 0))) { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_COLORSPACES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_encoding}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_encoding}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_encoding); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_colorspace); __Pyx_GIVEREF(__pyx_v_colorspace); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_colorspace); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_invalid_colorspace_s_must_be_one, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1323, __pyx_L1_error) } } #endif
1324: #ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h
1325: #undocumented and found the hard way, see:
1326: #https://www.xpra.org/trac/ticket/1046#comment:6
1327: #https://xpra.org/trac/ticket/1550#comment:13
+1328: min_w, min_h = 128, 128
__pyx_t_6 = 0x80; __pyx_t_7 = 0x80; __pyx_v_min_w = __pyx_t_6; __pyx_v_min_h = __pyx_t_7;
1329: #FIXME: we should probe this using WIDTH_MAX, HEIGHT_MAX!
1330: global MAX_SIZE
+1331: max_w, max_h = MAX_SIZE.get(encoding, (4096, 4096))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_MAX_SIZE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_encoding, __pyx_tuple__13}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_encoding, __pyx_tuple__13}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_v_encoding); __Pyx_INCREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_tuple__13); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1331, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_5 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_2), 2) < 0) __PYX_ERR(0, 1331, __pyx_L1_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1331, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_v_max_w = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_max_h = __pyx_t_5; __pyx_t_5 = 0; /* … */ __pyx_tuple__13 = PyTuple_Pack(2, __pyx_int_4096, __pyx_int_4096); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13);
+1332: has_lossless_mode = colorspace in ("XRGB", "ARGB", "BGRX", "BGRA" ) and encoding=="h264"
__Pyx_INCREF(__pyx_v_colorspace); __pyx_t_5 = __pyx_v_colorspace; __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_XRGB, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1332, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_4 = __pyx_t_10; goto __pyx_L7_bool_binop_done; } __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_ARGB, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1332, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_4 = __pyx_t_10; goto __pyx_L7_bool_binop_done; } __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_BGRX, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1332, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_4 = __pyx_t_10; goto __pyx_L7_bool_binop_done; } __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_BGRA, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1332, __pyx_L1_error) __pyx_t_4 = __pyx_t_10; __pyx_L7_bool_binop_done:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __pyx_t_4; if (__pyx_t_10) { } else { __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L5_bool_binop_done; } __pyx_t_5 = PyObject_RichCompare(__pyx_v_encoding, __pyx_n_s_h264, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1332, __pyx_L1_error) __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = __pyx_t_5; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_L5_bool_binop_done:; __pyx_v_has_lossless_mode = __pyx_t_1; __pyx_t_1 = 0;
+1333: cs = video_spec(encoding=encoding, output_colorspaces=get_COLORSPACES(encoding)[colorspace], has_lossless_mode=LOSSLESS_CODEC_SUPPORT.get(encoding, LOSSLESS_ENABLED),
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_video_spec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyDict_NewPresized(17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_encoding, __pyx_v_encoding) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_COLORSPACES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_11) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_encoding}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_encoding}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_encoding); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(__pyx_t_3, __pyx_v_colorspace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_output_colorspaces, __pyx_t_2) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LOSSLESS_CODEC_SUPPORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_encoding, __pyx_t_3}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_encoding, __pyx_t_3}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_13 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_8, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_8, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_has_lossless_mode, __pyx_t_2) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_cs = __pyx_t_12; __pyx_t_12 = 0;
+1334: codec_class=Encoder, codec_type=get_type(),
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_codec_class, ((PyObject *)__pyx_ptype_4xpra_6codecs_5nvenc_7encoder_Encoder)) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (__pyx_t_13) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1334, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1334, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_codec_type, __pyx_t_2) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1335: quality=60+has_lossless_mode*40, speed=100, setup_cost=80, cpu_cost=10, gpu_cost=100,
__pyx_t_2 = PyNumber_Multiply(__pyx_v_has_lossless_mode, __pyx_int_40); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = __Pyx_PyInt_AddCObj(__pyx_int_60, __pyx_t_2, 60, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_quality, __pyx_t_12) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_speed, __pyx_int_100) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_setup_cost, __pyx_int_80) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_cpu_cost, __pyx_int_10) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_gpu_cost, __pyx_int_100) < 0) __PYX_ERR(0, 1333, __pyx_L1_error)
1336: #using a hardware encoder for something this small is silly:
+1337: min_w=min_w, min_h=min_h,
__pyx_t_12 = __Pyx_PyInt_From_long(__pyx_v_min_w); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_min_w, __pyx_t_12) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyInt_From_long(__pyx_v_min_h); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_min_h, __pyx_t_12) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1338: max_w=max_w, max_h=max_h,
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_max_w, __pyx_v_max_w) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_max_h, __pyx_v_max_h) < 0) __PYX_ERR(0, 1333, __pyx_L1_error)
+1339: can_scale=True,
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_can_scale, Py_True) < 0) __PYX_ERR(0, 1333, __pyx_L1_error)
+1340: width_mask=WIDTH_MASK, height_mask=HEIGHT_MASK)
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_WIDTH_MASK); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_width_mask, __pyx_t_12) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_HEIGHT_MASK); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_height_mask, __pyx_t_12) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1341: cs.get_runtime_factor = get_runtime_factor
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_runtime_factor); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__Pyx_PyObject_SetAttrStr(__pyx_v_cs, __pyx_n_s_get_runtime_factor, __pyx_t_12) < 0) __PYX_ERR(0, 1341, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1342: return cs
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_cs); __pyx_r = __pyx_v_cs; goto __pyx_L0;
1343:
1344: #ie: NVENCAPI_VERSION=0x30 -> PRETTY_VERSION = [3, 0]
+1345: PRETTY_VERSION = [int(NVENCAPI_MAJOR_VERSION), int(NVENCAPI_MINOR_VERSION)]
__pyx_t_6 = __Pyx_PyInt_From_unsigned_int(NVENCAPI_MAJOR_VERSION); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(NVENCAPI_MINOR_VERSION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __pyx_t_6 = 0; __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_PRETTY_VERSION, __pyx_t_2) < 0) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1346:
+1347: def get_version():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_19get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_19get_version = {"get_version", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_19get_version, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_19get_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_version (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_18get_version(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_4xpra_6codecs_5nvenc_7encoder_11get_version_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_18get_version(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_version", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_version", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__73 = PyTuple_Pack(2, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1347, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__73); __Pyx_GIVEREF(__pyx_tuple__73); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_19get_version, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_version, __pyx_t_2) < 0) __PYX_ERR(0, 1347, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_version, 1347, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 1347, __pyx_L1_error)
+1348: return ".".join((str(x) for x in PRETTY_VERSION))
static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_11get_version_genexpr(CYTHON_UNUSED PyObject *__pyx_self) { struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_2_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_cur_scope = (struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_2_genexpr *)__pyx_tp_new_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_2_genexpr(__pyx_ptype_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_2_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1348, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4xpra_6codecs_5nvenc_7encoder_11get_version_2generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_get_version_locals_genexpr, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!gen)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_version.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_4xpra_6codecs_5nvenc_7encoder_11get_version_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1348, __pyx_L1_error) __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRETTY_VERSION); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1348, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 1348, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 1348, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1348, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_x); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_x, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_x); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_x); __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; __Pyx_XGIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; __pyx_cur_scope->__pyx_t_1 = __pyx_t_3; __pyx_cur_scope->__pyx_t_2 = __pyx_t_4; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L6_resume_from_yield:; __pyx_t_2 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_2); __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; __pyx_t_4 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1348, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; __Pyx_Coroutine_ResetAndClearException(__pyx_generator); __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_11get_version_genexpr(NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__14, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* … */ struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder___pyx_scope_struct_2_genexpr { PyObject_HEAD PyObject *__pyx_v_x; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
1349:
+1350: def get_type():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_21get_type(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_21get_type = {"get_type", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_21get_type, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_21get_type(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_type (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_20get_type(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_20get_type(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_type", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_21get_type, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_type, __pyx_t_2) < 0) __PYX_ERR(0, 1350, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_type, 1350, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(0, 1350, __pyx_L1_error)
+1351: return "nvenc"
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_nvenc); __pyx_r = __pyx_n_s_nvenc; goto __pyx_L0;
1352:
+1353: def get_info():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_23get_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_23get_info = {"get_info", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_23get_info, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_23get_info(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_info (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_22get_info(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_22get_info(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_v_info = NULL; PyObject *__pyx_v_cards = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_python_platform = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_info", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_info); __Pyx_XDECREF(__pyx_v_cards); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_python_platform); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__76 = PyTuple_Pack(4, __pyx_n_s_info, __pyx_n_s_cards, __pyx_n_s_v, __pyx_n_s_python_platform); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1353, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__76); __Pyx_GIVEREF(__pyx_tuple__76); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_23get_info, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_info, __pyx_t_2) < 0) __PYX_ERR(0, 1353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__77 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__76, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_info, 1353, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__77)) __PYX_ERR(0, 1353, __pyx_L1_error)
1354: global last_context_failure, context_counter, context_gen_counter
1355: info = {
+1356: "version" : PRETTY_VERSION,
__pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRETTY_VERSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_version, __pyx_t_2) < 0) __PYX_ERR(0, 1356, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1357: "device_count" : len(get_devices() or []),
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_devices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1357, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1357, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1357, __pyx_L1_error) if (!__pyx_t_6) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L3_bool_binop_done; } __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_L3_bool_binop_done:; __pyx_t_7 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1357, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_device_count, __pyx_t_2) < 0) __PYX_ERR(0, 1356, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1358: "context_count" : context_counter.get(),
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_3) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1358, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1358, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_context_count, __pyx_t_2) < 0) __PYX_ERR(0, 1356, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1359: "generation" : context_gen_counter.get(),
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_gen_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1359, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1359, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_generation, __pyx_t_2) < 0) __PYX_ERR(0, 1356, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_info = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1360: }
+1361: cards = get_cards()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_cards); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1361, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1361, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_cards = __pyx_t_1; __pyx_t_1 = 0;
+1362: if cards:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_cards); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1362, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+1363: info["cards"] = cards
if (unlikely(PyDict_SetItem(__pyx_v_info, __pyx_n_s_cards, __pyx_v_cards) < 0)) __PYX_ERR(0, 1363, __pyx_L1_error)
1364: #only show the version if we have it already (don't probe now)
+1365: v = get_nvidia_module_version(False)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_nvidia_module_version); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_v = __pyx_t_2; __pyx_t_2 = 0; /* … */ __pyx_tuple__15 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1365, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15);
+1366: if v:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1366, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+1367: info["kernel_module_version"] = v
if (unlikely(PyDict_SetItem(__pyx_v_info, __pyx_n_s_kernel_module_version, __pyx_v_v) < 0)) __PYX_ERR(0, 1367, __pyx_L1_error)
+1368: if LINUX:
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LINUX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1368, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ }
+1369: from xpra.scripts.config import python_platform
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_python_platform); __Pyx_GIVEREF(__pyx_n_s_python_platform); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_python_platform); __pyx_t_1 = __Pyx_Import(__pyx_n_s_xpra_scripts_config, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_python_platform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __pyx_v_python_platform = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1370: info["kernel_version"] = python_platform.uname()[2]
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_python_platform, __pyx_n_s_uname); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1370, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1370, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(PyDict_SetItem(__pyx_v_info, __pyx_n_s_kernel_version, __pyx_t_2) < 0)) __PYX_ERR(0, 1370, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1371: if last_context_failure>0:
__pyx_t_6 = ((__pyx_v_4xpra_6codecs_5nvenc_7encoder_last_context_failure > 0.0) != 0); if (__pyx_t_6) { /* … */ }
+1372: info["last_failure"] = int(monotonic_time()-last_context_failure)
__pyx_t_2 = __Pyx_PyInt_FromDouble((__pyx_f_4xpra_14monotonic_time_monotonic_time() - __pyx_v_4xpra_6codecs_5nvenc_7encoder_last_context_failure)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyDict_SetItem(__pyx_v_info, __pyx_n_s_last_failure, __pyx_t_2) < 0)) __PYX_ERR(0, 1372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1373: return info
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_info); __pyx_r = __pyx_v_info; goto __pyx_L0;
1374:
1375:
+1376: ENCODINGS = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ENCODINGS, __pyx_t_2) < 0) __PYX_ERR(0, 1376, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1377: def get_encodings():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_25get_encodings(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_25get_encodings = {"get_encodings", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_25get_encodings, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_25get_encodings(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_encodings (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_24get_encodings(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_24get_encodings(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_encodings", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.get_encodings", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_25get_encodings, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_encodings, __pyx_t_2) < 0) __PYX_ERR(0, 1377, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_get_encodings, 1377, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 1377, __pyx_L1_error)
1378: global ENCODINGS
+1379: return ENCODINGS
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ENCODINGS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1380:
+1381: cdef inline int roundup(int n, int m):
static CYTHON_INLINE int __pyx_f_4xpra_6codecs_5nvenc_7encoder_roundup(int __pyx_v_n, int __pyx_v_m) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("roundup", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1382: return (n + m - 1) & ~(m - 1)
__pyx_r = (((__pyx_v_n + __pyx_v_m) - 1) & (~(__pyx_v_m - 1))); goto __pyx_L0;
1383:
1384:
+1385: cdef uintptr_t cmalloc(size_t size, what) except 0:
static uintptr_t __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc(size_t __pyx_v_size, PyObject *__pyx_v_what) { void *__pyx_v_ptr; uintptr_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cmalloc", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.cmalloc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1386: cdef void *ptr = malloc(size)
__pyx_v_ptr = malloc(__pyx_v_size);
+1387: if ptr==NULL:
__pyx_t_1 = ((__pyx_v_ptr == NULL) != 0); if (__pyx_t_1) { /* … */ }
+1388: raise Exception("failed to allocate %i bytes of memory for %s" % (size, what))
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_INCREF(__pyx_v_what); __Pyx_GIVEREF(__pyx_v_what); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_what); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_allocate_i_bytes_of_me, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1388, __pyx_L1_error)
+1389: return <uintptr_t> ptr
__pyx_r = ((uintptr_t)__pyx_v_ptr); goto __pyx_L0;
1390:
+1391: cdef nvencStatusInfo(NVENCSTATUS ret):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_nvencStatusInfo(NVENCSTATUS __pyx_v_ret) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("nvencStatusInfo", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.nvencStatusInfo", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1392: if ret in NV_ENC_STATUS_TXT:
__pyx_t_1 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1392, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NV_ENC_STATUS_TXT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1392, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1392, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* … */ }
+1393: return "%s: %s" % (ret, NV_ENC_STATUS_TXT[ret])
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NV_ENC_STATUS_TXT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_ret, NVENCSTATUS, 1, __Pyx_PyInt_From_NVENCSTATUS, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
+1394: return str(ret)
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_ret); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1395:
+1396: class NVENCException(Exception):
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_Py3MetaclassPrepare(__pyx_t_3, __pyx_t_2, __pyx_n_s_NVENCException, __pyx_n_s_NVENCException, (PyObject *) NULL, __pyx_n_s_xpra_codecs_nvenc_encoder, (PyObject *) NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); /* … */ __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_3, __pyx_n_s_NVENCException, __pyx_t_2, __pyx_t_6, NULL, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NVENCException, __pyx_t_5) < 0) __PYX_ERR(0, 1396, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1397: def __init__(self, code, fn):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_14NVENCException_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_14NVENCException_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_14NVENCException_1__init__, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_14NVENCException_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_code = 0; PyObject *__pyx_v_fn = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_code,&__pyx_n_s_fn,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_code)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 1397, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fn)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 1397, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1397, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_self = values[0]; __pyx_v_code = values[1]; __pyx_v_fn = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1397, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.NVENCException.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_14NVENCException___init__(__pyx_self, __pyx_v_self, __pyx_v_code, __pyx_v_fn); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_14NVENCException___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_code, PyObject *__pyx_v_fn) { PyObject *__pyx_v_msg = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.NVENCException.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__79 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_code, __pyx_n_s_fn, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1397, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__79); __Pyx_GIVEREF(__pyx_tuple__79); /* … */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_14NVENCException_1__init__, 0, __pyx_n_s_NVENCException___init, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder, __pyx_d, ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyObject_SetItem(__pyx_t_6, __pyx_n_s_init, __pyx_t_5) < 0) __PYX_ERR(0, 1397, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_init, 1397, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 1397, __pyx_L1_error)
+1398: self.function = fn
if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_function, __pyx_v_fn) < 0) __PYX_ERR(0, 1398, __pyx_L1_error)
+1399: self.code = code
if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_code, __pyx_v_code) < 0) __PYX_ERR(0, 1399, __pyx_L1_error)
+1400: msg = "%s - returned %s" % (fn, nvencStatusInfo(code))
__pyx_t_1 = __Pyx_PyInt_As_NVENCSTATUS(__pyx_v_code); if (unlikely((__pyx_t_1 == ((NVENCSTATUS)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1400, __pyx_L1_error) __pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_nvencStatusInfo(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_fn); __Pyx_GIVEREF(__pyx_v_fn); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fn); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_returned_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+1401: Exception.__init__(self, msg)
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_self); __Pyx_GIVEREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_self); __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_msg); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1402:
+1403: cdef inline raiseNVENC(NVENCSTATUS ret, msg):
static CYTHON_INLINE PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(NVENCSTATUS __pyx_v_ret, PyObject *__pyx_v_msg) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("raiseNVENC", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.raiseNVENC", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1404: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+1405: log("raiseNVENC(%i, %s)", ret, msg)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_ret); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_raiseNVENC_i_s, __pyx_t_4, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_raiseNVENC_i_s, __pyx_t_4, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_raiseNVENC_i_s); __Pyx_GIVEREF(__pyx_kp_s_raiseNVENC_i_s); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_raiseNVENC_i_s); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_msg); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1406: if ret!=0:
__pyx_t_1 = ((__pyx_v_ret != 0) != 0); if (__pyx_t_1) { /* … */ }
+1407: raise NVENCException(ret, msg)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_NVENCException); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_ret); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_msg); __pyx_t_7 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1407, __pyx_L1_error)
1408:
1409:
+1410: cdef class Encoder:
struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder { PyObject_HEAD struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_vtab; unsigned int width; unsigned int height; unsigned int input_width; unsigned int input_height; unsigned int encoder_width; unsigned int encoder_height; unsigned int b_frames; PyObject *encoding; PyObject *src_format; PyObject *dst_formats; PyObject *scaling; int speed; int quality; uint32_t target_bitrate; uint32_t max_bitrate; PyObject *driver; int cuda_device_id; PyObject *cuda_info; PyObject *pycuda_info; PyObject *cuda_device_info; PyObject *cuda_device; PyObject *cuda_context; void *cuda_context_ptr; PyObject *kernel; PyObject *kernel_name; PyObject *max_block_sizes; PyObject *max_grid_sizes; unsigned long max_threads_per_block; uint64_t free_memory; uint64_t total_memory; NV_ENCODE_API_FUNCTION_LIST *functionList; void *context; GUID codec; NV_ENC_REGISTERED_PTR inputHandle; PyObject *inputBuffer; PyObject *cudaInputBuffer; PyObject *cudaOutputBuffer; unsigned int inputPitch; unsigned int outputPitch; void *bitstreamBuffer; NV_ENC_BUFFER_FORMAT bufferFmt; PyObject *codec_name; PyObject *preset_name; PyObject *pixel_format; uint8_t lossless; double time; uint64_t first_frame_timestamp; unsigned long frames; unsigned long index; PyObject *last_frame_times; uint64_t bytes_in; uint64_t bytes_out; PyObject *__weakref__; }; /* … */ struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder { GUID (*init_codec)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *); GUID (*get_codec)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *); GUID (*get_preset)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, GUID); PyObject *(*init_cuda_kernel)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *); PyObject *(*dump_caps)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, PyObject *, GUID); PyObject *(*init_params)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, GUID, NV_ENC_INITIALIZE_PARAMS *); PyObject *(*cuda_clean)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *); PyObject *(*flushEncoder)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *); PyObject *(*do_compress_image)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, PyObject *, struct __pyx_opt_args_4xpra_6codecs_5nvenc_7encoder_7Encoder_do_compress_image *__pyx_optional_args); unsigned int (*copy_image)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, PyObject *, PyObject *, unsigned int, int); PyObject *(*exec_kernel)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, unsigned int, unsigned int, unsigned int); NV_ENC_INPUT_PTR (*map_input_resource)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *); PyObject *(*unmap_input_resource)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, NV_ENC_INPUT_PTR); PyObject *(*nvenc_compress)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, int, NV_ENC_INPUT_PTR, struct __pyx_opt_args_4xpra_6codecs_5nvenc_7encoder_7Encoder_nvenc_compress *__pyx_optional_args); NV_ENC_PRESET_CONFIG *(*get_preset_config)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, PyObject *, GUID, GUID); PyObject *(*query_presets)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, GUID); PyObject *(*query_profiles)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, GUID); PyObject *(*query_input_formats)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, GUID); int (*query_encoder_caps)(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *, GUID, NV_ENC_CAPS); }; static struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_vtabptr_4xpra_6codecs_5nvenc_7encoder_Encoder;
1411: cdef unsigned int width
1412: cdef unsigned int height
1413: cdef unsigned int input_width
1414: cdef unsigned int input_height
1415: cdef unsigned int encoder_width
1416: cdef unsigned int encoder_height
1417: cdef unsigned int b_frames
1418: cdef object encoding
1419: cdef object src_format
1420: cdef object dst_formats
1421: cdef object scaling
1422: cdef int speed
1423: cdef int quality
1424: cdef uint32_t target_bitrate
1425: cdef uint32_t max_bitrate
1426: #PyCUDA:
1427: cdef object driver
1428: cdef int cuda_device_id
1429: cdef object cuda_info
1430: cdef object pycuda_info
1431: cdef object cuda_device_info
1432: cdef object cuda_device
1433: cdef object cuda_context
1434: cdef void *cuda_context_ptr
1435: cdef object kernel
1436: cdef object kernel_name
1437: cdef object max_block_sizes
1438: cdef object max_grid_sizes
1439: cdef unsigned long max_threads_per_block
1440: cdef uint64_t free_memory
1441: cdef uint64_t total_memory
1442: #NVENC:
1443: cdef NV_ENCODE_API_FUNCTION_LIST *functionList #@DuplicatedSignature
1444: cdef void *context
1445: cdef GUID codec
1446: cdef NV_ENC_REGISTERED_PTR inputHandle
1447: cdef object inputBuffer
1448: cdef object cudaInputBuffer
1449: cdef object cudaOutputBuffer
1450: cdef unsigned int inputPitch #note: this isn't the pitch (aka rowstride) we actually use!
1451: #just the value returned from the allocation call
1452: cdef unsigned int outputPitch
1453: cdef void *bitstreamBuffer
1454: cdef NV_ENC_BUFFER_FORMAT bufferFmt
1455: cdef object codec_name
1456: cdef object preset_name
1457: cdef object pixel_format
1458: cdef uint8_t lossless
1459: #statistics, etc:
1460: cdef double time
1461: cdef uint64_t first_frame_timestamp
1462: cdef unsigned long frames
1463: cdef unsigned long index
1464: cdef object last_frame_times
1465: cdef uint64_t bytes_in
1466: cdef uint64_t bytes_out
1467:
1468: cdef object __weakref__
1469:
+1470: cdef GUID init_codec(self) except *:
static GUID __pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_init_codec(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_v_codecs = NULL; PyObject *__pyx_v_internal_name = NULL; PyObject *__pyx_v_guid_str = NULL; GUID __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_codec", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_codec", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_XDECREF(__pyx_v_codecs); __Pyx_XDECREF(__pyx_v_internal_name); __Pyx_XDECREF(__pyx_v_guid_str); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1471: codecs = self.query_codecs()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_query_codecs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1471, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_codecs = __pyx_t_1; __pyx_t_1 = 0;
1472: #codecs={'H264': {"guid" : '6BC82762-4E63-4CA4-AA85-1E50F321F6BF', .. }
+1473: internal_name = {"H265" : "HEVC"}.get(self.codec_name.upper(), self.codec_name.upper())
__pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_H265, __pyx_n_s_HEVC) < 0) __PYX_ERR(0, 1473, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->codec_name, __pyx_n_s_upper); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->codec_name, __pyx_n_s_upper); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_internal_name = __pyx_t_4; __pyx_t_4 = 0;
+1474: guid_str = codecs.get(internal_name, {}).get("guid")
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_internal_name, __pyx_t_2}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_internal_name, __pyx_t_2}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_v_internal_name); __Pyx_GIVEREF(__pyx_v_internal_name); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_internal_name); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_guid_str = __pyx_t_4; __pyx_t_4 = 0; /* … */ __pyx_tuple__16 = PyTuple_Pack(1, __pyx_n_s_guid); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16);
+1475: assert guid_str, "%s not supported! (only available: %s)" % (self.codec_name, csv(codecs.keys()))
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_guid_str); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1475, __pyx_L1_error) if (unlikely(!__pyx_t_7)) { __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_csv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_1) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1475, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_2) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_5}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_5}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_v_self->codec_name); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_not_supported_only_available, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1475, __pyx_L1_error) } } #endif
+1476: self.codec = c_parseguid(guid_str)
__pyx_t_8 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_v_guid_str); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1476, __pyx_L1_error)
__pyx_v_self->codec = __pyx_t_8;
+1477: return self.codec
__pyx_r = __pyx_v_self->codec; goto __pyx_L0;
1478:
+1479: cdef GUID get_codec(self):
static GUID __pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_get_codec(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { GUID __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_codec", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1480: return self.codec
__pyx_r = __pyx_v_self->codec; goto __pyx_L0;
1481:
+1482: cdef GUID get_preset(self, GUID codec) except *:
static GUID __pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_get_preset(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, GUID __pyx_v_codec) { PyObject *__pyx_v_presets = NULL; PyObject *__pyx_v_options = NULL; PyObject *__pyx_v_name = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_preset_speed = NULL; PyObject *__pyx_v_preset_quality = NULL; PyObject *__pyx_v_is_lossless = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_l = NULL; PyObject *__pyx_v_score = NULL; PyObject *__pyx_v_preset = NULL; PyObject *__pyx_v_preset_guid = NULL; GUID __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_preset", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_18); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_preset", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_XDECREF(__pyx_v_presets); __Pyx_XDECREF(__pyx_v_options); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_preset_speed); __Pyx_XDECREF(__pyx_v_preset_quality); __Pyx_XDECREF(__pyx_v_is_lossless); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_l); __Pyx_XDECREF(__pyx_v_score); __Pyx_XDECREF(__pyx_v_preset); __Pyx_XDECREF(__pyx_v_preset_guid); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1483: presets = self.query_presets(codec)
__pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_presets(__pyx_v_self, __pyx_v_codec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1483, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_presets = __pyx_t_1; __pyx_t_1 = 0;
+1484: options = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_options = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1485: #if a preset was specified, give it the best score possible (-1):
+1486: if DESIRED_PRESET:
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DESIRED_PRESET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1486, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1486, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+1487: options[-1] = DESIRED_PRESET
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DESIRED_PRESET); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyDict_SetItem(__pyx_v_options, __pyx_int_neg_1, __pyx_t_1) < 0)) __PYX_ERR(0, 1487, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1488: #add all presets ranked by how far they are from the target speed and quality:
+1489: log("presets for %s: %s (pixel format=%s)", guidstr(codec), csv(presets.keys()), self.pixel_format)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_codec); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_csv); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_presets, __pyx_n_s_keys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (__pyx_t_9) { __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1489, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_8) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_kp_s_presets_for_s_s_pixel_format_s, __pyx_t_4, __pyx_t_5, __pyx_v_self->pixel_format}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_kp_s_presets_for_s_s_pixel_format_s, __pyx_t_4, __pyx_t_5, __pyx_v_self->pixel_format}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_9 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_presets_for_s_s_pixel_format_s); __Pyx_GIVEREF(__pyx_kp_s_presets_for_s_s_pixel_format_s); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_kp_s_presets_for_s_s_pixel_format_s); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_10, __pyx_v_self->pixel_format); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1490: for name, x in presets.items():
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_presets, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_9) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1490, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_11 = 0; __pyx_t_12 = NULL; } else { __pyx_t_11 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1490, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_12)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1490, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1490, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_12(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1490, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1490, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_9 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_9 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); index = 1; __pyx_t_5 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1490, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1490, __pyx_L1_error) __pyx_L7_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L4_continue:; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1491: preset_speed = PRESET_SPEED.get(name, 50)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESET_SPEED); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_name, __pyx_int_50}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_name, __pyx_int_50}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_10, __pyx_v_name); __Pyx_INCREF(__pyx_int_50); __Pyx_GIVEREF(__pyx_int_50); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_10, __pyx_int_50); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_preset_speed, __pyx_t_1); __pyx_t_1 = 0;
+1492: preset_quality = PRESET_QUALITY.get(name, 50)
__pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRESET_QUALITY); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1492, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1492, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_name, __pyx_int_50}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1492, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_name, __pyx_int_50}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1492, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1492, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, __pyx_v_name); __Pyx_INCREF(__pyx_int_50); __Pyx_GIVEREF(__pyx_int_50); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, __pyx_int_50); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1492, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_preset_quality, __pyx_t_1); __pyx_t_1 = 0;
+1493: is_lossless = name in LOSSLESS_PRESETS
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LOSSLESS_PRESETS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_name, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1493, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_is_lossless, __pyx_t_1); __pyx_t_1 = 0;
+1494: log("preset %s: speed=%s, quality=%s (lossless=%s - want lossless=%s)", name, preset_speed, preset_quality, is_lossless, self.lossless)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->lossless); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[7] = {__pyx_t_9, __pyx_kp_s_preset_s_speed_s_quality_s_lossl, __pyx_v_name, __pyx_v_preset_speed, __pyx_v_preset_quality, __pyx_v_is_lossless, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1494, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[7] = {__pyx_t_9, __pyx_kp_s_preset_s_speed_s_quality_s_lossl, __pyx_v_name, __pyx_v_preset_speed, __pyx_v_preset_quality, __pyx_v_is_lossless, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1494, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_6 = PyTuple_New(6+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_s_preset_s_speed_s_quality_s_lossl); __Pyx_GIVEREF(__pyx_kp_s_preset_s_speed_s_quality_s_lossl); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_kp_s_preset_s_speed_s_quality_s_lossl); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, __pyx_v_name); __Pyx_INCREF(__pyx_v_preset_speed); __Pyx_GIVEREF(__pyx_v_preset_speed); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_10, __pyx_v_preset_speed); __Pyx_INCREF(__pyx_v_preset_quality); __Pyx_GIVEREF(__pyx_v_preset_quality); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_10, __pyx_v_preset_quality); __Pyx_INCREF(__pyx_v_is_lossless); __Pyx_GIVEREF(__pyx_v_is_lossless); PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_10, __pyx_v_is_lossless); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_10, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1495: if is_lossless and self.pixel_format!="YUV444P":
__pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_is_lossless); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1495, __pyx_L1_error) if (__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L9_bool_binop_done; } __pyx_t_14 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_YUV444P, Py_NE)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1495, __pyx_L1_error) __pyx_t_2 = __pyx_t_14; __pyx_L9_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1496: continue
goto __pyx_L4_continue;
+1497: if preset_speed>=0 and preset_quality>=0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_preset_speed, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1497, __pyx_L1_error) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1497, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L12_bool_binop_done; } __pyx_t_1 = PyObject_RichCompare(__pyx_v_preset_quality, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1497, __pyx_L1_error) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1497, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_14; __pyx_L12_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1498: #quality (3) weighs more than speed (2):
+1499: v = 2 * abs(preset_speed-self.speed) + 3 * abs(preset_quality-self.quality)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyNumber_Subtract(__pyx_v_preset_speed, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Absolute(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Multiply(__pyx_int_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Subtract(__pyx_v_preset_quality, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Absolute(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Multiply(__pyx_int_3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_1); __pyx_t_1 = 0;
+1500: if self.lossless!=is_lossless:
__pyx_t_1 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->lossless); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_v_is_lossless, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1500, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1500, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_2) { /* … */ }
+1501: v -= 100
__pyx_t_6 = __Pyx_PyInt_SubtractObjC(__pyx_v_v, __pyx_int_100, 0x64, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_6); __pyx_t_6 = 0;
+1502: l = options.setdefault(v, [])
__pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyDict_SetDefault(__pyx_v_options, __pyx_v_v, __pyx_t_6, -1L); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_l, __pyx_t_1); __pyx_t_1 = 0;
+1503: if x not in l:
__pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_x, __pyx_v_l, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1503, __pyx_L1_error) __pyx_t_14 = (__pyx_t_2 != 0); if (__pyx_t_14) { /* … */ }
+1504: l.append((name, x))
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_x); __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_l, __pyx_t_1); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1504, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1505: log("get_preset(%s) speed=%s, quality=%s, lossless=%s, pixel_format=%s, options=%s", codecstr(codec), self.speed, self.quality, bool(self.lossless), self.pixel_format, options)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_codec); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->lossless); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyBool_FromLong((!(!__pyx_t_14))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[8] = {__pyx_t_7, __pyx_kp_s_get_preset_s_speed_s_quality_s_l, __pyx_t_6, __pyx_t_4, __pyx_t_5, __pyx_t_9, __pyx_v_self->pixel_format, __pyx_v_options}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[8] = {__pyx_t_7, __pyx_kp_s_get_preset_s_speed_s_quality_s_l, __pyx_t_6, __pyx_t_4, __pyx_t_5, __pyx_t_9, __pyx_v_self->pixel_format, __pyx_v_options}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_8 = PyTuple_New(7+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_get_preset_s_speed_s_quality_s_l); __Pyx_GIVEREF(__pyx_kp_s_get_preset_s_speed_s_quality_s_l); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_kp_s_get_preset_s_speed_s_quality_s_l); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_10, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_10, __pyx_t_9); __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_8, 5+__pyx_t_10, __pyx_v_self->pixel_format); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_8, 6+__pyx_t_10, __pyx_v_options); __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1506: for score in sorted(options.keys()):
__pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_options); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = ((PyObject*)__pyx_t_8); __pyx_t_8 = 0; __pyx_t_15 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1506, __pyx_L1_error) if (unlikely(__pyx_t_3 == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1506, __pyx_L1_error) } __pyx_t_8 = __pyx_t_3; __Pyx_INCREF(__pyx_t_8); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_8)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1506, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_score, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1507: for preset, preset_guid in options.get(score):
__pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_options, __pyx_v_score, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_16 = 0; __pyx_t_12 = NULL; } else { __pyx_t_16 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1507, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_12)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_16); __Pyx_INCREF(__pyx_t_3); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 1507, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_16 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_16); __Pyx_INCREF(__pyx_t_3); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 1507, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1507, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1507, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_9 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_9 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_9)) goto __pyx_L20_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); index = 1; __pyx_t_5 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L20_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1507, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L21_unpacking_done; __pyx_L20_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1507, __pyx_L1_error) __pyx_L21_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_preset, __pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_preset_guid, __pyx_t_5); __pyx_t_5 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1508: if preset and (preset in presets.keys()):
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_preset); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1508, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_14 = __pyx_t_2; goto __pyx_L23_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_presets, __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (__pyx_t_9) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1508, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1508, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_preset, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1508, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_17 = (__pyx_t_2 != 0); __pyx_t_14 = __pyx_t_17; __pyx_L23_bool_binop_done:; if (__pyx_t_14) { /* … */ }
+1509: log("using preset '%s' for speed=%s, quality=%s, lossless=%s, pixel_format=%s", preset, self.speed, self.quality, self.lossless, self.pixel_format)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->lossless); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[7] = {__pyx_t_7, __pyx_kp_s_using_preset_s_for_speed_s_quali, __pyx_v_preset, __pyx_t_9, __pyx_t_4, __pyx_t_6, __pyx_v_self->pixel_format}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[7] = {__pyx_t_7, __pyx_kp_s_using_preset_s_for_speed_s_quali, __pyx_v_preset, __pyx_t_9, __pyx_t_4, __pyx_t_6, __pyx_v_self->pixel_format}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_18 = PyTuple_New(6+__pyx_t_10); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_using_preset_s_for_speed_s_quali); __Pyx_GIVEREF(__pyx_kp_s_using_preset_s_for_speed_s_quali); PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_10, __pyx_kp_s_using_preset_s_for_speed_s_quali); __Pyx_INCREF(__pyx_v_preset); __Pyx_GIVEREF(__pyx_v_preset); PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_10, __pyx_v_preset); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_10, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_10, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_10, __pyx_t_6); __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_18, 5+__pyx_t_10, __pyx_v_self->pixel_format); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_18, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1510: return c_parseguid(preset_guid)
__pyx_t_19 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_v_preset_guid); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1510, __pyx_L1_error) __pyx_r = __pyx_t_19; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L0;
+1511: raise Exception("no matching presets available for '%s' with speed=%i and quality=%i" % (self.codec_name, self.speed, self.quality))
__pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_v_self->codec_name); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1); __pyx_t_8 = 0; __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_no_matching_presets_available_fo, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1511, __pyx_L1_error)
1512:
+1513: def init_context(self, int width, int height, src_format, dst_formats, encoding, int quality, int speed, scaling, options={}): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_1init_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_1init_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_width; int __pyx_v_height; PyObject *__pyx_v_src_format = 0; PyObject *__pyx_v_dst_formats = 0; PyObject *__pyx_v_encoding = 0; int __pyx_v_quality; int __pyx_v_speed; PyObject *__pyx_v_scaling = 0; PyObject *__pyx_v_options = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_context (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_src_format,&__pyx_n_s_dst_formats,&__pyx_n_s_encoding,&__pyx_n_s_quality,&__pyx_n_s_speed,&__pyx_n_s_scaling,&__pyx_n_s_options,0}; PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; values[8] = __pyx_k__17; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_width)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_height)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 1); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_src_format)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 2); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dst_formats)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 3); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoding)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 4); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quality)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 5); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_speed)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 6); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_scaling)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, 7); __PYX_ERR(0, 1513, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options); if (value) { values[8] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "init_context") < 0)) __PYX_ERR(0, 1513, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); values[6] = PyTuple_GET_ITEM(__pyx_args, 6); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_width = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1513, __pyx_L3_error) __pyx_v_height = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1513, __pyx_L3_error) __pyx_v_src_format = values[2]; __pyx_v_dst_formats = values[3]; __pyx_v_encoding = values[4]; __pyx_v_quality = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_quality == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1513, __pyx_L3_error) __pyx_v_speed = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_speed == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1513, __pyx_L3_error) __pyx_v_scaling = values[7]; __pyx_v_options = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("init_context", 0, 8, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1513, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_context", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_init_context(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), __pyx_v_width, __pyx_v_height, __pyx_v_src_format, __pyx_v_dst_formats, __pyx_v_encoding, __pyx_v_quality, __pyx_v_speed, __pyx_v_scaling, __pyx_v_options); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_init_context(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, int __pyx_v_width, int __pyx_v_height, PyObject *__pyx_v_src_format, PyObject *__pyx_v_dst_formats, PyObject *__pyx_v_encoding, int __pyx_v_quality, int __pyx_v_speed, PyObject *__pyx_v_scaling, PyObject *__pyx_v_options) { PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_u = NULL; double __pyx_v_start; CYTHON_UNUSED PyObject *__pyx_v_e = NULL; double __pyx_v_end; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_context", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_26); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_context", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_u); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_k__17 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
+1514: assert NvEncodeAPICreateInstance is not None, "encoder module is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NvEncodeAPICreateInstance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__pyx_t_1 != Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_encoder_module_is_not_initialize); __PYX_ERR(0, 1514, __pyx_L1_error) } } #endif
+1515: log("init_context%s", (width, height, src_format, dst_formats, encoding, quality, speed, scaling, options))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_quality); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_speed); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyTuple_New(9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5); __Pyx_INCREF(__pyx_v_src_format); __Pyx_GIVEREF(__pyx_v_src_format); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_src_format); __Pyx_INCREF(__pyx_v_dst_formats); __Pyx_GIVEREF(__pyx_v_dst_formats); PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_dst_formats); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_7); __Pyx_INCREF(__pyx_v_scaling); __Pyx_GIVEREF(__pyx_v_scaling); PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_v_scaling); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_8, 8, __pyx_v_options); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_init_context_s, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_init_context_s, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_context_s); __Pyx_GIVEREF(__pyx_kp_s_init_context_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_kp_s_init_context_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1516: assert src_format in ("ARGB", "XRGB", "BGRA", "BGRX"), "invalid source format %s" % src_format
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_INCREF(__pyx_v_src_format); __pyx_t_1 = __pyx_v_src_format; __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_ARGB, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1516, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L3_bool_binop_done; } __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_XRGB, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1516, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L3_bool_binop_done; } __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_BGRA, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1516, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L3_bool_binop_done; } __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_BGRX, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1516, __pyx_L1_error) __pyx_t_2 = __pyx_t_10; __pyx_L3_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) { __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_invalid_source_format_s, __pyx_v_src_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1516, __pyx_L1_error) } } #endif
+1517: assert "YUV420P" in dst_formats or "YUV444P" in dst_formats
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_YUV420P, __pyx_v_dst_formats, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1517, __pyx_L1_error) __pyx_t_11 = (__pyx_t_10 != 0); if (!__pyx_t_11) { } else { __pyx_t_2 = __pyx_t_11; goto __pyx_L7_bool_binop_done; } __pyx_t_11 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_YUV444P, __pyx_v_dst_formats, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1517, __pyx_L1_error) __pyx_t_10 = (__pyx_t_11 != 0); __pyx_t_2 = __pyx_t_10; __pyx_L7_bool_binop_done:; if (unlikely(!__pyx_t_2)) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1517, __pyx_L1_error) } } #endif
+1518: self.width = width
__pyx_v_self->width = __pyx_v_width;
+1519: self.height = height
__pyx_v_self->height = __pyx_v_height;
+1520: self.speed = speed
__pyx_v_self->speed = __pyx_v_speed;
+1521: self.quality = quality
__pyx_v_self->quality = __pyx_v_quality;
+1522: self.scaling = scaling or (1, 1)
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_scaling); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1522, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_scaling); __pyx_t_1 = __pyx_v_scaling; goto __pyx_L9_bool_binop_done; } __pyx_t_12.f0 = 1; __pyx_t_12.f1 = 1; __pyx_t_3 = __pyx_convert__to_py___pyx_ctuple_long__and_long(__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; __pyx_L9_bool_binop_done:; __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->scaling); __Pyx_DECREF(__pyx_v_self->scaling); __pyx_v_self->scaling = __pyx_t_1; __pyx_t_1 = 0;
+1523: v, u = self.scaling
__pyx_t_1 = __pyx_v_self->scaling; __Pyx_INCREF(__pyx_t_1); if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1523, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_6 = __pyx_t_13(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_8), 2) < 0) __PYX_ERR(0, 1523, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L12_unpacking_done; __pyx_L11_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1523, __pyx_L1_error) __pyx_L12_unpacking_done:; } __pyx_v_v = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_u = __pyx_t_6; __pyx_t_6 = 0;
+1524: self.input_width = roundup(width, 32)
__pyx_v_self->input_width = __pyx_f_4xpra_6codecs_5nvenc_7encoder_roundup(__pyx_v_width, 32);
+1525: self.input_height = roundup(height, 32)
__pyx_v_self->input_height = __pyx_f_4xpra_6codecs_5nvenc_7encoder_roundup(__pyx_v_height, 32);
+1526: self.encoder_width = roundup(width*v//u, 32)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_v_v); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_6, __pyx_v_u); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1526, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->encoder_width = __pyx_f_4xpra_6codecs_5nvenc_7encoder_roundup(__pyx_t_9, 32);
+1527: self.encoder_height = roundup(height*v//u, 32)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_v_v); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_6, __pyx_v_u); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1527, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->encoder_height = __pyx_f_4xpra_6codecs_5nvenc_7encoder_roundup(__pyx_t_9, 32);
+1528: self.src_format = src_format
__Pyx_INCREF(__pyx_v_src_format); __Pyx_GIVEREF(__pyx_v_src_format); __Pyx_GOTREF(__pyx_v_self->src_format); __Pyx_DECREF(__pyx_v_self->src_format); __pyx_v_self->src_format = __pyx_v_src_format;
+1529: self.dst_formats = dst_formats
__Pyx_INCREF(__pyx_v_dst_formats); __Pyx_GIVEREF(__pyx_v_dst_formats); __Pyx_GOTREF(__pyx_v_self->dst_formats); __Pyx_DECREF(__pyx_v_self->dst_formats); __pyx_v_self->dst_formats = __pyx_v_dst_formats;
+1530: self.encoding = encoding
__Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); __Pyx_GOTREF(__pyx_v_self->encoding); __Pyx_DECREF(__pyx_v_self->encoding); __pyx_v_self->encoding = __pyx_v_encoding;
+1531: self.codec_name = encoding.upper() #ie: "H264"
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_encoding, __pyx_n_s_upper); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->codec_name); __Pyx_DECREF(__pyx_v_self->codec_name); __pyx_v_self->codec_name = __pyx_t_1; __pyx_t_1 = 0;
+1532: self.preset_name = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->preset_name); __Pyx_DECREF(__pyx_v_self->preset_name); __pyx_v_self->preset_name = Py_None;
+1533: self.frames = 0
__pyx_v_self->frames = 0;
+1534: self.cuda_device = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_device); __Pyx_DECREF(__pyx_v_self->cuda_device); __pyx_v_self->cuda_device = Py_None;
+1535: self.cuda_context = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_context); __Pyx_DECREF(__pyx_v_self->cuda_context); __pyx_v_self->cuda_context = Py_None;
+1536: self.pixel_format = ""
__Pyx_INCREF(__pyx_kp_s__18); __Pyx_GIVEREF(__pyx_kp_s__18); __Pyx_GOTREF(__pyx_v_self->pixel_format); __Pyx_DECREF(__pyx_v_self->pixel_format); __pyx_v_self->pixel_format = __pyx_kp_s__18;
+1537: self.last_frame_times = deque(maxlen=200)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_deque); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1537, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1537, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_maxlen, __pyx_int_200) < 0) __PYX_ERR(0, 1537, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1537, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->last_frame_times); __Pyx_DECREF(__pyx_v_self->last_frame_times); __pyx_v_self->last_frame_times = __pyx_t_3; __pyx_t_3 = 0;
+1538: self.update_bitrate()
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_bitrate); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_1) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1538, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1538, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1539: cdef double start = monotonic_time()
__pyx_v_start = __pyx_f_4xpra_14monotonic_time_monotonic_time();
1540:
1541: #the pixel format we feed into the encoder
+1542: self.pixel_format = self.get_target_pixel_format(self.quality)
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_target_pixel_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->pixel_format); __Pyx_DECREF(__pyx_v_self->pixel_format); __pyx_v_self->pixel_format = __pyx_t_3; __pyx_t_3 = 0;
+1543: self.lossless = self.get_target_lossless(self.pixel_format, self.quality)
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_target_lossless); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_self->pixel_format, __pyx_t_7}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_self->pixel_format, __pyx_t_7}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_14 = __Pyx_PyInt_As_uint8_t(__pyx_t_3); if (unlikely((__pyx_t_14 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1543, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->lossless = __pyx_t_14;
1544:
+1545: self.select_cuda_device(options)
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_select_cuda_device); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_options); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_options}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1545, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_options}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1545, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_options); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1546: log("using %s %s compression at %s%% quality with pixel format %s", ["lossy","lossless"][self.lossless], encoding, self.quality, self.pixel_format)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_n_s_lossy); __Pyx_GIVEREF(__pyx_n_s_lossy); PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_lossy); __Pyx_INCREF(__pyx_n_s_lossless); __Pyx_GIVEREF(__pyx_n_s_lossless); PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_lossless); __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_t_7, __pyx_v_self->lossless, uint8_t, 0, __Pyx_PyInt_From_uint8_t, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_kp_s_using_s_s_compression_at_s_quali, __pyx_t_8, __pyx_v_encoding, __pyx_t_7, __pyx_v_self->pixel_format}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_kp_s_using_s_s_compression_at_s_quali, __pyx_t_8, __pyx_v_encoding, __pyx_t_7, __pyx_v_self->pixel_format}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_5 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_kp_s_using_s_s_compression_at_s_quali); __Pyx_GIVEREF(__pyx_kp_s_using_s_s_compression_at_s_quali); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_kp_s_using_s_s_compression_at_s_quali); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_9, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_9, __pyx_t_7); __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_9, __pyx_v_self->pixel_format); __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1547: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; goto __pyx_L18_try_end; __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L1_error; __pyx_L18_try_end:; }
+1548: self.init_cuda()
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_init_cuda); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1548, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L13_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1548, __pyx_L13_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1549: try:
/*try:*/ {
+1550: self.init_cuda_kernel()
__pyx_t_3 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->init_cuda_kernel(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1550, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; }
1551: finally:
+1552: self.cuda_context.pop()
/*finally:*/ { /*normal exit:*/{ __pyx_t_3 = __Pyx_PyObject_Pop(__pyx_v_self->cuda_context); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1552, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L21; } __pyx_L20_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_25); __pyx_t_9 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename; { __pyx_t_3 = __Pyx_PyObject_Pop(__pyx_v_self->cuda_context); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1552, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25); } __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22); __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19; goto __pyx_L13_error; __pyx_L23_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25); } __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; goto __pyx_L13_error; } __pyx_L21:; }
1553:
1554: #the example code accesses the cuda context after a context.pop()
1555: #(which is weird)
+1556: self.init_nvenc()
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_init_nvenc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1556, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1556, __pyx_L13_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1556, __pyx_L13_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1557:
+1558: record_device_success(self.cuda_device_id)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_record_device_success); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->cuda_device_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_7) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1558, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1559: except Exception as e:
__pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_18) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_context", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_8) < 0) __PYX_ERR(0, 1559, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_v_e = __pyx_t_6;
+1560: log("init_cuda failed", exc_info=True)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1560, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1560, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_exc_info, Py_True) < 0) __PYX_ERR(0, 1560, __pyx_L15_except_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__19, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1560, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_init_cuda_failed); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 1560, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19);
+1561: record_device_failure(self.cuda_device_id)
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_record_device_failure); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->cuda_device_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_26 = PyTuple_New(1+1); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_26); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_26, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1561, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1562: raise
__Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_6, __pyx_t_8); __pyx_t_3 = 0; __pyx_t_6 = 0; __pyx_t_8 = 0; __PYX_ERR(0, 1562, __pyx_L15_except_error) } goto __pyx_L15_except_error; __pyx_L15_except_error:;
1563:
+1564: cdef double end = monotonic_time()
__pyx_v_end = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+1565: log("init_context%s took %1.fms", (width, height, src_format, quality, speed, options), (end-start)*1000.0)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_quality); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_26 = __Pyx_PyInt_From_int(__pyx_v_speed); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_26); __pyx_t_5 = PyTuple_New(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); __Pyx_INCREF(__pyx_v_src_format); __Pyx_GIVEREF(__pyx_v_src_format); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_src_format); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_26); PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_26); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_v_options); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_7 = 0; __pyx_t_26 = 0; __pyx_t_26 = PyFloat_FromDouble(((__pyx_v_end - __pyx_v_start) * 1000.0)); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_26); __pyx_t_7 = NULL; __pyx_t_18 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_18 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_kp_s_init_context_s_took_1_fms, __pyx_t_5, __pyx_t_26}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_18, 3+__pyx_t_18); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_kp_s_init_context_s_took_1_fms, __pyx_t_5, __pyx_t_26}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_18, 3+__pyx_t_18); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; } else #endif { __pyx_t_1 = PyTuple_New(3+__pyx_t_18); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_context_s_took_1_fms); __Pyx_GIVEREF(__pyx_kp_s_init_context_s_took_1_fms); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_18, __pyx_kp_s_init_context_s_took_1_fms); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_18, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_26); PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_18, __pyx_t_26); __pyx_t_5 = 0; __pyx_t_26 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1566:
+1567: def select_cuda_device(self, options={}):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_3select_cuda_device(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_3select_cuda_device(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_options = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("select_cuda_device (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_options,0}; PyObject* values[1] = {0}; values[0] = __pyx_k__20; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "select_cuda_device") < 0)) __PYX_ERR(0, 1567, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_options = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("select_cuda_device", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1567, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.select_cuda_device", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_2select_cuda_device(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), __pyx_v_options); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_2select_cuda_device(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_options) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("select_cuda_device", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.select_cuda_device", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_k__20 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
+1568: self.cuda_device_id, self.cuda_device = select_device(options.get("cuda_device", -1), min_compute=MIN_COMPUTE)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_select_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_MIN_COMPUTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_min_compute, __pyx_t_4) < 0) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1568, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_1), 2) < 0) __PYX_ERR(0, 1568, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1568, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->cuda_device_id = __pyx_t_6; __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->cuda_device); __Pyx_DECREF(__pyx_v_self->cuda_device); __pyx_v_self->cuda_device = __pyx_t_2; __pyx_t_2 = 0; /* … */ __pyx_tuple__21 = PyTuple_Pack(2, __pyx_n_s_cuda_device, __pyx_int_neg_1); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21);
+1569: assert self.cuda_device_id>=0 and self.cuda_device, "failed to select a cuda device"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_8 = ((__pyx_v_self->cuda_device_id >= 0) != 0); if (__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L5_bool_binop_done; } __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_self->cuda_device); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1569, __pyx_L1_error) __pyx_t_7 = __pyx_t_8; __pyx_L5_bool_binop_done:; if (unlikely(!__pyx_t_7)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_failed_to_select_a_cuda_device); __PYX_ERR(0, 1569, __pyx_L1_error) } } #endif
+1570: log("selected device %s", device_info(self.cuda_device))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_device_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_9) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_self->cuda_device); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->cuda_device}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_v_self->cuda_device}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_INCREF(__pyx_v_self->cuda_device); __Pyx_GIVEREF(__pyx_v_self->cuda_device); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_self->cuda_device); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_s_selected_device_s, __pyx_t_3}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_s_selected_device_s, __pyx_t_3}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_kp_s_selected_device_s); __Pyx_GIVEREF(__pyx_kp_s_selected_device_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_6, __pyx_kp_s_selected_device_s); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_6, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1571:
1572:
+1573: def get_target_pixel_format(self, quality):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_5get_target_pixel_format(PyObject *__pyx_v_self, PyObject *__pyx_v_quality); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_5get_target_pixel_format(PyObject *__pyx_v_self, PyObject *__pyx_v_quality) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_target_pixel_format (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_4get_target_pixel_format(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_quality)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_4get_target_pixel_format(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_quality) { PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_hasyuv444 = NULL; PyObject *__pyx_v_hasyuv420 = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_target_pixel_format", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_target_pixel_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_hasyuv444); __Pyx_XDECREF(__pyx_v_hasyuv420); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1574: global NATIVE_RGB, YUV420_ENABLED, YUV444_ENABLED, LOSSLESS_ENABLED, YUV444_THRESHOLD, YUV444_CODEC_SUPPORT
+1575: v = None
__Pyx_INCREF(Py_None);
__pyx_v_v = Py_None;
+1576: if NATIVE_RGB and self.src_format in ("BGRX", "BGRA"):
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_NATIVE_RGB != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __Pyx_INCREF(__pyx_v_self->src_format); __pyx_t_3 = __pyx_v_self->src_format; __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_BGRX, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1576, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L6_bool_binop_done; } __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_BGRA, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1576, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L6_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+1577: v = "BGRX"
__Pyx_INCREF(__pyx_n_s_BGRX); __Pyx_DECREF_SET(__pyx_v_v, __pyx_n_s_BGRX);
1578: else:
+1579: x,y = self.scaling
/*else*/ { __pyx_t_3 = __pyx_v_self->scaling; __Pyx_INCREF(__pyx_t_3); if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1579, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 1579, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L9_unpacking_done; __pyx_L8_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1579, __pyx_L1_error) __pyx_L9_unpacking_done:; } __pyx_v_x = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_y = __pyx_t_6; __pyx_t_6 = 0;
+1580: hasyuv444 = YUV444_CODEC_SUPPORT.get(self.encoding, YUV444_ENABLED) and "YUV444P" in self.dst_formats
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_self->encoding, __pyx_t_5}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_self->encoding, __pyx_t_5}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_v_self->encoding); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1580, __pyx_L1_error) if (__pyx_t_1) { __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __Pyx_INCREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L10_bool_binop_done; } __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_YUV444P, __pyx_v_self->dst_formats, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1580, __pyx_L1_error) __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; __pyx_L10_bool_binop_done:; __pyx_v_hasyuv444 = __pyx_t_3; __pyx_t_3 = 0;
+1581: hasyuv420 = YUV420_ENABLED and "YUV420P" in self.dst_formats
if (__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV420_ENABLED) { } else { __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV420_ENABLED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L12_bool_binop_done; } __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_YUV420P, __pyx_v_self->dst_formats, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1581, __pyx_L1_error) __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; __pyx_L12_bool_binop_done:; __pyx_v_hasyuv420 = __pyx_t_3; __pyx_t_3 = 0;
+1582: if hasyuv444:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_hasyuv444); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1582, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
1583: #NVENC and the client can handle it,
1584: #now check quality and scaling:
1585: #(don't use YUV444 is we're going to downscale or use low quality anyway)
+1586: if (quality>=YUV444_THRESHOLD and x==1 and y==1) or not hasyuv420:
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_THRESHOLD); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyObject_RichCompare(__pyx_v_quality, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!__pyx_t_4) { goto __pyx_L17_next_or; } else { } __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_x, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!__pyx_t_4) { goto __pyx_L17_next_or; } else { } __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_y, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1586, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L16_bool_binop_done; } __pyx_L17_next_or:; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_hasyuv420); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1586, __pyx_L1_error) __pyx_t_2 = ((!__pyx_t_4) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L16_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+1587: v = "YUV444P"
__Pyx_INCREF(__pyx_n_s_YUV444P); __Pyx_DECREF_SET(__pyx_v_v, __pyx_n_s_YUV444P);
+1588: if not v:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1588, __pyx_L1_error) __pyx_t_2 = ((!__pyx_t_1) != 0); if (__pyx_t_2) { /* … */ } } __pyx_L3:;
+1589: if hasyuv420:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_hasyuv420); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1589, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L21; }
+1590: v = "NV12"
__Pyx_INCREF(__pyx_n_s_NV12); __Pyx_DECREF_SET(__pyx_v_v, __pyx_n_s_NV12);
1591: else:
+1592: raise Exception("no compatible formats found for quality=%i, scaling=%s, YUV420 support=%s, YUV444 support=%s, codec=%s, dst-formats=%s" % (quality, self.scaling, hasyuv420, hasyuv444, self.codec_name, self.dst_formats))
/*else*/ { __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_quality); __Pyx_GIVEREF(__pyx_v_quality); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_quality); __Pyx_INCREF(__pyx_v_self->scaling); __Pyx_GIVEREF(__pyx_v_self->scaling); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_self->scaling); __Pyx_INCREF(__pyx_v_hasyuv420); __Pyx_GIVEREF(__pyx_v_hasyuv420); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_hasyuv420); __Pyx_INCREF(__pyx_v_hasyuv444); __Pyx_GIVEREF(__pyx_v_hasyuv444); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_hasyuv444); __Pyx_INCREF(__pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_v_self->codec_name); PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_self->codec_name); __Pyx_INCREF(__pyx_v_self->dst_formats); __Pyx_GIVEREF(__pyx_v_self->dst_formats); PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_v_self->dst_formats); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_no_compatible_formats_found_for, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 1592, __pyx_L1_error) } __pyx_L21:;
+1593: log("get_target_pixel_format(%i)=%s for encoding=%s, scaling=%s, NATIVE_RGB=%s, YUV444_CODEC_SUPPORT=%s, YUV420_ENABLED=%s, YUV444_ENABLED=%s, YUV444_THRESHOLD=%s, LOSSLESS_ENABLED=%s, src_format=%s, dst_formats=%s",
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6);
+1594: quality, v, self.encoding, self.scaling, bool(NATIVE_RGB), YUV444_CODEC_SUPPORT, bool(YUV420_ENABLED), bool(YUV444_ENABLED), YUV444_THRESHOLD, bool(LOSSLESS_ENABLED), self.src_format, csv(self.dst_formats))
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_NATIVE_RGB); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV420_ENABLED); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_THRESHOLD); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_csv); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); } } if (!__pyx_t_16) { __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_self->dst_formats); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_15)) { PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_self->dst_formats}; __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_14); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) { PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_self->dst_formats}; __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_14); } else #endif { __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL; __Pyx_INCREF(__pyx_v_self->dst_formats); __Pyx_GIVEREF(__pyx_v_self->dst_formats); PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_self->dst_formats); __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } } __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[14] = {__pyx_t_15, __pyx_kp_s_get_target_pixel_format_i_s_for, __pyx_v_quality, __pyx_v_v, __pyx_v_self->encoding, __pyx_v_self->scaling, __pyx_t_7, __pyx_t_11, __pyx_t_5, __pyx_t_9, __pyx_t_12, __pyx_t_13, __pyx_v_self->src_format, __pyx_t_14}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 13+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[14] = {__pyx_t_15, __pyx_kp_s_get_target_pixel_format_i_s_for, __pyx_v_quality, __pyx_v_v, __pyx_v_self->encoding, __pyx_v_self->scaling, __pyx_t_7, __pyx_t_11, __pyx_t_5, __pyx_t_9, __pyx_t_12, __pyx_t_13, __pyx_v_self->src_format, __pyx_t_14}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 13+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif { __pyx_t_17 = PyTuple_New(13+__pyx_t_10); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (__pyx_t_15) { __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL; } __Pyx_INCREF(__pyx_kp_s_get_target_pixel_format_i_s_for); __Pyx_GIVEREF(__pyx_kp_s_get_target_pixel_format_i_s_for); PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_10, __pyx_kp_s_get_target_pixel_format_i_s_for); __Pyx_INCREF(__pyx_v_quality); __Pyx_GIVEREF(__pyx_v_quality); PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_10, __pyx_v_quality); __Pyx_INCREF(__pyx_v_v); __Pyx_GIVEREF(__pyx_v_v); PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_10, __pyx_v_v); __Pyx_INCREF(__pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_v_self->encoding); PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_10, __pyx_v_self->encoding); __Pyx_INCREF(__pyx_v_self->scaling); __Pyx_GIVEREF(__pyx_v_self->scaling); PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_10, __pyx_v_self->scaling); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_10, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_10, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_10, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_17, 8+__pyx_t_10, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_17, 9+__pyx_t_10, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_17, 10+__pyx_t_10, __pyx_t_13); __Pyx_INCREF(__pyx_v_self->src_format); __Pyx_GIVEREF(__pyx_v_self->src_format); PyTuple_SET_ITEM(__pyx_t_17, 11+__pyx_t_10, __pyx_v_self->src_format); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_17, 12+__pyx_t_10, __pyx_t_14); __pyx_t_7 = 0; __pyx_t_11 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1595: return v
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_v); __pyx_r = __pyx_v_v; goto __pyx_L0;
1596:
+1597: def get_target_lossless(self, pixel_format, quality):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_7get_target_lossless(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_7get_target_lossless(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_pixel_format = 0; PyObject *__pyx_v_quality = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_target_lossless (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pixel_format,&__pyx_n_s_quality,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pixel_format)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quality)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_target_lossless", 1, 2, 2, 1); __PYX_ERR(0, 1597, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_target_lossless") < 0)) __PYX_ERR(0, 1597, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_pixel_format = values[0]; __pyx_v_quality = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_target_lossless", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1597, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_target_lossless", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_6get_target_lossless(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), __pyx_v_pixel_format, __pyx_v_quality); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_6get_target_lossless(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_pixel_format, PyObject *__pyx_v_quality) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_target_lossless", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_target_lossless", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1598: global LOSSLESS_ENABLED, LOSSLESS_CODEC_SUPPORT
+1599: if pixel_format!="YUV444P":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_pixel_format, __pyx_n_s_YUV444P, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1599, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+1600: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
+1601: if not LOSSLESS_CODEC_SUPPORT.get(self.encoding, LOSSLESS_ENABLED):
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LOSSLESS_CODEC_SUPPORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_self->encoding, __pyx_t_3}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_self->encoding, __pyx_t_3}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_v_self->encoding); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1601, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = ((!__pyx_t_1) != 0); if (__pyx_t_8) { /* … */ }
+1602: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
+1603: return quality>=LOSSLESS_THRESHOLD
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_THRESHOLD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyObject_RichCompare(__pyx_v_quality, __pyx_t_2, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1603, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
1604:
+1605: def init_cuda(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_9init_cuda(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_9init_cuda(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_cuda (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_8init_cuda(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_8init_cuda(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { int __pyx_v_result; uintptr_t __pyx_v_context_pointer; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_cf = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_cuda", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_cuda", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_cf); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1606: cdef unsigned int plane_size_div
1607: cdef unsigned int max_input_stride
1608: cdef int result
1609: cdef uintptr_t context_pointer
1610:
+1611: assert self.cuda_device_id>=0 and self.cuda_device, "no NVENC device found!"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = ((__pyx_v_self->cuda_device_id >= 0) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L3_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->cuda_device); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1611, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_L3_bool_binop_done:; if (unlikely(!__pyx_t_1)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_no_NVENC_device_found); __PYX_ERR(0, 1611, __pyx_L1_error) } } #endif
1612: global last_context_failure
+1613: d = self.cuda_device
__pyx_t_3 = __pyx_v_self->cuda_device;
__Pyx_INCREF(__pyx_t_3);
__pyx_v_d = __pyx_t_3;
__pyx_t_3 = 0;
+1614: cf = driver.ctx_flags
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ctx_flags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_cf = __pyx_t_4; __pyx_t_4 = 0;
+1615: log("init_cuda() pixel format=%s, device_id=%s", self.pixel_format, self.cuda_device_id)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->cuda_device_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_init_cuda_pixel_format_s_device, __pyx_v_self->pixel_format, __pyx_t_5}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_init_cuda_pixel_format_s_device, __pyx_v_self->pixel_format, __pyx_t_5}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_cuda_pixel_format_s_device); __Pyx_GIVEREF(__pyx_kp_s_init_cuda_pixel_format_s_device); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_init_cuda_pixel_format_s_device); __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1616: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); goto __pyx_L1_error; __pyx_L10_try_end:; }
+1617: log("init_cuda cuda_device=%s (%s)", d, device_info(d))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_device_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_6) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_d); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_d}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_d}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_d); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_init_cuda_cuda_device_s_s, __pyx_v_d, __pyx_t_8}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_init_cuda_cuda_device_s_s, __pyx_v_d, __pyx_t_8}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_12 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_cuda_cuda_device_s_s); __Pyx_GIVEREF(__pyx_kp_s_init_cuda_cuda_device_s_s); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_7, __pyx_kp_s_init_cuda_cuda_device_s_s); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_7, __pyx_v_d); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1617, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1618: self.cuda_context = d.make_context(flags=cf.SCHED_AUTO | cf.MAP_HOST)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_make_context); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_cf, __pyx_n_s_SCHED_AUTO); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_cf, __pyx_n_s_MAP_HOST); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = PyNumber_Or(__pyx_t_12, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_flags, __pyx_t_5) < 0) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1618, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GIVEREF(__pyx_t_5); __Pyx_GOTREF(__pyx_v_self->cuda_context); __Pyx_DECREF(__pyx_v_self->cuda_context); __pyx_v_self->cuda_context = __pyx_t_5; __pyx_t_5 = 0;
+1619: assert self.cuda_context, "failed to create a CUDA context for device %s" % device_info(d)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->cuda_context); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1619, __pyx_L5_error) if (unlikely(!__pyx_t_1)) { __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_device_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_d}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_d}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_d); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_create_a_CUDA_context, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1619, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 1619, __pyx_L5_error) } } #endif
+1620: log("init_cuda cuda_context=%s", self.cuda_context)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1620, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_init_cuda_cuda_context_s, __pyx_v_self->cuda_context}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1620, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_init_cuda_cuda_context_s, __pyx_v_self->cuda_context}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1620, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1620, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_cuda_cuda_context_s); __Pyx_GIVEREF(__pyx_kp_s_init_cuda_cuda_context_s); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_kp_s_init_cuda_cuda_context_s); __Pyx_INCREF(__pyx_v_self->cuda_context); __Pyx_GIVEREF(__pyx_v_self->cuda_context); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_v_self->cuda_context); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1620, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1621: self.cuda_info = get_cuda_info()
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_cuda_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1621, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1621, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1621, __pyx_L5_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->cuda_info); __Pyx_DECREF(__pyx_v_self->cuda_info); __pyx_v_self->cuda_info = __pyx_t_3; __pyx_t_3 = 0;
+1622: log("init_cuda cuda info=%s", self.cuda_info)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1622, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_init_cuda_cuda_info_s, __pyx_v_self->cuda_info}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1622, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_init_cuda_cuda_info_s, __pyx_v_self->cuda_info}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1622, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1622, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_cuda_cuda_info_s); __Pyx_GIVEREF(__pyx_kp_s_init_cuda_cuda_info_s); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_init_cuda_cuda_info_s); __Pyx_INCREF(__pyx_v_self->cuda_info); __Pyx_GIVEREF(__pyx_v_self->cuda_info); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_self->cuda_info); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1622, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1623: self.pycuda_info = get_pycuda_info()
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_pycuda_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1623, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1623, __pyx_L5_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1623, __pyx_L5_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->pycuda_info); __Pyx_DECREF(__pyx_v_self->pycuda_info); __pyx_v_self->pycuda_info = __pyx_t_3; __pyx_t_3 = 0;
+1624: log("init_cuda pycuda info=%s", self.pycuda_info)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1624, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_init_cuda_pycuda_info_s, __pyx_v_self->pycuda_info}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1624, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_init_cuda_pycuda_info_s, __pyx_v_self->pycuda_info}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1624, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1624, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_cuda_pycuda_info_s); __Pyx_GIVEREF(__pyx_kp_s_init_cuda_pycuda_info_s); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_kp_s_init_cuda_pycuda_info_s); __Pyx_INCREF(__pyx_v_self->pycuda_info); __Pyx_GIVEREF(__pyx_v_self->pycuda_info); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_v_self->pycuda_info); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1624, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1625: self.cuda_device_info = {
__Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->cuda_device_info); __Pyx_DECREF(__pyx_v_self->cuda_device_info); __pyx_v_self->cuda_device_info = __pyx_t_3; __pyx_t_3 = 0;
+1626: "device" : {
__pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1626, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3);
+1627: "name" : d.name(),
__pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1627, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1627, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (__pyx_t_12) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1627, __pyx_L5_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1627, __pyx_L5_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_name, __pyx_t_4) < 0) __PYX_ERR(0, 1627, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1628: "pci_bus_id" : d.pci_bus_id(),
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_pci_bus_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1628, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (__pyx_t_12) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1628, __pyx_L5_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1628, __pyx_L5_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pci_bus_id, __pyx_t_4) < 0) __PYX_ERR(0, 1627, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1629: "memory" : int(d.total_memory()//1024//1024),
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_total_memory); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1629, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (__pyx_t_12) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1629, __pyx_L5_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1629, __pyx_L5_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_4, __pyx_int_1024, 0x400, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1629, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_8, __pyx_int_1024, 0x400, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1629, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1629, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_memory, __pyx_t_8) < 0) __PYX_ERR(0, 1627, __pyx_L5_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_device, __pyx_t_5) < 0) __PYX_ERR(0, 1626, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1630: },
+1631: "api_version" : self.cuda_context.get_api_version(),
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cuda_context, __pyx_n_s_get_api_version); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1631, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (__pyx_t_4) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1631, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1631, __pyx_L5_error) } __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_api_version, __pyx_t_5) < 0) __PYX_ERR(0, 1626, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1632: }
1633:
1634: #get the CUDA context (C pointer):
1635: #a bit of magic to pass a cython pointer to ctypes:
+1636: context_pointer = <uintptr_t> (&self.cuda_context_ptr)
__pyx_v_context_pointer = ((uintptr_t)(&__pyx_v_self->cuda_context_ptr));
+1637: result = cuCtxGetCurrent(ctypes.cast(context_pointer, POINTER(ctypes.c_void_p)))
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cuCtxGetCurrent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_cast); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_context_pointer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_POINTER); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_ctypes); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_c_void_p); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } if (!__pyx_t_14) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_6); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_15}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_15}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else #endif { __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __pyx_t_14 = NULL; __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_16, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_4, __pyx_t_6}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_4, __pyx_t_6}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_13); __pyx_t_13 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_7, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_16, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_12) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1637, __pyx_L5_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_result = __pyx_t_7;
+1638: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+1639: log("cuCtxGetCurrent() returned %s, cuda context pointer=%#x", CUDA_ERRORS_INFO.get(result, result), <uintptr_t> self.cuda_context_ptr)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_CUDA_ERRORS_INFO); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_t_6}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_t_6}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_13 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_7, __pyx_t_6); __pyx_t_8 = 0; __pyx_t_6 = 0; __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->cuda_context_ptr)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_kp_s_cuCtxGetCurrent_returned_s_cuda, __pyx_t_16, __pyx_t_12}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_kp_s_cuCtxGetCurrent_returned_s_cuda, __pyx_t_16, __pyx_t_12}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_6 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_13); __pyx_t_13 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuCtxGetCurrent_returned_s_cuda); __Pyx_GIVEREF(__pyx_kp_s_cuCtxGetCurrent_returned_s_cuda); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_cuCtxGetCurrent_returned_s_cuda); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_12); __pyx_t_16 = 0; __pyx_t_12 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1640: assert result==0, "failed to get current cuda context, cuCtxGetCurrent returned %s" % CUDA_ERRORS_INFO.get(result, result)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_result == 0) != 0))) { __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_CUDA_ERRORS_INFO); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_16 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_5, __pyx_t_12}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_5, __pyx_t_12}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_13 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_16) { __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_16); __pyx_t_16 = NULL; } __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_7, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_7, __pyx_t_12); __pyx_t_5 = 0; __pyx_t_12 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_get_current_cuda_conte, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1640, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1640, __pyx_L5_error) } } #endif
+1641: except driver.MemoryError as e:
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1641, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_MemoryError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1641, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_7) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_cuda", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_13) < 0) __PYX_ERR(0, 1641, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_v_e = __pyx_t_6;
+1642: last_context_failure = monotonic_time()
__pyx_v_4xpra_6codecs_5nvenc_7encoder_last_context_failure = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+1643: log("init_cuda %s", e)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1643, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_16 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_kp_s_init_cuda_s, __pyx_v_e}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1643, __pyx_L7_except_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_12); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_kp_s_init_cuda_s, __pyx_v_e}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1643, __pyx_L7_except_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_12); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1643, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_16) { __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_16); __pyx_t_16 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_cuda_s); __Pyx_GIVEREF(__pyx_kp_s_init_cuda_s); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_init_cuda_s); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_e); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1643, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1644: raise TransientCodecException("could not initialize cuda: %s" % e)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_TransientCodecException); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_could_not_initialize_cuda_s, __pyx_v_e); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_16 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_16) { __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_12); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_t_8}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_t_8}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_16); __pyx_t_16 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1644, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 1644, __pyx_L7_except_error) } goto __pyx_L7_except_error; __pyx_L7_except_error:;
1645:
+1646: cdef init_cuda_kernel(self):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_init_cuda_kernel(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { unsigned int __pyx_v_plane_size_div; unsigned int __pyx_v_wmult; unsigned int __pyx_v_hmult; unsigned int __pyx_v_max_input_stride; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_da = NULL; PyObject *__pyx_v_kernel_name = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_cuda_kernel", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_cuda_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_da); __Pyx_XDECREF(__pyx_v_kernel_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1647: global YUV420_ENABLED, YUV444_ENABLED, YUV444_CODEC_SUPPORT, NATIVE_RGB
+1648: assert self.cuda_device_id>=0 and self.cuda_device, "cuda device not set!"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = ((__pyx_v_self->cuda_device_id >= 0) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L3_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->cuda_device); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1648, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_L3_bool_binop_done:; if (unlikely(!__pyx_t_1)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_cuda_device_not_set); __PYX_ERR(0, 1648, __pyx_L1_error) } } #endif
1649: cdef unsigned int plane_size_div, wmult, hmult, max_input_stride
+1650: d = self.cuda_device
__pyx_t_3 = __pyx_v_self->cuda_device;
__Pyx_INCREF(__pyx_t_3);
__pyx_v_d = __pyx_t_3;
__pyx_t_3 = 0;
1651: #use alias to make code easier to read:
+1652: da = driver.device_attribute
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_device_attribute); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_da = __pyx_t_4; __pyx_t_4 = 0;
+1653: if self.pixel_format=="BGRX":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_BGRX, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1653, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L5; }
+1654: assert NATIVE_RGB
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_4xpra_6codecs_5nvenc_7encoder_NATIVE_RGB != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1654, __pyx_L1_error) } } #endif
+1655: kernel_name = None
__Pyx_INCREF(Py_None);
__pyx_v_kernel_name = Py_None;
+1656: self.bufferFmt = NV_ENC_BUFFER_FORMAT_ARGB
__pyx_v_self->bufferFmt = NV_ENC_BUFFER_FORMAT_ARGB;
+1657: plane_size_div= 1
__pyx_v_plane_size_div = 1;
+1658: wmult = 4
__pyx_v_wmult = 4;
+1659: hmult = 1
__pyx_v_hmult = 1;
1660: #if supported (separate plane flag), use YUV444P:
+1661: elif self.pixel_format=="YUV444P":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_YUV444P, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1661, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L5; }
+1662: assert YUV444_CODEC_SUPPORT.get(self.encoding, YUV444_ENABLED), "YUV444 is not enabled for %s" % self.encoding
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self->encoding, __pyx_t_3}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self->encoding, __pyx_t_3}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_v_self->encoding); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) { __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_YUV444_is_not_enabled_for_s, __pyx_v_self->encoding); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1662, __pyx_L1_error) } } #endif
+1663: kernel_name = "%s_to_YUV444" % (self.src_format.replace("X", "A")) #ie: ARGB_to_YUV444
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->src_format, __pyx_n_s_replace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_to_YUV444, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_kernel_name = __pyx_t_4; __pyx_t_4 = 0; /* … */ __pyx_tuple__22 = PyTuple_Pack(2, __pyx_n_s_X, __pyx_n_s_A); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22);
+1664: self.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444
__pyx_v_self->bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444;
1665: #3 full planes:
+1666: plane_size_div = 1
__pyx_v_plane_size_div = 1;
+1667: wmult = 1
__pyx_v_wmult = 1;
+1668: hmult = 3
__pyx_v_hmult = 3;
+1669: elif self.pixel_format=="NV12":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_NV12, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1669, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L5; }
+1670: assert YUV420_ENABLED
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV420_ENABLED != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1670, __pyx_L1_error) } } #endif
+1671: kernel_name = "%s_to_NV12" % (self.src_format.replace("X", "A")) #ie: BGRA_to_NV12
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->src_format, __pyx_n_s_replace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_to_NV12, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_kernel_name = __pyx_t_4; __pyx_t_4 = 0; /* … */ __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_X, __pyx_n_s_A); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 1671, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23);
+1672: self.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12
__pyx_v_self->bufferFmt = NV_ENC_BUFFER_FORMAT_NV12;
1673: #1 full Y plane and 2 U+V planes subsampled by 4:
+1674: plane_size_div = 2
__pyx_v_plane_size_div = 2;
+1675: wmult = 1
__pyx_v_wmult = 1;
+1676: hmult = 3
__pyx_v_hmult = 3;
1677: else:
+1678: raise Exception("BUG: invalid dst format: %s" % self.pixel_format)
/*else*/ { __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_BUG_invalid_dst_format_s, __pyx_v_self->pixel_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1678, __pyx_L1_error) } __pyx_L5:;
1679:
1680: #allocate CUDA "output" buffer (on device):
1681: #this is the buffer we feed into the encoder
1682: #the data may come from the CUDA kernel,
1683: #or it may be uploaded directly there (ie: BGRX)
+1684: self.cudaOutputBuffer, self.outputPitch = driver.mem_alloc_pitch(self.encoder_width*wmult, self.encoder_height*hmult//plane_size_div, 16)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_mem_alloc_pitch); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_unsigned_int((__pyx_v_self->encoder_width * __pyx_v_wmult)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(((__pyx_v_self->encoder_height * __pyx_v_hmult) / __pyx_v_plane_size_div)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_5, __pyx_t_3, __pyx_int_16}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_5, __pyx_t_3, __pyx_int_16}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_9 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_int_16); __Pyx_GIVEREF(__pyx_int_16); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_7, __pyx_int_16); __pyx_t_5 = 0; __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1684, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; index = 0; __pyx_t_8 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); index = 1; __pyx_t_9 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_3), 2) < 0) __PYX_ERR(0, 1684, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1684, __pyx_L1_error) __pyx_L7_unpacking_done:; } __pyx_t_11 = __Pyx_PyInt_As_unsigned_int(__pyx_t_9); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1684, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GIVEREF(__pyx_t_8); __Pyx_GOTREF(__pyx_v_self->cudaOutputBuffer); __Pyx_DECREF(__pyx_v_self->cudaOutputBuffer); __pyx_v_self->cudaOutputBuffer = __pyx_t_8; __pyx_t_8 = 0; __pyx_v_self->outputPitch = __pyx_t_11;
+1685: log("CUDA Output Buffer=%#x, pitch=%s", int(self.cudaOutputBuffer), self.outputPitch)
__pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyNumber_Int(__pyx_v_self->cudaOutputBuffer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->outputPitch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_CUDA_Output_Buffer_x_pitch_s, __pyx_t_8, __pyx_t_3}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_CUDA_Output_Buffer_x_pitch_s, __pyx_t_8, __pyx_t_3}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_6 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_CUDA_Output_Buffer_x_pitch_s); __Pyx_GIVEREF(__pyx_kp_s_CUDA_Output_Buffer_x_pitch_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_CUDA_Output_Buffer_x_pitch_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_3); __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1686:
+1687: if kernel_name:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_kernel_name); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1687, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L8; }
1688: #load the kernel:
+1689: self.kernel = get_CUDA_function(self.cuda_device_id, kernel_name)
__pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_CUDA_function); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->cuda_device_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_6, __pyx_v_kernel_name}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1689, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_6, __pyx_v_kernel_name}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1689, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_v_kernel_name); __Pyx_GIVEREF(__pyx_v_kernel_name); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_kernel_name); __pyx_t_6 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->kernel); __Pyx_DECREF(__pyx_v_self->kernel); __pyx_v_self->kernel = __pyx_t_4; __pyx_t_4 = 0;
+1690: self.kernel_name = kernel_name
__Pyx_INCREF(__pyx_v_kernel_name); __Pyx_GIVEREF(__pyx_v_kernel_name); __Pyx_GOTREF(__pyx_v_self->kernel_name); __Pyx_DECREF(__pyx_v_self->kernel_name); __pyx_v_self->kernel_name = __pyx_v_kernel_name;
+1691: assert self.kernel, "failed to load %s for device %i" % (self.kernel_name, self.cuda_device_id)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->kernel); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1691, __pyx_L1_error) if (unlikely(!__pyx_t_1)) { __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->cuda_device_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_self->kernel_name); __Pyx_GIVEREF(__pyx_v_self->kernel_name); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_self->kernel_name); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_load_s_for_device_i, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1691, __pyx_L1_error) } } #endif
1692: #allocate CUDA input buffer (on device) 32-bit RGBX
1693: #(and make it bigger just in case - subregions from XShm can have a huge rowstride)
1694: #(this is the buffer we feed into the kernel)
+1695: max_input_stride = MAX(2560, self.input_width)*4
__pyx_v_max_input_stride = (__pyx_f_4xpra_6codecs_5nvenc_7encoder_MAX(0xA00, __pyx_v_self->input_width) * 4);
+1696: self.cudaInputBuffer, self.inputPitch = driver.mem_alloc_pitch(max_input_stride, self.input_height, 16)
__pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_mem_alloc_pitch); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyInt_From_unsigned_int(__pyx_v_max_input_stride); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->input_height); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_9, __pyx_t_6, __pyx_int_16}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_9, __pyx_t_6, __pyx_int_16}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_5 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_int_16); __Pyx_GIVEREF(__pyx_int_16); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_7, __pyx_int_16); __pyx_t_9 = 0; __pyx_t_6 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1696, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext; index = 0; __pyx_t_8 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_8)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); index = 1; __pyx_t_5 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 2) < 0) __PYX_ERR(0, 1696, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L10_unpacking_done; __pyx_L9_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1696, __pyx_L1_error) __pyx_L10_unpacking_done:; } __pyx_t_11 = __Pyx_PyInt_As_unsigned_int(__pyx_t_5); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GIVEREF(__pyx_t_8); __Pyx_GOTREF(__pyx_v_self->cudaInputBuffer); __Pyx_DECREF(__pyx_v_self->cudaInputBuffer); __pyx_v_self->cudaInputBuffer = __pyx_t_8; __pyx_t_8 = 0; __pyx_v_self->inputPitch = __pyx_t_11;
+1697: log("CUDA Input Buffer=%#x, pitch=%s", int(self.cudaInputBuffer), self.inputPitch)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyNumber_Int(__pyx_v_self->cudaInputBuffer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->inputPitch); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_kp_s_CUDA_Input_Buffer_x_pitch_s, __pyx_t_8, __pyx_t_6}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_kp_s_CUDA_Input_Buffer_x_pitch_s, __pyx_t_8, __pyx_t_6}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_s_CUDA_Input_Buffer_x_pitch_s); __Pyx_GIVEREF(__pyx_kp_s_CUDA_Input_Buffer_x_pitch_s); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_kp_s_CUDA_Input_Buffer_x_pitch_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_t_6); __pyx_t_8 = 0; __pyx_t_6 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1698: #CUDA
+1699: self.max_block_sizes = d.get_attribute(da.MAX_BLOCK_DIM_X), d.get_attribute(da.MAX_BLOCK_DIM_Y), d.get_attribute(da.MAX_BLOCK_DIM_Z)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_da, __pyx_n_s_MAX_BLOCK_DIM_X); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_6) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_da, __pyx_n_s_MAX_BLOCK_DIM_Y); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (!__pyx_t_6) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_da, __pyx_n_s_MAX_BLOCK_DIM_Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } if (!__pyx_t_6) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_8 = 0; __Pyx_GIVEREF(__pyx_t_9); __Pyx_GOTREF(__pyx_v_self->max_block_sizes); __Pyx_DECREF(__pyx_v_self->max_block_sizes); __pyx_v_self->max_block_sizes = __pyx_t_9; __pyx_t_9 = 0;
+1700: self.max_grid_sizes = d.get_attribute(da.MAX_GRID_DIM_X), d.get_attribute(da.MAX_GRID_DIM_Y), d.get_attribute(da.MAX_GRID_DIM_Z)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_da, __pyx_n_s_MAX_GRID_DIM_X); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (!__pyx_t_4) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_da, __pyx_n_s_MAX_GRID_DIM_Y); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (!__pyx_t_4) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_8); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_da, __pyx_n_s_MAX_GRID_DIM_Z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_12); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_12); __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_12 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->max_grid_sizes); __Pyx_DECREF(__pyx_v_self->max_grid_sizes); __pyx_v_self->max_grid_sizes = __pyx_t_3; __pyx_t_3 = 0;
+1701: log("max_block_sizes=%s", self.max_block_sizes)
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_max_block_sizes_s, __pyx_v_self->max_block_sizes}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_max_block_sizes_s, __pyx_v_self->max_block_sizes}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_max_block_sizes_s); __Pyx_GIVEREF(__pyx_kp_s_max_block_sizes_s); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_kp_s_max_block_sizes_s); __Pyx_INCREF(__pyx_v_self->max_block_sizes); __Pyx_GIVEREF(__pyx_v_self->max_block_sizes); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_v_self->max_block_sizes); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1702: log("max_grid_sizes=%s", self.max_grid_sizes)
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_9 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_max_grid_sizes_s, __pyx_v_self->max_grid_sizes}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_max_grid_sizes_s, __pyx_v_self->max_grid_sizes}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_s_max_grid_sizes_s); __Pyx_GIVEREF(__pyx_kp_s_max_grid_sizes_s); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_max_grid_sizes_s); __Pyx_INCREF(__pyx_v_self->max_grid_sizes); __Pyx_GIVEREF(__pyx_v_self->max_grid_sizes); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_self->max_grid_sizes); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1703: self.max_threads_per_block = self.kernel.get_attribute(driver.function_attribute.MAX_THREADS_PER_BLOCK)
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->kernel, __pyx_n_s_get_attribute); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_function_attribute); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_MAX_THREADS_PER_BLOCK); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (!__pyx_t_9) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_13 = __Pyx_PyInt_As_unsigned_long(__pyx_t_3); if (unlikely((__pyx_t_13 == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->max_threads_per_block = __pyx_t_13;
+1704: log("max_threads_per_block=%s", self.max_threads_per_block)
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->max_threads_per_block); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_max_threads_per_block_s, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1704, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_max_threads_per_block_s, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1704, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_max_threads_per_block_s); __Pyx_GIVEREF(__pyx_kp_s_max_threads_per_block_s); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_kp_s_max_threads_per_block_s); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1705: else:
1706: #we don't use a CUDA kernel
+1707: self.kernel_name = None
/*else*/ { __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->kernel_name); __Pyx_DECREF(__pyx_v_self->kernel_name); __pyx_v_self->kernel_name = Py_None;
+1708: self.kernel = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->kernel); __Pyx_DECREF(__pyx_v_self->kernel); __pyx_v_self->kernel = Py_None;
+1709: self.cudaInputBuffer = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cudaInputBuffer); __Pyx_DECREF(__pyx_v_self->cudaInputBuffer); __pyx_v_self->cudaInputBuffer = Py_None;
+1710: self.inputPitch = self.outputPitch
__pyx_t_11 = __pyx_v_self->outputPitch; __pyx_v_self->inputPitch = __pyx_t_11;
+1711: self.max_block_sizes = 0
__Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_GOTREF(__pyx_v_self->max_block_sizes); __Pyx_DECREF(__pyx_v_self->max_block_sizes); __pyx_v_self->max_block_sizes = __pyx_int_0;
+1712: self.max_grid_sizes = 0
__Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_GOTREF(__pyx_v_self->max_grid_sizes); __Pyx_DECREF(__pyx_v_self->max_grid_sizes); __pyx_v_self->max_grid_sizes = __pyx_int_0;
+1713: self.max_threads_per_block = 0
__pyx_v_self->max_threads_per_block = 0; } __pyx_L8:;
1714:
1715: #allocate input buffer on host:
1716: #this is the buffer we upload to the device
+1717: self.inputBuffer = driver.pagelocked_zeros(self.inputPitch*self.input_height, dtype=numpy.byte)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_pagelocked_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_unsigned_int((__pyx_v_self->inputPitch * __pyx_v_self->input_height)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_byte); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GIVEREF(__pyx_t_8); __Pyx_GOTREF(__pyx_v_self->inputBuffer); __Pyx_DECREF(__pyx_v_self->inputBuffer); __pyx_v_self->inputBuffer = __pyx_t_8; __pyx_t_8 = 0;
+1718: log("inputBuffer=%s (size=%s)", self.inputBuffer, self.inputPitch*self.input_height)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyInt_From_unsigned_int((__pyx_v_self->inputPitch * __pyx_v_self->input_height)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_12, __pyx_kp_s_inputBuffer_s_size_s, __pyx_v_self->inputBuffer, __pyx_t_9}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1718, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_12, __pyx_kp_s_inputBuffer_s_size_s, __pyx_v_self->inputBuffer, __pyx_t_9}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1718, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_6 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_INCREF(__pyx_kp_s_inputBuffer_s_size_s); __Pyx_GIVEREF(__pyx_kp_s_inputBuffer_s_size_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_inputBuffer_s_size_s); __Pyx_INCREF(__pyx_v_self->inputBuffer); __Pyx_GIVEREF(__pyx_v_self->inputBuffer); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_self->inputBuffer); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1719:
1720:
+1721: def init_nvenc(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_11init_nvenc(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_11init_nvenc(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_nvenc (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_10init_nvenc(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_10init_nvenc(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_nvenc", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_nvenc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1722: self.open_encode_session()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_encode_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1722, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1722, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1723: self.init_encoder()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_init_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1723, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1723, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1724: self.init_buffers()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_init_buffers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1724, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1725:
+1726: def init_encoder(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_13init_encoder(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_13init_encoder(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_encoder (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_12init_encoder(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_12init_encoder(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { GUID __pyx_v_codec; NV_ENC_INITIALIZE_PARAMS *__pyx_v_params; NVENCSTATUS __pyx_v_r; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_encoder", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_encoder", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1727: cdef GUID codec = self.init_codec()
__pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->init_codec(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1727, __pyx_L1_error)
__pyx_v_codec = __pyx_t_1;
+1728: cdef NV_ENC_INITIALIZE_PARAMS *params = NULL
__pyx_v_params = NULL;
1729: cdef NVENCSTATUS r
+1730: params = <NV_ENC_INITIALIZE_PARAMS*> cmalloc(sizeof(NV_ENC_INITIALIZE_PARAMS), "initialization params")
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc((sizeof(NV_ENC_INITIALIZE_PARAMS)), __pyx_kp_s_initialization_params); if (unlikely(__pyx_t_2 == ((uintptr_t)0))) __PYX_ERR(0, 1730, __pyx_L1_error)
__pyx_v_params = ((NV_ENC_INITIALIZE_PARAMS *)__pyx_t_2);
+1731: assert memset(params, 0, sizeof(NV_ENC_INITIALIZE_PARAMS))!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((memset(__pyx_v_params, 0, (sizeof(NV_ENC_INITIALIZE_PARAMS))) != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1731, __pyx_L1_error) } } #endif
+1732: try:
/*try:*/ {
+1733: self.init_params(codec, params)
__pyx_t_3 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->init_params(__pyx_v_self, __pyx_v_codec, __pyx_v_params); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1733, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1734: if DEBUG_API:
__pyx_t_4 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_4) { /* … */ }
+1735: log("nvEncInitializeEncoder using encode=%s", codecstr(codec))
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1735, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_codec); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1735, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_nvEncInitializeEncoder_using_enc, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1735, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_nvEncInitializeEncoder_using_enc, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1735, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1735, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncInitializeEncoder_using_enc); __Pyx_GIVEREF(__pyx_kp_s_nvEncInitializeEncoder_using_enc); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_nvEncInitializeEncoder_using_enc); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1735, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1736: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L9; } __pyx_L9:; } }
+1737: r = self.functionList.nvEncInitializeEncoder(self.context, params)
__pyx_v_r = __pyx_v_self->functionList->nvEncInitializeEncoder(__pyx_v_self->context, __pyx_v_params); }
+1738: raiseNVENC(r, "initializing encoder")
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_initializing_encoder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1738, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1739: log("NVENC initialized with '%s' codec and '%s' preset" % (self.codec_name, self.preset_name))
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_v_self->codec_name); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_self->codec_name); __Pyx_INCREF(__pyx_v_self->preset_name); __Pyx_GIVEREF(__pyx_v_self->preset_name); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_self->preset_name); __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_NVENC_initialized_with_s_codec_a, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_9) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1739, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1740:
+1741: self.dump_caps(self.codec_name, codec)
__pyx_t_3 = __pyx_v_self->codec_name; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->dump_caps(__pyx_v_self, __pyx_t_3, __pyx_v_codec); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1741, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
1742: finally:
+1743: if params.encodeConfig!=NULL:
/*finally:*/ { /*normal exit:*/{ __pyx_t_4 = ((__pyx_v_params->encodeConfig != NULL) != 0); if (__pyx_t_4) { /* … */ } /* … */ __pyx_t_4 = ((__pyx_v_params->encodeConfig != NULL) != 0); if (__pyx_t_4) { /* … */ }
+1744: free(params.encodeConfig)
free(__pyx_v_params->encodeConfig); /* … */ free(__pyx_v_params->encodeConfig);
+1745: free(params)
free(__pyx_v_params); goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename; { /* … */ free(__pyx_v_params); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11; goto __pyx_L1_error; } __pyx_L5:; }
1746:
+1747: cdef dump_caps(self, codec_name, GUID codec):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_dump_caps(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_codec_name, GUID __pyx_v_codec) { PyObject *__pyx_v_caps = NULL; PyObject *__pyx_v_cap = NULL; PyObject *__pyx_v_descr = NULL; int __pyx_v_v; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dump_caps", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.dump_caps", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_caps); __Pyx_XDECREF(__pyx_v_cap); __Pyx_XDECREF(__pyx_v_descr); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1748: #test all caps:
+1749: caps = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_caps = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1750: for cap, descr in CAPS_NAMES.items():
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CAPS_NAMES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1750, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1750, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1750, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1750, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1750, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1750, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 1750, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1750, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_cap, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_descr, __pyx_t_6); __pyx_t_6 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1751: if cap!=NV_ENC_CAPS_EXPOSED_COUNT:
__pyx_t_1 = __Pyx_PyInt_From_NV_ENC_CAPS(NV_ENC_CAPS_EXPOSED_COUNT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1751, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_v_cap, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1751, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1751, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_9) { /* … */ }
+1752: v = self.query_encoder_caps(codec, cap)
__pyx_t_10 = ((NV_ENC_CAPS)__Pyx_PyInt_As_NV_ENC_CAPS(__pyx_v_cap)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1752, __pyx_L1_error) __pyx_t_11 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_encoder_caps(__pyx_v_self, __pyx_v_codec, __pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1752, __pyx_L1_error) __pyx_v_v = __pyx_t_11;
+1753: caps[descr] = v
__pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_v); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(PyDict_SetItem(__pyx_v_caps, __pyx_v_descr, __pyx_t_6) < 0)) __PYX_ERR(0, 1753, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1754: log("caps(%s)=%s", codec_name, caps)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_kp_s_caps_s_s, __pyx_v_codec_name, __pyx_v_caps}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1754, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_kp_s_caps_s_s, __pyx_v_codec_name, __pyx_v_caps}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1754, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_2 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_kp_s_caps_s_s); __Pyx_GIVEREF(__pyx_kp_s_caps_s_s); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_kp_s_caps_s_s); __Pyx_INCREF(__pyx_v_codec_name); __Pyx_GIVEREF(__pyx_v_codec_name); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, __pyx_v_codec_name); __Pyx_INCREF(__pyx_v_caps); __Pyx_GIVEREF(__pyx_v_caps); PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_11, __pyx_v_caps); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1755:
+1756: cdef init_params(self, GUID codec, NV_ENC_INITIALIZE_PARAMS *params):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_init_params(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, GUID __pyx_v_codec, NV_ENC_INITIALIZE_PARAMS *__pyx_v_params) { GUID __pyx_v_preset; NV_ENC_CONFIG *__pyx_v_config; NV_ENC_PRESET_CONFIG *__pyx_v_presetConfig; PyObject *__pyx_v_input_format = NULL; PyObject *__pyx_v_input_formats = NULL; PyObject *__pyx_v_qpmin = NULL; PyObject *__pyx_v_qpmax = NULL; PyObject *__pyx_v_qp = NULL; long __pyx_v_chromaFormatIDC; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_params", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_params", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_input_format); __Pyx_XDECREF(__pyx_v_input_formats); __Pyx_XDECREF(__pyx_v_qpmin); __Pyx_XDECREF(__pyx_v_qpmax); __Pyx_XDECREF(__pyx_v_qp); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1757: #caller must free the config!
1758: cdef GUID preset
+1759: cdef NV_ENC_CONFIG *config = NULL
__pyx_v_config = NULL;
+1760: cdef NV_ENC_PRESET_CONFIG *presetConfig = NULL #@DuplicatedSignature
__pyx_v_presetConfig = NULL;
+1761: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 1761, __pyx_L1_error) } } #endif
+1762: preset = self.get_preset(self.codec)
__pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->get_preset(__pyx_v_self, __pyx_v_self->codec); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1762, __pyx_L1_error)
__pyx_v_preset = __pyx_t_1;
+1763: self.preset_name = CODEC_PRESETS_GUIDS.get(guidstr(preset), guidstr(preset))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_CODEC_PRESETS_GUIDS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->preset_name); __Pyx_DECREF(__pyx_v_self->preset_name); __pyx_v_self->preset_name = __pyx_t_2; __pyx_t_2 = 0;
+1764: log("init_params(%s) using preset=%s", codecstr(codec), presetstr(preset))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_codec); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_presetstr(__pyx_v_preset); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_s_init_params_s_using_preset_s, __pyx_t_8, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_s_init_params_s_using_preset_s, __pyx_t_8, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_6 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_params_s_using_preset_s); __Pyx_GIVEREF(__pyx_kp_s_init_params_s_using_preset_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_init_params_s_using_preset_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_5); __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1764, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1765:
+1766: input_format = BUFFER_FORMAT[self.bufferFmt]
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BUFFER_FORMAT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(__pyx_v_self->bufferFmt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyObject_GetItem(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_input_format = __pyx_t_6; __pyx_t_6 = 0;
+1767: input_formats = self.query_input_formats(codec)
__pyx_t_6 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_input_formats(__pyx_v_self, __pyx_v_codec); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_input_formats = __pyx_t_6; __pyx_t_6 = 0;
+1768: assert input_format in input_formats, "%s does not support %s (only: %s)" % (self.codec_name, input_format, input_formats)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_v_input_format, __pyx_v_input_formats, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1768, __pyx_L1_error) if (unlikely(!(__pyx_t_9 != 0))) { __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_v_self->codec_name); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self->codec_name); __Pyx_INCREF(__pyx_v_input_format); __Pyx_GIVEREF(__pyx_v_input_format); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_input_format); __Pyx_INCREF(__pyx_v_input_formats); __Pyx_GIVEREF(__pyx_v_input_formats); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_input_formats); __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_does_not_support_s_only_s, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1768, __pyx_L1_error) } } #endif
1769:
+1770: assert memset(params, 0, sizeof(NV_ENC_INITIALIZE_PARAMS))!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((memset(__pyx_v_params, 0, (sizeof(NV_ENC_INITIALIZE_PARAMS))) != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1770, __pyx_L1_error) } } #endif
+1771: config = <NV_ENC_CONFIG*> cmalloc(sizeof(NV_ENC_CONFIG), "encoder config")
__pyx_t_10 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc((sizeof(NV_ENC_CONFIG)), __pyx_kp_s_encoder_config); if (unlikely(__pyx_t_10 == ((uintptr_t)0))) __PYX_ERR(0, 1771, __pyx_L1_error)
__pyx_v_config = ((NV_ENC_CONFIG *)__pyx_t_10);
1772:
+1773: presetConfig = self.get_preset_config(self.preset_name, codec, preset)
__pyx_t_4 = __pyx_v_self->preset_name; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->get_preset_config(__pyx_v_self, __pyx_t_4, __pyx_v_codec, __pyx_v_preset); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1773, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_presetConfig = __pyx_t_11;
+1774: assert presetConfig!=NULL, "could not find preset %s" % self.preset_name
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_presetConfig != NULL) != 0))) { __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_could_not_find_preset_s, __pyx_v_self->preset_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1774, __pyx_L1_error) } } #endif
+1775: try:
/*try:*/ {
+1776: assert memcpy(config, &presetConfig.presetCfg, sizeof(NV_ENC_CONFIG))!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((memcpy(__pyx_v_config, (&__pyx_v_presetConfig->presetCfg), (sizeof(NV_ENC_CONFIG))) != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1776, __pyx_L4_error) } } #endif
1777:
+1778: params.version = NV_ENC_INITIALIZE_PARAMS_VER
__pyx_v_params->version = NV_ENC_INITIALIZE_PARAMS_VER;
+1779: params.encodeGUID = codec
__pyx_v_params->encodeGUID = __pyx_v_codec;
+1780: params.presetGUID = preset
__pyx_v_params->presetGUID = __pyx_v_preset;
+1781: params.encodeWidth = self.encoder_width
__pyx_t_12 = __pyx_v_self->encoder_width; __pyx_v_params->encodeWidth = __pyx_t_12;
+1782: params.encodeHeight = self.encoder_height
__pyx_t_12 = __pyx_v_self->encoder_height; __pyx_v_params->encodeHeight = __pyx_t_12;
+1783: params.maxEncodeWidth = self.encoder_width
__pyx_t_12 = __pyx_v_self->encoder_width; __pyx_v_params->maxEncodeWidth = __pyx_t_12;
+1784: params.maxEncodeHeight = self.encoder_height
__pyx_t_12 = __pyx_v_self->encoder_height; __pyx_v_params->maxEncodeHeight = __pyx_t_12;
+1785: params.darWidth = self.encoder_width
__pyx_t_12 = __pyx_v_self->encoder_width; __pyx_v_params->darWidth = __pyx_t_12;
+1786: params.darHeight = self.encoder_height
__pyx_t_12 = __pyx_v_self->encoder_height; __pyx_v_params->darHeight = __pyx_t_12;
+1787: params.enableEncodeAsync = 0 #not supported on Linux
__pyx_v_params->enableEncodeAsync = 0;
+1788: params.enablePTD = 1 #not supported in sync mode!?
__pyx_v_params->enablePTD = 1;
+1789: params.reportSliceOffsets = 0
__pyx_v_params->reportSliceOffsets = 0;
+1790: params.enableSubFrameWrite = 0
__pyx_v_params->enableSubFrameWrite = 0;
1791:
+1792: params.frameRateNum = 30
__pyx_v_params->frameRateNum = 30;
+1793: params.frameRateDen = 1
__pyx_v_params->frameRateDen = 1;
+1794: params.encodeConfig = config
__pyx_v_params->encodeConfig = __pyx_v_config;
1795:
1796: #config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR #FIXME: check NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES caps
1797: #config.rcParams.enableMinQP = 1
1798: #config.rcParams.enableMaxQP = 1
+1799: config.gopLength = NVENC_INFINITE_GOPLENGTH
__pyx_v_config->gopLength = NVENC_INFINITE_GOPLENGTH;
+1800: config.frameIntervalP = 1
__pyx_v_config->frameIntervalP = 1;
1801: #0=max quality, 63 lowest quality
+1802: qpmin = QP_MAX_VALUE-min(QP_MAX_VALUE, int(QP_MAX_VALUE*(self.quality)//100))
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_long(((__pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE * __pyx_v_self->quality) / 0x64)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_9) { __Pyx_INCREF(__pyx_t_6); __pyx_t_2 = __pyx_t_6; } else { __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __pyx_t_8; __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1802, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_qpmin = __pyx_t_6; __pyx_t_6 = 0;
+1803: qpmax = QP_MAX_VALUE-max(0, int(QP_MAX_VALUE*self.quality//100))
__pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE * __pyx_v_self->quality) / 0x64)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = 0; __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) { __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = __pyx_t_2; } else { __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Subtract(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1803, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_qpmax = __pyx_t_2; __pyx_t_2 = 0;
+1804: config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME
__pyx_v_config->frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME;
1805: #config.mvPrecision = NV_ENC_MV_PRECISION_FULL_PEL
1806: if True:
1807: #const QP:
+1808: config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP
__pyx_v_config->rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
+1809: if self.preset_name.find("lossless")>=0:
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->preset_name, __pyx_n_s_find); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1809, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1809, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1809, __pyx_L4_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1809, __pyx_L4_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { /* … */ goto __pyx_L6; } /* … */ __pyx_tuple__24 = PyTuple_Pack(1, __pyx_n_s_lossless); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 1809, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24);
+1810: qp = 0
__Pyx_INCREF(__pyx_int_0);
__pyx_v_qp = __pyx_int_0;
1811: else:
+1812: qp = min(QP_MAX_VALUE, max(0, (qpmin + qpmax)//2))
/*else*/ { __pyx_t_2 = PyNumber_Add(__pyx_v_qpmin, __pyx_v_qpmax); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_13 = 0; __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_6, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) { __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = __pyx_t_4; } else { __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __pyx_v_4xpra_6codecs_5nvenc_7encoder_QP_MAX_VALUE; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_9) { __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = __pyx_t_4; } else { __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1812, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __pyx_t_6; __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_qp = __pyx_t_4; __pyx_t_4 = 0; } __pyx_L6:;
+1813: config.rcParams.constQP.qpInterP = qp
__pyx_t_14 = __Pyx_PyInt_As_uint32_t(__pyx_v_qp); if (unlikely((__pyx_t_14 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1813, __pyx_L4_error) __pyx_v_config->rcParams.constQP.qpInterP = __pyx_t_14;
+1814: config.rcParams.constQP.qpInterB = qp
__pyx_t_14 = __Pyx_PyInt_As_uint32_t(__pyx_v_qp); if (unlikely((__pyx_t_14 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1814, __pyx_L4_error) __pyx_v_config->rcParams.constQP.qpInterB = __pyx_t_14;
+1815: config.rcParams.constQP.qpIntra = qp
__pyx_t_14 = __Pyx_PyInt_As_uint32_t(__pyx_v_qp); if (unlikely((__pyx_t_14 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1815, __pyx_L4_error) __pyx_v_config->rcParams.constQP.qpIntra = __pyx_t_14;
1816: else:
1817: config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR
1818: config.rcParams.averageBitRate = 500000
1819: config.rcParams.maxBitRate = 600000
1820: #config.rcParams.vbvBufferSize = 0
1821: #config.rcParams.vbvInitialDelay = 0
1822: #config.rcParams.enableInitialRCQP = 1
1823: #config.rcParams.initialRCQP.qpInterP = qpmin
1824: #config.rcParams.initialRCQP.qpIntra = qpmin
1825: #config.rcParams.initialRCQP.qpInterB = qpmin
1826:
+1827: if self.pixel_format=="BGRX":
__pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_BGRX, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1827, __pyx_L4_error) if (__pyx_t_9) { /* … */ goto __pyx_L7; }
+1828: chromaFormatIDC = 3
__pyx_v_chromaFormatIDC = 3;
+1829: elif self.pixel_format=="NV12":
__pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_NV12, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1829, __pyx_L4_error) if (__pyx_t_9) { /* … */ goto __pyx_L7; }
+1830: chromaFormatIDC = 1
__pyx_v_chromaFormatIDC = 1;
+1831: elif self.pixel_format=="YUV444P":
__pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_YUV444P, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1831, __pyx_L4_error) if (__pyx_t_9) { /* … */ goto __pyx_L7; }
+1832: chromaFormatIDC = 3
__pyx_v_chromaFormatIDC = 3;
1833: else:
+1834: raise Exception("unknown pixel format %s" % self.pixel_format)
/*else*/ { __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_unknown_pixel_format_s, __pyx_v_self->pixel_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1834, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1834, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1834, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1834, __pyx_L4_error) } __pyx_L7:;
1835:
+1836: if self.codec_name=="H264":
__pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->codec_name, __pyx_n_s_H264, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1836, __pyx_L4_error) if (__pyx_t_9) { /* … */ goto __pyx_L8; }
+1837: config.encodeCodecConfig.h264Config.chromaFormatIDC = chromaFormatIDC
__pyx_v_config->encodeCodecConfig.h264Config.chromaFormatIDC = __pyx_v_chromaFormatIDC;
1838: #config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 0
1839: #config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 0
+1840: config.encodeCodecConfig.h264Config.idrPeriod = config.gopLength
__pyx_t_14 = __pyx_v_config->gopLength; __pyx_v_config->encodeCodecConfig.h264Config.idrPeriod = __pyx_t_14;
+1841: config.encodeCodecConfig.h264Config.enableIntraRefresh = 0
__pyx_v_config->encodeCodecConfig.h264Config.enableIntraRefresh = 0;
1842: #config.encodeCodecConfig.h264Config.maxNumRefFrames = 16
1843: #config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = 1 #AVCOL_SPC_BT709 ?
1844: #config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = 1 #AVCOL_PRI_BT709 ?
1845: #config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = 1 #AVCOL_TRC_BT709 ?
1846: #config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = 1
1847: else:
+1848: assert self.codec_name=="H265"
/*else*/ { #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->codec_name, __pyx_n_s_H265, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1848, __pyx_L4_error) if (unlikely(!__pyx_t_9)) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1848, __pyx_L4_error) } } #endif
+1849: config.encodeCodecConfig.hevcConfig.chromaFormatIDC = chromaFormatIDC
__pyx_v_config->encodeCodecConfig.hevcConfig.chromaFormatIDC = __pyx_v_chromaFormatIDC;
1850: #config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_HEVC_5
+1851: config.encodeCodecConfig.hevcConfig.idrPeriod = config.gopLength
__pyx_t_14 = __pyx_v_config->gopLength; __pyx_v_config->encodeCodecConfig.hevcConfig.idrPeriod = __pyx_t_14;
+1852: config.encodeCodecConfig.hevcConfig.enableIntraRefresh = 0
__pyx_v_config->encodeCodecConfig.hevcConfig.enableIntraRefresh = 0; } __pyx_L8:; }
1853: #config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = 16
1854: #config.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFormat = ...
1855: finally:
+1856: if presetConfig!=NULL:
/*finally:*/ { /*normal exit:*/{ __pyx_t_9 = ((__pyx_v_presetConfig != NULL) != 0); if (__pyx_t_9) { /* … */ } goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_7 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __pyx_t_9 = ((__pyx_v_presetConfig != NULL) != 0); if (__pyx_t_9) { /* … */ } } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L1_error; } __pyx_L5:; }
+1857: free(presetConfig)
free(__pyx_v_presetConfig); /* … */ free(__pyx_v_presetConfig);
1858:
+1859: def init_buffers(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_15init_buffers(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_15init_buffers(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_buffers (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_14init_buffers(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_14init_buffers(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { NV_ENC_REGISTER_RESOURCE __pyx_v_registerResource; NV_ENC_CREATE_BITSTREAM_BUFFER __pyx_v_createBitstreamBufferParams; uintptr_t __pyx_v_resource; CYTHON_UNUSED unsigned char *__pyx_v_cptr; NVENCSTATUS __pyx_v_r; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_buffers", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.init_buffers", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1860: cdef NV_ENC_REGISTER_RESOURCE registerResource
1861: cdef NV_ENC_CREATE_INPUT_BUFFER createInputBufferParams
1862: cdef NV_ENC_CREATE_BITSTREAM_BUFFER createBitstreamBufferParams
1863: cdef uintptr_t resource
1864: cdef Py_ssize_t size
+1865: cdef unsigned char* cptr = NULL
__pyx_v_cptr = NULL;
1866: cdef NVENCSTATUS r #
+1867: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 1867, __pyx_L1_error) } } #endif
1868: #register CUDA input buffer:
+1869: memset(®isterResource, 0, sizeof(NV_ENC_REGISTER_RESOURCE))
memset((&__pyx_v_registerResource), 0, (sizeof(NV_ENC_REGISTER_RESOURCE)));
+1870: registerResource.version = NV_ENC_REGISTER_RESOURCE_VER
__pyx_v_registerResource.version = NV_ENC_REGISTER_RESOURCE_VER;
+1871: registerResource.resourceType = NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR
__pyx_v_registerResource.resourceType = NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR;
+1872: resource = int(self.cudaOutputBuffer)
__pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_self->cudaOutputBuffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_2 == ((uintptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1872, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_resource = __pyx_t_2;
+1873: registerResource.resourceToRegister = <void *> resource
__pyx_v_registerResource.resourceToRegister = ((void *)__pyx_v_resource);
+1874: registerResource.width = self.encoder_width
__pyx_t_3 = __pyx_v_self->encoder_width; __pyx_v_registerResource.width = __pyx_t_3;
+1875: registerResource.height = self.encoder_height
__pyx_t_3 = __pyx_v_self->encoder_height; __pyx_v_registerResource.height = __pyx_t_3;
+1876: registerResource.pitch = self.outputPitch
__pyx_t_3 = __pyx_v_self->outputPitch; __pyx_v_registerResource.pitch = __pyx_t_3;
+1877: registerResource.bufferFormat = self.bufferFmt
__pyx_t_4 = __pyx_v_self->bufferFmt; __pyx_v_registerResource.bufferFormat = __pyx_t_4;
+1878: if DEBUG_API:
__pyx_t_5 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_5) { /* … */ }
+1879: log("nvEncRegisterResource(%#x)", <uintptr_t> ®isterResource)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_registerResource))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_nvEncRegisterResource_x, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1879, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_nvEncRegisterResource_x, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1879, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncRegisterResource_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncRegisterResource_x); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_nvEncRegisterResource_x); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1880: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+1881: r = self.functionList.nvEncRegisterResource(self.context, ®isterResource)
__pyx_v_r = __pyx_v_self->functionList->nvEncRegisterResource(__pyx_v_self->context, (&__pyx_v_registerResource)); }
+1882: raiseNVENC(r, "registering CUDA input buffer")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_registering_CUDA_input_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1883: self.inputHandle = registerResource.registeredResource
__pyx_t_11 = __pyx_v_registerResource.registeredResource; __pyx_v_self->inputHandle = __pyx_t_11;
+1884: log("input handle for CUDA buffer: %#x", <uintptr_t> self.inputHandle)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->inputHandle)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_input_handle_for_CUDA_buffer_x, __pyx_t_10}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1884, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_input_handle_for_CUDA_buffer_x, __pyx_t_10}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1884, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_input_handle_for_CUDA_buffer_x); __Pyx_GIVEREF(__pyx_kp_s_input_handle_for_CUDA_buffer_x); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_kp_s_input_handle_for_CUDA_buffer_x); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1885:
1886: #allocate output buffer:
+1887: memset(&createBitstreamBufferParams, 0, sizeof(NV_ENC_CREATE_BITSTREAM_BUFFER))
memset((&__pyx_v_createBitstreamBufferParams), 0, (sizeof(NV_ENC_CREATE_BITSTREAM_BUFFER)));
+1888: createBitstreamBufferParams.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER
__pyx_v_createBitstreamBufferParams.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER;
1889: #this is the uncompressed size - must be big enough for the compressed stream:
+1890: createBitstreamBufferParams.size = min(1024*1024*2, self.encoder_width*self.encoder_height*3//2)
__pyx_t_12 = (((__pyx_v_self->encoder_width * __pyx_v_self->encoder_height) * 3) / 2); __pyx_t_13 = 0x200000; if (((__pyx_t_12 < __pyx_t_13) != 0)) { __pyx_t_14 = __pyx_t_12; } else { __pyx_t_14 = __pyx_t_13; } __pyx_v_createBitstreamBufferParams.size = __pyx_t_14;
+1891: createBitstreamBufferParams.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED
__pyx_v_createBitstreamBufferParams.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;
+1892: if DEBUG_API:
__pyx_t_5 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_5) { /* … */ }
+1893: log("nvEncCreateBitstreamBuffer(%#x)", <uintptr_t> &createBitstreamBufferParams)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_createBitstreamBufferParams))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_nvEncCreateBitstreamBuffer_x, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1893, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_nvEncCreateBitstreamBuffer_x, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1893, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncCreateBitstreamBuffer_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncCreateBitstreamBuffer_x); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_kp_s_nvEncCreateBitstreamBuffer_x); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1894: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L10; } __pyx_L10:; } }
+1895: r = self.functionList.nvEncCreateBitstreamBuffer(self.context, &createBitstreamBufferParams)
__pyx_v_r = __pyx_v_self->functionList->nvEncCreateBitstreamBuffer(__pyx_v_self->context, (&__pyx_v_createBitstreamBufferParams)); }
+1896: raiseNVENC(r, "creating output buffer")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_creating_output_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1896, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1897: self.bitstreamBuffer = createBitstreamBufferParams.bitstreamBuffer
__pyx_t_15 = __pyx_v_createBitstreamBufferParams.bitstreamBuffer; __pyx_v_self->bitstreamBuffer = __pyx_t_15;
+1898: log("output bitstream buffer=%#x", <uintptr_t> self.bitstreamBuffer)
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->bitstreamBuffer)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_output_bitstream_buffer_x, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1898, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_output_bitstream_buffer_x, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1898, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_output_bitstream_buffer_x); __Pyx_GIVEREF(__pyx_kp_s_output_bitstream_buffer_x); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_output_bitstream_buffer_x); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1899: assert self.bitstreamBuffer!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->bitstreamBuffer != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1899, __pyx_L1_error) } } #endif
1900:
1901:
+1902: def get_info(self): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_17get_info(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_17get_info(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_info (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_16get_info(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_16get_info(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { double __pyx_v_pps; PyObject *__pyx_v_info = NULL; unsigned PY_LONG_LONG __pyx_v_b; double __pyx_v_t; uint64_t __pyx_v_m; int __pyx_v_f; double __pyx_v_now; double __pyx_v_last_time; double __pyx_v_cut_off; double __pyx_v_ms_per_frame; PyObject *__pyx_v_start = NULL; PyObject *__pyx_v_end = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_info", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_info", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_info); __Pyx_XDECREF(__pyx_v_start); __Pyx_XDECREF(__pyx_v_end); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1903: global YUV444_CODEC_SUPPORT, YUV444_ENABLED, LOSSLESS_CODEC_SUPPORT, LOSSLESS_ENABLED
1904: cdef double pps
+1905: info = get_info()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1905, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1905, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_info = __pyx_t_1; __pyx_t_1 = 0;
+1906: info.update({
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_info, __pyx_n_s_update); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+1907: "width" : self.width,
__pyx_t_3 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->width); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_width, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1908: "height" : self.height,
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->height); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_height, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1909: "frames" : self.frames,
__pyx_t_4 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->frames); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_frames, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1910: "codec" : self.codec_name,
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_codec, __pyx_v_self->codec_name) < 0) __PYX_ERR(0, 1907, __pyx_L1_error)
+1911: "encoder_width" : self.encoder_width,
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->encoder_width); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1911, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_encoder_width, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1912: "encoder_height" : self.encoder_height,
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->encoder_height); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_encoder_height, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1913: "bitrate" : self.target_bitrate,
__pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_self->target_bitrate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_bitrate, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1914: "quality" : self.quality,
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quality, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1915: "speed" : self.speed,
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_speed, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1916: "lossless" : {
+1917: "" : self.lossless,
__pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_uint8_t(__pyx_v_self->lossless); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_kp_s__18, __pyx_t_5) < 0) __PYX_ERR(0, 1917, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1918: "supported" : LOSSLESS_CODEC_SUPPORT.get(self.encoding, LOSSLESS_ENABLED),
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_LOSSLESS_CODEC_SUPPORT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_self->encoding, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_self->encoding, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_v_self->encoding); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_supported, __pyx_t_5) < 0) __PYX_ERR(0, 1917, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1919: "threshold" : LOSSLESS_THRESHOLD
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_THRESHOLD); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_threshold, __pyx_t_5) < 0) __PYX_ERR(0, 1917, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_lossless, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1920: },
1921: "yuv444" : {
+1922: "supported" : YUV444_CODEC_SUPPORT.get(self.encoding, YUV444_ENABLED),
__pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_get); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self->encoding, __pyx_t_7}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_self->encoding, __pyx_t_7}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_v_self->encoding); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_self->encoding); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_supported, __pyx_t_5) < 0) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1923: "threshold" : YUV444_THRESHOLD,
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_THRESHOLD); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_threshold, __pyx_t_5) < 0) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_yuv444, __pyx_t_4) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1924: },
+1925: "cuda-device" : self.cuda_device_info,
if (PyDict_SetItem(__pyx_t_3, __pyx_kp_s_cuda_device_2, __pyx_v_self->cuda_device_info) < 0) __PYX_ERR(0, 1907, __pyx_L1_error)
+1926: "cuda" : self.cuda_info,
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_cuda, __pyx_v_self->cuda_info) < 0) __PYX_ERR(0, 1907, __pyx_L1_error)
+1927: "pycuda" : self.pycuda_info,
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pycuda, __pyx_v_self->pycuda_info) < 0) __PYX_ERR(0, 1907, __pyx_L1_error) __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1906, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1906, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1906, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1928: })
+1929: if self.scaling!=(1,1):
__pyx_t_1 = PyObject_RichCompare(__pyx_v_self->scaling, __pyx_tuple__25, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1929, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1929, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_11) { /* … */ } /* … */ __pyx_tuple__25 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 1929, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25);
+1930: info.update({
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_info, __pyx_n_s_update); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+1931: "input_width" : self.input_width,
__pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1931, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->input_width); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1931, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_input_width, __pyx_t_3) < 0) __PYX_ERR(0, 1931, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1932: "input_height" : self.input_height,
__pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->input_height); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_input_height, __pyx_t_3) < 0) __PYX_ERR(0, 1931, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1933: "scaling" : self.scaling})
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_scaling, __pyx_v_self->scaling) < 0) __PYX_ERR(0, 1931, __pyx_L1_error) __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1930, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1930, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1934: if self.src_format:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_self->src_format); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1934, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
+1935: info["src_format"] = self.src_format
__pyx_t_1 = __pyx_v_self->src_format; __Pyx_INCREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_src_format, __pyx_t_1) < 0)) __PYX_ERR(0, 1935, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1936: if self.pixel_format:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_self->pixel_format); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1936, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
+1937: info["pixel_format"] = self.pixel_format
__pyx_t_1 = __pyx_v_self->pixel_format; __Pyx_INCREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_pixel_format, __pyx_t_1) < 0)) __PYX_ERR(0, 1937, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1938: cdef unsigned long long b = self.bytes_in
__pyx_t_12 = __pyx_v_self->bytes_in; __pyx_v_b = __pyx_t_12;
+1939: if b>0 and self.bytes_out>0:
__pyx_t_13 = ((__pyx_v_b > 0) != 0); if (__pyx_t_13) { } else { __pyx_t_11 = __pyx_t_13; goto __pyx_L7_bool_binop_done; } __pyx_t_13 = ((__pyx_v_self->bytes_out > 0) != 0); __pyx_t_11 = __pyx_t_13; __pyx_L7_bool_binop_done:; if (__pyx_t_11) { /* … */ }
+1940: info.update({
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_info, __pyx_n_s_update); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1940, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+1941: "bytes_in" : self.bytes_in,
__pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->bytes_in); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_bytes_in, __pyx_t_5) < 0) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1942: "bytes_out" : self.bytes_out,
__pyx_t_5 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->bytes_out); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_bytes_out, __pyx_t_5) < 0) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1943: "ratio_pct" : int(100 * self.bytes_out // b)})
__pyx_t_5 = __Pyx_PyInt_From_uint64_t(((0x64 * __pyx_v_self->bytes_out) / __pyx_v_b)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_ratio_pct, __pyx_t_5) < 0) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1940, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1940, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1940, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1940, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1940, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1944: if self.preset_name:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_self->preset_name); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1944, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
+1945: info["preset"] = self.preset_name
__pyx_t_1 = __pyx_v_self->preset_name; __Pyx_INCREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_preset, __pyx_t_1) < 0)) __PYX_ERR(0, 1945, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1946: cdef double t = self.time
__pyx_t_14 = __pyx_v_self->time; __pyx_v_t = __pyx_t_14;
+1947: info["total_time_ms"] = int(self.time*1000.0)
__pyx_t_1 = __Pyx_PyInt_FromDouble((__pyx_v_self->time * 1000.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1947, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_total_time_ms, __pyx_t_1) < 0)) __PYX_ERR(0, 1947, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1948: if self.frames>0 and t>0:
__pyx_t_13 = ((__pyx_v_self->frames > 0) != 0); if (__pyx_t_13) { } else { __pyx_t_11 = __pyx_t_13; goto __pyx_L11_bool_binop_done; } __pyx_t_13 = ((__pyx_v_t > 0.0) != 0); __pyx_t_11 = __pyx_t_13; __pyx_L11_bool_binop_done:; if (__pyx_t_11) { /* … */ }
+1949: pps = float(self.width) * float(self.height) * float(self.frames) / t
__pyx_v_pps = (((((double)__pyx_v_self->width) * ((double)__pyx_v_self->height)) * ((double)__pyx_v_self->frames)) / __pyx_v_t);
+1950: info["pixels_per_second"] = int(pps)
__pyx_t_1 = __Pyx_PyInt_FromDouble(__pyx_v_pps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_pixels_per_second, __pyx_t_1) < 0)) __PYX_ERR(0, 1950, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1951: info["free_memory"] = int(self.free_memory)
__pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->free_memory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_free_memory, __pyx_t_1) < 0)) __PYX_ERR(0, 1951, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1952: info["total_memory"] = int(self.total_memory)
__pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->total_memory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_total_memory, __pyx_t_1) < 0)) __PYX_ERR(0, 1952, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1953: cdef uint64_t m = self.total_memory
__pyx_t_12 = __pyx_v_self->total_memory; __pyx_v_m = __pyx_t_12;
+1954: if m>0:
__pyx_t_11 = ((__pyx_v_m > 0) != 0); if (__pyx_t_11) { /* … */ }
+1955: info["free_memory_pct"] = int(100.0*self.free_memory/m)
__pyx_t_1 = __Pyx_PyInt_FromDouble(((100.0 * __pyx_v_self->free_memory) / __pyx_v_m)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1955, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_free_memory_pct, __pyx_t_1) < 0)) __PYX_ERR(0, 1955, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1956: #calculate fps:
+1957: cdef int f = 0
__pyx_v_f = 0;
+1958: cdef double now = monotonic_time()
__pyx_v_now = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+1959: cdef double last_time = now
__pyx_v_last_time = __pyx_v_now;
+1960: cdef double cut_off = now-10.0
__pyx_v_cut_off = (__pyx_v_now - 10.0);
+1961: cdef double ms_per_frame = 0
__pyx_v_ms_per_frame = 0.0;
+1962: for start,end in tuple(self.last_frame_times):
__pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_self->last_frame_times); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_15); __Pyx_INCREF(__pyx_t_1); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 1962, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1962, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_16 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_16(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L16_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_16(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L16_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_5), 2) < 0) __PYX_ERR(0, 1962, __pyx_L1_error) __pyx_t_16 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L17_unpacking_done; __pyx_L16_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_16 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1962, __pyx_L1_error) __pyx_L17_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_start, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_end, __pyx_t_4); __pyx_t_4 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1963: if end>cut_off:
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_cut_off); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1963, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyObject_RichCompare(__pyx_v_end, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1963, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1963, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_11) { /* … */ }
+1964: f += 1
__pyx_v_f = (__pyx_v_f + 1);
+1965: last_time = min(last_time, end)
__Pyx_INCREF(__pyx_v_end); __pyx_t_4 = __pyx_v_end; __pyx_t_14 = __pyx_v_last_time; __pyx_t_3 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1965, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1965, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1965, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_11) { __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; } else { __pyx_t_5 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1965, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_14 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_14 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1965, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_last_time = __pyx_t_14;
+1966: ms_per_frame += (end-start)
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_ms_per_frame); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyNumber_Subtract(__pyx_v_end, __pyx_v_start); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_14 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_14 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1966, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ms_per_frame = __pyx_t_14;
+1967: if f>0 and last_time<now:
__pyx_t_13 = ((__pyx_v_f > 0) != 0); if (__pyx_t_13) { } else { __pyx_t_11 = __pyx_t_13; goto __pyx_L20_bool_binop_done; } __pyx_t_13 = ((__pyx_v_last_time < __pyx_v_now) != 0); __pyx_t_11 = __pyx_t_13; __pyx_L20_bool_binop_done:; if (__pyx_t_11) { /* … */ }
+1968: info["fps"] = int(0.5+f/(now-last_time))
__pyx_t_2 = __Pyx_PyInt_FromDouble((0.5 + (__pyx_v_f / (__pyx_v_now - __pyx_v_last_time)))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_fps, __pyx_t_2) < 0)) __PYX_ERR(0, 1968, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1969: info["ms_per_frame"] = int(1000.0*ms_per_frame/f)
__pyx_t_2 = __Pyx_PyInt_FromDouble(((1000.0 * __pyx_v_ms_per_frame) / __pyx_v_f)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1969, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyObject_SetItem(__pyx_v_info, __pyx_n_s_ms_per_frame, __pyx_t_2) < 0)) __PYX_ERR(0, 1969, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1970: return info
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_info); __pyx_r = __pyx_v_info; goto __pyx_L0;
1971:
+1972: def __repr__(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_19__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_19__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_18__repr__(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_18__repr__(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1973: return "nvenc(%s/%s/%s - %s - %4ix%-4i)" % (self.src_format, self.pixel_format, self.codec_name, self.preset_name, self.width, self.height)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->width); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->height); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_self->src_format); __Pyx_GIVEREF(__pyx_v_self->src_format); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->src_format); __Pyx_INCREF(__pyx_v_self->pixel_format); __Pyx_GIVEREF(__pyx_v_self->pixel_format); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->pixel_format); __Pyx_INCREF(__pyx_v_self->codec_name); __Pyx_GIVEREF(__pyx_v_self->codec_name); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->codec_name); __Pyx_INCREF(__pyx_v_self->preset_name); __Pyx_GIVEREF(__pyx_v_self->preset_name); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->preset_name); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_nvenc_s_s_s_s_4ix_4i, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
1974:
+1975: def is_closed(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_21is_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_21is_closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_closed (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_20is_closed(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_20is_closed(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_closed", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.is_closed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1976: return self.context==NULL
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->context == NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1976, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1977:
+1978: def __dealloc__(self):
/* Python wrapper */ static void __pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_23__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_23__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_22__dealloc__(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_22__dealloc__(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_WriteUnraisable("xpra.codecs.nvenc.encoder.Encoder.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
+1979: self.clean()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1979, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1979, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1980:
+1981: def clean(self): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_25clean(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_25clean(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("clean (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_24clean(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_24clean(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("clean", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.clean", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1982: log("clean() cuda_context=%s, encoder context=%#x", self.cuda_context, <uintptr_t> self.context)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->context)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_clean_cuda_context_s_encoder_con, __pyx_v_self->cuda_context, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1982, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_clean_cuda_context_s_encoder_con, __pyx_v_self->cuda_context, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1982, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_clean_cuda_context_s_encoder_con); __Pyx_GIVEREF(__pyx_kp_s_clean_cuda_context_s_encoder_con); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_clean_cuda_context_s_encoder_con); __Pyx_INCREF(__pyx_v_self->cuda_context); __Pyx_GIVEREF(__pyx_v_self->cuda_context); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_self->cuda_context); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1983: if self.cuda_context:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->cuda_context); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1983, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+1984: self.cuda_context.push()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cuda_context, __pyx_n_s_push); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1984, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1984, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1985: try:
/*try:*/ {
+1986: self.cuda_clean()
__pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->cuda_clean(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1986, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
1987: finally:
+1988: self.cuda_context.pop()
/*finally:*/ { /*normal exit:*/{ __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_self->cuda_context); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1988, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_self->cuda_context); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1988, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1989: self.cuda_context.detach()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cuda_context, __pyx_n_s_detach); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1989, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1989, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cuda_context, __pyx_n_s_detach); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1989, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1989, __pyx_L8_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1989, __pyx_L8_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1990: self.cuda_context = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_context); __Pyx_DECREF(__pyx_v_self->cuda_context); __pyx_v_self->cuda_context = Py_None; goto __pyx_L6; } __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_5 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename; { /* … */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_context); __Pyx_DECREF(__pyx_v_self->cuda_context); __pyx_v_self->cuda_context = Py_None; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9; goto __pyx_L1_error; __pyx_L8_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; goto __pyx_L1_error; } __pyx_L6:; }
+1991: self.width = 0
__pyx_v_self->width = 0;
+1992: self.height = 0
__pyx_v_self->height = 0;
+1993: self.input_width = 0
__pyx_v_self->input_width = 0;
+1994: self.input_height = 0
__pyx_v_self->input_height = 0;
+1995: self.encoder_width = 0
__pyx_v_self->encoder_width = 0;
+1996: self.encoder_height = 0
__pyx_v_self->encoder_height = 0;
+1997: self.src_format = ""
__Pyx_INCREF(__pyx_kp_s__18); __Pyx_GIVEREF(__pyx_kp_s__18); __Pyx_GOTREF(__pyx_v_self->src_format); __Pyx_DECREF(__pyx_v_self->src_format); __pyx_v_self->src_format = __pyx_kp_s__18;
+1998: self.dst_formats = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dst_formats); __Pyx_DECREF(__pyx_v_self->dst_formats); __pyx_v_self->dst_formats = __pyx_t_1; __pyx_t_1 = 0;
+1999: self.scaling = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->scaling); __Pyx_DECREF(__pyx_v_self->scaling); __pyx_v_self->scaling = Py_None;
+2000: self.speed = 0
__pyx_v_self->speed = 0;
+2001: self.quality = 0
__pyx_v_self->quality = 0;
2002: #PyCUDA:
+2003: self.driver = 0
__Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_GOTREF(__pyx_v_self->driver); __Pyx_DECREF(__pyx_v_self->driver); __pyx_v_self->driver = __pyx_int_0;
+2004: self.cuda_device_id = -1
__pyx_v_self->cuda_device_id = -1;
+2005: self.cuda_info = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_info); __Pyx_DECREF(__pyx_v_self->cuda_info); __pyx_v_self->cuda_info = Py_None;
+2006: self.pycuda_info = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->pycuda_info); __Pyx_DECREF(__pyx_v_self->pycuda_info); __pyx_v_self->pycuda_info = Py_None;
+2007: self.cuda_device_info = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_device_info); __Pyx_DECREF(__pyx_v_self->cuda_device_info); __pyx_v_self->cuda_device_info = Py_None;
+2008: self.cuda_device = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cuda_device); __Pyx_DECREF(__pyx_v_self->cuda_device); __pyx_v_self->cuda_device = Py_None;
+2009: self.kernel = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->kernel); __Pyx_DECREF(__pyx_v_self->kernel); __pyx_v_self->kernel = Py_None;
+2010: self.kernel_name = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->kernel_name); __Pyx_DECREF(__pyx_v_self->kernel_name); __pyx_v_self->kernel_name = Py_None;
+2011: self.max_block_sizes = 0
__Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_GOTREF(__pyx_v_self->max_block_sizes); __Pyx_DECREF(__pyx_v_self->max_block_sizes); __pyx_v_self->max_block_sizes = __pyx_int_0;
+2012: self.max_grid_sizes = 0
__Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_GOTREF(__pyx_v_self->max_grid_sizes); __Pyx_DECREF(__pyx_v_self->max_grid_sizes); __pyx_v_self->max_grid_sizes = __pyx_int_0;
+2013: self.max_threads_per_block = 0
__pyx_v_self->max_threads_per_block = 0;
+2014: self.free_memory = 0
__pyx_v_self->free_memory = 0;
+2015: self.total_memory = 0
__pyx_v_self->total_memory = 0;
2016: #NVENC (mostly already cleaned up in cuda_clean):
+2017: self.inputPitch = 0
__pyx_v_self->inputPitch = 0;
+2018: self.outputPitch = 0
__pyx_v_self->outputPitch = 0;
+2019: self.bitstreamBuffer = NULL
__pyx_v_self->bitstreamBuffer = NULL;
+2020: self.bufferFmt = NV_ENC_BUFFER_FORMAT_UNDEFINED
__pyx_v_self->bufferFmt = NV_ENC_BUFFER_FORMAT_UNDEFINED;
+2021: self.codec_name = ""
__Pyx_INCREF(__pyx_kp_s__18); __Pyx_GIVEREF(__pyx_kp_s__18); __Pyx_GOTREF(__pyx_v_self->codec_name); __Pyx_DECREF(__pyx_v_self->codec_name); __pyx_v_self->codec_name = __pyx_kp_s__18;
+2022: self.preset_name = ""
__Pyx_INCREF(__pyx_kp_s__18); __Pyx_GIVEREF(__pyx_kp_s__18); __Pyx_GOTREF(__pyx_v_self->preset_name); __Pyx_DECREF(__pyx_v_self->preset_name); __pyx_v_self->preset_name = __pyx_kp_s__18;
+2023: self.pixel_format = ""
__Pyx_INCREF(__pyx_kp_s__18); __Pyx_GIVEREF(__pyx_kp_s__18); __Pyx_GOTREF(__pyx_v_self->pixel_format); __Pyx_DECREF(__pyx_v_self->pixel_format); __pyx_v_self->pixel_format = __pyx_kp_s__18;
2024: #statistics, etc:
+2025: self.time = 0
__pyx_v_self->time = 0.0;
+2026: self.frames = 0
__pyx_v_self->frames = 0;
+2027: self.first_frame_timestamp = 0
__pyx_v_self->first_frame_timestamp = 0;
+2028: self.last_frame_times = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2028, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->last_frame_times); __Pyx_DECREF(__pyx_v_self->last_frame_times); __pyx_v_self->last_frame_times = __pyx_t_1; __pyx_t_1 = 0;
+2029: self.bytes_in = 0
__pyx_v_self->bytes_in = 0;
+2030: self.bytes_out = 0
__pyx_v_self->bytes_out = 0;
2031:
2032:
+2033: cdef cuda_clean(self):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_cuda_clean(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { NVENCSTATUS __pyx_v_r; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cuda_clean", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.cuda_clean", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2034: cdef NVENCSTATUS r #@DuplicatedSignature
+2035: if self.context!=NULL and self.frames>0:
__pyx_t_2 = ((__pyx_v_self->context != NULL) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = ((__pyx_v_self->frames > 0) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+2036: self.flushEncoder()
__pyx_t_3 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->flushEncoder(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2036, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2037: if self.inputHandle!=NULL and self.context!=NULL:
__pyx_t_2 = ((__pyx_v_self->inputHandle != NULL) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L7_bool_binop_done; } __pyx_t_2 = ((__pyx_v_self->context != NULL) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L7_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+2038: log("cuda_clean() unregistering CUDA output buffer input handle %#x", <uintptr_t> self.inputHandle)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->inputHandle)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_cuda_clean_unregistering_CUDA_ou, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_cuda_clean_unregistering_CUDA_ou, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_unregistering_CUDA_ou); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_unregistering_CUDA_ou); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_unregistering_CUDA_ou); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2039: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2040: log("nvEncUnregisterResource(%#x)", <uintptr_t> self.inputHandle)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->inputHandle)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncUnregisterResource_x, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2040, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncUnregisterResource_x, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2040, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncUnregisterResource_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncUnregisterResource_x); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_nvEncUnregisterResource_x); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2041: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L12; } __pyx_L12:; } }
+2042: r = self.functionList.nvEncUnregisterResource(self.context, self.inputHandle)
__pyx_v_r = __pyx_v_self->functionList->nvEncUnregisterResource(__pyx_v_self->context, __pyx_v_self->inputHandle); }
+2043: raiseNVENC(r, "unregistering CUDA input buffer")
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_unregistering_CUDA_input_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2043, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2044: self.inputHandle = NULL
__pyx_v_self->inputHandle = NULL;
+2045: if self.inputBuffer is not None:
__pyx_t_1 = (__pyx_v_self->inputBuffer != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* … */ }
+2046: log("cuda_clean() freeing CUDA host buffer %s", self.inputBuffer)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_cuda_clean_freeing_CUDA_host_buf, __pyx_v_self->inputBuffer}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2046, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_cuda_clean_freeing_CUDA_host_buf, __pyx_v_self->inputBuffer}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2046, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_freeing_CUDA_host_buf); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_freeing_CUDA_host_buf); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_freeing_CUDA_host_buf); __Pyx_INCREF(__pyx_v_self->inputBuffer); __Pyx_GIVEREF(__pyx_v_self->inputBuffer); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_self->inputBuffer); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2047: self.inputBuffer = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->inputBuffer); __Pyx_DECREF(__pyx_v_self->inputBuffer); __pyx_v_self->inputBuffer = Py_None;
+2048: if self.cudaInputBuffer is not None:
__pyx_t_2 = (__pyx_v_self->cudaInputBuffer != Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* … */ }
+2049: log("cuda_clean() freeing CUDA input buffer %#x", int(self.cudaInputBuffer))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyNumber_Int(__pyx_v_self->cudaInputBuffer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_cuda_clean_freeing_CUDA_input_bu, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2049, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_cuda_clean_freeing_CUDA_input_bu, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2049, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_freeing_CUDA_input_bu); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_freeing_CUDA_input_bu); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_freeing_CUDA_input_bu); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2050: self.cudaInputBuffer.free()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cudaInputBuffer, __pyx_n_s_free); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2050, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2050, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2051: self.cudaInputBuffer = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cudaInputBuffer); __Pyx_DECREF(__pyx_v_self->cudaInputBuffer); __pyx_v_self->cudaInputBuffer = Py_None;
+2052: if self.cudaOutputBuffer is not None:
__pyx_t_1 = (__pyx_v_self->cudaOutputBuffer != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* … */ }
+2053: log("cuda_clean() freeing CUDA output buffer %#x", int(self.cudaOutputBuffer))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_v_self->cudaOutputBuffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_cuda_clean_freeing_CUDA_output_b, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2053, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_cuda_clean_freeing_CUDA_output_b, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2053, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_freeing_CUDA_output_b); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_freeing_CUDA_output_b); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_freeing_CUDA_output_b); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2054: self.cudaOutputBuffer.free()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cudaOutputBuffer, __pyx_n_s_free); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_6) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2054, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2054, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2055: self.cudaOutputBuffer = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->cudaOutputBuffer); __Pyx_DECREF(__pyx_v_self->cudaOutputBuffer); __pyx_v_self->cudaOutputBuffer = Py_None;
+2056: if self.context!=NULL:
__pyx_t_2 = ((__pyx_v_self->context != NULL) != 0); if (__pyx_t_2) { /* … */ }
+2057: if self.bitstreamBuffer!=NULL:
__pyx_t_2 = ((__pyx_v_self->bitstreamBuffer != NULL) != 0); if (__pyx_t_2) { /* … */ }
+2058: log("cuda_clean() destroying output bitstream buffer %#x", <uintptr_t> self.bitstreamBuffer)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->bitstreamBuffer)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_cuda_clean_destroying_output_bit, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_cuda_clean_destroying_output_bit, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_destroying_output_bit); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_destroying_output_bit); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_destroying_output_bit); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2059: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2060: log("nvEncDestroyBitstreamBuffer(%#x)", <uintptr_t> self.bitstreamBuffer)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->bitstreamBuffer)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_nvEncDestroyBitstreamBuffer_x, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_nvEncDestroyBitstreamBuffer_x, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncDestroyBitstreamBuffer_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncDestroyBitstreamBuffer_x); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_kp_s_nvEncDestroyBitstreamBuffer_x); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2061: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L21; } __pyx_L21:; } }
+2062: r = self.functionList.nvEncDestroyBitstreamBuffer(self.context, self.bitstreamBuffer)
__pyx_v_r = __pyx_v_self->functionList->nvEncDestroyBitstreamBuffer(__pyx_v_self->context, __pyx_v_self->bitstreamBuffer); }
+2063: raiseNVENC(r, "destroying output buffer")
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_destroying_output_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2064: self.bitstreamBuffer = NULL
__pyx_v_self->bitstreamBuffer = NULL;
+2065: log("cuda_clean() destroying encoder %#x", <uintptr_t> self.context)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->context)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_cuda_clean_destroying_encoder_x, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2065, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_cuda_clean_destroying_encoder_x, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2065, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_destroying_encoder_x); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_destroying_encoder_x); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_destroying_encoder_x); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2066: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2067: log("nvEncDestroyEncoder(%#x)", <uintptr_t> self.context)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->context)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncDestroyEncoder_x, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2067, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncDestroyEncoder_x, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2067, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncDestroyEncoder_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncDestroyEncoder_x); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_nvEncDestroyEncoder_x); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2068: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L25; } __pyx_L25:; } }
+2069: r = self.functionList.nvEncDestroyEncoder(self.context)
__pyx_v_r = __pyx_v_self->functionList->nvEncDestroyEncoder(__pyx_v_self->context); }
+2070: raiseNVENC(r, "destroying context")
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_destroying_context); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2071: self.context = NULL
__pyx_v_self->context = NULL;
2072: global context_counter
+2073: context_counter.decrease()
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_decrease); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2073, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2073, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2074: log("cuda_clean() (still %s context%s in use)", context_counter, engs(context_counter))
__pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_engs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_10) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_cuda_clean_still_s_context_s_in, __pyx_t_4, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_cuda_clean_still_s_context_s_in, __pyx_t_4, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_11 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_cuda_clean_still_s_context_s_in); __Pyx_GIVEREF(__pyx_kp_s_cuda_clean_still_s_context_s_in); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_7, __pyx_kp_s_cuda_clean_still_s_context_s_in); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_7, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2075: self.cuda_context_ptr = <void *> 0
__pyx_v_self->cuda_context_ptr = ((void *)0);
2076:
+2077: def get_width(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_27get_width(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_27get_width(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_width (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_26get_width(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_26get_width(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_width", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_width", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2078: return self.width
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->width); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2078, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2079:
+2080: def get_height(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_29get_height(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_29get_height(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_height (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_28get_height(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_28get_height(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_height", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_height", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2081: return self.height
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->height); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2082:
+2083: def get_type(self): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_31get_type(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_31get_type(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_type (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_30get_type(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_30get_type(CYTHON_UNUSED struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_type", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2084: return "nvenc"
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_nvenc); __pyx_r = __pyx_n_s_nvenc; goto __pyx_L0;
2085:
+2086: def get_encoding(self): #@DuplicatedSignature
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_33get_encoding(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_33get_encoding(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_encoding (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_32get_encoding(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_32get_encoding(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_encoding", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2087: return self.encoding
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->encoding); __pyx_r = __pyx_v_self->encoding; goto __pyx_L0;
2088:
+2089: def get_src_format(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_35get_src_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_35get_src_format(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_src_format (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_34get_src_format(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_34get_src_format(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_src_format", 0); /* … */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2090: return self.src_format
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->src_format); __pyx_r = __pyx_v_self->src_format; goto __pyx_L0;
2091:
+2092: def set_encoding_speed(self, speed):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_37set_encoding_speed(PyObject *__pyx_v_self, PyObject *__pyx_v_speed); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_37set_encoding_speed(PyObject *__pyx_v_self, PyObject *__pyx_v_speed) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_encoding_speed (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_36set_encoding_speed(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_speed)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_36set_encoding_speed(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_speed) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_encoding_speed", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.set_encoding_speed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2093: if self.speed!=speed:
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_speed, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2093, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2093, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+2094: self.speed = speed
__pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_speed); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2094, __pyx_L1_error) __pyx_v_self->speed = __pyx_t_4;
+2095: self.update_bitrate()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_bitrate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (__pyx_t_5) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2095, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2095, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2096:
+2097: def set_encoding_quality(self, quality):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_39set_encoding_quality(PyObject *__pyx_v_self, PyObject *__pyx_v_quality); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_39set_encoding_quality(PyObject *__pyx_v_self, PyObject *__pyx_v_quality) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_encoding_quality (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_38set_encoding_quality(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_quality)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_38set_encoding_quality(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_quality) { PyObject *__pyx_v_raw_delta = NULL; PyObject *__pyx_v_max_delta = NULL; PyObject *__pyx_v_delta = NULL; PyObject *__pyx_v_target_quality = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_encoding_quality", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.set_encoding_quality", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_raw_delta); __Pyx_XDECREF(__pyx_v_max_delta); __Pyx_XDECREF(__pyx_v_delta); __Pyx_XDECREF(__pyx_v_target_quality); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2098: cdef NVENCSTATUS r #@DuplicatedSignature
2099: cdef NV_ENC_RECONFIGURE_PARAMS reconfigure_params
+2100: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2100, __pyx_L1_error) } } #endif
+2101: if self.quality==quality:
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_quality, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+2102: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+2103: log("set_encoding_quality(%s) current quality=%s", quality, self.quality)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_set_encoding_quality_s_current_q, __pyx_v_quality, __pyx_t_4}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2103, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_set_encoding_quality_s_current_q, __pyx_v_quality, __pyx_t_4}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2103, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_set_encoding_quality_s_current_q); __Pyx_GIVEREF(__pyx_kp_s_set_encoding_quality_s_current_q); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_set_encoding_quality_s_current_q); __Pyx_INCREF(__pyx_v_quality); __Pyx_GIVEREF(__pyx_v_quality); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_quality); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2104: if quality<LOSSLESS_THRESHOLD:
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_THRESHOLD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_v_quality, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L4; }
2105: #edge resistance:
+2106: raw_delta = quality-self.quality
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Subtract(__pyx_v_quality, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_raw_delta = __pyx_t_2; __pyx_t_2 = 0;
+2107: max_delta = max(-1, min(1, raw_delta))*10
__Pyx_INCREF(__pyx_v_raw_delta); __pyx_t_2 = __pyx_v_raw_delta; __pyx_t_8 = 1; __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_7, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; } else { __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = -1L; __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; } else { __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_int_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_max_delta = __pyx_t_2; __pyx_t_2 = 0;
+2108: if abs(raw_delta)<abs(max_delta):
__pyx_t_2 = PyNumber_Absolute(__pyx_v_raw_delta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Absolute(__pyx_v_max_delta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L5; }
+2109: delta = raw_delta
__Pyx_INCREF(__pyx_v_raw_delta);
__pyx_v_delta = __pyx_v_raw_delta;
2110: else:
+2111: delta = max_delta
/*else*/ {
__Pyx_INCREF(__pyx_v_max_delta);
__pyx_v_delta = __pyx_v_max_delta;
}
__pyx_L5:;
+2112: target_quality = quality-delta
__pyx_t_7 = PyNumber_Subtract(__pyx_v_quality, __pyx_v_delta); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_target_quality = __pyx_t_7; __pyx_t_7 = 0;
2113: else:
+2114: target_quality = 100
/*else*/ {
__Pyx_INCREF(__pyx_int_100);
__pyx_v_target_quality = __pyx_int_100;
}
__pyx_L4:;
+2115: self.quality = quality
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_quality); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2115, __pyx_L1_error) __pyx_v_self->quality = __pyx_t_6;
+2116: log("set_encoding_quality(%s) target quality=%s", quality, target_quality)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_kp_s_set_encoding_quality_s_target_qu, __pyx_v_quality, __pyx_v_target_quality}; __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_7); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_kp_s_set_encoding_quality_s_target_qu, __pyx_v_quality, __pyx_v_target_quality}; __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_7); } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_kp_s_set_encoding_quality_s_target_qu); __Pyx_GIVEREF(__pyx_kp_s_set_encoding_quality_s_target_qu); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_kp_s_set_encoding_quality_s_target_qu); __Pyx_INCREF(__pyx_v_quality); __Pyx_GIVEREF(__pyx_v_quality); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_quality); __Pyx_INCREF(__pyx_v_target_quality); __Pyx_GIVEREF(__pyx_v_target_quality); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_6, __pyx_v_target_quality); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2117: #code removed:
2118: #new_pixel_format = self.get_target_pixel_format(target_quality)
2119: #etc...
2120: #we can't switch pixel format,
2121: #because we would need to free the buffers and re-allocate new ones
2122: #best to just tear down the encoder context and create a new one
+2123: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2124:
+2125: def update_bitrate(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_41update_bitrate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_41update_bitrate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("update_bitrate (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_40update_bitrate(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_40update_bitrate(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { double __pyx_v_MPixels; double __pyx_v_mult; PyObject *__pyx_v_lim = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("update_bitrate", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.update_bitrate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_lim); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2126: #use an exponential scale so for a 1Kx1K image (after scaling), roughly:
2127: #speed=0 -> 1Mbit/s
2128: #speed=50 -> 10Mbit/s
2129: #speed=90 -> 66Mbit/s
2130: #speed=100 -> 100Mbit/s
+2131: MPixels = (self.encoder_width * self.encoder_height) / (1000.0 * 1000.0)
__pyx_v_MPixels = ((__pyx_v_self->encoder_width * __pyx_v_self->encoder_height) / (1000.0 * 1000.0));
+2132: if self.pixel_format=="NV12":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_NV12, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2132, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L3; }
2133: #subsampling halves the input size:
+2134: mult = 0.5
__pyx_v_mult = 0.5;
2135: else:
2136: #yuv444p preserves it:
+2137: mult = 1.0
/*else*/ { __pyx_v_mult = 1.0; } __pyx_L3:;
+2138: lim = 100*1000000
__Pyx_INCREF(__pyx_int_100000000);
__pyx_v_lim = __pyx_int_100000000;
+2139: self.target_bitrate = min(lim, max(1000000, int(((0.5+self.speed/200.0)**8)*lim*MPixels*mult)))
__pyx_t_2 = PyFloat_FromDouble(pow((0.5 + (__pyx_v_self->speed / 200.0)), 8.0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_v_lim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble(__pyx_v_MPixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble(__pyx_v_mult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Multiply(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = 0xF4240; __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; } else { __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_lim); __pyx_t_3 = __pyx_v_lim; __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2139, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = __pyx_t_2; } else { __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = __pyx_t_3; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_7 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_self->target_bitrate = __pyx_t_7;
+2140: self.max_bitrate = 2*self.target_bitrate
__pyx_v_self->max_bitrate = (2 * __pyx_v_self->target_bitrate);
2141:
2142:
+2143: cdef flushEncoder(self):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_flushEncoder(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { NV_ENC_PIC_PARAMS __pyx_v_picParams; NVENCSTATUS __pyx_v_r; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("flushEncoder", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.flushEncoder", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2144: cdef NV_ENC_PIC_PARAMS picParams
2145: cdef NVENCSTATUS r #@DuplicatedSignature
+2146: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2146, __pyx_L1_error) } } #endif
+2147: memset(&picParams, 0, sizeof(NV_ENC_PIC_PARAMS))
memset((&__pyx_v_picParams), 0, (sizeof(NV_ENC_PIC_PARAMS)));
+2148: picParams.version = NV_ENC_PIC_PARAMS_VER
__pyx_v_picParams.version = NV_ENC_PIC_PARAMS_VER;
+2149: picParams.encodePicFlags = NV_ENC_PIC_FLAG_EOS
__pyx_v_picParams.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
+2150: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2151: log("nvEncEncodePicture(%#x)", <uintptr_t> &picParams)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_picParams))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncEncodePicture_x, __pyx_t_4}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2151, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncEncodePicture_x, __pyx_t_4}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2151, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncEncodePicture_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncEncodePicture_x); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_nvEncEncodePicture_x); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2152: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2153: r = self.functionList.nvEncEncodePicture(self.context, &picParams)
__pyx_v_r = __pyx_v_self->functionList->nvEncEncodePicture(__pyx_v_self->context, (&__pyx_v_picParams)); }
+2154: raiseNVENC(r, "flushing encoder buffer")
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_flushing_encoder_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2155:
+2156: def compress_image(self, image, quality=-1, speed=-1, options={}, retry=0):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_43compress_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_43compress_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_image = 0; PyObject *__pyx_v_quality = 0; PyObject *__pyx_v_speed = 0; PyObject *__pyx_v_options = 0; PyObject *__pyx_v_retry = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("compress_image (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image,&__pyx_n_s_quality,&__pyx_n_s_speed,&__pyx_n_s_options,&__pyx_n_s_retry,0}; PyObject* values[5] = {0,0,0,0,0}; values[1] = ((PyObject *)__pyx_int_neg_1); values[2] = ((PyObject *)__pyx_int_neg_1); values[3] = __pyx_k__26; values[4] = ((PyObject *)__pyx_int_0); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_image)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quality); if (value) { values[1] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_speed); if (value) { values[2] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_retry); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compress_image") < 0)) __PYX_ERR(0, 2156, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_image = values[0]; __pyx_v_quality = values[1]; __pyx_v_speed = values[2]; __pyx_v_options = values[3]; __pyx_v_retry = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("compress_image", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2156, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.compress_image", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_42compress_image(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), __pyx_v_image, __pyx_v_quality, __pyx_v_speed, __pyx_v_options, __pyx_v_retry); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_42compress_image(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_image, PyObject *__pyx_v_quality, PyObject *__pyx_v_speed, PyObject *__pyx_v_options, PyObject *__pyx_v_retry) { PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("compress_image", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.compress_image", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_k__26 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
+2157: self.cuda_context.push()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cuda_context, __pyx_n_s_push); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2158: try:
{ /*try:*/ { /* … */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L0; }
+2159: try:
/*try:*/ {
+2160: if quality>=0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_quality, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2160, __pyx_L10_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2160, __pyx_L10_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_7) { /* … */ }
+2161: self.set_encoding_quality(quality)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_encoding_quality); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2161, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_quality); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_quality}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_quality}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2161, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_quality); __Pyx_GIVEREF(__pyx_v_quality); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_quality); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2162: if speed>=0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_speed, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2162, __pyx_L10_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2162, __pyx_L10_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_7) { /* … */ }
+2163: self.set_encoding_speed(speed)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_encoding_speed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2163, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_8) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_speed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2163, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_speed}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2163, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_speed}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2163, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2163, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_INCREF(__pyx_v_speed); __Pyx_GIVEREF(__pyx_v_speed); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_speed); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2163, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2164: return self.do_compress_image(image, options)
__Pyx_XDECREF(__pyx_r); __pyx_t_9.__pyx_n = 1; __pyx_t_9.options = __pyx_v_options; __pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->do_compress_image(__pyx_v_self, __pyx_v_image, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2164, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L9_return; }
2165: finally:
+2166: self.cuda_context.pop()
/*finally:*/ { __pyx_L10_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __pyx_t_10 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename; { __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_self->cuda_context); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2166, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); } __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12; goto __pyx_L3_error; __pyx_L15_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; goto __pyx_L3_error; } __pyx_L9_return: { __pyx_t_18 = __pyx_r; __pyx_r = 0; __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_self->cuda_context); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2166, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_18; __pyx_t_18 = 0; goto __pyx_L7_try_return; } }
+2167: except driver.LogicError as e:
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2167, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_LogicError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2167, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_11) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.compress_image", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 2167, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1;
+2168: if retry>0:
__pyx_t_8 = PyObject_RichCompare(__pyx_v_retry, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2168, __pyx_L5_except_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2168, __pyx_L5_except_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_7) { /* … */ }
+2169: raise
__Pyx_GIVEREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; __PYX_ERR(0, 2169, __pyx_L5_except_error)
+2170: log.warn("Warning: PyCUDA %s", e)
__pyx_t_19 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 2170, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_warn); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2170, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_20))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_20)) { PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_kp_s_Warning_PyCUDA_s, __pyx_v_e}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2170, __pyx_L5_except_error) __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_20)) { PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_kp_s_Warning_PyCUDA_s, __pyx_v_e}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2170, __pyx_L5_except_error) __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif { __pyx_t_21 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2170, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_21); if (__pyx_t_19) { __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_19); __pyx_t_19 = NULL; } __Pyx_INCREF(__pyx_kp_s_Warning_PyCUDA_s); __Pyx_GIVEREF(__pyx_kp_s_Warning_PyCUDA_s); PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_11, __pyx_kp_s_Warning_PyCUDA_s); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_11, __pyx_v_e); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_21, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2170, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2171: del e
__Pyx_DECREF(__pyx_v_e);
__pyx_v_e = NULL;
+2172: self.clean()
__pyx_t_20 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clean); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2172, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_21 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) { __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_21)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_21); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); } } if (__pyx_t_21) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_t_21); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2172, __pyx_L5_except_error) __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } else { __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_20); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2172, __pyx_L5_except_error) } __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2173: self.init_cuda()
__pyx_t_20 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_init_cuda); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2173, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_21 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) { __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_21)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_21); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); } } if (__pyx_t_21) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_t_21); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2173, __pyx_L5_except_error) __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } else { __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_20); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2173, __pyx_L5_except_error) } __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2174: return self.convert_image(image, options, retry+1)
__Pyx_XDECREF(__pyx_r); __pyx_t_20 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_convert_image); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2174, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_21 = __Pyx_PyInt_AddObjC(__pyx_v_retry, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2174, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_19 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_20)) { PyObject *__pyx_temp[4] = {__pyx_t_19, __pyx_v_image, __pyx_v_options, __pyx_t_21}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2174, __pyx_L5_except_error) __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_20)) { PyObject *__pyx_temp[4] = {__pyx_t_19, __pyx_v_image, __pyx_v_options, __pyx_t_21}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2174, __pyx_L5_except_error) __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } else #endif { __pyx_t_22 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 2174, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_22); if (__pyx_t_19) { __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_19); __pyx_t_19 = NULL; } __Pyx_INCREF(__pyx_v_image); __Pyx_GIVEREF(__pyx_v_image); PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_11, __pyx_v_image); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_11, __pyx_v_options); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_22, 2+__pyx_t_11, __pyx_t_21); __pyx_t_21 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_22, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2174, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; } __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_r = __pyx_t_8; __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L6_except_return; } goto __pyx_L5_except_error; __pyx_L5_except_error:;
2175:
+2176: cdef do_compress_image(self, image, options={}):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_do_compress_image(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_image, struct __pyx_opt_args_4xpra_6codecs_5nvenc_7encoder_7Encoder_do_compress_image *__pyx_optional_args) { PyObject *__pyx_v_options = __pyx_k__27; unsigned int __pyx_v_stride; unsigned int __pyx_v_w; unsigned int __pyx_v_h; PyObject *__pyx_v_gpu_buffer = NULL; unsigned long __pyx_v_input_size; NV_ENC_INPUT_PTR __pyx_v_mappedResource; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("do_compress_image", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_options = __pyx_optional_args->options; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.do_compress_image", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_gpu_buffer); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_k__27 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ struct __pyx_opt_args_4xpra_6codecs_5nvenc_7encoder_7Encoder_do_compress_image { int __pyx_n; PyObject *options; };
2177: cdef unsigned int stride, w, h
+2178: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2178, __pyx_L1_error) } } #endif
+2179: assert self.context!=NULL, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->context != NULL) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2179, __pyx_L1_error) } } #endif
+2180: w = image.get_width()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2180, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_w = __pyx_t_4;
+2181: h = image.get_height()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_height); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2181, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_4;
+2182: gpu_buffer = image.get_gpu_buffer()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_gpu_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2182, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2182, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_gpu_buffer = __pyx_t_1; __pyx_t_1 = 0;
+2183: stride = image.get_rowstride()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2183, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2183, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2183, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_stride = __pyx_t_4;
+2184: log("compress_image(%s, %s) kernel_name=%s, GPU buffer=%s", image, options, self.kernel_name, gpu_buffer)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_kp_s_compress_image_s_s_kernel_name_s, __pyx_v_image, __pyx_v_options, __pyx_v_self->kernel_name, __pyx_v_gpu_buffer}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2184, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_kp_s_compress_image_s_s_kernel_name_s, __pyx_v_image, __pyx_v_options, __pyx_v_self->kernel_name, __pyx_v_gpu_buffer}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2184, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_kp_s_compress_image_s_s_kernel_name_s); __Pyx_GIVEREF(__pyx_kp_s_compress_image_s_s_kernel_name_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_compress_image_s_s_kernel_name_s); __Pyx_INCREF(__pyx_v_image); __Pyx_GIVEREF(__pyx_v_image); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_image); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_options); __Pyx_INCREF(__pyx_v_self->kernel_name); __Pyx_GIVEREF(__pyx_v_self->kernel_name); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_self->kernel_name); __Pyx_INCREF(__pyx_v_gpu_buffer); __Pyx_GIVEREF(__pyx_v_gpu_buffer); PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_gpu_buffer); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2185: assert image.get_planes()==ImageWrapper.PACKED, "invalid number of planes: %s" % image.get_planes()
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_planes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2185, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ImageWrapper); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_PACKED); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) { __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_planes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_1) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2185, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_invalid_number_of_planes_s, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 2185, __pyx_L1_error) } } #endif
+2186: assert (w & WIDTH_MASK)<=self.input_width, "invalid width: %s" % w
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_WIDTH_MASK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->input_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) { __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_width_s, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 2186, __pyx_L1_error) } } #endif
+2187: assert (h & HEIGHT_MASK)<=self.input_height, "invalid height: %s" % h
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_HEIGHT_MASK); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_And(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->input_height); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) { __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_invalid_height_s, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 2187, __pyx_L1_error) } } #endif
+2188: assert self.inputBuffer is not None, "BUG: encoder is closed?"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = (__pyx_v_self->inputBuffer != Py_None); if (unlikely(!(__pyx_t_7 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_BUG_encoder_is_closed); __PYX_ERR(0, 2188, __pyx_L1_error) } } #endif
2189:
+2190: if self.frames==0:
__pyx_t_7 = ((__pyx_v_self->frames == 0) != 0); if (__pyx_t_7) { /* … */ }
2191: #first frame, record pts:
+2192: self.first_frame_timestamp = image.get_timestamp()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_1) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2192, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyInt_As_uint64_t(__pyx_t_6); if (unlikely((__pyx_t_8 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_self->first_frame_timestamp = __pyx_t_8;
2193:
2194: cdef unsigned long input_size
+2195: if self.kernel:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->kernel); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2195, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L4; }
2196: #copy to input buffer, CUDA kernel converts into output buffer:
+2197: if gpu_buffer and stride<=self.inputPitch:
__pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_gpu_buffer); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 2197, __pyx_L1_error) if (__pyx_t_9) { } else { __pyx_t_7 = __pyx_t_9; goto __pyx_L6_bool_binop_done; } __pyx_t_9 = ((__pyx_v_stride <= __pyx_v_self->inputPitch) != 0); __pyx_t_7 = __pyx_t_9; __pyx_L6_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L5; }
+2198: driver.memcpy_dtod(self.cudaInputBuffer, int(gpu_buffer), stride*h)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_memcpy_dtod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_gpu_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int((__pyx_v_stride * __pyx_v_h)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_v_self->cudaInputBuffer, __pyx_t_2, __pyx_t_3}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_v_self->cudaInputBuffer, __pyx_t_2, __pyx_t_3}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_11 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_v_self->cudaInputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaInputBuffer); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_v_self->cudaInputBuffer); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+2199: log("GPU memcopy from %s to %s", gpu_buffer, self.cudaInputBuffer)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_kp_s_GPU_memcopy_from_s_to_s, __pyx_v_gpu_buffer, __pyx_v_self->cudaInputBuffer}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_kp_s_GPU_memcopy_from_s_to_s, __pyx_v_gpu_buffer, __pyx_v_self->cudaInputBuffer}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_INCREF(__pyx_kp_s_GPU_memcopy_from_s_to_s); __Pyx_GIVEREF(__pyx_kp_s_GPU_memcopy_from_s_to_s); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_kp_s_GPU_memcopy_from_s_to_s); __Pyx_INCREF(__pyx_v_gpu_buffer); __Pyx_GIVEREF(__pyx_v_gpu_buffer); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_gpu_buffer); __Pyx_INCREF(__pyx_v_self->cudaInputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaInputBuffer); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_5, __pyx_v_self->cudaInputBuffer); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2200: else:
+2201: stride = self.copy_image(image, self.inputBuffer, self.inputPitch, False)
/*else*/ { __pyx_t_6 = __pyx_v_self->inputBuffer; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->copy_image(__pyx_v_self, __pyx_v_image, __pyx_t_6, __pyx_v_self->inputPitch, 0); if (unlikely(__pyx_t_4 == ((unsigned int)-1))) __PYX_ERR(0, 2201, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_stride = __pyx_t_4;
+2202: driver.memcpy_htod(self.cudaInputBuffer, self.inputBuffer)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_memcpy_htod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_self->cudaInputBuffer, __pyx_v_self->inputBuffer}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2202, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_self->cudaInputBuffer, __pyx_v_self->inputBuffer}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2202, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_11 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_v_self->cudaInputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaInputBuffer); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_v_self->cudaInputBuffer); __Pyx_INCREF(__pyx_v_self->inputBuffer); __Pyx_GIVEREF(__pyx_v_self->inputBuffer); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_v_self->inputBuffer); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L5:;
+2203: self.exec_kernel(w, h, stride)
__pyx_t_6 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->exec_kernel(__pyx_v_self, __pyx_v_w, __pyx_v_h, __pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+2204: input_size = self.inputPitch * self.input_height
__pyx_v_input_size = (__pyx_v_self->inputPitch * __pyx_v_self->input_height);
2205: else:
2206: #go direct to the CUDA "output" buffer:
+2207: if gpu_buffer and stride<=self.outputPitch:
/*else*/ { __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_gpu_buffer); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 2207, __pyx_L1_error) if (__pyx_t_9) { } else { __pyx_t_7 = __pyx_t_9; goto __pyx_L9_bool_binop_done; } __pyx_t_9 = ((__pyx_v_stride <= __pyx_v_self->outputPitch) != 0); __pyx_t_7 = __pyx_t_9; __pyx_L9_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L8; }
+2208: driver.memcpy_dtod(self.cudaOutputBuffer, int(gpu_buffer), stride*h)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_memcpy_dtod); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_gpu_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int((__pyx_v_stride * __pyx_v_h)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_self->cudaOutputBuffer, __pyx_t_3, __pyx_t_1}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_self->cudaOutputBuffer, __pyx_t_3, __pyx_t_1}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_self->cudaOutputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaOutputBuffer); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_v_self->cudaOutputBuffer); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_t_1); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+2209: log("GPU memcopy from %s to %s", gpu_buffer, self.cudaOutputBuffer)
__pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_GPU_memcopy_from_s_to_s, __pyx_v_gpu_buffer, __pyx_v_self->cudaOutputBuffer}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2209, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_GPU_memcopy_from_s_to_s, __pyx_v_gpu_buffer, __pyx_v_self->cudaOutputBuffer}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2209, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_1 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_GPU_memcopy_from_s_to_s); __Pyx_GIVEREF(__pyx_kp_s_GPU_memcopy_from_s_to_s); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_5, __pyx_kp_s_GPU_memcopy_from_s_to_s); __Pyx_INCREF(__pyx_v_gpu_buffer); __Pyx_GIVEREF(__pyx_v_gpu_buffer); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_5, __pyx_v_gpu_buffer); __Pyx_INCREF(__pyx_v_self->cudaOutputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaOutputBuffer); PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_5, __pyx_v_self->cudaOutputBuffer); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2210: else:
+2211: stride = self.copy_image(image, self.inputBuffer, self.inputPitch, True)
/*else*/ { __pyx_t_6 = __pyx_v_self->inputBuffer; __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->copy_image(__pyx_v_self, __pyx_v_image, __pyx_t_6, __pyx_v_self->inputPitch, 1); if (unlikely(__pyx_t_4 == ((unsigned int)-1))) __PYX_ERR(0, 2211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_stride = __pyx_t_4;
+2212: driver.memcpy_htod(self.cudaOutputBuffer, self.inputBuffer)
__pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_memcpy_htod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_self->cudaOutputBuffer, __pyx_v_self->inputBuffer}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2212, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_self->cudaOutputBuffer, __pyx_v_self->inputBuffer}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2212, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_INCREF(__pyx_v_self->cudaOutputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaOutputBuffer); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_v_self->cudaOutputBuffer); __Pyx_INCREF(__pyx_v_self->inputBuffer); __Pyx_GIVEREF(__pyx_v_self->inputBuffer); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_self->inputBuffer); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L8:;
+2213: input_size = stride * self.encoder_height
__pyx_v_input_size = (__pyx_v_stride * __pyx_v_self->encoder_height); } __pyx_L4:;
+2214: self.bytes_in += input_size
__pyx_v_self->bytes_in = (__pyx_v_self->bytes_in + __pyx_v_input_size);
2215:
+2216: cdef NV_ENC_INPUT_PTR mappedResource = self.map_input_resource()
__pyx_v_mappedResource = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->map_input_resource(__pyx_v_self);
+2217: assert mappedResource!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_mappedResource != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2217, __pyx_L1_error) } } #endif
+2218: try:
/*try:*/ {
+2219: return self.nvenc_compress(input_size, mappedResource, image.get_timestamp())
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2219, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (__pyx_t_10) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2219, __pyx_L12_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else { __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2219, __pyx_L12_error) } __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12.__pyx_n = 1; __pyx_t_12.timestamp = __pyx_t_6; __pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->nvenc_compress(__pyx_v_self, __pyx_v_input_size, __pyx_v_mappedResource, &__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2219, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L11_return; }
2220: finally:
+2221: self.unmap_input_resource(mappedResource)
/*finally:*/ { __pyx_L12_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_5 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->unmap_input_resource(__pyx_v_self, __pyx_v_mappedResource); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2221, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; __pyx_L15_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; goto __pyx_L1_error; } __pyx_L11_return: { __pyx_t_20 = __pyx_r; __pyx_r = 0; __pyx_t_1 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->unmap_input_resource(__pyx_v_self, __pyx_v_mappedResource); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_20; __pyx_t_20 = 0; goto __pyx_L0; } }
2222:
+2223: cdef unsigned int copy_image(self, image, target_buffer, unsigned int target_stride, int strict_stride) except -1:
static unsigned int __pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_copy_image(CYTHON_UNUSED struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_image, PyObject *__pyx_v_target_buffer, unsigned int __pyx_v_target_stride, int __pyx_v_strict_stride) { unsigned int __pyx_v_image_stride; unsigned int __pyx_v_h; unsigned int __pyx_v_i; unsigned int __pyx_v_stride; unsigned int __pyx_v_min_stride; PyObject *__pyx_v_pixels = NULL; PyObject *__pyx_v_buf = 0; double __pyx_v_start; unsigned long __pyx_v_copy_len; unsigned long __pyx_v_pix_len; PyObject *__pyx_v_tmp = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; double __pyx_v_end; unsigned int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("copy_image", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.copy_image", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pixels); __Pyx_XDECREF(__pyx_v_buf); __Pyx_XDECREF(__pyx_v_tmp); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2224: log("copy_image(%s, %s, %i, %i)", image, target_buffer, target_stride, strict_stride)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_target_stride); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_strict_stride); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_5, __pyx_kp_s_copy_image_s_s_i_i, __pyx_v_image, __pyx_v_target_buffer, __pyx_t_3, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_5, __pyx_kp_s_copy_image_s_s_i_i, __pyx_v_image, __pyx_v_target_buffer, __pyx_t_3, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_copy_image_s_s_i_i); __Pyx_GIVEREF(__pyx_kp_s_copy_image_s_s_i_i); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_copy_image_s_s_i_i); __Pyx_INCREF(__pyx_v_image); __Pyx_GIVEREF(__pyx_v_image); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_image); __Pyx_INCREF(__pyx_v_target_buffer); __Pyx_GIVEREF(__pyx_v_target_buffer); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_target_buffer); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2225: cdef unsigned int image_stride = image.get_rowstride()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_rowstride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_7) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2225, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_image_stride = __pyx_t_8;
+2226: cdef unsigned int h = image.get_height()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_height); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_7) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2226, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyInt_As_unsigned_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_8;
2227: cdef unsigned int i, stride, min_stride
+2228: pixels = image.get_pixels()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_get_pixels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_7) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2228, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2228, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_pixels = __pyx_t_1; __pyx_t_1 = 0;
+2229: assert pixels is not None, "failed to get pixels from %s" % image
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_9 = (__pyx_v_pixels != Py_None); if (unlikely(!(__pyx_t_9 != 0))) { __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_get_pixels_from_s, __pyx_v_image); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2229, __pyx_L1_error) } } #endif
2230: #copy to input buffer:
2231: cdef object buf
+2232: if isinstance(pixels, (bytearray, bytes)):
__pyx_t_10 = PyByteArray_Check(__pyx_v_pixels);
__pyx_t_11 = (__pyx_t_10 != 0);
if (!__pyx_t_11) {
} else {
__pyx_t_9 = __pyx_t_11;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_11 = PyBytes_Check(__pyx_v_pixels);
__pyx_t_10 = (__pyx_t_11 != 0);
__pyx_t_9 = __pyx_t_10;
__pyx_L4_bool_binop_done:;
__pyx_t_10 = (__pyx_t_9 != 0);
if (__pyx_t_10) {
/* … */
}
+2233: pixels = memoryview(pixels)
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_pixels); __Pyx_GIVEREF(__pyx_v_pixels); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_pixels); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_pixels, __pyx_t_2); __pyx_t_2 = 0;
+2234: if isinstance(pixels, memoryview):
__pyx_t_10 = PyObject_IsInstance(__pyx_v_pixels, __pyx_builtin_memoryview); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 2234, __pyx_L1_error) __pyx_t_9 = (__pyx_t_10 != 0); if (__pyx_t_9) { /* … */ goto __pyx_L6; }
2235: #copy memoryview to inputBuffer directly:
+2236: buf = target_buffer
__Pyx_INCREF(__pyx_v_target_buffer);
__pyx_v_buf = __pyx_v_target_buffer;
2237: else:
2238: #this is a numpy.ndarray type:
+2239: buf = target_buffer.data
/*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_target_buffer, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_buf = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L6:;
+2240: cdef double start = monotonic_time()
__pyx_v_start = __pyx_f_4xpra_14monotonic_time_monotonic_time();
2241: cdef unsigned long copy_len
+2242: cdef unsigned long pix_len = len(pixels)
__pyx_t_12 = PyObject_Length(__pyx_v_pixels); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2242, __pyx_L1_error) __pyx_v_pix_len = __pyx_t_12;
+2243: assert pix_len>=(h*image_stride), "image pixel buffer is too small: expected at least %ix%i=%i bytes but got %i bytes" % (h, image_stride, h*image_stride, pix_len)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_pix_len >= (__pyx_v_h * __pyx_v_image_stride)) != 0))) { __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_image_stride); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyInt_From_unsigned_int((__pyx_v_h * __pyx_v_image_stride)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyInt_From_unsigned_long(__pyx_v_pix_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_image_pixel_buffer_is_too_small, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 2243, __pyx_L1_error) } } #endif
+2244: if image_stride<=target_stride and not strict_stride:
__pyx_t_10 = ((__pyx_v_image_stride <= __pyx_v_target_stride) != 0); if (__pyx_t_10) { } else { __pyx_t_9 = __pyx_t_10; goto __pyx_L8_bool_binop_done; } __pyx_t_10 = ((!(__pyx_v_strict_stride != 0)) != 0); __pyx_t_9 = __pyx_t_10; __pyx_L8_bool_binop_done:; if (__pyx_t_9) { /* … */ goto __pyx_L7; }
+2245: stride = image_stride
__pyx_v_stride = __pyx_v_image_stride;
+2246: copy_len = h*image_stride
__pyx_v_copy_len = (__pyx_v_h * __pyx_v_image_stride);
2247: #assert pix_len<=input_size, "too many pixels (expected %s max, got %s) image: %sx%s stride=%s, input buffer: stride=%s, height=%s" % (input_size, pix_len, w, h, stride, self.inputPitch, self.input_height)
+2248: log("copying %s bytes from %s into %s (len=%i), in one shot", pix_len, type(pixels), type(target_buffer), len(target_buffer))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_unsigned_long(__pyx_v_pix_len); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = PyObject_Length(__pyx_v_target_buffer); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2248, __pyx_L1_error) __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[6] = {__pyx_t_2, __pyx_kp_s_copying_s_bytes_from_s_into_s_le, __pyx_t_7, ((PyObject *)Py_TYPE(__pyx_v_pixels)), ((PyObject *)Py_TYPE(__pyx_v_target_buffer)), __pyx_t_1}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[6] = {__pyx_t_2, __pyx_kp_s_copying_s_bytes_from_s_into_s_le, __pyx_t_7, ((PyObject *)Py_TYPE(__pyx_v_pixels)), ((PyObject *)Py_TYPE(__pyx_v_target_buffer)), __pyx_t_1}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_5 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_kp_s_copying_s_bytes_from_s_into_s_le); __Pyx_GIVEREF(__pyx_kp_s_copying_s_bytes_from_s_into_s_le); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_kp_s_copying_s_bytes_from_s_into_s_le); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_7); __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels))); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, ((PyObject *)Py_TYPE(__pyx_v_pixels))); __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_target_buffer))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_target_buffer))); PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_6, ((PyObject *)Py_TYPE(__pyx_v_target_buffer))); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_6, __pyx_t_1); __pyx_t_7 = 0; __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2249: #log("target: %s, %s, %s", buf.shape, buf.size, buf.dtype)
+2250: if isinstance(pixels, memoryview):
__pyx_t_9 = PyObject_IsInstance(__pyx_v_pixels, __pyx_builtin_memoryview); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 2250, __pyx_L1_error) __pyx_t_10 = (__pyx_t_9 != 0); if (__pyx_t_10) { /* … */ goto __pyx_L10; }
+2251: tmp = numpy.asarray(pixels, numpy.int8)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_pixels, __pyx_t_1}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_pixels, __pyx_t_1}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_pixels); __Pyx_GIVEREF(__pyx_v_pixels); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_pixels); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_tmp = __pyx_t_4; __pyx_t_4 = 0;
2252: else:
+2253: tmp = numpy.frombuffer(pixels, numpy.int8)
/*else*/ { __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_pixels, __pyx_t_1}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_pixels, __pyx_t_1}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_pixels); __Pyx_GIVEREF(__pyx_v_pixels); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_v_pixels); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_tmp = __pyx_t_4; __pyx_t_4 = 0; } __pyx_L10:;
+2254: buf[:copy_len] = tmp[:copy_len]
__pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_tmp, 0, __pyx_v_copy_len, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_PyObject_SetSlice(__pyx_v_buf, __pyx_t_4, 0, __pyx_v_copy_len, NULL, NULL, NULL, 0, 1, 1) < 0) __PYX_ERR(0, 2254, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2255: else:
2256: #ouch, we need to copy the source pixels into the smaller buffer
2257: #before uploading to the device... this is probably costly!
+2258: stride = target_stride
/*else*/ { __pyx_v_stride = __pyx_v_target_stride;
+2259: min_stride = min(stride, image_stride)
__pyx_t_8 = __pyx_v_image_stride; __pyx_t_13 = __pyx_v_stride; if (((__pyx_t_8 < __pyx_t_13) != 0)) { __pyx_t_14 = __pyx_t_8; } else { __pyx_t_14 = __pyx_t_13; } __pyx_v_min_stride = __pyx_t_14;
+2260: log("copying %s bytes from %s into %s, %i stride at a time (from image stride=%i, target stride=%i)", stride*h, type(pixels), type(target_buffer), min_stride, image_stride, target_stride)
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From_unsigned_int((__pyx_v_stride * __pyx_v_h)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_min_stride); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyInt_From_unsigned_int(__pyx_v_image_stride); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_target_stride); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[8] = {__pyx_t_15, __pyx_kp_s_copying_s_bytes_from_s_into_s_i, __pyx_t_3, ((PyObject *)Py_TYPE(__pyx_v_pixels)), ((PyObject *)Py_TYPE(__pyx_v_target_buffer)), __pyx_t_1, __pyx_t_5, __pyx_t_2}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[8] = {__pyx_t_15, __pyx_kp_s_copying_s_bytes_from_s_into_s_i, __pyx_t_3, ((PyObject *)Py_TYPE(__pyx_v_pixels)), ((PyObject *)Py_TYPE(__pyx_v_target_buffer)), __pyx_t_1, __pyx_t_5, __pyx_t_2}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_16 = PyTuple_New(7+__pyx_t_6); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_15) { __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL; } __Pyx_INCREF(__pyx_kp_s_copying_s_bytes_from_s_into_s_i); __Pyx_GIVEREF(__pyx_kp_s_copying_s_bytes_from_s_into_s_i); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_6, __pyx_kp_s_copying_s_bytes_from_s_into_s_i); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_6, __pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_pixels))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_pixels))); PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_6, ((PyObject *)Py_TYPE(__pyx_v_pixels))); __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_target_buffer))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_target_buffer))); PyTuple_SET_ITEM(__pyx_t_16, 3+__pyx_t_6, ((PyObject *)Py_TYPE(__pyx_v_target_buffer))); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_16, 4+__pyx_t_6, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_16, 5+__pyx_t_6, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_16, 6+__pyx_t_6, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2261: copy_len = min_stride * h
__pyx_v_copy_len = (__pyx_v_min_stride * __pyx_v_h);
+2262: for i in range(h):
__pyx_t_14 = __pyx_v_h; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_14; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+2263: x = i*stride
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int((__pyx_v_i * __pyx_v_stride)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_4); __pyx_t_4 = 0;
+2264: y = i*image_stride
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int((__pyx_v_i * __pyx_v_image_stride)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_4); __pyx_t_4 = 0;
+2265: buf[x:x+min_stride] = pixels[y:y+min_stride]
__pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_min_stride); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = PyNumber_Add(__pyx_v_y, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_pixels, 0, 0, &__pyx_v_y, &__pyx_t_7, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_unsigned_int(__pyx_v_min_stride); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_16 = PyNumber_Add(__pyx_v_x, __pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__Pyx_PyObject_SetSlice(__pyx_v_buf, __pyx_t_4, 0, 0, &__pyx_v_x, &__pyx_t_16, NULL, 0, 0, 1) < 0) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __pyx_L7:;
+2266: cdef double end = monotonic_time()
__pyx_v_end = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2267: log("copy_image: %i bytes uploaded in %ims", copy_len, int(1000*(end-start)))
__pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_7 = __Pyx_PyInt_From_unsigned_long(__pyx_v_copy_len); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_FromDouble((1000.0 * (__pyx_v_end - __pyx_v_start))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_copy_image_i_bytes_uploaded_in_i, __pyx_t_7, __pyx_t_2}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_copy_image_i_bytes_uploaded_in_i, __pyx_t_7, __pyx_t_2}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_1 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_copy_image_i_bytes_uploaded_in_i); __Pyx_GIVEREF(__pyx_kp_s_copy_image_i_bytes_uploaded_in_i); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_6, __pyx_kp_s_copy_image_i_bytes_uploaded_in_i); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_6, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_6, __pyx_t_2); __pyx_t_7 = 0; __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2268: return stride
__pyx_r = __pyx_v_stride; goto __pyx_L0;
2269:
+2270: cdef exec_kernel(self, unsigned int w, unsigned int h, unsigned int stride):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_exec_kernel(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, unsigned int __pyx_v_w, unsigned int __pyx_v_h, unsigned int __pyx_v_stride) { uint8_t __pyx_v_dx; uint8_t __pyx_v_dy; uint32_t __pyx_v_blockw; uint32_t __pyx_v_blockh; uint32_t __pyx_v_gridw; uint32_t __pyx_v_gridh; unsigned int __pyx_v_in_w; unsigned int __pyx_v_in_h; double __pyx_v_start; PyObject *__pyx_v_args = NULL; double __pyx_v_end; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exec_kernel", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.exec_kernel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2271: cdef uint8_t dx, dy
+2272: if self.pixel_format=="NV12":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_NV12, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2272, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L3; }
2273: #(these values are derived from the kernel code - which we should know nothing about here..)
2274: #divide each dimension by 2 since we process 4 pixels at a time:
+2275: dx, dy = 2, 2
__pyx_t_2 = 2; __pyx_t_3 = 2; __pyx_v_dx = __pyx_t_2; __pyx_v_dy = __pyx_t_3;
+2276: elif self.pixel_format=="YUV444P":
__pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_self->pixel_format, __pyx_n_s_YUV444P, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2276, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L3; }
2277: #one pixel at a time:
+2278: dx, dy = 1, 1
__pyx_t_3 = 1; __pyx_t_2 = 1; __pyx_v_dx = __pyx_t_3; __pyx_v_dy = __pyx_t_2;
2279: else:
+2280: raise Exception("bug: invalid pixel format '%s'" % self.pixel_format)
/*else*/ { __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_bug_invalid_pixel_format_s, __pyx_v_self->pixel_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 2280, __pyx_L1_error) } __pyx_L3:;
2281:
2282: #FIXME: find better values and validate against max_block/max_grid:
2283: #calculate grids/blocks:
2284: #a block is a group of threads: (blockw * blockh) threads
2285: #a grid is a group of blocks: (gridw * gridh) blocks
+2286: cdef uint32_t blockw = 32
__pyx_v_blockw = 32;
+2287: cdef uint32_t blockh = 32
__pyx_v_blockh = 32;
+2288: cdef uint32_t gridw = MAX(1, w//(blockw*dx))
__pyx_v_gridw = __pyx_f_4xpra_6codecs_5nvenc_7encoder_MAX(1, (__pyx_v_w / (__pyx_v_blockw * __pyx_v_dx)));
+2289: cdef uint32_t gridh = MAX(1, h//(blockh*dy))
__pyx_v_gridh = __pyx_f_4xpra_6codecs_5nvenc_7encoder_MAX(1, (__pyx_v_h / (__pyx_v_blockh * __pyx_v_dy)));
2290: #if dx or dy made us round down, add one:
+2291: if gridw*dx*blockw<w:
__pyx_t_1 = ((((__pyx_v_gridw * __pyx_v_dx) * __pyx_v_blockw) < __pyx_v_w) != 0); if (__pyx_t_1) { /* … */ }
+2292: gridw += 1
__pyx_v_gridw = (__pyx_v_gridw + 1);
+2293: if gridh*dy*blockh<h:
__pyx_t_1 = ((((__pyx_v_gridh * __pyx_v_dy) * __pyx_v_blockh) < __pyx_v_h) != 0); if (__pyx_t_1) { /* … */ }
+2294: gridh += 1
__pyx_v_gridh = (__pyx_v_gridh + 1);
+2295: cdef unsigned int in_w = self.input_width
__pyx_t_6 = __pyx_v_self->input_width; __pyx_v_in_w = __pyx_t_6;
+2296: cdef unsigned int in_h = self.input_height
__pyx_t_6 = __pyx_v_self->input_height; __pyx_v_in_h = __pyx_t_6;
+2297: if self.scaling!=(1,1):
__pyx_t_4 = PyObject_RichCompare(__pyx_v_self->scaling, __pyx_tuple__28, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2297, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2297, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* … */ } /* … */ __pyx_tuple__28 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 2297, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28);
2298: #scaling so scale exact dimensions, not padded input dimensions:
+2299: in_w, in_h = w, h
__pyx_t_6 = __pyx_v_w; __pyx_t_7 = __pyx_v_h; __pyx_v_in_w = __pyx_t_6; __pyx_v_in_h = __pyx_t_7;
2300:
+2301: cdef double start = monotonic_time()
__pyx_v_start = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2302: args = (self.cudaInputBuffer, numpy.int32(in_w), numpy.int32(in_h), numpy.int32(stride),
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_unsigned_int(__pyx_v_in_w); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (!__pyx_t_9) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_5}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_5}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyInt_From_unsigned_int(__pyx_v_in_h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_9) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_8); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_10}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_10}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int32); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyInt_From_unsigned_int(__pyx_v_stride); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } if (!__pyx_t_9) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_11}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_11}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* … */ __pyx_t_15 = PyTuple_New(10); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_v_self->cudaInputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaInputBuffer); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_self->cudaInputBuffer); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_5); __Pyx_INCREF(__pyx_v_self->cudaOutputBuffer); __Pyx_GIVEREF(__pyx_v_self->cudaOutputBuffer); PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_v_self->cudaOutputBuffer); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_15, 5, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_15, 6, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 7, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 8, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 9, __pyx_t_14); __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_v_args = ((PyObject*)__pyx_t_15); __pyx_t_15 = 0;
+2303: self.cudaOutputBuffer, numpy.int32(self.encoder_width), numpy.int32(self.encoder_height), numpy.int32(self.outputPitch),
__pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_int32); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->encoder_width); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (!__pyx_t_9) { __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_10); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_12}; __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_12}; __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_int32); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->encoder_height); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (!__pyx_t_9) { __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_13}; __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_13}; __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_int32); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->outputPitch); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } if (!__pyx_t_9) { __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_12); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_14}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_14}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif { __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+2304: numpy.int32(w), numpy.int32(h))
__pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_int32); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyInt_From_unsigned_int(__pyx_v_w); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); } } if (!__pyx_t_9) { __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_13); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_14)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_15}; __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_15}; __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else #endif { __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_16, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_int32); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyInt_From_unsigned_int(__pyx_v_h); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); } } if (!__pyx_t_9) { __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_14); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_15)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_16}; __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_16}; __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif { __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_16); __pyx_t_16 = 0; __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_17, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } } __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2305: log("calling %s%s with block=%s, grid=%s", self.kernel, args, (blockw,blockh,1), (gridw, gridh))
__pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = __Pyx_PyInt_From_uint32_t(__pyx_v_blockw); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyInt_From_uint32_t(__pyx_v_blockh); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_12); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_int_1); __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyInt_From_uint32_t(__pyx_v_gridw); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyInt_From_uint32_t(__pyx_v_gridh); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_18 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_18 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_14)) { PyObject *__pyx_temp[6] = {__pyx_t_13, __pyx_kp_s_calling_s_s_with_block_s_grid_s, __pyx_v_self->kernel, __pyx_v_args, __pyx_t_11, __pyx_t_10}; __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_18, 5+__pyx_t_18); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) { PyObject *__pyx_temp[6] = {__pyx_t_13, __pyx_kp_s_calling_s_s_with_block_s_grid_s, __pyx_v_self->kernel, __pyx_v_args, __pyx_t_11, __pyx_t_10}; __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_18, 5+__pyx_t_18); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_12 = PyTuple_New(5+__pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL; } __Pyx_INCREF(__pyx_kp_s_calling_s_s_with_block_s_grid_s); __Pyx_GIVEREF(__pyx_kp_s_calling_s_s_with_block_s_grid_s); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_18, __pyx_kp_s_calling_s_s_with_block_s_grid_s); __Pyx_INCREF(__pyx_v_self->kernel); __Pyx_GIVEREF(__pyx_v_self->kernel); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_18, __pyx_v_self->kernel); __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_18, __pyx_v_args); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_18, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_18, __pyx_t_10); __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_12, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2306: self.kernel(*args, block=(blockw,blockh,1), grid=(gridw, gridh))
__pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = __Pyx_PyInt_From_uint32_t(__pyx_v_blockw); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_12 = __Pyx_PyInt_From_uint32_t(__pyx_v_blockh); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_12); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_int_1); __pyx_t_14 = 0; __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_block, __pyx_t_10) < 0) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyInt_From_uint32_t(__pyx_v_gridw); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = __Pyx_PyInt_From_uint32_t(__pyx_v_gridh); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_12); __pyx_t_10 = 0; __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_grid, __pyx_t_14) < 0) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_Call(__pyx_v_self->kernel, __pyx_v_args, __pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+2307: self.cuda_context.synchronize()
__pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cuda_context, __pyx_n_s_synchronize); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); } } if (__pyx_t_12) { __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { __pyx_t_14 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2307, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+2308: cdef double end = monotonic_time()
__pyx_v_end = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2309: log("compress_image(..) kernel %s took %.1f ms", self.kernel_name, (end - start)*1000.0)
__pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_12 = PyFloat_FromDouble(((__pyx_v_end - __pyx_v_start) * 1000.0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_18 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_18 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_15)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_compress_image_kernel_s_took_1f, __pyx_v_self->kernel_name, __pyx_t_12}; __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_18, 3+__pyx_t_18); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2309, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_compress_image_kernel_s_took_1f, __pyx_v_self->kernel_name, __pyx_t_12}; __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_18, 3+__pyx_t_18); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2309, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_11 = PyTuple_New(3+__pyx_t_18); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_compress_image_kernel_s_took_1f); __Pyx_GIVEREF(__pyx_kp_s_compress_image_kernel_s_took_1f); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_18, __pyx_kp_s_compress_image_kernel_s_took_1f); __Pyx_INCREF(__pyx_v_self->kernel_name); __Pyx_GIVEREF(__pyx_v_self->kernel_name); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_18, __pyx_v_self->kernel_name); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_18, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_11, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
2310:
+2311: cdef NV_ENC_INPUT_PTR map_input_resource(self):
static NV_ENC_INPUT_PTR __pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_map_input_resource(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { NVENCSTATUS __pyx_v_r; NV_ENC_MAP_INPUT_RESOURCE __pyx_v_mapInputResource; NV_ENC_INPUT_PTR __pyx_v_mappedResource; NV_ENC_INPUT_PTR __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("map_input_resource", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("xpra.codecs.nvenc.encoder.Encoder.map_input_resource", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
2312: cdef NVENCSTATUS r #@DuplicatedSignature
2313: cdef NV_ENC_MAP_INPUT_RESOURCE mapInputResource
2314: #map buffer so nvenc can access it:
+2315: memset(&mapInputResource, 0, sizeof(NV_ENC_MAP_INPUT_RESOURCE))
memset((&__pyx_v_mapInputResource), 0, (sizeof(NV_ENC_MAP_INPUT_RESOURCE)));
+2316: mapInputResource.version = NV_ENC_MAP_INPUT_RESOURCE_VER
__pyx_v_mapInputResource.version = NV_ENC_MAP_INPUT_RESOURCE_VER;
+2317: mapInputResource.registeredResource = self.inputHandle
__pyx_t_1 = __pyx_v_self->inputHandle; __pyx_v_mapInputResource.registeredResource = __pyx_t_1;
+2318: mapInputResource.mappedBufferFmt = self.bufferFmt
__pyx_t_2 = __pyx_v_self->bufferFmt; __pyx_v_mapInputResource.mappedBufferFmt = __pyx_t_2;
+2319: if DEBUG_API:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_3) { /* … */ }
+2320: log("nvEncMapInputResource(%#x) inputHandle=%#x", <uintptr_t> &mapInputResource, <uintptr_t> self.inputHandle)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_mapInputResource))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->inputHandle)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_s_nvEncMapInputResource_x_inputHan, __pyx_t_6, __pyx_t_7}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_s_nvEncMapInputResource_x_inputHan, __pyx_t_6, __pyx_t_7}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncMapInputResource_x_inputHan); __Pyx_GIVEREF(__pyx_kp_s_nvEncMapInputResource_x_inputHan); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_nvEncMapInputResource_x_inputHan); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7); __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2321: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2322: r = self.functionList.nvEncMapInputResource(self.context, &mapInputResource)
__pyx_v_r = __pyx_v_self->functionList->nvEncMapInputResource(__pyx_v_self->context, (&__pyx_v_mapInputResource)); }
+2323: raiseNVENC(r, "mapping input resource")
__pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_mapping_input_resource); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2324: cdef NV_ENC_INPUT_PTR mappedResource = mapInputResource.mappedResource
__pyx_t_11 = __pyx_v_mapInputResource.mappedResource; __pyx_v_mappedResource = __pyx_t_11;
+2325: if DEBUG_API:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_3) { /* … */ }
+2326: log("compress_image(..) device buffer mapped to %#x", <uintptr_t> mappedResource)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_mappedResource)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_compress_image_device_buffer_map, __pyx_t_10}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2326, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_compress_image_device_buffer_map, __pyx_t_10}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2326, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_compress_image_device_buffer_map); __Pyx_GIVEREF(__pyx_kp_s_compress_image_device_buffer_map); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_kp_s_compress_image_device_buffer_map); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2327: return mappedResource
__pyx_r = __pyx_v_mappedResource; goto __pyx_L0;
2328:
+2329: cdef unmap_input_resource(self, NV_ENC_INPUT_PTR mappedResource):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_unmap_input_resource(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, NV_ENC_INPUT_PTR __pyx_v_mappedResource) { int __pyx_v_r; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unmap_input_resource", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.unmap_input_resource", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+2330: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2331: log("nvEncUnmapInputResource(%#x)", <uintptr_t> mappedResource)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_mappedResource)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncUnmapInputResource_x, __pyx_t_4}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2331, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncUnmapInputResource_x, __pyx_t_4}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2331, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncUnmapInputResource_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncUnmapInputResource_x); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_nvEncUnmapInputResource_x); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2332: cdef int r
+2333: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2334: r = self.functionList.nvEncUnmapInputResource(self.context, mappedResource)
__pyx_v_r = __pyx_v_self->functionList->nvEncUnmapInputResource(__pyx_v_self->context, __pyx_v_mappedResource); }
+2335: raiseNVENC(r, "unmapping input resource")
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_unmapping_input_resource); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2336:
+2337: cdef nvenc_compress(self, int input_size, NV_ENC_INPUT_PTR input, timestamp=0):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_nvenc_compress(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, int __pyx_v_input_size, NV_ENC_INPUT_PTR __pyx_v_input, struct __pyx_opt_args_4xpra_6codecs_5nvenc_7encoder_7Encoder_nvenc_compress *__pyx_optional_args) { PyObject *__pyx_v_timestamp = ((PyObject *)__pyx_int_0); NVENCSTATUS __pyx_v_r; NV_ENC_PIC_PARAMS __pyx_v_picParams; NV_ENC_LOCK_BITSTREAM __pyx_v_lockOutputBuffer; double __pyx_v_start; double __pyx_v_encode_end; PyObject *__pyx_v_size = NULL; PyObject *__pyx_v_data = NULL; double __pyx_v_download_end; PyObject *__pyx_v_client_options = NULL; double __pyx_v_end; double __pyx_v_elapsed; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("nvenc_compress", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_timestamp = __pyx_optional_args->timestamp; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_XDECREF(__pyx_t_23); __Pyx_XDECREF(__pyx_t_24); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.nvenc_compress", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_size); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_client_options); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_4xpra_6codecs_5nvenc_7encoder_7Encoder_nvenc_compress { int __pyx_n; PyObject *timestamp; };
2338: cdef NVENCSTATUS r #@DuplicatedSignature
2339: cdef NV_ENC_PIC_PARAMS picParams #@DuplicatedSignature
2340: cdef NV_ENC_LOCK_BITSTREAM lockOutputBuffer
+2341: assert input_size>0, "invalid input size %i" % input_size
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_input_size > 0) != 0))) { __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_input_size_i, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 2341, __pyx_L1_error) } } #endif
2342:
+2343: cdef double start = monotonic_time()
__pyx_v_start = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2344: if DEBUG_API:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_3) { /* … */ }
+2345: log("nvEncEncodePicture(%#x)", <uintptr_t> &picParams)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_picParams))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncEncodePicture_x, __pyx_t_4}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_nvEncEncodePicture_x, __pyx_t_4}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncEncodePicture_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncEncodePicture_x); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_nvEncEncodePicture_x); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2346: memset(&picParams, 0, sizeof(NV_ENC_PIC_PARAMS))
memset((&__pyx_v_picParams), 0, (sizeof(NV_ENC_PIC_PARAMS)));
+2347: picParams.version = NV_ENC_PIC_PARAMS_VER
__pyx_v_picParams.version = NV_ENC_PIC_PARAMS_VER;
+2348: picParams.bufferFmt = self.bufferFmt
__pyx_t_8 = __pyx_v_self->bufferFmt; __pyx_v_picParams.bufferFmt = __pyx_t_8;
+2349: picParams.pictureStruct = NV_ENC_PIC_STRUCT_FRAME
__pyx_v_picParams.pictureStruct = NV_ENC_PIC_STRUCT_FRAME;
+2350: picParams.inputWidth = self.encoder_width
__pyx_t_9 = __pyx_v_self->encoder_width; __pyx_v_picParams.inputWidth = __pyx_t_9;
+2351: picParams.inputHeight = self.encoder_height
__pyx_t_9 = __pyx_v_self->encoder_height; __pyx_v_picParams.inputHeight = __pyx_t_9;
+2352: picParams.inputPitch = self.outputPitch
__pyx_t_9 = __pyx_v_self->outputPitch; __pyx_v_picParams.inputPitch = __pyx_t_9;
+2353: picParams.inputBuffer = input
__pyx_v_picParams.inputBuffer = __pyx_v_input;
+2354: picParams.outputBitstream = self.bitstreamBuffer
__pyx_t_10 = __pyx_v_self->bitstreamBuffer; __pyx_v_picParams.outputBitstream = __pyx_t_10;
2355: #picParams.pictureType: required when enablePTD is disabled
+2356: if self.frames==0:
__pyx_t_3 = ((__pyx_v_self->frames == 0) != 0); if (__pyx_t_3) { /* … */ goto __pyx_L4; }
2357: #only the first frame needs to be IDR (as we never lose frames)
+2358: picParams.pictureType = NV_ENC_PIC_TYPE_IDR
__pyx_v_picParams.pictureType = NV_ENC_PIC_TYPE_IDR;
+2359: picParams.encodePicFlags = NV_ENC_PIC_FLAG_OUTPUT_SPSPPS
__pyx_v_picParams.encodePicFlags = NV_ENC_PIC_FLAG_OUTPUT_SPSPPS;
2360: else:
+2361: picParams.pictureType = NV_ENC_PIC_TYPE_P
/*else*/ { __pyx_v_picParams.pictureType = NV_ENC_PIC_TYPE_P; } __pyx_L4:;
+2362: if self.encoding=="h264":
__pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_self->encoding, __pyx_n_s_h264, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2362, __pyx_L1_error) if (__pyx_t_3) { /* … */ goto __pyx_L5; }
+2363: picParams.codecPicParams.h264PicParams.displayPOCSyntax = 2*self.frames
__pyx_v_picParams.codecPicParams.h264PicParams.displayPOCSyntax = (2 * __pyx_v_self->frames);
+2364: picParams.codecPicParams.h264PicParams.refPicFlag = self.frames==0
__pyx_v_picParams.codecPicParams.h264PicParams.refPicFlag = (__pyx_v_self->frames == 0);
2365: #this causes crashes with Pascal (ie GTX-1070):
2366: #picParams.codecPicParams.h264PicParams.sliceMode = 3 #sliceModeData specifies the number of slices
2367: #picParams.codecPicParams.h264PicParams.sliceModeData = 1 #1 slice!
2368: else:
+2369: picParams.codecPicParams.hevcPicParams.displayPOCSyntax = 2*self.frames
/*else*/ { __pyx_v_picParams.codecPicParams.hevcPicParams.displayPOCSyntax = (2 * __pyx_v_self->frames);
+2370: picParams.codecPicParams.hevcPicParams.refPicFlag = self.frames==0
__pyx_v_picParams.codecPicParams.hevcPicParams.refPicFlag = (__pyx_v_self->frames == 0); } __pyx_L5:;
+2371: picParams.frameIdx = self.frames
__pyx_t_11 = __pyx_v_self->frames; __pyx_v_picParams.frameIdx = __pyx_t_11;
+2372: picParams.inputTimeStamp = timestamp-self.first_frame_timestamp
__pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->first_frame_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Subtract(__pyx_v_timestamp, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyInt_As_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_12 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_picParams.inputTimeStamp = __pyx_t_12;
2373: #inputDuration = 0 #FIXME: use frame delay?
2374: #picParams.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR #FIXME: check NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES caps
2375: #picParams.rcParams.enableMinQP = 1
2376: #picParams.rcParams.enableMaxQP = 1
2377: #0=max quality, 63 lowest quality
2378: #qmin = QP_MAX_VALUE-min(QP_MAX_VALUE, int(QP_MAX_VALUE*(self.quality+20)/100))
2379: #qmax = QP_MAX_VALUE-max(0, int(QP_MAX_VALUE*(self.quality-20)/100))
2380: #picParams.rcParams.minQP.qpInterB = qmin
2381: #picParams.rcParams.minQP.qpInterP = qmin
2382: #picParams.rcParams.minQP.qpIntra = qmin
2383: #picParams.rcParams.maxQP.qpInterB = qmax
2384: #picParams.rcParams.maxQP.qpInterP = qmax
2385: #picParams.rcParams.maxQP.qpIntra = qmax
2386: #picParams.rcParams.averageBitRate = self.target_bitrate
2387: #picParams.rcParams.maxBitRate = self.max_bitrate
2388:
+2389: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L8; } __pyx_L8:; } }
+2390: r = self.functionList.nvEncEncodePicture(self.context, &picParams)
__pyx_v_r = __pyx_v_self->functionList->nvEncEncodePicture(__pyx_v_self->context, (&__pyx_v_picParams)); }
+2391: raiseNVENC(r, "error during picture encoding")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_error_during_picture_encoding); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2392: cdef double encode_end = monotonic_time()
__pyx_v_encode_end = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2393: log("compress_image(..) encoded in %.1f ms", (encode_end-start)*1000.0)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyFloat_FromDouble(((__pyx_v_encode_end - __pyx_v_start) * 1000.0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_compress_image_encoded_in_1f_ms, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_compress_image_encoded_in_1f_ms, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_compress_image_encoded_in_1f_ms); __Pyx_GIVEREF(__pyx_kp_s_compress_image_encoded_in_1f_ms); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_kp_s_compress_image_encoded_in_1f_ms); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2394:
+2395: memset(&lockOutputBuffer, 0, sizeof(NV_ENC_LOCK_BITSTREAM))
memset((&__pyx_v_lockOutputBuffer), 0, (sizeof(NV_ENC_LOCK_BITSTREAM)));
2396: #lock output buffer:
+2397: lockOutputBuffer.version = NV_ENC_LOCK_BITSTREAM_VER
__pyx_v_lockOutputBuffer.version = NV_ENC_LOCK_BITSTREAM_VER;
+2398: lockOutputBuffer.doNotWait = 0
__pyx_v_lockOutputBuffer.doNotWait = 0;
+2399: lockOutputBuffer.outputBitstream = self.bitstreamBuffer
__pyx_t_10 = __pyx_v_self->bitstreamBuffer; __pyx_v_lockOutputBuffer.outputBitstream = __pyx_t_10;
+2400: if DEBUG_API:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_3) { /* … */ }
+2401: log("nvEncLockBitstream(%#x) bitstreamBuffer=%#x", <uintptr_t> &lockOutputBuffer, <uintptr_t> self.bitstreamBuffer)
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_lockOutputBuffer))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->bitstreamBuffer)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_nvEncLockBitstream_x_bitstreamBu, __pyx_t_5, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_nvEncLockBitstream_x_bitstreamBu, __pyx_t_5, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_13 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncLockBitstream_x_bitstreamBu); __Pyx_GIVEREF(__pyx_kp_s_nvEncLockBitstream_x_bitstreamBu); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_6, __pyx_kp_s_nvEncLockBitstream_x_bitstreamBu); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_6, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_6, __pyx_t_7); __pyx_t_5 = 0; __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2402: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L12; } __pyx_L12:; } }
+2403: r = self.functionList.nvEncLockBitstream(self.context, &lockOutputBuffer)
__pyx_v_r = __pyx_v_self->functionList->nvEncLockBitstream(__pyx_v_self->context, (&__pyx_v_lockOutputBuffer)); }
+2404: raiseNVENC(r, "locking output buffer")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_locking_output_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2405: assert lockOutputBuffer.bitstreamBufferPtr!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_lockOutputBuffer.bitstreamBufferPtr != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2405, __pyx_L1_error) } } #endif
2406: #copy to python buffer:
+2407: size = lockOutputBuffer.bitstreamSizeInBytes
__pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_lockOutputBuffer.bitstreamSizeInBytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_size = __pyx_t_1; __pyx_t_1 = 0;
+2408: self.bytes_out += size
__pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->bytes_out); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = __Pyx_PyInt_As_uint64_t(__pyx_t_2); if (unlikely((__pyx_t_12 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_self->bytes_out = __pyx_t_12;
+2409: data = (<char *> lockOutputBuffer.bitstreamBufferPtr)[:size]
__pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_v_size); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2409, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((char *)__pyx_v_lockOutputBuffer.bitstreamBufferPtr) + 0, __pyx_t_14 - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_data = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2410: if DEBUG_API:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_3) { /* … */ }
+2411: log("nvEncUnlockBitstream(%#x)", <uintptr_t> self.bitstreamBuffer)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_13 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->bitstreamBuffer)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_nvEncUnlockBitstream_x, __pyx_t_13}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2411, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_nvEncUnlockBitstream_x, __pyx_t_13}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2411, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncUnlockBitstream_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncUnlockBitstream_x); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_kp_s_nvEncUnlockBitstream_x); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2412: if lockOutputBuffer.bitstreamBufferPtr!=NULL:
__pyx_t_3 = ((__pyx_v_lockOutputBuffer.bitstreamBufferPtr != NULL) != 0); if (__pyx_t_3) { /* … */ }
+2413: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L17; } __pyx_L17:; } }
+2414: r = self.functionList.nvEncUnlockBitstream(self.context, self.bitstreamBuffer)
__pyx_v_r = __pyx_v_self->functionList->nvEncUnlockBitstream(__pyx_v_self->context, __pyx_v_self->bitstreamBuffer); }
+2415: raiseNVENC(r, "unlocking output buffer")
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_unlocking_output_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2416:
+2417: cdef double download_end = monotonic_time()
__pyx_v_download_end = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2418: log("compress_image(..) download took %.1f ms", (download_end-encode_end)*1000.0)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyFloat_FromDouble(((__pyx_v_download_end - __pyx_v_encode_end) * 1000.0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_13 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_kp_s_compress_image_download_took_1f, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_kp_s_compress_image_download_took_1f, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_13); __pyx_t_13 = NULL; } __Pyx_INCREF(__pyx_kp_s_compress_image_download_took_1f); __Pyx_GIVEREF(__pyx_kp_s_compress_image_download_took_1f); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_compress_image_download_took_1f); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2419: #update info:
+2420: self.free_memory, self.total_memory = driver.mem_get_info()
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_mem_get_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (__pyx_t_1) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2420, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 2420, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_15 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_7 = __pyx_t_15(__pyx_t_5); if (unlikely(!__pyx_t_7)) goto __pyx_L18_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); index = 1; __pyx_t_1 = __pyx_t_15(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L18_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_5), 2) < 0) __PYX_ERR(0, 2420, __pyx_L1_error) __pyx_t_15 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L19_unpacking_done; __pyx_L18_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_15 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 2420, __pyx_L1_error) __pyx_L19_unpacking_done:; } __pyx_t_12 = __Pyx_PyInt_As_uint64_t(__pyx_t_7); if (unlikely((__pyx_t_12 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_16 = __Pyx_PyInt_As_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_16 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->free_memory = __pyx_t_12; __pyx_v_self->total_memory = __pyx_t_16;
2421:
2422: client_options = {
+2423: "frame" : int(self.frames),
__pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->frames); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_frame, __pyx_t_1) < 0) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2424: "pts" : int(timestamp-self.first_frame_timestamp),
__pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->first_frame_timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyNumber_Subtract(__pyx_v_timestamp, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_pts, __pyx_t_1) < 0) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2425: "speed" : self.speed,
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->speed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_speed, __pyx_t_1) < 0) __PYX_ERR(0, 2423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_client_options = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
2426: }
+2427: if self.lossless:
__pyx_t_3 = (__pyx_v_self->lossless != 0); if (__pyx_t_3) { /* … */ goto __pyx_L20; }
+2428: client_options["quality"] = 100
if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_quality, __pyx_int_100) < 0)) __PYX_ERR(0, 2428, __pyx_L1_error)
+2429: client_options["lossless"] = True
if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_lossless, Py_True) < 0)) __PYX_ERR(0, 2429, __pyx_L1_error)
2430: else:
+2431: client_options["quality"] = min(99, self.quality) #ensure we cap it at 99 because this is lossy
/*else*/ { __pyx_t_6 = __pyx_v_self->quality; __pyx_t_17 = 99; if (((__pyx_t_6 < __pyx_t_17) != 0)) { __pyx_t_18 = __pyx_t_6; } else { __pyx_t_18 = __pyx_t_17; } __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_18); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_quality, __pyx_t_2) < 0)) __PYX_ERR(0, 2431, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L20:;
+2432: if self.scaling!=(1,1):
__pyx_t_2 = PyObject_RichCompare(__pyx_v_self->scaling, __pyx_tuple__29, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2432, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2432, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ } /* … */ __pyx_tuple__29 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 2432, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29);
+2433: client_options["scaled_size"] = self.encoder_width, self.encoder_height
__pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->encoder_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->encoder_height); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_1 = 0; if (unlikely(PyDict_SetItem(__pyx_v_client_options, __pyx_n_s_scaled_size, __pyx_t_7) < 0)) __PYX_ERR(0, 2433, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+2434: cdef double end = monotonic_time()
__pyx_v_end = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2435: self.frames += 1
__pyx_v_self->frames = (__pyx_v_self->frames + 1);
+2436: self.last_frame_times.append((start, end))
__pyx_t_7 = PyFloat_FromDouble(__pyx_v_start); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_end); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_7 = 0; __pyx_t_1 = 0; __pyx_t_19 = __Pyx_PyObject_Append(__pyx_v_self->last_frame_times, __pyx_t_2); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 2436, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2437: elapsed = end-start
__pyx_v_elapsed = (__pyx_v_end - __pyx_v_start);
+2438: self.time += elapsed
__pyx_v_self->time = (__pyx_v_self->time + __pyx_v_elapsed);
+2439: log("compress_image(..) %s %s returning %s bytes (%.1f%%) for %s frame %i took %.1fms",
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+2440: get_type(), get_version(),
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (__pyx_t_13) { __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2440, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else { __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2440, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_version); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } if (__pyx_t_4) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2440, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2440, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+2441: size, 100.0*size/input_size, PIC_TYPES.get(picParams.pictureType, picParams.pictureType), self.frames, 1000.0*elapsed)
__pyx_t_13 = PyNumber_Multiply(__pyx_float_100_0, __pyx_v_size); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_20 = __Pyx_PyNumber_Divide(__pyx_t_13, __pyx_t_4); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_PIC_TYPES); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_get); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(__pyx_v_picParams.pictureType); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_22 = __Pyx_PyInt_From_NV_ENC_PIC_TYPE(__pyx_v_picParams.pictureType); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_23 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_21))) { __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_21); if (likely(__pyx_t_23)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); __Pyx_INCREF(__pyx_t_23); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_21, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_21)) { PyObject *__pyx_temp[3] = {__pyx_t_23, __pyx_t_13, __pyx_t_22}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_21, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_21)) { PyObject *__pyx_temp[3] = {__pyx_t_23, __pyx_t_13, __pyx_t_22}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_21, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; } else #endif { __pyx_t_24 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); if (__pyx_t_23) { __Pyx_GIVEREF(__pyx_t_23); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_23); __pyx_t_23 = NULL; } __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_6, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_6, __pyx_t_22); __pyx_t_13 = 0; __pyx_t_22 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_24, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->frames); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_24 = PyFloat_FromDouble((1000.0 * __pyx_v_elapsed)); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_22 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_22)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_22); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[9] = {__pyx_t_22, __pyx_kp_s_compress_image_s_s_returning_s_b, __pyx_t_7, __pyx_t_5, __pyx_v_size, __pyx_t_20, __pyx_t_4, __pyx_t_21, __pyx_t_24}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 8+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2439, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[9] = {__pyx_t_22, __pyx_kp_s_compress_image_s_s_returning_s_b, __pyx_t_7, __pyx_t_5, __pyx_v_size, __pyx_t_20, __pyx_t_4, __pyx_t_21, __pyx_t_24}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 8+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2439, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } else #endif { __pyx_t_13 = PyTuple_New(8+__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_22) { __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_22); __pyx_t_22 = NULL; } __Pyx_INCREF(__pyx_kp_s_compress_image_s_s_returning_s_b); __Pyx_GIVEREF(__pyx_kp_s_compress_image_s_s_returning_s_b); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_6, __pyx_kp_s_compress_image_s_s_returning_s_b); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_6, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_6, __pyx_t_5); __Pyx_INCREF(__pyx_v_size); __Pyx_GIVEREF(__pyx_v_size); PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_6, __pyx_v_size); __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_6, __pyx_t_20); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_6, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_13, 6+__pyx_t_6, __pyx_t_21); __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_13, 7+__pyx_t_6, __pyx_t_24); __pyx_t_7 = 0; __pyx_t_5 = 0; __pyx_t_20 = 0; __pyx_t_4 = 0; __pyx_t_21 = 0; __pyx_t_24 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2442: return data, client_options
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data); __Pyx_INCREF(__pyx_v_client_options); __Pyx_GIVEREF(__pyx_v_client_options); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_client_options); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
2443:
2444:
+2445: cdef NV_ENC_PRESET_CONFIG *get_preset_config(self, name, GUID encode_GUID, GUID preset_GUID) except *:
static NV_ENC_PRESET_CONFIG *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_get_preset_config(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_name, GUID __pyx_v_encode_GUID, GUID __pyx_v_preset_GUID) { NV_ENC_PRESET_CONFIG *__pyx_v_presetConfig; NVENCSTATUS __pyx_v_r; NV_ENC_PRESET_CONFIG *__pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_preset_config", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.get_preset_config", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
2446: """ you must free it after use! """
2447: cdef NV_ENC_PRESET_CONFIG *presetConfig #@DuplicatedSignature
2448: cdef NVENCSTATUS r #@DuplicatedSignature
+2449: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2449, __pyx_L1_error) } } #endif
+2450: presetConfig = <NV_ENC_PRESET_CONFIG*> cmalloc(sizeof(NV_ENC_PRESET_CONFIG), "preset config")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc((sizeof(NV_ENC_PRESET_CONFIG)), __pyx_kp_s_preset_config); if (unlikely(__pyx_t_1 == ((uintptr_t)0))) __PYX_ERR(0, 2450, __pyx_L1_error)
__pyx_v_presetConfig = ((NV_ENC_PRESET_CONFIG *)__pyx_t_1);
+2451: memset(presetConfig, 0, sizeof(NV_ENC_PRESET_CONFIG))
memset(__pyx_v_presetConfig, 0, (sizeof(NV_ENC_PRESET_CONFIG)));
+2452: presetConfig.version = NV_ENC_PRESET_CONFIG_VER
__pyx_v_presetConfig->version = NV_ENC_PRESET_CONFIG_VER;
+2453: presetConfig.presetCfg.version = NV_ENC_CONFIG_VER
__pyx_v_presetConfig->presetCfg.version = NV_ENC_CONFIG_VER;
+2454: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2455: log("nvEncGetEncodePresetConfig(%s, %s)", codecstr(encode_GUID), presetstr(preset_GUID))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_presetstr(__pyx_v_preset_GUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_kp_s_nvEncGetEncodePresetConfig_s_s, __pyx_t_5, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_kp_s_nvEncGetEncodePresetConfig_s_s, __pyx_t_5, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodePresetConfig_s_s); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodePresetConfig_s_s); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_nvEncGetEncodePresetConfig_s_s); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2456: r = self.functionList.nvEncGetEncodePresetConfig(self.context, encode_GUID, preset_GUID, presetConfig)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodePresetConfig(__pyx_v_self->context, __pyx_v_encode_GUID, __pyx_v_preset_GUID, __pyx_v_presetConfig);
+2457: if r!=0:
__pyx_t_2 = ((__pyx_v_r != 0) != 0); if (__pyx_t_2) { /* … */ }
+2458: log.warn("failed to get preset config for %s (%s / %s): %s", name, guidstr(encode_GUID), guidstr(preset_GUID), NV_ENC_STATUS_TXT.get(r, r))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset_GUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_NV_ENC_STATUS_TXT); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_get); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_r); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_11 = __Pyx_PyInt_From_NVENCSTATUS(__pyx_v_r); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_7, __pyx_t_11}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_7, __pyx_t_11}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif { __pyx_t_13 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_8, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_8, __pyx_t_11); __pyx_t_7 = 0; __pyx_t_11 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_kp_s_failed_to_get_preset_config_for, __pyx_v_name, __pyx_t_4, __pyx_t_6, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_kp_s_failed_to_get_preset_config_for, __pyx_v_name, __pyx_t_4, __pyx_t_6, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_13 = PyTuple_New(5+__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_failed_to_get_preset_config_for); __Pyx_GIVEREF(__pyx_kp_s_failed_to_get_preset_config_for); PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_8, __pyx_kp_s_failed_to_get_preset_config_for); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_8, __pyx_v_name); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_8, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_8, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_8, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2459: return NULL
__pyx_r = NULL; goto __pyx_L0;
+2460: return presetConfig
__pyx_r = __pyx_v_presetConfig; goto __pyx_L0;
2461:
+2462: cdef object query_presets(self, GUID encode_GUID):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_query_presets(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, GUID __pyx_v_encode_GUID) { uint32_t __pyx_v_presetCount; uint32_t __pyx_v_presetsRetCount; GUID *__pyx_v_preset_GUIDs; GUID __pyx_v_preset_GUID; NV_ENC_PRESET_CONFIG *__pyx_v_presetConfig; NV_ENC_CONFIG *__pyx_v_encConfig; NVENCSTATUS __pyx_v_r; PyObject *__pyx_v_presets = NULL; PyObject *__pyx_v_unknowns = NULL; uint32_t __pyx_v_x; PyObject *__pyx_v_preset_name = NULL; PyObject *__pyx_v_gop = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("query_presets", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.query_presets", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_presets); __Pyx_XDECREF(__pyx_v_unknowns); __Pyx_XDECREF(__pyx_v_preset_name); __Pyx_XDECREF(__pyx_v_gop); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2463: cdef uint32_t presetCount
2464: cdef uint32_t presetsRetCount
2465: cdef GUID* preset_GUIDs
2466: cdef GUID preset_GUID
2467: cdef NV_ENC_PRESET_CONFIG *presetConfig
2468: cdef NV_ENC_CONFIG *encConfig
2469: cdef NVENCSTATUS r #@DuplicatedSignature
+2470: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2470, __pyx_L1_error) } } #endif
+2471: presets = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_presets = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2472: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2473: log("nvEncGetEncodePresetCount(%s, %#x)", codecstr(encode_GUID), <uintptr_t> &presetCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_presetCount))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetEncodePresetCount_s_x, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetEncodePresetCount_s_x, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodePresetCount_s_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodePresetCount_s_x); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_nvEncGetEncodePresetCount_s_x); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2474: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2475: r = self.functionList.nvEncGetEncodePresetCount(self.context, encode_GUID, &presetCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodePresetCount(__pyx_v_self->context, __pyx_v_encode_GUID, (&__pyx_v_presetCount)); }
+2476: raiseNVENC(r, "getting preset count for %s" % guidstr(encode_GUID))
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_getting_preset_count_for_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2477: log("found %s preset%s:", presetCount, engs(presetCount))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_presetCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_engs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_uint32_t(__pyx_v_presetCount); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_9) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_found_s_preset_s, __pyx_t_8, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_found_s_preset_s, __pyx_t_8, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_found_s_preset_s); __Pyx_GIVEREF(__pyx_kp_s_found_s_preset_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_kp_s_found_s_preset_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_5); __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2478: assert presetCount<2**8
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_presetCount < 0x100) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2478, __pyx_L1_error) } } #endif
+2479: preset_GUIDs = <GUID*> cmalloc(sizeof(GUID) * presetCount, "preset GUIDs")
__pyx_t_11 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc(((sizeof(GUID)) * __pyx_v_presetCount), __pyx_kp_s_preset_GUIDs); if (unlikely(__pyx_t_11 == ((uintptr_t)0))) __PYX_ERR(0, 2479, __pyx_L1_error)
__pyx_v_preset_GUIDs = ((GUID *)__pyx_t_11);
+2480: try:
/*try:*/ {
+2481: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2482: log("nvEncGetEncodePresetGUIDs(%s, %#x)", codecstr(encode_GUID), <uintptr_t> &presetCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_presetCount))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_s_nvEncGetEncodePresetGUIDs_s_x, __pyx_t_10, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_s_nvEncGetEncodePresetGUIDs_s_x, __pyx_t_10, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodePresetGUIDs_s_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodePresetGUIDs_s_x); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_kp_s_nvEncGetEncodePresetGUIDs_s_x); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_7, __pyx_t_5); __pyx_t_10 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2482, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2483: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L13; } __pyx_L13:; } }
+2484: r = self.functionList.nvEncGetEncodePresetGUIDs(self.context, encode_GUID, preset_GUIDs, presetCount, &presetsRetCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodePresetGUIDs(__pyx_v_self->context, __pyx_v_encode_GUID, __pyx_v_preset_GUIDs, __pyx_v_presetCount, (&__pyx_v_presetsRetCount)); }
+2485: raiseNVENC(r, "getting encode presets")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_encode_presets); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2485, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2486: assert presetsRetCount==presetCount
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_presetsRetCount == __pyx_v_presetCount) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2486, __pyx_L8_error) } } #endif
+2487: unknowns = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2487, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_unknowns = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2488: for x in range(presetCount):
__pyx_t_12 = __pyx_v_presetCount; for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_x = __pyx_t_13;
+2489: preset_GUID = preset_GUIDs[x]
__pyx_v_preset_GUID = (__pyx_v_preset_GUIDs[__pyx_v_x]);
+2490: preset_name = CODEC_PRESETS_GUIDS.get(guidstr(preset_GUID))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_CODEC_PRESETS_GUIDS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2490, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_preset_name, __pyx_t_1); __pyx_t_1 = 0;
+2491: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2492: log("* %s : %s", guidstr(preset_GUID), preset_name or "unknown!")
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2492, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset_GUID); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2492, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_preset_name); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2492, __pyx_L8_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_preset_name); __pyx_t_3 = __pyx_v_preset_name; goto __pyx_L17_bool_binop_done; } __Pyx_INCREF(__pyx_kp_s_unknown); __pyx_t_3 = __pyx_kp_s_unknown; __pyx_L17_bool_binop_done:; __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_s_s_2, __pyx_t_10, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2492, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_s_s_2, __pyx_t_10, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2492, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2492, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_s_2); __Pyx_GIVEREF(__pyx_kp_s_s_s_2); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_s_s_2); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_3); __pyx_t_10 = 0; __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2492, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2493: presetConfig = self.get_preset_config(preset_name, encode_GUID, preset_GUID)
__pyx_t_14 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->get_preset_config(__pyx_v_self, __pyx_v_preset_name, __pyx_v_encode_GUID, __pyx_v_preset_GUID); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2493, __pyx_L8_error)
__pyx_v_presetConfig = __pyx_t_14;
+2494: if presetConfig!=NULL:
__pyx_t_2 = ((__pyx_v_presetConfig != NULL) != 0); if (__pyx_t_2) { /* … */ }
+2495: try:
/*try:*/ {
+2496: encConfig = &presetConfig.presetCfg
__pyx_v_encConfig = (&__pyx_v_presetConfig->presetCfg);
+2497: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2498: log("presetConfig.presetCfg=%s", <uintptr_t> encConfig)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2498, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_encConfig)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2498, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_s_presetConfig_presetCfg_s, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2498, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_s_presetConfig_presetCfg_s, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2498, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2498, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_kp_s_presetConfig_presetCfg_s); __Pyx_GIVEREF(__pyx_kp_s_presetConfig_presetCfg_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_kp_s_presetConfig_presetCfg_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2498, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2499: gop = {NVENC_INFINITE_GOPLENGTH : "infinite"}.get(encConfig.gopLength, encConfig.gopLength)
__pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2499, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(NVENC_INFINITE_GOPLENGTH); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2499, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_1, __pyx_t_4, __pyx_n_s_infinite) < 0) __PYX_ERR(0, 2499, __pyx_L23_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_encConfig->gopLength); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2499, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyInt_From_uint32_t(__pyx_v_encConfig->gopLength); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2499, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = __Pyx_PyDict_GetItemDefault(__pyx_t_1, __pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2499, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_gop, __pyx_t_8); __pyx_t_8 = 0;
+2500: log("* %-20s P frame interval=%i, gop length=%-10s", preset_name or "unknown!", encConfig.frameIntervalP, gop)
__pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2500, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_preset_name); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2500, __pyx_L23_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_preset_name); __pyx_t_4 = __pyx_v_preset_name; goto __pyx_L26_bool_binop_done; } __Pyx_INCREF(__pyx_kp_s_unknown); __pyx_t_4 = __pyx_kp_s_unknown; __pyx_L26_bool_binop_done:; __pyx_t_1 = __Pyx_PyInt_From_int32_t(__pyx_v_encConfig->frameIntervalP); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2500, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_kp_s_20s_P_frame_interval_i_gop_leng, __pyx_t_4, __pyx_t_1, __pyx_v_gop}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2500, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_kp_s_20s_P_frame_interval_i_gop_leng, __pyx_t_4, __pyx_t_1, __pyx_v_gop}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2500, __pyx_L23_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_5 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2500, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_kp_s_20s_P_frame_interval_i_gop_leng); __Pyx_GIVEREF(__pyx_kp_s_20s_P_frame_interval_i_gop_leng); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_kp_s_20s_P_frame_interval_i_gop_leng); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_7, __pyx_t_1); __Pyx_INCREF(__pyx_v_gop); __Pyx_GIVEREF(__pyx_v_gop); PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_7, __pyx_v_gop); __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2500, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
2501: finally:
+2502: free(presetConfig)
/*finally:*/ { /*normal exit:*/{ free(__pyx_v_presetConfig); goto __pyx_L24; } __pyx_L23_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_7 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { free(__pyx_v_presetConfig); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L8_error; } __pyx_L24:; }
+2503: if preset_name is None:
__pyx_t_2 = (__pyx_v_preset_name == Py_None); __pyx_t_23 = (__pyx_t_2 != 0); if (__pyx_t_23) { /* … */ goto __pyx_L32; }
+2504: unknowns.append(guidstr(preset_GUID))
__pyx_t_8 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset_GUID); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2504, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_unknowns, __pyx_t_8); if (unlikely(__pyx_t_24 == ((int)-1))) __PYX_ERR(0, 2504, __pyx_L8_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2505: else:
+2506: presets[preset_name] = guidstr(preset_GUID)
/*else*/ { __pyx_t_8 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_preset_GUID); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2506, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely(PyDict_SetItem(__pyx_v_presets, __pyx_v_preset_name, __pyx_t_8) < 0)) __PYX_ERR(0, 2506, __pyx_L8_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_L32:; }
+2507: if len(unknowns)>0:
__pyx_t_25 = PyList_GET_SIZE(__pyx_v_unknowns); if (unlikely(__pyx_t_25 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2507, __pyx_L8_error) __pyx_t_23 = ((__pyx_t_25 > 0) != 0); if (__pyx_t_23) { /* … */ } }
+2508: log.warn("Warning: found some unknown NVENC presets: %s", b", ".join(unknowns))
__pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyBytes_Join(__pyx_kp_b__30, __pyx_v_unknowns); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_1 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_s_Warning_found_some_unknown_NVENC, __pyx_t_10}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_s_Warning_found_some_unknown_NVENC, __pyx_t_10}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_kp_s_Warning_found_some_unknown_NVENC); __Pyx_GIVEREF(__pyx_kp_s_Warning_found_some_unknown_NVENC); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_15, __pyx_kp_s_Warning_found_some_unknown_NVENC); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_15, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2508, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2509: finally:
+2510: free(preset_GUIDs)
/*finally:*/ { /*normal exit:*/{ free(__pyx_v_preset_GUIDs); goto __pyx_L9; } __pyx_L8_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_15 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_26 = __pyx_filename; { free(__pyx_v_preset_GUIDs); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ErrRestore(__pyx_t_22, __pyx_t_21, __pyx_t_20); __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_26; goto __pyx_L1_error; } __pyx_L9:; }
+2511: if DEBUG_API:
__pyx_t_23 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_23) { /* … */ }
+2512: log("query_presets(%s)=%s", codecstr(encode_GUID), presets)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_query_presets_s_s, __pyx_t_4, __pyx_v_presets}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2512, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_query_presets_s_s, __pyx_t_4, __pyx_v_presets}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2512, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_1 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_query_presets_s_s); __Pyx_GIVEREF(__pyx_kp_s_query_presets_s_s); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_7, __pyx_kp_s_query_presets_s_s); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_7, __pyx_t_4); __Pyx_INCREF(__pyx_v_presets); __Pyx_GIVEREF(__pyx_v_presets); PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_7, __pyx_v_presets); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2513: return presets
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_presets); __pyx_r = __pyx_v_presets; goto __pyx_L0;
2514:
+2515: cdef object query_profiles(self, GUID encode_GUID):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_query_profiles(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, GUID __pyx_v_encode_GUID) { uint32_t __pyx_v_profileCount; uint32_t __pyx_v_profilesRetCount; GUID *__pyx_v_profile_GUIDs; GUID __pyx_v_profile_GUID; NVENCSTATUS __pyx_v_r; PyObject *__pyx_v_profiles = NULL; PyObject *__pyx_v_PROFILES_GUIDS = NULL; uint32_t __pyx_v_x; PyObject *__pyx_v_profile_name = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("query_profiles", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.query_profiles", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_profiles); __Pyx_XDECREF(__pyx_v_PROFILES_GUIDS); __Pyx_XDECREF(__pyx_v_profile_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2516: cdef uint32_t profileCount
2517: cdef uint32_t profilesRetCount
2518: cdef GUID* profile_GUIDs
2519: cdef GUID profile_GUID
2520: cdef NVENCSTATUS r #@DuplicatedSignature
+2521: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2521, __pyx_L1_error) } } #endif
+2522: profiles = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_profiles = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2523: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2524: log("nvEncGetEncodeProfileGUIDCount(%s, %#x)", codecstr(encode_GUID), <uintptr_t> &profileCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_profileCount))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetEncodeProfileGUIDCount_s, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetEncodeProfileGUIDCount_s, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodeProfileGUIDCount_s); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodeProfileGUIDCount_s); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_nvEncGetEncodeProfileGUIDCount_s); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2525: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2526: r = self.functionList.nvEncGetEncodeProfileGUIDCount(self.context, encode_GUID, &profileCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodeProfileGUIDCount(__pyx_v_self->context, __pyx_v_encode_GUID, (&__pyx_v_profileCount)); }
+2527: raiseNVENC(r, "getting profile count")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_profile_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2528: log("%s profiles:", profileCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_profileCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_s_profiles, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2528, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_s_profiles, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2528, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_profiles); __Pyx_GIVEREF(__pyx_kp_s_s_profiles); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_kp_s_s_profiles); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2529: assert profileCount<2**8
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_profileCount < 0x100) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2529, __pyx_L1_error) } } #endif
+2530: profile_GUIDs = <GUID*> cmalloc(sizeof(GUID) * profileCount, "profile GUIDs")
__pyx_t_9 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc(((sizeof(GUID)) * __pyx_v_profileCount), __pyx_kp_s_profile_GUIDs); if (unlikely(__pyx_t_9 == ((uintptr_t)0))) __PYX_ERR(0, 2530, __pyx_L1_error)
__pyx_v_profile_GUIDs = ((GUID *)__pyx_t_9);
+2531: PROFILES_GUIDS = CODEC_PROFILES_GUIDS.get(guidstr(encode_GUID), {})
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_CODEC_PROFILES_GUIDS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8); __pyx_t_3 = 0; __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_PROFILES_GUIDS = __pyx_t_1; __pyx_t_1 = 0;
+2532: try:
/*try:*/ {
+2533: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2534: log("nvEncGetEncodeProfileGUIDs(%s, %#x, %#x)", codecstr(encode_GUID), <uintptr_t> profile_GUIDs, <uintptr_t> &profileCount)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_profile_GUIDs)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_profileCount))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_kp_s_nvEncGetEncodeProfileGUIDs_s_x_x, __pyx_t_6, __pyx_t_8, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_kp_s_nvEncGetEncodeProfileGUIDs_s_x_x, __pyx_t_6, __pyx_t_8, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_10 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodeProfileGUIDs_s_x_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodeProfileGUIDs_s_x_x); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_kp_s_nvEncGetEncodeProfileGUIDs_s_x_x); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_7, __pyx_t_3); __pyx_t_6 = 0; __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2534, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2535: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L13; } __pyx_L13:; } }
+2536: r = self.functionList.nvEncGetEncodeProfileGUIDs(self.context, encode_GUID, profile_GUIDs, profileCount, &profilesRetCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodeProfileGUIDs(__pyx_v_self->context, __pyx_v_encode_GUID, __pyx_v_profile_GUIDs, __pyx_v_profileCount, (&__pyx_v_profilesRetCount)); }
+2537: raiseNVENC(r, "getting encode profiles")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_encode_profiles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2537, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2538: #(void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount)
+2539: assert profilesRetCount==profileCount
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_profilesRetCount == __pyx_v_profileCount) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2539, __pyx_L8_error) } } #endif
+2540: for x in range(profileCount):
__pyx_t_11 = __pyx_v_profileCount; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_x = __pyx_t_12;
+2541: profile_GUID = profile_GUIDs[x]
__pyx_v_profile_GUID = (__pyx_v_profile_GUIDs[__pyx_v_x]);
+2542: profile_name = PROFILES_GUIDS.get(guidstr(profile_GUID))
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_PROFILES_GUIDS, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_profile_GUID); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_10}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_10}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2542, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_profile_name, __pyx_t_1); __pyx_t_1 = 0;
+2543: log("* %s : %s", guidstr(profile_GUID), profile_name)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2543, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_profile_GUID); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2543, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_s_s_2, __pyx_t_8, __pyx_v_profile_name}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2543, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_s_s_s_2, __pyx_t_8, __pyx_v_profile_name}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2543, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2543, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_s_2); __Pyx_GIVEREF(__pyx_kp_s_s_s_2); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_kp_s_s_s_2); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_v_profile_name); __Pyx_GIVEREF(__pyx_v_profile_name); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_v_profile_name); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2543, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2544: profiles[profile_name] = guidstr(profile_GUID)
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_profile_GUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2544, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyDict_SetItem(__pyx_v_profiles, __pyx_v_profile_name, __pyx_t_1) < 0)) __PYX_ERR(0, 2544, __pyx_L8_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } }
2545: finally:
+2546: free(profile_GUIDs)
/*finally:*/ { /*normal exit:*/{ free(__pyx_v_profile_GUIDs); goto __pyx_L9; } __pyx_L8_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_7 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { free(__pyx_v_profile_GUIDs); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L9:; }
+2547: return profiles
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_profiles); __pyx_r = __pyx_v_profiles; goto __pyx_L0;
2548:
+2549: cdef object query_input_formats(self, GUID encode_GUID):
static PyObject *__pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_query_input_formats(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, GUID __pyx_v_encode_GUID) { uint32_t __pyx_v_inputFmtCount; NV_ENC_BUFFER_FORMAT *__pyx_v_inputFmts; uint32_t __pyx_v_inputFmtsRetCount; NV_ENC_BUFFER_FORMAT __pyx_v_inputFmt; NVENCSTATUS __pyx_v_r; PyObject *__pyx_v_input_formats = NULL; uint32_t __pyx_v_x; PyObject *__pyx_v_format_mask = NULL; PyObject *__pyx_v_format_name = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("query_input_formats", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.query_input_formats", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_input_formats); __Pyx_XDECREF(__pyx_v_format_mask); __Pyx_XDECREF(__pyx_v_format_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2550: cdef uint32_t inputFmtCount
2551: cdef NV_ENC_BUFFER_FORMAT* inputFmts
2552: cdef uint32_t inputFmtsRetCount
2553: cdef NV_ENC_BUFFER_FORMAT inputFmt
2554: cdef NVENCSTATUS r #@DuplicatedSignature
+2555: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2555, __pyx_L1_error) } } #endif
+2556: input_formats = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_input_formats = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2557: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2558: log("nvEncGetInputFormatCount(%s, %#x)", codecstr(encode_GUID), <uintptr_t> &inputFmtCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_inputFmtCount))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetInputFormatCount_s_x, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetInputFormatCount_s_x, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetInputFormatCount_s_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetInputFormatCount_s_x); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_nvEncGetInputFormatCount_s_x); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2559: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2560: r = self.functionList.nvEncGetInputFormatCount(self.context, encode_GUID, &inputFmtCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetInputFormatCount(__pyx_v_self->context, __pyx_v_encode_GUID, (&__pyx_v_inputFmtCount)); }
+2561: raiseNVENC(r, "getting input format count")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_input_format_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2562: log("%s input format type%s:", inputFmtCount, engs(inputFmtCount))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_inputFmtCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_engs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_uint32_t(__pyx_v_inputFmtCount); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_9) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_s_input_format_type_s, __pyx_t_8, __pyx_t_5}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_s_input_format_type_s, __pyx_t_8, __pyx_t_5}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_input_format_type_s); __Pyx_GIVEREF(__pyx_kp_s_s_input_format_type_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_kp_s_s_input_format_type_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_5); __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2563: assert inputFmtCount>0 and inputFmtCount<2**8
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_11 = ((__pyx_v_inputFmtCount > 0) != 0); if (__pyx_t_11) { } else { __pyx_t_2 = __pyx_t_11; goto __pyx_L7_bool_binop_done; } __pyx_t_11 = ((__pyx_v_inputFmtCount < 0x100) != 0); __pyx_t_2 = __pyx_t_11; __pyx_L7_bool_binop_done:; if (unlikely(!__pyx_t_2)) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2563, __pyx_L1_error) } } #endif
+2564: inputFmts = <NV_ENC_BUFFER_FORMAT*> cmalloc(sizeof(int) * inputFmtCount, "input formats")
__pyx_t_12 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc(((sizeof(int)) * __pyx_v_inputFmtCount), __pyx_kp_s_input_formats); if (unlikely(__pyx_t_12 == ((uintptr_t)0))) __PYX_ERR(0, 2564, __pyx_L1_error)
__pyx_v_inputFmts = ((NV_ENC_BUFFER_FORMAT *)__pyx_t_12);
+2565: try:
/*try:*/ {
+2566: if DEBUG_API:
__pyx_t_2 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_2) { /* … */ }
+2567: log("nvEncGetInputFormats(%s, %#x, %i, %#x)", codecstr(encode_GUID), <uintptr_t> inputFmts, inputFmtCount, <uintptr_t> &inputFmtsRetCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_inputFmts)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_inputFmtCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_inputFmtsRetCount))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[6] = {__pyx_t_6, __pyx_kp_s_nvEncGetInputFormats_s_x_i_x, __pyx_t_10, __pyx_t_5, __pyx_t_8, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[6] = {__pyx_t_6, __pyx_kp_s_nvEncGetInputFormats_s_x_i_x, __pyx_t_10, __pyx_t_5, __pyx_t_8, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_9 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetInputFormats_s_x_i_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetInputFormats_s_x_i_x); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_kp_s_nvEncGetInputFormats_s_x_i_x); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_7, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 4+__pyx_t_7, __pyx_t_4); __pyx_t_10 = 0; __pyx_t_5 = 0; __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2567, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2568: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L15; } __pyx_L15:; } }
+2569: r = self.functionList.nvEncGetInputFormats(self.context, encode_GUID, inputFmts, inputFmtCount, &inputFmtsRetCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetInputFormats(__pyx_v_self->context, __pyx_v_encode_GUID, __pyx_v_inputFmts, __pyx_v_inputFmtCount, (&__pyx_v_inputFmtsRetCount)); }
+2570: raiseNVENC(r, "getting input formats")
__pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_input_formats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2570, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2571: assert inputFmtsRetCount==inputFmtCount
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_inputFmtsRetCount == __pyx_v_inputFmtCount) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2571, __pyx_L10_error) } } #endif
+2572: for x in range(inputFmtCount):
__pyx_t_13 = __pyx_v_inputFmtCount; for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_x = __pyx_t_14;
+2573: inputFmt = inputFmts[x]
__pyx_v_inputFmt = (__pyx_v_inputFmts[__pyx_v_x]);
+2574: log("* %#x", inputFmt)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2574, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(__pyx_v_inputFmt); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2574, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_x, __pyx_t_9}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2574, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_x, __pyx_t_9}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2574, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2574, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_x); __Pyx_GIVEREF(__pyx_kp_s_x); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_x); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2574, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2575: for format_mask in sorted(BUFFER_FORMAT.keys()):
__pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_BUFFER_FORMAT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2575, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_keys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2575, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } if (__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2575, __pyx_L10_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2575, __pyx_L10_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2575, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; __pyx_t_15 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 2575, __pyx_L10_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 2575, __pyx_L10_error) } __pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_16); __Pyx_INCREF(__pyx_t_1); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 2575, __pyx_L10_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2575, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_format_mask, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } }
+2576: if format_mask>0 and (format_mask & inputFmt)>0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_format_mask, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2576, __pyx_L10_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2576, __pyx_L10_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_11) { } else { __pyx_t_2 = __pyx_t_11; goto __pyx_L21_bool_binop_done; } __pyx_t_1 = __Pyx_PyInt_From_NV_ENC_BUFFER_FORMAT(__pyx_v_inputFmt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2576, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyNumber_And(__pyx_v_format_mask, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2576, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2576, __pyx_L10_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2576, __pyx_L10_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_11; __pyx_L21_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+2577: format_name = BUFFER_FORMAT.get(format_mask)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_BUFFER_FORMAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_format_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_format_mask}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_format_mask}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_format_mask); __Pyx_GIVEREF(__pyx_v_format_mask); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_format_mask); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2577, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_format_name, __pyx_t_1); __pyx_t_1 = 0;
+2578: log(" + %#x : %s", format_mask, format_name)
__pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2578, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_x_s, __pyx_v_format_mask, __pyx_v_format_name}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2578, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_x_s, __pyx_v_format_mask, __pyx_v_format_name}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2578, __pyx_L10_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2578, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_x_s); __Pyx_GIVEREF(__pyx_kp_s_x_s); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_kp_s_x_s); __Pyx_INCREF(__pyx_v_format_mask); __Pyx_GIVEREF(__pyx_v_format_mask); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_v_format_mask); __Pyx_INCREF(__pyx_v_format_name); __Pyx_GIVEREF(__pyx_v_format_name); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_v_format_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2578, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2579: input_formats[format_name] = hex(format_mask)
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2579, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_format_mask); __Pyx_GIVEREF(__pyx_v_format_mask); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_format_mask); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_hex, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2579, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(PyDict_SetItem(__pyx_v_input_formats, __pyx_v_format_name, __pyx_t_8) < 0)) __PYX_ERR(0, 2579, __pyx_L10_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2580: finally:
+2581: free(inputFmts)
/*finally:*/ { /*normal exit:*/{ free(__pyx_v_inputFmts); goto __pyx_L11; } __pyx_L10_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __pyx_t_7 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename; { free(__pyx_v_inputFmts); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24); } __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21); __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18; goto __pyx_L1_error; } __pyx_L11:; }
+2582: return input_formats
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_input_formats); __pyx_r = __pyx_v_input_formats; goto __pyx_L0;
2583:
+2584: cdef int query_encoder_caps(self, GUID encode_GUID, NV_ENC_CAPS caps_type) except *:
static int __pyx_f_4xpra_6codecs_5nvenc_7encoder_7Encoder_query_encoder_caps(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, GUID __pyx_v_encode_GUID, NV_ENC_CAPS __pyx_v_caps_type) { int __pyx_v_val; NV_ENC_CAPS_PARAM __pyx_v_encCaps; NVENCSTATUS __pyx_v_r; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("query_encoder_caps", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.query_encoder_caps", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
2585: cdef int val
2586: cdef NV_ENC_CAPS_PARAM encCaps
2587: cdef NVENCSTATUS r #@DuplicatedSignature
+2588: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2588, __pyx_L1_error) } } #endif
+2589: memset(&encCaps, 0, sizeof(NV_ENC_CAPS_PARAM))
memset((&__pyx_v_encCaps), 0, (sizeof(NV_ENC_CAPS_PARAM)));
+2590: encCaps.version = NV_ENC_CAPS_PARAM_VER
__pyx_v_encCaps.version = NV_ENC_CAPS_PARAM_VER;
+2591: encCaps.capsToQuery = caps_type
__pyx_v_encCaps.capsToQuery = __pyx_v_caps_type;
+2592: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; } __pyx_L5:; } }
+2593: r = self.functionList.nvEncGetEncodeCaps(self.context, encode_GUID, &encCaps, &val)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodeCaps(__pyx_v_self->context, __pyx_v_encode_GUID, (&__pyx_v_encCaps), (&__pyx_v_val)); }
+2594: raiseNVENC(r, "getting encode caps for %s" % CAPS_NAMES.get(caps_type, caps_type))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CAPS_NAMES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_NV_ENC_CAPS(__pyx_v_caps_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_NV_ENC_CAPS(__pyx_v_caps_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_getting_encode_caps_for_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2595: if DEBUG_API:
__pyx_t_8 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_8) { /* … */ }
+2596: log("query_encoder_caps(%s, %s) %s=%s", codecstr(encode_GUID), caps_type, CAPS_NAMES.get(caps_type, caps_type), val)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_codecstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyInt_From_NV_ENC_CAPS(__pyx_v_caps_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_CAPS_NAMES); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_NV_ENC_CAPS(__pyx_v_caps_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyInt_From_NV_ENC_CAPS(__pyx_v_caps_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_5, __pyx_t_10}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_5, __pyx_t_10}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_12 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_6, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_6, __pyx_t_10); __pyx_t_5 = 0; __pyx_t_10 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_val); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[6] = {__pyx_t_12, __pyx_kp_s_query_encoder_caps_s_s_s_s, __pyx_t_7, __pyx_t_4, __pyx_t_2, __pyx_t_9}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[6] = {__pyx_t_12, __pyx_kp_s_query_encoder_caps_s_s_s_s, __pyx_t_7, __pyx_t_4, __pyx_t_2, __pyx_t_9}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_10 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_INCREF(__pyx_kp_s_query_encoder_caps_s_s_s_s); __Pyx_GIVEREF(__pyx_kp_s_query_encoder_caps_s_s_s_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_6, __pyx_kp_s_query_encoder_caps_s_s_s_s); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_6, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_6, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_6, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_6, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_9 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2597: return val
__pyx_r = __pyx_v_val; goto __pyx_L0;
2598:
+2599: def query_codecs(self, full_query=False):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_45query_codecs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_45query_codecs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_full_query = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("query_codecs (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_full_query,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_False); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_full_query); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "query_codecs") < 0)) __PYX_ERR(0, 2599, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_full_query = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("query_codecs", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2599, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.query_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_44query_codecs(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self), __pyx_v_full_query); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_44query_codecs(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self, PyObject *__pyx_v_full_query) { uint32_t __pyx_v_GUIDCount; uint32_t __pyx_v_GUIDRetCount; GUID *__pyx_v_encode_GUIDs; GUID __pyx_v_encode_GUID; NVENCSTATUS __pyx_v_r; PyObject *__pyx_v_codecs = NULL; uint32_t __pyx_v_x; PyObject *__pyx_v_codec_name = NULL; int __pyx_v_maxw; int __pyx_v_maxh; int __pyx_v_async; int __pyx_v_rate_control; PyObject *__pyx_v_codec = NULL; PyObject *__pyx_v_presets = NULL; PyObject *__pyx_v_profiles = NULL; PyObject *__pyx_v_input_formats = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("query_codecs", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.query_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_codecs); __Pyx_XDECREF(__pyx_v_codec_name); __Pyx_XDECREF(__pyx_v_codec); __Pyx_XDECREF(__pyx_v_presets); __Pyx_XDECREF(__pyx_v_profiles); __Pyx_XDECREF(__pyx_v_input_formats); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2600: cdef uint32_t GUIDCount
2601: cdef uint32_t GUIDRetCount
2602: cdef GUID* encode_GUIDs
2603: cdef GUID encode_GUID
2604: cdef NVENCSTATUS r #@DuplicatedSignature
+2605: assert self.context, "context is not initialized"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(__pyx_v_self->context != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_is_not_initialized); __PYX_ERR(0, 2605, __pyx_L1_error) } } #endif
+2606: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2607: log("nvEncGetEncodeGUIDCount(%#x, %#x)", <uintptr_t> self.context, <uintptr_t> &GUIDCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->context)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_GUIDCount))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetEncodeGUIDCount_x_x, __pyx_t_4, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_nvEncGetEncodeGUIDCount_x_x, __pyx_t_4, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodeGUIDCount_x_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodeGUIDCount_x_x); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_nvEncGetEncodeGUIDCount_x_x); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2608: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L6; } __pyx_L6:; } }
+2609: r = self.functionList.nvEncGetEncodeGUIDCount(self.context, &GUIDCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodeGUIDCount(__pyx_v_self->context, (&__pyx_v_GUIDCount)); }
+2610: raiseNVENC(r, "getting encoder count")
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_encoder_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2611: log("found %i encoder%s:", GUIDCount, engs(GUIDCount))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_uint32_t(__pyx_v_GUIDCount); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_engs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_uint32_t(__pyx_v_GUIDCount); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_9) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_found_i_encoder_s, __pyx_t_8, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_found_i_encoder_s, __pyx_t_8, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_found_i_encoder_s); __Pyx_GIVEREF(__pyx_kp_s_found_i_encoder_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_kp_s_found_i_encoder_s); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_5); __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2612: assert GUIDCount<2**8
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_GUIDCount < 0x100) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2612, __pyx_L1_error) } } #endif
+2613: encode_GUIDs = <GUID*> cmalloc(sizeof(GUID) * GUIDCount, "encode GUIDs")
__pyx_t_11 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc(((sizeof(GUID)) * __pyx_v_GUIDCount), __pyx_kp_s_encode_GUIDs); if (unlikely(__pyx_t_11 == ((uintptr_t)0))) __PYX_ERR(0, 2613, __pyx_L1_error)
__pyx_v_encode_GUIDs = ((GUID *)__pyx_t_11);
+2614: codecs = {}
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_codecs = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2615: try:
/*try:*/ {
+2616: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2617: log("nvEncGetEncodeGUIDs(%#x, %i, %#x)", <uintptr_t> encode_GUIDs, GUIDCount, <uintptr_t> &GUIDRetCount)
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_encode_GUIDs)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_GUIDCount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)(&__pyx_v_GUIDRetCount))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_kp_s_nvEncGetEncodeGUIDs_x_i_x, __pyx_t_10, __pyx_t_5, __pyx_t_8}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_kp_s_nvEncGetEncodeGUIDs_x_i_x, __pyx_t_10, __pyx_t_5, __pyx_t_8}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_nvEncGetEncodeGUIDs_x_i_x); __Pyx_GIVEREF(__pyx_kp_s_nvEncGetEncodeGUIDs_x_i_x); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_nvEncGetEncodeGUIDs_x_i_x); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_7, __pyx_t_8); __pyx_t_10 = 0; __pyx_t_5 = 0; __pyx_t_8 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2617, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2618: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L13; } __pyx_L13:; } }
+2619: r = self.functionList.nvEncGetEncodeGUIDs(self.context, encode_GUIDs, GUIDCount, &GUIDRetCount)
__pyx_v_r = __pyx_v_self->functionList->nvEncGetEncodeGUIDs(__pyx_v_self->context, __pyx_v_encode_GUIDs, __pyx_v_GUIDCount, (&__pyx_v_GUIDRetCount)); }
+2620: raiseNVENC(r, "getting list of encode GUIDs")
__pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_list_of_encode_GUIDs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2620, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2621: assert GUIDRetCount==GUIDCount, "expected %s items but got %s" % (GUIDCount, GUIDRetCount)
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_GUIDRetCount == __pyx_v_GUIDCount) != 0))) { __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_GUIDCount); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2621, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_GUIDRetCount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2621, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2621, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_expected_s_items_but_got_s, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2621, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 2621, __pyx_L8_error) } } #endif
+2622: for x in range(GUIDRetCount):
__pyx_t_12 = __pyx_v_GUIDRetCount; for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_x = __pyx_t_13;
+2623: encode_GUID = encode_GUIDs[x]
__pyx_v_encode_GUID = (__pyx_v_encode_GUIDs[__pyx_v_x]);
+2624: codec_name = CODEC_GUIDS.get(guidstr(encode_GUID))
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_CODEC_GUIDS); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2624, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_codec_name, __pyx_t_3); __pyx_t_3 = 0;
+2625: if not codec_name:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_codec_name); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2625, __pyx_L8_error) __pyx_t_14 = ((!__pyx_t_1) != 0); if (__pyx_t_14) { /* … */ goto __pyx_L16; }
+2626: log("[%s] unknown codec GUID: %s", x, guidstr(encode_GUID))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_x); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_s_s_unknown_codec_GUID_s, __pyx_t_5, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_s_s_unknown_codec_GUID_s, __pyx_t_5, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_unknown_codec_GUID_s); __Pyx_GIVEREF(__pyx_kp_s_s_unknown_codec_GUID_s); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_7, __pyx_kp_s_s_unknown_codec_GUID_s); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_7, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_7, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2626, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2627: else:
+2628: log("[%s] %s", x, codec_name)
/*else*/ { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2628, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __Pyx_PyInt_From_uint32_t(__pyx_v_x); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2628, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_s_s_3, __pyx_t_10, __pyx_v_codec_name}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2628, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_s_s_3, __pyx_t_10, __pyx_v_codec_name}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2628, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_5 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2628, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_s_3); __Pyx_GIVEREF(__pyx_kp_s_s_s_3); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_kp_s_s_s_3); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_10); __Pyx_INCREF(__pyx_v_codec_name); __Pyx_GIVEREF(__pyx_v_codec_name); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_7, __pyx_v_codec_name); __pyx_t_10 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2628, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L16:;
2629:
+2630: maxw = self.query_encoder_caps(encode_GUID, NV_ENC_CAPS_WIDTH_MAX)
__pyx_t_7 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_encoder_caps(__pyx_v_self, __pyx_v_encode_GUID, NV_ENC_CAPS_WIDTH_MAX); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2630, __pyx_L8_error)
__pyx_v_maxw = __pyx_t_7;
+2631: maxh = self.query_encoder_caps(encode_GUID, NV_ENC_CAPS_HEIGHT_MAX)
__pyx_t_7 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_encoder_caps(__pyx_v_self, __pyx_v_encode_GUID, NV_ENC_CAPS_HEIGHT_MAX); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2631, __pyx_L8_error)
__pyx_v_maxh = __pyx_t_7;
+2632: async = self.query_encoder_caps(encode_GUID, NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT)
__pyx_t_7 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_encoder_caps(__pyx_v_self, __pyx_v_encode_GUID, NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2632, __pyx_L8_error)
__pyx_v_async = __pyx_t_7;
+2633: rate_control = self.query_encoder_caps(encode_GUID, NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES)
__pyx_t_7 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_encoder_caps(__pyx_v_self, __pyx_v_encode_GUID, NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2633, __pyx_L8_error)
__pyx_v_rate_control = __pyx_t_7;
2634: codec = {
+2635: "guid" : guidstr(encode_GUID),
__pyx_t_3 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2635, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_guidstr(__pyx_v_encode_GUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2635, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_guid, __pyx_t_2) < 0) __PYX_ERR(0, 2635, __pyx_L8_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2636: "name" : codec_name,
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_name, __pyx_v_codec_name) < 0) __PYX_ERR(0, 2635, __pyx_L8_error)
+2637: "max-size" : (maxw, maxh),
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_maxw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2637, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_maxh); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2637, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2637, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5); __pyx_t_2 = 0; __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_kp_s_max_size, __pyx_t_10) < 0) __PYX_ERR(0, 2635, __pyx_L8_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+2638: "async" : async,
__pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_async); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2638, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_async, __pyx_t_10) < 0) __PYX_ERR(0, 2635, __pyx_L8_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+2639: "rate-control" : rate_control
__pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_rate_control); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2639, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_3, __pyx_kp_s_rate_control, __pyx_t_10) < 0) __PYX_ERR(0, 2635, __pyx_L8_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_codec, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
2640: }
+2641: if full_query:
__pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_full_query); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2641, __pyx_L8_error) if (__pyx_t_14) { /* … */ }
+2642: presets = self.query_presets(encode_GUID)
__pyx_t_3 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_presets(__pyx_v_self, __pyx_v_encode_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2642, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_presets, __pyx_t_3); __pyx_t_3 = 0;
+2643: profiles = self.query_profiles(encode_GUID)
__pyx_t_3 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_profiles(__pyx_v_self, __pyx_v_encode_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2643, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_profiles, __pyx_t_3); __pyx_t_3 = 0;
+2644: input_formats = self.query_input_formats(encode_GUID)
__pyx_t_3 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self->__pyx_vtab)->query_input_formats(__pyx_v_self, __pyx_v_encode_GUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2644, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_input_formats, __pyx_t_3); __pyx_t_3 = 0;
+2645: codec.update({
__pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_codec, __pyx_n_s_update); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2645, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10);
+2646: "presets" : presets,
__pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2646, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_presets, __pyx_v_presets) < 0) __PYX_ERR(0, 2646, __pyx_L8_error)
+2647: "profiles" : profiles,
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_profiles, __pyx_v_profiles) < 0) __PYX_ERR(0, 2646, __pyx_L8_error)
+2648: "input-formats" : input_formats,
if (PyDict_SetItem(__pyx_t_5, __pyx_kp_s_input_formats_2, __pyx_v_input_formats) < 0) __PYX_ERR(0, 2646, __pyx_L8_error) __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } if (!__pyx_t_2) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2645, __pyx_L8_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2645, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2645, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2645, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2645, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2649: })
+2650: codecs[codec_name] = codec
if (unlikely(PyDict_SetItem(__pyx_v_codecs, __pyx_v_codec_name, __pyx_v_codec) < 0)) __PYX_ERR(0, 2650, __pyx_L8_error) } }
2651: finally:
+2652: free(encode_GUIDs)
/*finally:*/ { /*normal exit:*/{ free(__pyx_v_encode_GUIDs); goto __pyx_L9; } __pyx_L8_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_7 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { free(__pyx_v_encode_GUIDs); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L1_error; } __pyx_L9:; }
+2653: log("codecs=%s", csv(codecs.keys()))
__pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_csv); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyDict_Keys(__pyx_v_codecs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_8) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_6); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_2}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_2}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_codecs_s, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_codecs_s, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_codecs_s); __Pyx_GIVEREF(__pyx_kp_s_codecs_s); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_15, __pyx_kp_s_codecs_s); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_15, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2654: return codecs
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_codecs); __pyx_r = __pyx_v_codecs; goto __pyx_L0;
2655:
2656:
+2657: def open_encode_session(self):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_47open_encode_session(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_7Encoder_47open_encode_session(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("open_encode_session (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_46open_encode_session(((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_7Encoder_46open_encode_session(struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_self) { NVENCSTATUS __pyx_v_r; NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS __pyx_v_params; unsigned char *__pyx_v_cstr; CYTHON_UNUSED PyObject *__pyx_v_pstr = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("open_encode_session", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.Encoder.open_encode_session", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pstr); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2658: global context_counter, context_gen_counter, last_context_failure
2659: cdef NVENCSTATUS r #@DuplicatedSignature
2660: cdef int t
2661: cdef NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS params
2662:
+2663: assert self.functionList is NULL, "session already active"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->functionList == NULL) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_session_already_active); __PYX_ERR(0, 2663, __pyx_L1_error) } } #endif
+2664: assert self.context is NULL, "context already set"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->context == NULL) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_context_already_set); __PYX_ERR(0, 2664, __pyx_L1_error) } } #endif
+2665: assert self.cuda_context and self.cuda_context_ptr!=NULL, "cuda context is not set"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->cuda_context); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2665, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L3_bool_binop_done; } __pyx_t_2 = ((__pyx_v_self->cuda_context_ptr != NULL) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L3_bool_binop_done:; if (unlikely(!__pyx_t_1)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_cuda_context_is_not_set); __PYX_ERR(0, 2665, __pyx_L1_error) } } #endif
2666: #params = <NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS*> malloc(sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS))
+2667: log("open_encode_session() cuda_context=%s, cuda_context_ptr=%#x", self.cuda_context, <uintptr_t> self.cuda_context_ptr)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->cuda_context_ptr)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_open_encode_session_cuda_context, __pyx_v_self->cuda_context, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2667, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_open_encode_session_cuda_context, __pyx_v_self->cuda_context, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2667, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_open_encode_session_cuda_context); __Pyx_GIVEREF(__pyx_kp_s_open_encode_session_cuda_context); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_open_encode_session_cuda_context); __Pyx_INCREF(__pyx_v_self->cuda_context); __Pyx_GIVEREF(__pyx_v_self->cuda_context); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_self->cuda_context); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2668:
+2669: self.functionList = <NV_ENCODE_API_FUNCTION_LIST*> cmalloc(sizeof(NV_ENCODE_API_FUNCTION_LIST), "function list")
__pyx_t_9 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_cmalloc((sizeof(NV_ENCODE_API_FUNCTION_LIST)), __pyx_kp_s_function_list); if (unlikely(__pyx_t_9 == ((uintptr_t)0))) __PYX_ERR(0, 2669, __pyx_L1_error)
__pyx_v_self->functionList = ((NV_ENCODE_API_FUNCTION_LIST *)__pyx_t_9);
+2670: assert memset(self.functionList, 0, sizeof(NV_ENCODE_API_FUNCTION_LIST))!=NULL
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((memset(__pyx_v_self->functionList, 0, (sizeof(NV_ENCODE_API_FUNCTION_LIST))) != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 2670, __pyx_L1_error) } } #endif
+2671: log("open_encode_session() functionList=%#x", <uintptr_t> self.functionList)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->functionList)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_open_encode_session_functionList, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_open_encode_session_functionList, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_open_encode_session_functionList); __Pyx_GIVEREF(__pyx_kp_s_open_encode_session_functionList); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_open_encode_session_functionList); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2672:
2673: #get NVENC function pointers:
+2674: memset(self.functionList, 0, sizeof(NV_ENCODE_API_FUNCTION_LIST))
memset(__pyx_v_self->functionList, 0, (sizeof(NV_ENCODE_API_FUNCTION_LIST)));
+2675: self.functionList.version = NV_ENCODE_API_FUNCTION_LIST_VER
__pyx_v_self->functionList->version = NV_ENCODE_API_FUNCTION_LIST_VER;
+2676: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2677: log("NvEncodeAPICreateInstance(%#x)", <uintptr_t> self.functionList)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->functionList)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_NvEncodeAPICreateInstance_x, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_NvEncodeAPICreateInstance_x, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_s_NvEncodeAPICreateInstance_x); __Pyx_GIVEREF(__pyx_kp_s_NvEncodeAPICreateInstance_x); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_kp_s_NvEncodeAPICreateInstance_x); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2678: r = NvEncodeAPICreateInstance(<uintptr_t> self.functionList)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NvEncodeAPICreateInstance); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->functionList)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_6) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_10 = __Pyx_PyInt_As_NVENCSTATUS(__pyx_t_3); if (unlikely((__pyx_t_10 == ((NVENCSTATUS)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_r = __pyx_t_10;
+2679: raiseNVENC(r, "getting API function list")
__pyx_t_3 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_getting_API_function_list); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2680: assert self.functionList.nvEncOpenEncodeSessionEx!=NULL, "looks like NvEncodeAPICreateInstance failed!"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->functionList->nvEncOpenEncodeSessionEx != NULL) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_looks_like_NvEncodeAPICreateInst); __PYX_ERR(0, 2680, __pyx_L1_error) } } #endif
2681:
2682: #NVENC init:
+2683: memset(¶ms, 0, sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS))
memset((&__pyx_v_params), 0, (sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS)));
+2684: params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER
__pyx_v_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER;
+2685: params.deviceType = NV_ENC_DEVICE_TYPE_CUDA
__pyx_v_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
+2686: params.device = self.cuda_context_ptr
__pyx_t_11 = __pyx_v_self->cuda_context_ptr; __pyx_v_params.device = __pyx_t_11;
+2687: params.reserved = &CLIENT_KEY_GUID
__pyx_v_params.reserved = (&__pyx_v_4xpra_6codecs_5nvenc_7encoder_CLIENT_KEY_GUID);
+2688: params.apiVersion = NVENCAPI_VERSION
__pyx_v_params.apiVersion = NVENCAPI_VERSION;
+2689: cstr = <unsigned char*> ¶ms
__pyx_v_cstr = ((unsigned char *)(&__pyx_v_params));
+2690: pstr = cstr[:sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS)]
__pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_cstr) + 0, (sizeof(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS)) - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_pstr = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2691: if DEBUG_API:
__pyx_t_1 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_DEBUG_API != 0); if (__pyx_t_1) { /* … */ }
+2692: log("calling nvEncOpenEncodeSessionEx @ %#x", <uintptr_t> self.functionList.nvEncOpenEncodeSessionEx)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->functionList->nvEncOpenEncodeSessionEx)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_calling_nvEncOpenEncodeSessionEx, __pyx_t_8}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2692, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_calling_nvEncOpenEncodeSessionEx, __pyx_t_8}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2692, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_calling_nvEncOpenEncodeSessionEx); __Pyx_GIVEREF(__pyx_kp_s_calling_nvEncOpenEncodeSessionEx); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_calling_nvEncOpenEncodeSessionEx); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2693: self.context = NULL
__pyx_v_self->context = NULL;
+2694: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L9; } __pyx_L9:; } }
+2695: r = self.functionList.nvEncOpenEncodeSessionEx(¶ms, &self.context)
__pyx_v_r = __pyx_v_self->functionList->nvEncOpenEncodeSessionEx((&__pyx_v_params), (&__pyx_v_self->context)); }
+2696: if r==NV_ENC_ERR_UNSUPPORTED_DEVICE:
__pyx_t_1 = ((__pyx_v_r == NV_ENC_ERR_UNSUPPORTED_DEVICE) != 0); if (__pyx_t_1) { /* … */ }
+2697: last_context_failure = monotonic_time()
__pyx_v_4xpra_6codecs_5nvenc_7encoder_last_context_failure = __pyx_f_4xpra_14monotonic_time_monotonic_time();
+2698: msg = "NV_ENC_ERR_UNSUPPORTED_DEVICE: could not open encode session (out of resources / no more codec contexts?)"
__Pyx_INCREF(__pyx_kp_s_NV_ENC_ERR_UNSUPPORTED_DEVICE_co);
__pyx_v_msg = __pyx_kp_s_NV_ENC_ERR_UNSUPPORTED_DEVICE_co;
+2699: log(msg)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_6) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2699, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_msg); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2700: raise TransientCodecException(msg)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_TransientCodecException); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2700, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_msg); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 2700, __pyx_L1_error)
+2701: if self.context==NULL:
__pyx_t_1 = ((__pyx_v_self->context == NULL) != 0); if (__pyx_t_1) { /* … */ }
+2702: raise TransientCodecException("cannot open encoding session, context is NULL")
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_TransientCodecException); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 2702, __pyx_L1_error) /* … */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_cannot_open_encoding_session_con); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 2702, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31);
+2703: raiseNVENC(r, "opening session")
__pyx_t_4 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_raiseNVENC(__pyx_v_r, __pyx_kp_s_opening_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2704: context_counter.increase()
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_increase); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (__pyx_t_3) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2704, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2704, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2705: context_gen_counter.increase()
__pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_gen_counter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_increase); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_6) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2705, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2705, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2706: log("success, encoder context=%#x (%s context%s in use)", <uintptr_t> self.context, context_counter, engs(context_counter))
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_self->context)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_engs); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_context_counter); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (!__pyx_t_14) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL; __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_12, __pyx_kp_s_success_encoder_context_x_s_cont, __pyx_t_6, __pyx_t_8, __pyx_t_5}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_12, __pyx_kp_s_success_encoder_context_x_s_cont, __pyx_t_6, __pyx_t_8, __pyx_t_5}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_15 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_INCREF(__pyx_kp_s_success_encoder_context_x_s_cont); __Pyx_GIVEREF(__pyx_kp_s_success_encoder_context_x_s_cont); PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_7, __pyx_kp_s_success_encoder_context_x_s_cont); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_7, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_7, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_7, __pyx_t_5); __pyx_t_6 = 0; __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2707:
2708:
+2709: _init_message = False
if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_message, Py_False) < 0) __PYX_ERR(0, 2709, __pyx_L1_error)
+2710: def init_module():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_27init_module(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_27init_module = {"init_module", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_27init_module, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_27init_module(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_module (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_26init_module(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_26init_module(CYTHON_UNUSED PyObject *__pyx_self) { struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *__pyx_v_test_encoder = 0; PyObject *__pyx_v_devices = NULL; int __pyx_v_success; PyObject *__pyx_v_valid_keys = NULL; PyObject *__pyx_v_failed_keys = NULL; PyObject *__pyx_v_try_keys = NULL; PyObject *__pyx_v_TEST_ENCODINGS = NULL; PyObject *__pyx_v_FAILED_ENCODINGS = NULL; PyObject *__pyx_v_client_key = NULL; PyObject *__pyx_v_device_id = NULL; PyObject *__pyx_v_options = NULL; PyObject *__pyx_v_codecs = NULL; PyObject *__pyx_v_test_encodings = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_v_nvenc_encoding_name = NULL; PyObject *__pyx_v_codec_query = NULL; PyObject *__pyx_v_cmax = NULL; PyObject *__pyx_v_qmax = NULL; PyObject *__pyx_v_qmx = NULL; PyObject *__pyx_v_qmy = NULL; PyObject *__pyx_v_cmx = NULL; PyObject *__pyx_v_cmy = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_encoding = NULL; PyObject *__pyx_v_colorspaces = NULL; PyObject *__pyx_v_src_format = NULL; PyObject *__pyx_v_dst_formats = NULL; int __pyx_v_yuv444_support; int __pyx_v_lossless_support; PyObject *__pyx_v_x = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_module", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_24); __Pyx_XDECREF(__pyx_t_27); __Pyx_XDECREF(__pyx_t_28); __Pyx_XDECREF(__pyx_t_29); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.init_module", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_test_encoder); __Pyx_XDECREF(__pyx_v_devices); __Pyx_XDECREF(__pyx_v_valid_keys); __Pyx_XDECREF(__pyx_v_failed_keys); __Pyx_XDECREF(__pyx_v_try_keys); __Pyx_XDECREF(__pyx_v_TEST_ENCODINGS); __Pyx_XDECREF(__pyx_v_FAILED_ENCODINGS); __Pyx_XDECREF(__pyx_v_client_key); __Pyx_XDECREF(__pyx_v_device_id); __Pyx_XDECREF(__pyx_v_options); __Pyx_XDECREF(__pyx_v_codecs); __Pyx_XDECREF(__pyx_v_test_encodings); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_nvenc_encoding_name); __Pyx_XDECREF(__pyx_v_codec_query); __Pyx_XDECREF(__pyx_v_cmax); __Pyx_XDECREF(__pyx_v_qmax); __Pyx_XDECREF(__pyx_v_qmx); __Pyx_XDECREF(__pyx_v_qmy); __Pyx_XDECREF(__pyx_v_cmx); __Pyx_XDECREF(__pyx_v_cmy); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XDECREF(__pyx_v_colorspaces); __Pyx_XDECREF(__pyx_v_src_format); __Pyx_XDECREF(__pyx_v_dst_formats); __Pyx_XDECREF(__pyx_v_x); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__81 = PyTuple_Pack(31, __pyx_n_s_test_encoder, __pyx_n_s_max_version, __pyx_n_s_devices, __pyx_n_s_success, __pyx_n_s_valid_keys, __pyx_n_s_failed_keys, __pyx_n_s_try_keys, __pyx_n_s_TEST_ENCODINGS, __pyx_n_s_FAILED_ENCODINGS, __pyx_n_s_client_key, __pyx_n_s_device_id, __pyx_n_s_options, __pyx_n_s_codecs, __pyx_n_s_test_encodings, __pyx_n_s_e, __pyx_n_s_nvenc_encoding_name, __pyx_n_s_codec_query, __pyx_n_s_cmax, __pyx_n_s_qmax, __pyx_n_s_qmx, __pyx_n_s_qmy, __pyx_n_s_cmx, __pyx_n_s_cmy, __pyx_n_s_v, __pyx_n_s_encoding, __pyx_n_s_colorspaces, __pyx_n_s_src_format, __pyx_n_s_dst_formats, __pyx_n_s_yuv444_support, __pyx_n_s_lossless_support, __pyx_n_s_x_2); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 2710, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__81); __Pyx_GIVEREF(__pyx_tuple__81); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_27init_module, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_module, __pyx_t_2) < 0) __PYX_ERR(0, 2710, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(0, 0, 31, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_init_module, 2710, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 2710, __pyx_L1_error)
+2711: log("nvenc.init_module()")
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_nvenc_init_module); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 2711, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32);
2712: #TODO: this should be a build time check:
+2713: if NVENCAPI_MAJOR_VERSION<0x7:
__pyx_t_3 = ((NVENCAPI_MAJOR_VERSION < 0x7) != 0); if (__pyx_t_3) { /* … */ }
+2714: raise Exception("unsupported version of NVENC: %#x" % NVENCAPI_VERSION)
__pyx_t_2 = __Pyx_PyInt_From_uint32_t(NVENCAPI_VERSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_unsupported_version_of_NVENC_x, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2714, __pyx_L1_error)
+2715: log("NVENC encoder API version %s", ".".join([str(x) for x in PRETTY_VERSION]))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PRETTY_VERSION); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2715, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_6))) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2715, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2715, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_8(__pyx_t_6); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2715, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_x); __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyString_Join(__pyx_kp_s__14, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_NVENC_encoder_API_version_s, __pyx_t_6}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_NVENC_encoder_API_version_s, __pyx_t_6}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_NVENC_encoder_API_version_s); __Pyx_GIVEREF(__pyx_kp_s_NVENC_encoder_API_version_s); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_kp_s_NVENC_encoder_API_version_s); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2716:
2717: cdef Encoder test_encoder
2718: cdef uint32_t max_version
2719: #cdef NVENCSTATUS r = NvEncodeAPIGetMaxSupportedVersion(&max_version)
2720: #raiseNVENC(r, "querying max version")
2721: #log(" maximum supported version: %s", max_version)
2722:
2723: #load the library / DLL:
+2724: init_nvencode_library()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_nvencode_library); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_9) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2724, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2724, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2725:
2726: #make sure we have devices we can use:
+2727: devices = init_all_devices()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_all_devices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_9) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2727, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2727, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_devices = __pyx_t_1; __pyx_t_1 = 0;
+2728: if len(devices)==0:
__pyx_t_7 = PyObject_Length(__pyx_v_devices); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2728, __pyx_L1_error) __pyx_t_3 = ((__pyx_t_7 == 0) != 0); if (__pyx_t_3) { /* … */ }
+2729: log("nvenc: no compatible devices found")
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_nvenc_no_compatible_devices_foun); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 2729, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__33); __Pyx_GIVEREF(__pyx_tuple__33);
+2730: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2731:
+2732: success = False
__pyx_v_success = 0;
+2733: valid_keys = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2733, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_valid_keys = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2734: failed_keys = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2734, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_failed_keys = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2735: try_keys = CLIENT_KEYS_STR or [None]
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_CLIENT_KEYS_STR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2735, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2735, __pyx_L1_error) if (!__pyx_t_3) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L7_bool_binop_done; } __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2735, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); PyList_SET_ITEM(__pyx_t_1, 0, Py_None); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_L7_bool_binop_done:; __pyx_v_try_keys = __pyx_t_2; __pyx_t_2 = 0;
+2736: TEST_ENCODINGS = ["h264", "h265"]
__pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2736, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_h264); __Pyx_GIVEREF(__pyx_n_s_h264); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_h264); __Pyx_INCREF(__pyx_n_s_h265); __Pyx_GIVEREF(__pyx_n_s_h265); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_h265); __pyx_v_TEST_ENCODINGS = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2737: FAILED_ENCODINGS = set()
__pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_FAILED_ENCODINGS = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
2738: global YUV444_ENABLED, YUV444_CODEC_SUPPORT, LOSSLESS_ENABLED, ENCODINGS, MAX_SIZE
+2739: if not validate_driver_yuv444lossless():
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_validate_driver_yuv444lossless); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2739, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (__pyx_t_9) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2739, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2739, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2739, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = ((!__pyx_t_3) != 0); if (__pyx_t_11) { /* … */ }
+2740: if YUV444_ENABLED:
__pyx_t_11 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED != 0); if (__pyx_t_11) { /* … */ }
+2741: YUV444_ENABLED = False
__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED = 0;
+2742: if LOSSLESS_ENABLED:
__pyx_t_11 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED != 0); if (__pyx_t_11) { /* … */ }
+2743: LOSSLESS_ENABLED = False
__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED = 0;
2744: #check NVENC availibility by creating a context:
+2745: for client_key in try_keys:
if (likely(PyList_CheckExact(__pyx_v_try_keys)) || PyTuple_CheckExact(__pyx_v_try_keys)) { __pyx_t_2 = __pyx_v_try_keys; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_try_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2745, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2745, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2745, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2745, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_client_key, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2746: if client_key:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_client_key); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2746, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
2747: #this will set the global key object used by all encoder contexts:
+2748: log("init_module() testing with key '%s'", client_key)
__pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_init_module_testing_with_key_s, __pyx_v_client_key}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_init_module_testing_with_key_s, __pyx_v_client_key}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_module_testing_with_key_s); __Pyx_GIVEREF(__pyx_kp_s_init_module_testing_with_key_s); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_10, __pyx_kp_s_init_module_testing_with_key_s); __Pyx_INCREF(__pyx_v_client_key); __Pyx_GIVEREF(__pyx_v_client_key); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_10, __pyx_v_client_key); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2749: global CLIENT_KEY_GUID
+2750: CLIENT_KEY_GUID = c_parseguid(client_key)
__pyx_t_12 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_v_client_key); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2750, __pyx_L1_error)
__pyx_v_4xpra_6codecs_5nvenc_7encoder_CLIENT_KEY_GUID = __pyx_t_12;
2751:
+2752: for device_id in devices:
if (likely(PyList_CheckExact(__pyx_v_devices)) || PyTuple_CheckExact(__pyx_v_devices)) { __pyx_t_1 = __pyx_v_devices; __Pyx_INCREF(__pyx_t_1); __pyx_t_13 = 0; __pyx_t_14 = NULL; } else { __pyx_t_13 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_devices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2752, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_9); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 2752, __pyx_L1_error) #else __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } else { if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_9); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 2752, __pyx_L1_error) #else __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } } else { __pyx_t_9 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_9)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2752, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_9); } __Pyx_XDECREF_SET(__pyx_v_device_id, __pyx_t_9); __pyx_t_9 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2753: log("testing encoder with device %s", device_id)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_testing_encoder_with_device_s, __pyx_v_device_id}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_testing_encoder_with_device_s, __pyx_v_device_id}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_testing_encoder_with_device_s); __Pyx_GIVEREF(__pyx_kp_s_testing_encoder_with_device_s); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, __pyx_kp_s_testing_encoder_with_device_s); __Pyx_INCREF(__pyx_v_device_id); __Pyx_GIVEREF(__pyx_v_device_id); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, __pyx_v_device_id); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2754: options = {"cuda_device" : device_id}
__pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_cuda_device, __pyx_v_device_id) < 0) __PYX_ERR(0, 2754, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_options, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+2755: try:
/*try:*/ {
+2756: test_encoder = Encoder()
__pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4xpra_6codecs_5nvenc_7encoder_Encoder), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2756, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_test_encoder, ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_t_9)); __pyx_t_9 = 0;
+2757: test_encoder.select_cuda_device(options)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_select_cuda_device); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2757, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_options); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2757, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_options}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2757, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_options}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2757, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2757, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_options); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2757, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2758: test_encoder.init_cuda()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_init_cuda); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2758, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_6) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2758, __pyx_L20_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2758, __pyx_L20_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2759: log("test encoder=%s", test_encoder)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2759, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_test_encoder_s, ((PyObject *)__pyx_v_test_encoder)}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2759, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_test_encoder_s, ((PyObject *)__pyx_v_test_encoder)}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2759, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2759, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_test_encoder_s); __Pyx_GIVEREF(__pyx_kp_s_test_encoder_s); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, __pyx_kp_s_test_encoder_s); __Pyx_INCREF(((PyObject *)__pyx_v_test_encoder)); __Pyx_GIVEREF(((PyObject *)__pyx_v_test_encoder)); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, ((PyObject *)__pyx_v_test_encoder)); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2759, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2760: test_encoder.open_encode_session()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_open_encode_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2760, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2760, __pyx_L20_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2760, __pyx_L20_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2761: log("init_encoder() %s", test_encoder)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2761, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_init_encoder_s, ((PyObject *)__pyx_v_test_encoder)}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2761, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_init_encoder_s, ((PyObject *)__pyx_v_test_encoder)}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2761, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2761, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_init_encoder_s); __Pyx_GIVEREF(__pyx_kp_s_init_encoder_s); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_10, __pyx_kp_s_init_encoder_s); __Pyx_INCREF(((PyObject *)__pyx_v_test_encoder)); __Pyx_GIVEREF(((PyObject *)__pyx_v_test_encoder)); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_10, ((PyObject *)__pyx_v_test_encoder)); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2761, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2762: codecs = test_encoder.query_codecs()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_query_codecs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2762, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_6) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2762, __pyx_L20_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2762, __pyx_L20_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_codecs, __pyx_t_9); __pyx_t_9 = 0;
+2763: log("device %i supports: %s", device_id, codecs)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2763, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_device_i_supports_s, __pyx_v_device_id, __pyx_v_codecs}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2763, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_device_i_supports_s, __pyx_v_device_id, __pyx_v_codecs}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2763, __pyx_L20_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_5 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2763, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_device_i_supports_s); __Pyx_GIVEREF(__pyx_kp_s_device_i_supports_s); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, __pyx_kp_s_device_i_supports_s); __Pyx_INCREF(__pyx_v_device_id); __Pyx_GIVEREF(__pyx_v_device_id); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, __pyx_v_device_id); __Pyx_INCREF(__pyx_v_codecs); __Pyx_GIVEREF(__pyx_v_codecs); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_10, __pyx_v_codecs); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2763, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; }
2764: finally:
+2765: test_encoder.clean()
/*finally:*/ { /*normal exit:*/{ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_clean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2765, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2765, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ if (unlikely(!__pyx_v_test_encoder)) { __Pyx_RaiseUnboundLocalError("test_encoder"); __PYX_ERR(0, 2765, __pyx_L25_error) } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_clean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2765, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2765, __pyx_L25_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2765, __pyx_L25_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2766: test_encoder = None
__Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_test_encoder, ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)Py_None)); goto __pyx_L21; } __pyx_L20_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_10 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { /* … */ __Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_test_encoder, ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)Py_None)); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L1_error; __pyx_L25_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; goto __pyx_L1_error; } __pyx_L21:; }
2767:
+2768: test_encodings = []
__pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_test_encodings, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+2769: for e in TEST_ENCODINGS:
__pyx_t_9 = __pyx_v_TEST_ENCODINGS; __Pyx_INCREF(__pyx_t_9); __pyx_t_23 = 0; for (;;) { if (__pyx_t_23 >= PyList_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_23); __Pyx_INCREF(__pyx_t_4); __pyx_t_23++; if (unlikely(0 < 0)) __PYX_ERR(0, 2769, __pyx_L1_error) #else __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_23); __pyx_t_23++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L26_continue:; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2770: if e in FAILED_ENCODINGS:
__pyx_t_11 = (__Pyx_PySequence_ContainsTF(__pyx_v_e, __pyx_v_FAILED_ENCODINGS, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2770, __pyx_L1_error) __pyx_t_3 = (__pyx_t_11 != 0); if (__pyx_t_3) { /* … */ }
+2771: continue
goto __pyx_L26_continue;
2772: nvenc_encoding_name = {
+2773: "h264" : "H264",
__pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2773, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_h264, __pyx_n_s_H264) < 0) __PYX_ERR(0, 2773, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_h265, __pyx_n_s_HEVC) < 0) __PYX_ERR(0, 2773, __pyx_L1_error)
2774: "h265" : "HEVC",
+2775: }.get(e, e)
__pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_t_4, __pyx_v_e, __pyx_v_e); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2775, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_nvenc_encoding_name, __pyx_t_5); __pyx_t_5 = 0;
+2776: codec_query = codecs.get(nvenc_encoding_name)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_6) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_nvenc_encoding_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_nvenc_encoding_name}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_nvenc_encoding_name}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_24 = PyTuple_New(1+1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(__pyx_v_nvenc_encoding_name); __Pyx_GIVEREF(__pyx_v_nvenc_encoding_name); PyTuple_SET_ITEM(__pyx_t_24, 0+1, __pyx_v_nvenc_encoding_name); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_24, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_codec_query, __pyx_t_5); __pyx_t_5 = 0;
+2777: if not codec_query:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_codec_query); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2777, __pyx_L1_error) __pyx_t_11 = ((!__pyx_t_3) != 0); if (__pyx_t_11) { /* … */ }
+2778: log("%s is not supported on this device", e)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_24 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_24)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_24); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_kp_s_s_is_not_supported_on_this_devi, __pyx_v_e}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_kp_s_s_is_not_supported_on_this_devi, __pyx_v_e}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_24) { __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_24); __pyx_t_24 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_is_not_supported_on_this_devi); __Pyx_GIVEREF(__pyx_kp_s_s_is_not_supported_on_this_devi); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_15, __pyx_kp_s_s_is_not_supported_on_this_devi); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_15, __pyx_v_e); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2779: FAILED_ENCODINGS.add(e)
__pyx_t_25 = PySet_Add(__pyx_v_FAILED_ENCODINGS, __pyx_v_e); if (unlikely(__pyx_t_25 == ((int)-1))) __PYX_ERR(0, 2779, __pyx_L1_error)
+2780: continue
goto __pyx_L26_continue;
2781: #ensure MAX_SIZE is set:
+2782: cmax = MAX_SIZE.get(e)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_MAX_SIZE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_4) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_e); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_e}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_e}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_24 = PyTuple_New(1+1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_24, 0+1, __pyx_v_e); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_24, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_cmax, __pyx_t_5); __pyx_t_5 = 0;
+2783: qmax = codec_query.get("max-size")
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_codec_query, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_qmax, __pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_max_size); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 2783, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34);
+2784: if qmax:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_qmax); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2784, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
2785: #minimum of current value and value for this device:
+2786: qmx, qmy = qmax
if ((likely(PyTuple_CheckExact(__pyx_v_qmax))) || (PyList_CheckExact(__pyx_v_qmax))) { PyObject* sequence = __pyx_v_qmax; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 2786, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { Py_ssize_t index = -1; __pyx_t_24 = PyObject_GetIter(__pyx_v_qmax); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_26 = Py_TYPE(__pyx_t_24)->tp_iternext; index = 0; __pyx_t_6 = __pyx_t_26(__pyx_t_24); if (unlikely(!__pyx_t_6)) goto __pyx_L31_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_5 = __pyx_t_26(__pyx_t_24); if (unlikely(!__pyx_t_5)) goto __pyx_L31_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_26(__pyx_t_24), 2) < 0) __PYX_ERR(0, 2786, __pyx_L1_error) __pyx_t_26 = NULL; __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; goto __pyx_L32_unpacking_done; __pyx_L31_unpacking_failed:; __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __pyx_t_26 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 2786, __pyx_L1_error) __pyx_L32_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_qmx, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_qmy, __pyx_t_5); __pyx_t_5 = 0;
+2787: cmx, cmy = cmax or qmax
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_cmax); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2787, __pyx_L1_error) if (!__pyx_t_11) { } else { __Pyx_INCREF(__pyx_v_cmax); __pyx_t_5 = __pyx_v_cmax; goto __pyx_L33_bool_binop_done; } __Pyx_INCREF(__pyx_v_qmax); __pyx_t_5 = __pyx_v_qmax; __pyx_L33_bool_binop_done:; if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 2787, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_24 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_24 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_24); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_24 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_26 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_6 = __pyx_t_26(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L35_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_24 = __pyx_t_26(__pyx_t_4); if (unlikely(!__pyx_t_24)) goto __pyx_L35_unpacking_failed; __Pyx_GOTREF(__pyx_t_24); if (__Pyx_IternextUnpackEndCheck(__pyx_t_26(__pyx_t_4), 2) < 0) __PYX_ERR(0, 2787, __pyx_L1_error) __pyx_t_26 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L36_unpacking_done; __pyx_L35_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_26 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 2787, __pyx_L1_error) __pyx_L36_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_cmx, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_cmy, __pyx_t_24); __pyx_t_24 = 0;
+2788: v = min(qmx, cmx), min(qmy, cmy)
__Pyx_INCREF(__pyx_v_cmx); __pyx_t_5 = __pyx_v_cmx; __Pyx_INCREF(__pyx_v_qmx); __pyx_t_24 = __pyx_v_qmx; __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_t_24, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2788, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2788, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_11) { __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = __pyx_t_5; } else { __Pyx_INCREF(__pyx_t_24); __pyx_t_6 = __pyx_t_24; } __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_v_cmy); __pyx_t_5 = __pyx_v_cmy; __Pyx_INCREF(__pyx_v_qmy); __pyx_t_24 = __pyx_v_qmy; __pyx_t_27 = PyObject_RichCompare(__pyx_t_5, __pyx_t_24, Py_LT); __Pyx_XGOTREF(__pyx_t_27); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2788, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_27); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2788, __pyx_L1_error) __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; if (__pyx_t_11) { __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = __pyx_t_5; } else { __Pyx_INCREF(__pyx_t_24); __pyx_t_4 = __pyx_t_24; } __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_v, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
+2789: log("max-size(%s)=%s", e, v)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_max_size_s_s, __pyx_v_e, __pyx_v_v}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_max_size_s_s, __pyx_v_e, __pyx_v_v}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_24 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_max_size_s_s); __Pyx_GIVEREF(__pyx_kp_s_max_size_s_s); PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_15, __pyx_kp_s_max_size_s_s); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_15, __pyx_v_e); __Pyx_INCREF(__pyx_v_v); __Pyx_GIVEREF(__pyx_v_v); PyTuple_SET_ITEM(__pyx_t_24, 2+__pyx_t_15, __pyx_v_v); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_24, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2790: MAX_SIZE[e] = v
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_MAX_SIZE); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_v_e, __pyx_v_v) < 0)) __PYX_ERR(0, 2790, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2791: test_encodings.append(e)
__pyx_t_25 = __Pyx_PyList_Append(__pyx_v_test_encodings, __pyx_v_e); if (unlikely(__pyx_t_25 == ((int)-1))) __PYX_ERR(0, 2791, __pyx_L1_error)
2792:
+2793: log("will test: %s", test_encodings)
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2793, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_will_test_s, __pyx_v_test_encodings}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2793, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_will_test_s, __pyx_v_test_encodings}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2793, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_24 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2793, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_will_test_s); __Pyx_GIVEREF(__pyx_kp_s_will_test_s); PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_15, __pyx_kp_s_will_test_s); __Pyx_INCREF(__pyx_v_test_encodings); __Pyx_GIVEREF(__pyx_v_test_encodings); PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_15, __pyx_v_test_encodings); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_24, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2793, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2794: for encoding in test_encodings:
__pyx_t_9 = __pyx_v_test_encodings; __Pyx_INCREF(__pyx_t_9); __pyx_t_23 = 0; for (;;) { if (__pyx_t_23 >= PyList_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_23); __Pyx_INCREF(__pyx_t_5); __pyx_t_23++; if (unlikely(0 < 0)) __PYX_ERR(0, 2794, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_23); __pyx_t_23++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_v_encoding, __pyx_t_5); __pyx_t_5 = 0; /* … */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2795: colorspaces = get_input_colorspaces(encoding)
__pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_input_colorspaces); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_24))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_24); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_24); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_24, function); } } if (!__pyx_t_4) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_24, __pyx_v_encoding); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_24, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2795, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_24, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2795, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_encoding); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_XDECREF_SET(__pyx_v_colorspaces, __pyx_t_5); __pyx_t_5 = 0;
+2796: assert colorspaces, "cannot use NVENC: no colorspaces available"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_colorspaces); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2796, __pyx_L1_error) if (unlikely(!__pyx_t_11)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_cannot_use_NVENC_no_colorspaces); __PYX_ERR(0, 2796, __pyx_L1_error) } } #endif
+2797: src_format = colorspaces[0]
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_colorspaces, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_src_format, __pyx_t_5); __pyx_t_5 = 0;
+2798: dst_formats = get_output_colorspaces(encoding, src_format)
__pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_output_colorspaces); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_6 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_24))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_24); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_24); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_24, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_encoding, __pyx_v_src_format}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_24, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2798, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_encoding, __pyx_v_src_format}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_24, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2798, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_15, __pyx_v_encoding); __Pyx_INCREF(__pyx_v_src_format); __Pyx_GIVEREF(__pyx_v_src_format); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_15, __pyx_v_src_format); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_XDECREF_SET(__pyx_v_dst_formats, __pyx_t_5); __pyx_t_5 = 0;
+2799: try:
/*try:*/ {
+2800: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; goto __pyx_L51_try_end; __pyx_L44_error:; __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20); goto __pyx_L42_error; __pyx_L45_exception_handled:; __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20); __pyx_L51_try_end:; } }
+2801: test_encoder = Encoder()
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4xpra_6codecs_5nvenc_7encoder_Encoder), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2801, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_test_encoder, ((struct __pyx_obj_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_t_5)); __pyx_t_5 = 0;
+2802: test_encoder.init_context(1920, 1080, src_format, dst_formats, encoding, 50, 100, (1,1), options)
__pyx_t_24 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_init_context); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2802, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_4 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_24))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_24); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_24); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_24, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[10] = {__pyx_t_4, __pyx_int_1920, __pyx_int_1080, __pyx_v_src_format, __pyx_v_dst_formats, __pyx_v_encoding, __pyx_int_50, __pyx_int_100, __pyx_tuple__35, __pyx_v_options}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_24, __pyx_temp+1-__pyx_t_15, 9+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2802, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[10] = {__pyx_t_4, __pyx_int_1920, __pyx_int_1080, __pyx_v_src_format, __pyx_v_dst_formats, __pyx_v_encoding, __pyx_int_50, __pyx_int_100, __pyx_tuple__35, __pyx_v_options}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_24, __pyx_temp+1-__pyx_t_15, 9+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2802, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_6 = PyTuple_New(9+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2802, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_int_1920); __Pyx_GIVEREF(__pyx_int_1920); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_15, __pyx_int_1920); __Pyx_INCREF(__pyx_int_1080); __Pyx_GIVEREF(__pyx_int_1080); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_15, __pyx_int_1080); __Pyx_INCREF(__pyx_v_src_format); __Pyx_GIVEREF(__pyx_v_src_format); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_15, __pyx_v_src_format); __Pyx_INCREF(__pyx_v_dst_formats); __Pyx_GIVEREF(__pyx_v_dst_formats); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_15, __pyx_v_dst_formats); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_15, __pyx_v_encoding); __Pyx_INCREF(__pyx_int_50); __Pyx_GIVEREF(__pyx_int_50); PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_15, __pyx_int_50); __Pyx_INCREF(__pyx_int_100); __Pyx_GIVEREF(__pyx_int_100); PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_15, __pyx_int_100); __Pyx_INCREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); PyTuple_SET_ITEM(__pyx_t_6, 7+__pyx_t_15, __pyx_tuple__35); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); PyTuple_SET_ITEM(__pyx_t_6, 8+__pyx_t_15, __pyx_v_options); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2802, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_tuple__35 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 2802, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35);
+2803: success = True
__pyx_v_success = 1;
+2804: if client_key:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_client_key); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2804, __pyx_L44_error) if (__pyx_t_11) { /* … */ }
+2805: log("the license key '%s' is valid", client_key)
__pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2805, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_6 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_24))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_24); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_24); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_24, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_the_license_key_s_is_valid, __pyx_v_client_key}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_24, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2805, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_24)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_the_license_key_s_is_valid, __pyx_v_client_key}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_24, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2805, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2805, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_the_license_key_s_is_valid); __Pyx_GIVEREF(__pyx_kp_s_the_license_key_s_is_valid); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_15, __pyx_kp_s_the_license_key_s_is_valid); __Pyx_INCREF(__pyx_v_client_key); __Pyx_GIVEREF(__pyx_v_client_key); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_15, __pyx_v_client_key); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2805, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2806: valid_keys.append(client_key)
__pyx_t_25 = __Pyx_PyList_Append(__pyx_v_valid_keys, __pyx_v_client_key); if (unlikely(__pyx_t_25 == ((int)-1))) __PYX_ERR(0, 2806, __pyx_L44_error)
2807: #check for YUV444 support
+2808: yuv444_support = YUV444_ENABLED and test_encoder.query_encoder_caps(test_encoder.get_codec(), <NV_ENC_CAPS> NV_ENC_CAPS_SUPPORT_YUV444_ENCODE)
if (__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED) {
} else {
__pyx_t_15 = __pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED;
goto __pyx_L53_bool_binop_done;
}
__pyx_t_10 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_test_encoder->__pyx_vtab)->query_encoder_caps(__pyx_v_test_encoder, ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_test_encoder->__pyx_vtab)->get_codec(__pyx_v_test_encoder), ((NV_ENC_CAPS)NV_ENC_CAPS_SUPPORT_YUV444_ENCODE)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2808, __pyx_L44_error)
__pyx_t_15 = __pyx_t_10;
__pyx_L53_bool_binop_done:;
__pyx_v_yuv444_support = __pyx_t_15;
+2809: YUV444_CODEC_SUPPORT[encoding] = yuv444_support
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_yuv444_support); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2809, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2809, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_24); if (unlikely(PyObject_SetItem(__pyx_t_24, __pyx_v_encoding, __pyx_t_5) < 0)) __PYX_ERR(0, 2809, __pyx_L44_error) __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2810: if YUV444_ENABLED and not yuv444_support:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED != 0); if (__pyx_t_3) { } else { __pyx_t_11 = __pyx_t_3; goto __pyx_L56_bool_binop_done; } __pyx_t_3 = ((!(__pyx_v_yuv444_support != 0)) != 0); __pyx_t_11 = __pyx_t_3; __pyx_L56_bool_binop_done:; if (__pyx_t_11) { /* … */ }
+2811: log.warn("Warning: hardware or nvenc library version does not support YUV444 with %s", encoding)
__pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2811, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2811, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __pyx_t_24 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_24)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_24); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_kp_s_Warning_hardware_or_nvenc_librar, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2811, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_kp_s_Warning_hardware_or_nvenc_librar, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2811, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2811, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_24) { __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_24); __pyx_t_24 = NULL; } __Pyx_INCREF(__pyx_kp_s_Warning_hardware_or_nvenc_librar); __Pyx_GIVEREF(__pyx_kp_s_Warning_hardware_or_nvenc_librar); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_15, __pyx_kp_s_Warning_hardware_or_nvenc_librar); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_15, __pyx_v_encoding); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2811, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2812: log("%s YUV444 support: %s", encoding, YUV444_CODEC_SUPPORT.get(encoding, YUV444_ENABLED))
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_YUV444_CODEC_SUPPORT); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_n_s_get); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __pyx_t_24 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_YUV444_ENABLED); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_28 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) { __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_27); if (likely(__pyx_t_28)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27); __Pyx_INCREF(__pyx_t_28); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_27, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_28, __pyx_v_encoding, __pyx_t_24}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_28, __pyx_v_encoding, __pyx_t_24}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } else #endif { __pyx_t_29 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_29); if (__pyx_t_28) { __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_28); __pyx_t_28 = NULL; } __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_29, 0+__pyx_t_15, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_29, 1+__pyx_t_15, __pyx_t_24); __pyx_t_24 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_29, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; } __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __pyx_t_27 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_27 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_27)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_27); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_27, __pyx_kp_s_s_YUV444_support_s, __pyx_v_encoding, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_27, __pyx_kp_s_s_YUV444_support_s, __pyx_v_encoding, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_29 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_29); if (__pyx_t_27) { __Pyx_GIVEREF(__pyx_t_27); PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_t_27); __pyx_t_27 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_YUV444_support_s); __Pyx_GIVEREF(__pyx_kp_s_s_YUV444_support_s); PyTuple_SET_ITEM(__pyx_t_29, 0+__pyx_t_15, __pyx_kp_s_s_YUV444_support_s); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_29, 1+__pyx_t_15, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_29, 2+__pyx_t_15, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_29, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2812, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2813: #check for lossless:
+2814: lossless_support = yuv444_support and LOSSLESS_ENABLED and test_encoder.query_encoder_caps(test_encoder.get_codec(), <NV_ENC_CAPS> NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE)
if (__pyx_v_yuv444_support) {
} else {
__pyx_t_15 = __pyx_v_yuv444_support;
goto __pyx_L58_bool_binop_done;
}
if (__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED) {
} else {
__pyx_t_15 = __pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED;
goto __pyx_L58_bool_binop_done;
}
__pyx_t_10 = ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_test_encoder->__pyx_vtab)->query_encoder_caps(__pyx_v_test_encoder, ((struct __pyx_vtabstruct_4xpra_6codecs_5nvenc_7encoder_Encoder *)__pyx_v_test_encoder->__pyx_vtab)->get_codec(__pyx_v_test_encoder), ((NV_ENC_CAPS)NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2814, __pyx_L44_error)
__pyx_t_15 = __pyx_t_10;
__pyx_L58_bool_binop_done:;
__pyx_v_lossless_support = __pyx_t_15;
+2815: LOSSLESS_CODEC_SUPPORT[encoding] = lossless_support
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_lossless_support); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2815, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_LOSSLESS_CODEC_SUPPORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2815, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_v_encoding, __pyx_t_5) < 0)) __PYX_ERR(0, 2815, __pyx_L44_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2816: if LOSSLESS_ENABLED and not lossless_support:
__pyx_t_3 = (__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED != 0); if (__pyx_t_3) { } else { __pyx_t_11 = __pyx_t_3; goto __pyx_L62_bool_binop_done; } __pyx_t_3 = ((!(__pyx_v_lossless_support != 0)) != 0); __pyx_t_11 = __pyx_t_3; __pyx_L62_bool_binop_done:; if (__pyx_t_11) { /* … */ }
+2817: log.warn("Warning: hardware or nvenc library version does not support lossless mode with %s", encoding)
__pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2817, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2817, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_29); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_29))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_29); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_29); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_29, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_29)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_Warning_hardware_or_nvenc_librar_2, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_29, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2817, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_29)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_Warning_hardware_or_nvenc_librar_2, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_29, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2817, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2817, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_Warning_hardware_or_nvenc_librar_2); __Pyx_GIVEREF(__pyx_kp_s_Warning_hardware_or_nvenc_librar_2); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_15, __pyx_kp_s_Warning_hardware_or_nvenc_librar_2); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_15, __pyx_v_encoding); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_29, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2817, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2818: log("%s lossless support: %s", encoding, LOSSLESS_CODEC_SUPPORT.get(encoding, LOSSLESS_ENABLED))
__pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_29); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_LOSSLESS_CODEC_SUPPORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_4xpra_6codecs_5nvenc_7encoder_LOSSLESS_ENABLED); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_24 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) { __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_27); if (likely(__pyx_t_24)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27); __Pyx_INCREF(__pyx_t_24); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_27, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_v_encoding, __pyx_t_4}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_v_encoding, __pyx_t_4}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_28 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_28); if (__pyx_t_24) { __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_24); __pyx_t_24 = NULL; } __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_28, 0+__pyx_t_15, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_28, 1+__pyx_t_15, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_28, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; } __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __pyx_t_27 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_29))) { __pyx_t_27 = PyMethod_GET_SELF(__pyx_t_29); if (likely(__pyx_t_27)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_29); __Pyx_INCREF(__pyx_t_27); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_29, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_29)) { PyObject *__pyx_temp[4] = {__pyx_t_27, __pyx_kp_s_s_lossless_support_s, __pyx_v_encoding, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_29, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_29)) { PyObject *__pyx_temp[4] = {__pyx_t_27, __pyx_kp_s_s_lossless_support_s, __pyx_v_encoding, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_29, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_28 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_28); if (__pyx_t_27) { __Pyx_GIVEREF(__pyx_t_27); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_27); __pyx_t_27 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_lossless_support_s); __Pyx_GIVEREF(__pyx_kp_s_s_lossless_support_s); PyTuple_SET_ITEM(__pyx_t_28, 0+__pyx_t_15, __pyx_kp_s_s_lossless_support_s); __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); PyTuple_SET_ITEM(__pyx_t_28, 1+__pyx_t_15, __pyx_v_encoding); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_28, 2+__pyx_t_15, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_29, __pyx_t_28, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2818, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; } __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+2819: except NVENCException as e:
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_NVENCException); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2819, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_15) { __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.init_module", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_29, &__pyx_t_28) < 0) __PYX_ERR(0, 2819, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_29); __Pyx_GOTREF(__pyx_t_28); __Pyx_INCREF(__pyx_t_29); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_29);
+2820: log("encoder %s failed: %s", test_encoder, e)
__pyx_t_27 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2820, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_4 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_27); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_27, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_encoder_s_failed_s, ((PyObject *)__pyx_v_test_encoder), __pyx_v_e}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2820, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_s_encoder_s_failed_s, ((PyObject *)__pyx_v_test_encoder), __pyx_v_e}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2820, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_24 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2820, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_24); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_kp_s_encoder_s_failed_s); __Pyx_GIVEREF(__pyx_kp_s_encoder_s_failed_s); PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_15, __pyx_kp_s_encoder_s_failed_s); __Pyx_INCREF(((PyObject *)__pyx_v_test_encoder)); __Pyx_GIVEREF(((PyObject *)__pyx_v_test_encoder)); PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_15, ((PyObject *)__pyx_v_test_encoder)); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_24, 2+__pyx_t_15, __pyx_v_e); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_24, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2820, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2821: #special handling for license key issues:
+2822: if e.code==NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY:
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_code); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2822, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_27 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2822, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_24 = PyObject_RichCompare(__pyx_t_6, __pyx_t_27, Py_EQ); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2822, __pyx_L46_except_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_24); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2822, __pyx_L46_except_error) __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; if (__pyx_t_11) { /* … */ goto __pyx_L66; }
+2823: if client_key:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_client_key); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2823, __pyx_L46_except_error) if (__pyx_t_11) { /* … */ goto __pyx_L67; }
+2824: log("invalid license key '%s' (skipped)", client_key)
__pyx_t_27 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2824, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_6 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_27); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_27, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_invalid_license_key_s_skipped, __pyx_v_client_key}; __pyx_t_24 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2824, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_24); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_invalid_license_key_s_skipped, __pyx_v_client_key}; __pyx_t_24 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2824, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_24); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2824, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_invalid_license_key_s_skipped); __Pyx_GIVEREF(__pyx_kp_s_invalid_license_key_s_skipped); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_15, __pyx_kp_s_invalid_license_key_s_skipped); __Pyx_INCREF(__pyx_v_client_key); __Pyx_GIVEREF(__pyx_v_client_key); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_15, __pyx_v_client_key); __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_4, NULL); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2824, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_24); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
+2825: failed_keys.append(client_key)
__pyx_t_25 = __Pyx_PyList_Append(__pyx_v_failed_keys, __pyx_v_client_key); if (unlikely(__pyx_t_25 == ((int)-1))) __PYX_ERR(0, 2825, __pyx_L46_except_error)
2826: else:
+2827: log("a license key is required")
/*else*/ { __pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2827, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_27 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2827, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; } __pyx_L67:; /* … */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_a_license_key_is_required); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 2827, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36);
+2828: elif e.code==NV_ENC_ERR_INVALID_VERSION:
__pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_code); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2828, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_24 = __Pyx_PyInt_From_unsigned_int(NV_ENC_ERR_INVALID_VERSION); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2828, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_4 = PyObject_RichCompare(__pyx_t_27, __pyx_t_24, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2828, __pyx_L46_except_error) __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2828, __pyx_L46_except_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_11) { /* … */ }
2829: #we can bail out already:
+2830: raise Exception("version mismatch, you need a newer/older codec build or newer/older drivers")
__pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2830, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 2830, __pyx_L46_except_error) /* … */ __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_version_mismatch_you_need_a_newe); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 2830, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37);
2831: else:
2832: #it seems that newer version will fail with
2833: #seemingly random errors when we supply the wrong key
+2834: log.warn("error during NVENC encoder test: %s", e)
/*else*/ { __pyx_t_24 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2834, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_n_s_warn); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2834, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; __pyx_t_24 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) { __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_27); if (likely(__pyx_t_24)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27); __Pyx_INCREF(__pyx_t_24); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_27, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_kp_s_error_during_NVENC_encoder_test, __pyx_v_e}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2834, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_24, __pyx_kp_s_error_during_NVENC_encoder_test, __pyx_v_e}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2834, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2834, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_24) { __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_24); __pyx_t_24 = NULL; } __Pyx_INCREF(__pyx_kp_s_error_during_NVENC_encoder_test); __Pyx_GIVEREF(__pyx_kp_s_error_during_NVENC_encoder_test); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_15, __pyx_kp_s_error_during_NVENC_encoder_test); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_15, __pyx_v_e); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2834, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2835: if client_key:
__pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_client_key); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2835, __pyx_L46_except_error) if (__pyx_t_11) { /* … */ goto __pyx_L68; }
+2836: log(" license key '%s' may not be valid (skipped)", client_key)
__pyx_t_27 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2836, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_6 = NULL; __pyx_t_15 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_27); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_27, function); __pyx_t_15 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_license_key_s_may_not_be_valid, __pyx_v_client_key}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2836, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_license_key_s_may_not_be_valid, __pyx_v_client_key}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2836, __pyx_L46_except_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif { __pyx_t_24 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 2836, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_24); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_kp_s_license_key_s_may_not_be_valid); __Pyx_GIVEREF(__pyx_kp_s_license_key_s_may_not_be_valid); PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_15, __pyx_kp_s_license_key_s_may_not_be_valid); __Pyx_INCREF(__pyx_v_client_key); __Pyx_GIVEREF(__pyx_v_client_key); PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_15, __pyx_v_client_key); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_24, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2836, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0; } __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2837: failed_keys.append(client_key)
__pyx_t_25 = __Pyx_PyList_Append(__pyx_v_failed_keys, __pyx_v_client_key); if (unlikely(__pyx_t_25 == ((int)-1))) __PYX_ERR(0, 2837, __pyx_L46_except_error)
2838: else:
+2839: log(" a license key may be required")
/*else*/ { __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2839, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_27 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 2839, __pyx_L46_except_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; } __pyx_L68:; } __pyx_L66:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; goto __pyx_L45_exception_handled; } goto __pyx_L46_except_error; __pyx_L46_except_error:; /* … */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_a_license_key_may_be_required); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 2839, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__38); __Pyx_GIVEREF(__pyx_tuple__38);
2840: finally:
+2841: if test_encoder:
/*finally:*/ { /*normal exit:*/{ __pyx_t_11 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_test_encoder)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2841, __pyx_L1_error) if (__pyx_t_11) { /* … */ } goto __pyx_L43; } __pyx_L42_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_15 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_30 = __pyx_filename; { __pyx_t_11 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_test_encoder)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2841, __pyx_L73_error) if (__pyx_t_11) { /* … */ } } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22); __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_30; goto __pyx_L1_error; __pyx_L73_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17); } __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; goto __pyx_L1_error; } __pyx_L43:; }
+2842: test_encoder.clean()
__pyx_t_29 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_clean); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_29))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_29); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_29); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_29, function); } } if (__pyx_t_5) { __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_29, __pyx_t_5); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_28 = __Pyx_PyObject_CallNoArg(__pyx_t_29); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2842, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_28); __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; /* … */ __pyx_t_29 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_test_encoder), __pyx_n_s_clean); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2842, __pyx_L73_error) __Pyx_GOTREF(__pyx_t_29); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_29))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_29); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_29); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_29, function); } } if (__pyx_t_5) { __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_29, __pyx_t_5); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2842, __pyx_L73_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { __pyx_t_28 = __Pyx_PyObject_CallNoArg(__pyx_t_29); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2842, __pyx_L73_error) } __Pyx_GOTREF(__pyx_t_28); __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
+2843: if success:
__pyx_t_11 = (__pyx_v_success != 0); if (__pyx_t_11) { /* … */ goto __pyx_L75; }
2844: #pick the first valid license key:
+2845: if len(valid_keys)>0:
__pyx_t_7 = PyList_GET_SIZE(__pyx_v_valid_keys); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2845, __pyx_L1_error) __pyx_t_11 = ((__pyx_t_7 > 0) != 0); if (__pyx_t_11) { /* … */ goto __pyx_L76; }
+2846: x = valid_keys[0]
__pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_valid_keys, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2846, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_2); __pyx_t_2 = 0;
+2847: log("using the license key '%s'", x)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2847, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_using_the_license_key_s, __pyx_v_x}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2847, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_using_the_license_key_s, __pyx_v_x}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2847, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_28 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2847, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_28); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_s_using_the_license_key_s); __Pyx_GIVEREF(__pyx_kp_s_using_the_license_key_s); PyTuple_SET_ITEM(__pyx_t_28, 0+__pyx_t_10, __pyx_kp_s_using_the_license_key_s); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_28, 1+__pyx_t_10, __pyx_v_x); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2847, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2848: CLIENT_KEY_GUID = c_parseguid(x)
__pyx_t_12 = __pyx_f_4xpra_6codecs_5nvenc_7encoder_c_parseguid(__pyx_v_x); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2848, __pyx_L1_error)
__pyx_v_4xpra_6codecs_5nvenc_7encoder_CLIENT_KEY_GUID = __pyx_t_12;
2849: else:
+2850: log("no license keys are required")
/*else*/ { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L76:; /* … */ __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_no_license_keys_are_required); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 2850, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__39); __Pyx_GIVEREF(__pyx_tuple__39);
+2851: ENCODINGS[:] = [x for x in TEST_ENCODINGS if x not in FAILED_ENCODINGS]
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_v_TEST_ENCODINGS; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; for (;;) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_28 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_28); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 2851, __pyx_L1_error) #else __pyx_t_28 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_28); #endif __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_28); __pyx_t_28 = 0; __pyx_t_11 = (__Pyx_PySequence_ContainsTF(__pyx_v_x, __pyx_v_FAILED_ENCODINGS, Py_NE)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2851, __pyx_L1_error) __pyx_t_3 = (__pyx_t_11 != 0); if (__pyx_t_3) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_v_x))) __PYX_ERR(0, 2851, __pyx_L1_error) } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ENCODINGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_PyObject_SetSlice(__pyx_t_2, __pyx_t_1, 0, 0, NULL, NULL, &__pyx_slice__40, 0, 0, 1) < 0) __PYX_ERR(0, 2851, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_slice__40 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__40)) __PYX_ERR(0, 2851, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__40); __Pyx_GIVEREF(__pyx_slice__40);
2852: else:
2853: #we got license key error(s)
+2854: if len(failed_keys)>0:
/*else*/ { __pyx_t_7 = PyList_GET_SIZE(__pyx_v_failed_keys); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2854, __pyx_L1_error) __pyx_t_3 = ((__pyx_t_7 > 0) != 0); if (__pyx_t_3) { /* … */ }
+2855: raise Exception("the license %s specified may be invalid" % (["key", "keys"][len(failed_keys)>1]))
__pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_key); __Pyx_GIVEREF(__pyx_n_s_key); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_key); __Pyx_INCREF(__pyx_n_s_keys); __Pyx_GIVEREF(__pyx_n_s_keys); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_keys); __pyx_t_7 = PyList_GET_SIZE(__pyx_v_failed_keys); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2855, __pyx_L1_error) __pyx_t_3 = (__pyx_t_7 > 1); __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_t_1, __pyx_t_3, int, 1, __Pyx_PyBool_FromLong, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_the_license_s_specified_may_be_i, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2855, __pyx_L1_error)
2856: else:
+2857: raise Exception("you may need to provide a license key")
/*else*/ { __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2857, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2857, __pyx_L1_error) } } __pyx_L75:; /* … */ __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_you_may_need_to_provide_a_licens); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 2857, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__41); __Pyx_GIVEREF(__pyx_tuple__41);
2858: global _init_message
+2859: if ENCODINGS and not _init_message:
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ENCODINGS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_11) { } else { __pyx_t_3 = __pyx_t_11; goto __pyx_L82_bool_binop_done; } __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_31 = ((!__pyx_t_11) != 0); __pyx_t_3 = __pyx_t_31; __pyx_L82_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+2860: log.info("NVENC v%i successfully initialized with codecs: %s", NVENCAPI_MAJOR_VERSION, csv(ENCODINGS))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_info); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_28); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(NVENCAPI_MAJOR_VERSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s_csv); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ENCODINGS); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_27 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_29))) { __pyx_t_27 = PyMethod_GET_SELF(__pyx_t_29); if (likely(__pyx_t_27)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_29); __Pyx_INCREF(__pyx_t_27); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_29, function); } } if (!__pyx_t_27) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_29, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_29)) { PyObject *__pyx_temp[2] = {__pyx_t_27, __pyx_t_5}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_29, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_29)) { PyObject *__pyx_temp[2] = {__pyx_t_27, __pyx_t_5}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_29, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_27); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_27); __pyx_t_27 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_29, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __pyx_t_29 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_28))) { __pyx_t_29 = PyMethod_GET_SELF(__pyx_t_28); if (likely(__pyx_t_29)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_28); __Pyx_INCREF(__pyx_t_29); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_28, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_28)) { PyObject *__pyx_temp[4] = {__pyx_t_29, __pyx_kp_s_NVENC_v_i_successfully_initializ, __pyx_t_2, __pyx_t_9}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_28, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_28)) { PyObject *__pyx_temp[4] = {__pyx_t_29, __pyx_kp_s_NVENC_v_i_successfully_initializ, __pyx_t_2, __pyx_t_9}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_28, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_29) { __Pyx_GIVEREF(__pyx_t_29); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_29); __pyx_t_29 = NULL; } __Pyx_INCREF(__pyx_kp_s_NVENC_v_i_successfully_initializ); __Pyx_GIVEREF(__pyx_kp_s_NVENC_v_i_successfully_initializ); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_10, __pyx_kp_s_NVENC_v_i_successfully_initializ); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_10, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_10, __pyx_t_9); __pyx_t_2 = 0; __pyx_t_9 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_28, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2861: _init_message = True
if (PyDict_SetItem(__pyx_d, __pyx_n_s_init_message, Py_True) < 0) __PYX_ERR(0, 2861, __pyx_L1_error)
2862:
2863:
+2864: def cleanup_module():
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_29cleanup_module(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_29cleanup_module = {"cleanup_module", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_29cleanup_module, METH_NOARGS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_29cleanup_module(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cleanup_module (wrapper)", 0); __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_28cleanup_module(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_28cleanup_module(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cleanup_module", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.cleanup_module", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_29cleanup_module, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_cleanup_module, __pyx_t_2) < 0) __PYX_ERR(0, 2864, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_xpra_codecs_nvenc_encoder_pyx, __pyx_n_s_cleanup_module, 2864, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(0, 2864, __pyx_L1_error)
+2865: log("nvenc.cleanup_module()")
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2865, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2865, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_nvenc_cleanup_module); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 2865, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42);
+2866: reset_state()
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_reset_state); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2866, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (__pyx_t_3) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2866, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2866, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2867:
+2868: def selftest(full=False):
/* Python wrapper */ static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_31selftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4xpra_6codecs_5nvenc_7encoder_31selftest = {"selftest", (PyCFunction)__pyx_pw_4xpra_6codecs_5nvenc_7encoder_31selftest, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4xpra_6codecs_5nvenc_7encoder_31selftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_full = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("selftest (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_full,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_False); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_full); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "selftest") < 0)) __PYX_ERR(0, 2868, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_full = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("selftest", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2868, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.selftest", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4xpra_6codecs_5nvenc_7encoder_30selftest(__pyx_self, __pyx_v_full); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4xpra_6codecs_5nvenc_7encoder_30selftest(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_full) { PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_NVENC_UNSUPPORTED_DRIVER_VERSION = NULL; PyObject *__pyx_v_get_encoder_max_sizes = NULL; PyObject *__pyx_v_encoder = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("selftest", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("xpra.codecs.nvenc.encoder.selftest", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_NVENC_UNSUPPORTED_DRIVER_VERSION); __Pyx_XDECREF(__pyx_v_get_encoder_max_sizes); __Pyx_XDECREF(__pyx_v_encoder); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__84 = PyTuple_Pack(5, __pyx_n_s_full, __pyx_n_s_v, __pyx_n_s_NVENC_UNSUPPORTED_DRIVER_VERSION, __pyx_n_s_get_encoder_max_sizes, __pyx_n_s_encoder); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 2868, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__84); __Pyx_GIVEREF(__pyx_tuple__84); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_5nvenc_7encoder_31selftest, NULL, __pyx_n_s_xpra_codecs_nvenc_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2868, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_selftest, __pyx_t_2) < 0) __PYX_ERR(0, 2868, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2869: v = get_nvidia_module_version(True)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_nvidia_module_version); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_v = __pyx_t_2; __pyx_t_2 = 0; /* … */ __pyx_tuple__43 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 2869, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__43); __Pyx_GIVEREF(__pyx_tuple__43);
+2870: assert NVENCAPI_MAJOR_VERSION>=7, "unsupported NVENC version %i" % NVENCAPI_MAJOR_VERSION
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((NVENCAPI_MAJOR_VERSION >= 7) != 0))) { __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(NVENCAPI_MAJOR_VERSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_unsupported_NVENC_version_i, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2870, __pyx_L1_error) } } #endif
+2871: if v:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2871, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+2872: NVENC_UNSUPPORTED_DRIVER_VERSION = envbool("XPRA_NVENC_UNSUPPORTED_DRIVER_VERSION", False)
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_envbool); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_NVENC_UNSUPPORTED_DRIVER_VERSION = __pyx_t_2; __pyx_t_2 = 0; /* … */ __pyx_tuple__44 = PyTuple_Pack(2, __pyx_n_s_XPRA_NVENC_UNSUPPORTED_DRIVER_VE, Py_False); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 2872, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44);
2873: #SDK 7.0 requires version 367 or later
2874: #SDK 7.1 requires version 375 or later
+2875: if v<[367, 0] or (NVENCAPI_MINOR_VERSION>0 and v<[375, 0]):
__pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_367); __Pyx_GIVEREF(__pyx_int_367); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_367); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_0); __pyx_t_1 = PyObject_RichCompare(__pyx_v_v, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2875, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2875, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = ((NVENCAPI_MINOR_VERSION > 0) != 0); if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_int_375); __Pyx_GIVEREF(__pyx_int_375); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_375); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); __pyx_t_2 = PyObject_RichCompare(__pyx_v_v, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2875, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2875, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+2876: if not NVENC_UNSUPPORTED_DRIVER_VERSION:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_NVENC_UNSUPPORTED_DRIVER_VERSION); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2876, __pyx_L1_error) __pyx_t_4 = ((!__pyx_t_3) != 0); if (__pyx_t_4) { /* … */ }
+2877: raise ImportError("unsupported NVidia driver version %s\nuse XPRA_NVENC_UNSUPPORTED_DRIVER_VERSION=1 to force enable it" % pver(v))
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pver); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_5) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_v}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_v}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_v_v); __Pyx_GIVEREF(__pyx_v_v); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_v); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_unsupported_NVidia_driver_versio, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2877, __pyx_L1_error)
2878: #this is expensive, so don't run it unless "full" is set:
+2879: if full:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_full); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 2879, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+2880: from xpra.codecs.codec_checks import get_encoder_max_sizes
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_encoder_max_sizes); __Pyx_GIVEREF(__pyx_n_s_get_encoder_max_sizes); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_encoder_max_sizes); __pyx_t_2 = __Pyx_Import(__pyx_n_s_xpra_codecs_codec_checks, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_encoder_max_sizes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v_get_encoder_max_sizes = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2881: from xpra.codecs.nvenc import encoder
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2881, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_encoder); __Pyx_GIVEREF(__pyx_n_s_encoder); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_encoder); __pyx_t_1 = __Pyx_Import(__pyx_n_s_xpra_codecs_nvenc, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2881, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2881, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __pyx_v_encoder = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2882: init_module()
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_init_module); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_6) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2882, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2882, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2883: log.info("%s max dimensions: %s", encoder, get_encoder_max_sizes(encoder))
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v_get_encoder_max_sizes); __pyx_t_5 = __pyx_v_get_encoder_max_sizes; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_7) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_encoder}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_encoder}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_INCREF(__pyx_v_encoder); __Pyx_GIVEREF(__pyx_v_encoder); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_encoder); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_s_max_dimensions_s, __pyx_v_encoder, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_kp_s_s_max_dimensions_s, __pyx_v_encoder, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_kp_s_s_max_dimensions_s); __Pyx_GIVEREF(__pyx_kp_s_s_max_dimensions_s); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_kp_s_s_max_dimensions_s); __Pyx_INCREF(__pyx_v_encoder); __Pyx_GIVEREF(__pyx_v_encoder); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_v_encoder); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;