![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include <cassert>#include <climits>#include <condition_variable>#include <mutex>#include <utility>#include <cmpto_j2k_enc.h>#include "debug.h"#include "host.h"#include "lib_common.h"#include "module.h"#include "tv.h"#include "utils/color_out.h"#include "utils/macros.h"#include "utils/misc.h"#include "utils/parallel_conv.h"#include "utils/video_frame_pool.h"#include "video_codec.h"#include "video_compress.h"#include "video_frame.h"
Go to the source code of this file.
Classes | |
| struct | custom_data |
| auxilliary data structure passed with encoded frame More... | |
| struct | state_video_compress_j2k |
| struct | state_video_compress_j2k::module_data |
Macros | |
| #define | ASSIGN_CHECK_VAL(var, str, minval) |
| #define | CHECK_OK(cmd, err_msg, action_fail) |
| #define | CPU_CONV_PARAM "j2k-enc-cpu-conv" |
| #define | DEFAULT_MEM_LIMIT 1000000000LLU |
| #define | DEFAULT_POOL_SIZE 4 |
| #define | DEFAULT_QUALITY 0.7 |
| #define | DEFAULT_TILE_LIMIT 1 |
| number of frames that encoder encodes at moment | |
| #define | HANDLE_ERROR_COMPRESS_POP do { cmpto_j2k_enc_img_destroy(img); goto start; } while (0) |
| #define | HANDLE_ERROR_COMPRESS_PUSH |
| #define | MOD_NAME "[Cmpto J2K enc.] " |
| #define | NOOP ((void) 0) |
Functions | |
| ADD_TO_PARAM (CPU_CONV_PARAM, "* " CPU_CONV_PARAM "\n" " Enforce CPU conversion instead of CUDA (applicable to R12L now)\n") | |
| static void | cleanup_common (struct state_video_compress_j2k *s) |
| static bool | configure_with (struct state_video_compress_j2k *s, struct video_desc desc) |
| static void | do_gpu_copy (std::shared_ptr< video_frame > &ret, video_frame *in_frame) |
| copies frame from RAM to GPU | |
| static compress_module_info | get_cmpto_j2k_module_info () |
| static shared_ptr< video_frame > | get_copy (struct state_video_compress_j2k *s, video_frame *frame) |
| static void | j2k_compress_done (struct module *mod) |
| static struct module * | j2k_compress_init (struct module *parent, const char *c_cfg) |
| static std::shared_ptr< video_frame > | j2k_compress_pop (struct module *state) |
| static void | j2k_compress_push (struct module *state, std::shared_ptr< video_frame > tx) |
| static void | j2k_compressed_frame_dispose (struct video_frame *frame) |
| static void | parallel_conv (video_frame *dst, video_frame *src) |
| REGISTER_MODULE (cmpto_j2k, &j2k_compress_info, LIBRARY_CLASS_VIDEO_COMPRESS, VIDEO_COMPRESS_ABI_VERSION) | |
| static void | release_cstream (void *custom_data, size_t custom_data_size, const void *codestream, size_t codestream_size) |
| static void | release_cstream_cuda (void *img_custom_data, size_t img_custom_data_size, int, const void *samples, size_t samples_size) |
| static void | set_pool (struct state_video_compress_j2k *s, bool have_gpu_preprocess) |
| static void | usage () |
Variables | ||
| struct { | ||
| enum cmpto_sample_format_type cmpto_sf | ||
| codec_t convert_codec | ||
| cmpto_j2k_enc_preprocessor_run_callback_cuda cuda_convert_func | ||
| codec_t ug_codec | ||
| } | codecs [] | |
| static struct video_compress_info | j2k_compress_info | |
| const cmpto_j2k_enc_preprocessor_run_callback_cuda | r12l_to_rg48_cuda | |
| struct { | ||
| const char * description | ||
| const bool is_boolean | ||
| const char * key | ||
| const char * label | ||
| const char * opt_str | ||
| const char * placeholder | ||
| } | usage_opts [] | |
Main idea behind the code below is to control how many frames the encoder holds. The codec itself doesn't have a limit, thus without that it is possible to run out of memory. This is possible even in the case when the GPU is powerful enough due to the fact that CUDA registers the new buffers which is very slow and because of that the frames cumulate before the GPU encoder.
Definition in file cmpto_j2k.cpp.
| #define ASSIGN_CHECK_VAL | ( | var, | |
| str, | |||
| minval ) |
Definition at line 507 of file cmpto_j2k.cpp.
Referenced by j2k_compress_init().
| #define CHECK_OK | ( | cmd, | |
| err_msg, | |||
| action_fail ) |
Definition at line 82 of file cmpto_j2k.cpp.
Referenced by configure_with(), j2k_compress_pop(), and j2k_compress_push().
| #define CPU_CONV_PARAM "j2k-enc-cpu-conv" |
Definition at line 206 of file cmpto_j2k.cpp.
Referenced by configure_with(), and usage().
| #define DEFAULT_MEM_LIMIT 1000000000LLU |
Definition at line 99 of file cmpto_j2k.cpp.
| #define DEFAULT_POOL_SIZE 4 |
default max size of state_video_compress_j2k::pool and also value for state_video_compress_j2k::max_in_frames
Definition at line 95 of file cmpto_j2k.cpp.
| #define DEFAULT_QUALITY 0.7 |
Definition at line 92 of file cmpto_j2k.cpp.
| #define DEFAULT_TILE_LIMIT 1 |
number of frames that encoder encodes at moment
Definition at line 98 of file cmpto_j2k.cpp.
| #define HANDLE_ERROR_COMPRESS_POP do { cmpto_j2k_enc_img_destroy(img); goto start; } while (0) |
Definition at line 397 of file cmpto_j2k.cpp.
Referenced by j2k_compress_pop().
| #define HANDLE_ERROR_COMPRESS_PUSH |
Definition at line 592 of file cmpto_j2k.cpp.
Referenced by j2k_compress_push().
| #define MOD_NAME "[Cmpto J2K enc.] " |
Definition at line 80 of file cmpto_j2k.cpp.
Referenced by j2k_compress_init().
| #define NOOP ((void) 0) |
Definition at line 91 of file cmpto_j2k.cpp.
Referenced by configure_with(), j2k_compress_pop(), and j2k_compress_push().
| ADD_TO_PARAM | ( | CPU_CONV_PARAM | , |
| "* " CPU_CONV_PARAM "\n" " Enforce CPU conversion instead of CUDA (applicable to R12L now)\n" | ) |
|
static |
Definition at line 704 of file cmpto_j2k.cpp.
References state_video_compress_j2k::context, and state_video_compress_j2k::enc_settings.
Referenced by configure_with(), and j2k_compress_done().
|
static |
Definition at line 237 of file cmpto_j2k.cpp.
References CHECK_OK, cleanup_common(), codec_is_a_rgb(), codecs, video_desc::color_spec, state_video_compress_j2k::compressed_desc, state_video_compress_j2k::configure_cv, state_video_compress_j2k::configured, state_video_compress_j2k::context, CPU_CONV_PARAM, cuda_convert_func, cuda_devices, cuda_devices_count, desc, state_video_compress_j2k::enc_settings, format_in_si_units(), video_desc::fps, state_video_compress_j2k::frame_popped, get_commandline_param(), video_desc::height, state_video_compress_j2k::in_frames, J2K, J2KR, state_video_compress_j2k::lock, LOG_LEVEL_ERROR, log_msg(), state_video_compress_j2k::max_in_frames, state_video_compress_j2k::mct, state_video_compress_j2k::mem_limit, MSG, NOOP, state_video_compress_j2k::precompress_codec, state_video_compress_j2k::quality, state_video_compress_j2k::rate, state_video_compress_j2k::saved_desc, set_pool(), snprintf_ch, video_desc::tile_count, state_video_compress_j2k::tile_limit, and video_desc::width.
Referenced by j2k_compress_push().

|
static |
copies frame from RAM to GPU
Does the pixel format conversion as well if specified.
Definition at line 349 of file cmpto_j2k.cpp.
References cuda_devices, cuda_wrapper_memcpy(), CUDA_WRAPPER_MEMCPY_HOST_TO_DEVICE, cuda_wrapper_set_device(), tile::data, tile::data_len, and video_frame::tiles.
Referenced by get_copy().

|
static |
Definition at line 717 of file cmpto_j2k.cpp.
References codec_info, compress_module_info::codecs, codec_info_t::name, compress_module_info::name, compress_module_info::opts, and usage_opts.
|
static |
Definition at line 362 of file cmpto_j2k.cpp.
References tile::data, tile::data_len, do_gpu_copy(), frame, video_frame_pool::get_frame(), parallel_conv(), state_video_compress_j2k::pool, state_video_compress_j2k::pool_in_device_memory, state_video_compress_j2k::precompress_codec, video_frame::tiles, and VC_NONE.
Referenced by j2k_compress_push().

|
static |
Definition at line 695 of file cmpto_j2k.cpp.
References cleanup_common(), and module::priv_data.
Referenced by j2k_compress_init().

Definition at line 520 of file cmpto_j2k.cpp.
References ASSIGN_CHECK_VAL, INIT_NOERR, IS_KEY_PREFIX, j2k_compress_done(), LOG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, log_msg(), MOD_NAME, MODULE_CLASS_DATA, module_init_default(), module_register(), parent, and usage().

|
static |
Definition at line 398 of file cmpto_j2k.cpp.
References video_frame::callbacks, CHECK_OK, video_frame::compress_end, tile::data, tile::data_len, custom_data::desc, video_frame_callbacks::dispose, get_time_in_ns(), HANDLE_ERROR_COMPRESS_POP, j2k_compressed_frame_dispose(), len, LOG_LEVEL_ERROR, log_msg(), custom_data::metadata, NOOP, start(), state, video_frame::tiles, vf_alloc_desc(), and vf_restore_metadata().

|
static |
Definition at line 601 of file cmpto_j2k.cpp.
References CHECK_OK, video_desc::color_spec, state_video_compress_j2k::compressed_desc, state_video_compress_j2k::configure_cv, configure_with(), state_video_compress_j2k::configured, state_video_compress_j2k::context, cuda_devices, custom_data::desc, desc, state_video_compress_j2k::enc_settings, custom_data::frame, state_video_compress_j2k::frame_popped, get_copy(), HANDLE_ERROR_COMPRESS_PUSH, video_desc::height, state_video_compress_j2k::in_frames, state_video_compress_j2k::lock, state_video_compress_j2k::max_in_frames, custom_data::metadata, NOOP, state_video_compress_j2k::pool, state_video_compress_j2k::pool_in_device_memory, state_video_compress_j2k::precompress_codec, video_frame_pool::reconfigure(), release_cstream(), release_cstream_cuda(), state_video_compress_j2k::saved_desc, state_video_compress_j2k::should_exit, state, vc_get_datalen(), vc_get_linesize(), VC_NONE, vf_store_metadata(), video_desc_eq(), video_desc_from_frame(), and video_desc::width.

|
static |
Definition at line 571 of file cmpto_j2k.cpp.
References tile::data, frame, video_frame::tiles, and vf_free().
Referenced by j2k_compress_pop().

|
static |
Definition at line 167 of file cmpto_j2k.cpp.
References video_frame::color_spec, tile::data, DEBUG, get_decoder_from_to(), get_time_in_ns(), tile::height, log_level, LOG_LEVEL_DEBUG, MSG, NS_TO_MS, parallel_pix_conv(), video_frame::tiles, vc_get_linesize(), and tile::width.
Referenced by get_copy().

| REGISTER_MODULE | ( | cmpto_j2k | , |
| & | j2k_compress_info, | ||
| LIBRARY_CLASS_VIDEO_COMPRESS | , | ||
| VIDEO_COMPRESS_ABI_VERSION | ) |
|
static |
Definition at line 577 of file cmpto_j2k.cpp.
References custom_data::frame.
Referenced by j2k_compress_push(), and release_cstream_cuda().
|
static |
Definition at line 585 of file cmpto_j2k.cpp.
References release_cstream().
Referenced by j2k_compress_push().

|
static |
Definition at line 212 of file cmpto_j2k.cpp.
References cuda_devices_count, cuda_wrapper_free(), cuda_wrapper_free_host(), cuda_wrapper_malloc(), cuda_wrapper_malloc_host(), state_video_compress_j2k::max_in_frames, MSG, state_video_compress_j2k::pool, state_video_compress_j2k::pool_in_device_memory, state_video_compress_j2k::precompress_codec, and VC_NONE.
Referenced by configure_with().

|
static |
Definition at line 468 of file cmpto_j2k.cpp.
References color_printf(), CPU_CONV_PARAM, TBOLD, TERM_BOLD, TERM_RESET, TRED, and usage_opts.
Referenced by j2k_compress_init().

| enum cmpto_sample_format_type cmpto_sf |
Definition at line 193 of file cmpto_j2k.cpp.
Referenced by j2k_decompress_reconfigure().
| struct { ... } codecs[] |
Referenced by configure_with().
| codec_t convert_codec |
Definition at line 194 of file cmpto_j2k.cpp.
| cmpto_j2k_enc_preprocessor_run_callback_cuda cuda_convert_func |
Definition at line 195 of file cmpto_j2k.cpp.
Referenced by configure_with().
| const char* description |
Definition at line 455 of file cmpto_j2k.cpp.
| const bool is_boolean |
Definition at line 457 of file cmpto_j2k.cpp.
Referenced by dev_add_option().
|
static |
Definition at line 736 of file cmpto_j2k.cpp.
| const char* key |
Definition at line 454 of file cmpto_j2k.cpp.
| const char* label |
Definition at line 453 of file cmpto_j2k.cpp.
| const char* opt_str |
Definition at line 456 of file cmpto_j2k.cpp.
| const char* placeholder |
Definition at line 458 of file cmpto_j2k.cpp.
| const cmpto_j2k_enc_preprocessor_run_callback_cuda r12l_to_rg48_cuda |
Definition at line 184 of file cmpto_j2k.cpp.
| codec_t ug_codec |
Definition at line 192 of file cmpto_j2k.cpp.
| struct { ... } usage_opts[] |
Referenced by get_cmpto_j2k_module_info(), and usage().