struct module * jpeg_compress_init(struct module *parent, char * opts) { struct state_video_compress_jpeg *s; int frame_idx; s = (struct state_video_compress_jpeg *) malloc(sizeof(struct state_video_compress_jpeg)); for (frame_idx = 0; frame_idx < 2; frame_idx++) { s->out[frame_idx] = NULL; } s->decoded = NULL; if(opts && strcmp(opts, "help") == 0) { printf("JPEG comperssion usage:\n"); printf("\t-c JPEG[:<quality>[:<restart_interval>]]\n"); return &compress_init_noerr; } else if(opts && strcmp(opts, "list_devices") == 0) { printf("CUDA devices:\n"); gpujpeg_print_devices_info(); return &compress_init_noerr; } s->restart_interval = -1; gpujpeg_set_default_parameters(&s->encoder_param); if(opts) { parse_fmt(s, opts); } else { printf("[JPEG] setting default encode parameters (quality: %d)\n", s->encoder_param.quality ); } int ret; printf("Initializing CUDA device %d...\n", cuda_devices[0]); ret = gpujpeg_init_device(cuda_devices[0], TRUE); if(ret != 0) { fprintf(stderr, "[JPEG] initializing CUDA device %d failed.\n", cuda_devices[0]); return NULL; } s->encoder = NULL; /* not yet configured */ platform_spin_init(&s->spin); module_init_default(&s->module_data); s->module_data.cls = MODULE_CLASS_DATA; s->module_data.priv_data = s; s->module_data.deleter = jpeg_compress_done; s->module_data.msg_callback = compress_change_callback; module_register(&s->module_data, parent); return &s->module_data; }
void * jpeg_compress_init(char * opts) { struct compress_jpeg_state *s; int frame_idx; s = (struct compress_jpeg_state *) malloc(sizeof(struct compress_jpeg_state)); for (frame_idx = 0; frame_idx < 2; frame_idx++) { s->out[frame_idx] = NULL; } s->decoded = NULL; if(opts && strcmp(opts, "help") == 0) { printf("JPEG comperssion usage:\n"); printf("\t-c JPEG[:<quality>]\n"); return NULL; } else if(opts && strcmp(opts, "list_devices") == 0) { printf("CUDA devices:\n"); gpujpeg_print_devices_info(); return NULL; } if(opts) { char *tok, *save_ptr = NULL; gpujpeg_set_default_parameters(&s->encoder_param); tok = strtok_r(opts, ":", &save_ptr); s->encoder_param.quality = atoi(tok); int ret; printf("Initializing CUDA device %d...\n", cuda_device); ret = gpujpeg_init_device(cuda_device, TRUE); if(ret != 0) { fprintf(stderr, "[JPEG] initializing CUDA device %d failed.\n", cuda_device); return NULL; } tok = strtok_r(NULL, ":", &save_ptr); if(tok) { fprintf(stderr, "[JPEG] WARNING: Trailing configuration parameters.\n"); } } else { gpujpeg_set_default_parameters(&s->encoder_param); printf("[JPEG] setting default encode parameters (quality: %d)\n", s->encoder_param.quality ); } s->encoder = NULL; /* not yet configured */ return s; }