60 void *allocate(
size_t size)
override {
68 void deallocate(
void *ptr)
override {
72 return new cuda_buffer_data_allocator(*
this);
76struct state_video_compress_cuda_dxt {
80 char *cuda_uyvy_buffer;
82 char *cuda_out_buffer;
90static void cuda_dxt_compress_done(
struct module *mod);
95 state_video_compress_cuda_dxt *s =
96 new state_video_compress_cuda_dxt();
99 if (
fmt &&
fmt[0] !=
'\0') {
100 if (strcasecmp(
fmt,
"DXT5") == 0) {
102 }
else if (strcasecmp(
fmt,
"DXT1") == 0) {
106 "\t-c cuda_dxt[:DXT1|:DXT5]\n");
115 s->module_data.
deleter = cuda_dxt_compress_done;
118 return &s->module_data;
121static void cleanup(
struct state_video_compress_cuda_dxt *s)
127 if (s->cuda_uyvy_buffer) {
129 s->cuda_uyvy_buffer = NULL;
131 if (s->cuda_in_buffer) {
133 s->cuda_in_buffer = NULL;
135 if (s->cuda_out_buffer) {
137 s->cuda_out_buffer = NULL;
147 " to 8 bits. You may directly capture 8-bit signal to improve performance.\n";
157 if (s->in_codec ==
UYVY) {
160 fprintf(stderr,
"Could not allocate CUDA UYVY buffer.\n");
169 fprintf(stderr,
"Could not allocate CUDA output buffer.\n");
183 fprintf(stderr,
"Could not allocate CUDA output buffer.\n");
190shared_ptr<video_frame> cuda_dxt_compress_tile(
struct module *mod, shared_ptr<video_frame>
tx)
196 struct state_video_compress_cuda_dxt *s =
197 (
struct state_video_compress_cuda_dxt *) mod->
priv_data;
206 fprintf(stderr,
"[CUDA DXT] Reconfiguration failed!\n");
212 if (
tx->color_spec == s->in_codec) {
213 in_buffer =
tx->tiles[0].data;
215 unsigned char *line1 = (
unsigned char *)
tx->tiles[0].data;
216 unsigned char *line2 = (
unsigned char *) s->in_buffer;
218 for (
int i = 0; i < (int)
tx->tiles[0].height; ++i) {
220 s->in_codec), 0, 8, 16);
224 in_buffer = s->in_buffer;
227 if (s->in_codec ==
UYVY) {
229 tx->tiles[0].height * 2,
241 tx->tiles[0].height * 3,
248 int (*cuda_dxt_enc_func)(
const void * src,
void * out,
int size_x,
int size_y,
251 if (s->out_codec ==
DXT1) {
252 if (s->in_codec ==
RGB) {
258 if (s->in_codec ==
RGB) {
264 int ret = cuda_dxt_enc_func(s->cuda_in_buffer, s->cuda_out_buffer,
271 shared_ptr<video_frame> out = s->pool.
get_frame();
274 out->tiles[0].data_len,
283static void cuda_dxt_compress_done(
struct module *mod)
285 struct state_video_compress_cuda_dxt *s =
286 (
struct state_video_compress_cuda_dxt *) mod->
priv_data;
295 cuda_dxt_compress_init,
297 cuda_dxt_compress_tile,
struct video_desc video_desc_from_frame(const struct video_frame *frame)
Returns struct video_desc from video frame.
int vc_get_linesize(unsigned int width, codec_t codec)
const char * get_codec_name(codec_t codec)
static const audio_codec_t supported_codecs[]
int cuda_yuv_to_dxt1(const void *src, void *out, int size_x, int size_y, cuda_wrapper_stream_t stream)
int cuda_yuv_to_dxt6(const void *src, void *out, int size_x, int size_y, cuda_wrapper_stream_t stream)
int cuda_rgb_to_dxt6(const void *src, void *out, int size_x, int size_y, cuda_wrapper_stream_t stream)
int cuda_rgb_to_dxt1(const void *src, void *out, int size_x, int size_y, cuda_wrapper_stream_t stream)
int cuda_yuv422_to_yuv444(const void *src, void *out, int pix_count, cuda_wrapper_stream_t str)
Interface of DXT compression CUDA implementation.
int cuda_wrapper_set_device(int index)
int cuda_wrapper_malloc_host(void **buffer, size_t data_len)
void * cuda_wrapper_stream_t
int cuda_wrapper_free(void *buffer)
const char * cuda_wrapper_last_error_string(void)
int cuda_wrapper_memcpy(void *dst, const void *src, size_t count, int kind)
int cuda_wrapper_malloc(void **buffer, size_t data_len)
This file contais wrapper around CUDA functions.
#define CUDA_WRAPPER_SUCCESS
#define CUDA_WRAPPER_MEMCPY_HOST_TO_DEVICE
#define CUDA_WRAPPER_MEMCPY_DEVICE_TO_HOST
#define LOG_LEVEL_NOTICE
information that may be interesting
void module_init_default(struct module *module_data)
void module_register(struct module *module_data, struct module *parent)
#define VIDEO_COMPRESS_ABI_VERSION
unsigned int cuda_devices[MAX_CUDA_DEVICES]
@ LIBRARY_CLASS_VIDEO_COMPRESS
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
decoder_t get_best_decoder_from(codec_t in, const codec_t *out_candidates, codec_t *out)
decoder_func_t * decoder_t
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
std::shared_ptr< video_frame > get_frame()
void reconfigure(struct video_desc new_desc, size_t new_size=SIZE_MAX)
@ DXT1
S3 Texture Compression DXT1.
@ RGB
RGB 8-bit (packed into 24-bit word)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ VIDEO_CODEC_NONE
dummy color spec
@ DXT5
S3 Texture Compression DXT5.
This is an umbrella header for video functions.
int get_bits_per_component(codec_t codec)
API for video compress drivers.
bool video_desc_eq_excl_param(struct video_desc a, struct video_desc b, unsigned int excluded_params)
Compares two video descriptions.