![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include <algorithm>#include <cassert>#include <cmpto_j2k_dec.h>#include <cstdint>#include <cstdlib>#include <cstring>#include <mutex>#include <ostream>#include <pthread.h>#include <queue>#include <utility>#include "cuda_wrapper/kernels.hpp"#include "debug.h"#include "host.h"#include "lib_common.h"#include "pixfmt_conv.h"#include "types.h"#include "utils/macros.h"#include "utils/misc.h"#include "utils/parallel_conv.h"#include "video_codec.h"#include "video_decompress.h"
Go to the source code of this file.
Classes | |
| struct | conv_props |
| struct | state_decompress_j2k |
| struct | state_decompress_j2k::desc |
Macros | |
| #define | CHECK_OK(cmd, err_msg, action_fail) |
| #define | CPU_CONV_PARAM "j2k-dec-cpu-conv" |
| #define | NOOP ((void) 0) |
Functions | |
| ADD_TO_PARAM ("j2k-dec-encoder-queue", "* j2k-encoder-queue=<len>\n" " max number of frames held by encoder\n") | |
| ADD_TO_PARAM ("j2k-dec-mem-limit", "* j2k-dec-mem-limit=<limit>\n" " J2K max memory usage in bytes.\n") | |
| ADD_TO_PARAM ("j2k-dec-queue-len", "* j2k-queue-len=<len>\n" " max queue len\n") | |
| ADD_TO_PARAM ("j2k-dec-tile-limit", "* j2k-dec-tile-limit=<limit>\n" " number of tiles decoded at moment (less to reduce latency, more to increase performance, 0 unlimited)\n") | |
| ADD_TO_PARAM (CPU_CONV_PARAM, "* " CPU_CONV_PARAM "\n" " Enforce CPU conversion instead of CUDA (applicable to R12L now)\n") | |
| static void * | decompress_j2k_worker (void *args) |
| static decompress_status | j2k_decompress (void *state, unsigned char *dst, unsigned char *buffer, unsigned int src_len, int, struct video_frame_callbacks *, struct pixfmt_desc *internal_prop) |
| static void | j2k_decompress_cleanup_common (struct state_decompress_j2k *s) |
| static void | j2k_decompress_done (void *state) |
| static int | j2k_decompress_get_priority (codec_t compression, struct pixfmt_desc internal, codec_t ugc) |
| static int | j2k_decompress_get_property (void *state, int property, void *val, size_t *len) |
| static void * | j2k_decompress_init (void) |
| static int | j2k_decompress_reconfigure (void *state, struct video_desc desc, int rshift, int gshift, int bshift, int pitch, codec_t out_codec) |
| static decompress_status | j2k_probe_internal_codec (codec_t in_codec, unsigned char *buffer, size_t len, struct pixfmt_desc *internal_prop) |
| static void | print_dropped (unsigned long long int dropped) |
| static void | r12l_postprocessor_get_sz (void *, void *, size_t, int size_x, int size_y, struct cmpto_j2k_dec_comp_format *, int comp_count, size_t *temp_buffer_size, size_t *output_buffer_size) |
| REGISTER_MODULE (j2k, &j2k_decompress_info, LIBRARY_CLASS_VIDEO_DECOMPRESS, VIDEO_DECOMPRESS_ABI_VERSION) | |
| static void | release_cstream (void *custom_data, size_t custom_data_size, const void *codestream, size_t codestream_size) |
| static void | rg48_to_r12l (unsigned char *dst_buffer, unsigned char *src_buffer, unsigned int width, unsigned int height) |
| static bool | set_postprocess_convert (struct state_decompress_j2k *s, struct cmpto_j2k_dec_ctx_cfg *ctx_cfg, const struct conv_props *codec) |
Variables | |
| static const struct conv_props | codecs [] |
| constexpr const int | DEFAULT_MAX_IN_FRAMES = 4 |
| maximal number of concurrently decompressed frames | |
| constexpr const int | DEFAULT_MAX_QUEUE_SIZE = 2 |
| maximal size of queue for decompressed frames | |
| constexpr const int64_t | DEFAULT_MEM_LIMIT = 1000000000LL |
| constexpr const int | DEFAULT_TILE_LIMIT = 2 |
| static const struct video_decompress_info | j2k_decompress_info |
| constexpr const char * | MOD_NAME = "[J2K dec.] " |
| const cmpto_j2k_dec_postprocessor_run_callback_cuda | r12l_postprocess_cuda |
Some of the concepts are similar to encoder (eg. keeping limited number of frames in decoder) so please refer to that file.
Problematic part of following code is that UltraGrid decompress API is synchronous only while the CMPTO J2K decoder is inherently asynchronous. Threrefore the integration works in following fashion:
Definition in file cmpto_j2k.cpp.
| #define CHECK_OK | ( | cmd, | |
| err_msg, | |||
| action_fail ) |
Definition at line 125 of file cmpto_j2k.cpp.
Referenced by decompress_j2k_worker(), j2k_decompress(), j2k_decompress_reconfigure(), and set_postprocess_convert().
| #define CPU_CONV_PARAM "j2k-dec-cpu-conv" |
Definition at line 297 of file cmpto_j2k.cpp.
Referenced by set_postprocess_convert().
| #define NOOP ((void) 0) |
Definition at line 133 of file cmpto_j2k.cpp.
Referenced by decompress_j2k_worker(), and j2k_decompress_reconfigure().
| ADD_TO_PARAM | ( | "j2k-dec-encoder-queue" | ) |
| ADD_TO_PARAM | ( | "j2k-dec-mem-limit" | ) |
| ADD_TO_PARAM | ( | "j2k-dec-queue-len" | ) |
| ADD_TO_PARAM | ( | "j2k-dec-tile-limit" | ) |
| ADD_TO_PARAM | ( | CPU_CONV_PARAM | , |
| "* " CPU_CONV_PARAM "\n" " Enforce CPU conversion instead of CUDA (applicable to R12L now)\n" | ) |
|
static |
This function just runs in thread and gets decompressed images from decoder putting them to queue (or dropping if full).
Definition at line 165 of file cmpto_j2k.cpp.
References CHECK_OK, state_decompress_j2k::convert, state_decompress_j2k::decoder, state_decompress_j2k::decompressed_frames, state_decompress_j2k::dropped, state_decompress_j2k::in_frames, len, state_decompress_j2k::lock, LOG_LEVEL_ERROR, log_msg(), state_decompress_j2k::max_queue_size, NOOP, state_decompress_j2k::out_codec, print_dropped(), and vc_get_linesize().
Referenced by j2k_decompress_reconfigure().

|
static |
Main decompress function - passes frame to the codec and checks if there are some decoded frames. If so, copies that to framebuffer. In the opposite case it just returns false.
Definition at line 468 of file cmpto_j2k.cpp.
References CHECK_OK, state_decompress_j2k::decoder, DECODER_GOT_FRAME, DECODER_NO_FRAME, state_decompress_j2k::decompressed_frames, state_decompress_j2k::dropped, state_decompress_j2k::in_frames, j2k_probe_internal_codec(), state_decompress_j2k::lock, LOG, LOG_LEVEL_WARNING, state_decompress_j2k::max_in_frames, MOD_NAME, state_decompress_j2k::out_codec, state_decompress_j2k::pitch, print_dropped(), release_cstream(), state_decompress_j2k::settings, state, vc_get_linesize(), and VIDEO_CODEC_NONE.

|
static |
Definition at line 546 of file cmpto_j2k.cpp.
References state_decompress_j2k::convert, state_decompress_j2k::decoder, state_decompress_j2k::decompressed_frames, LOG_LEVEL_VERBOSE, log_msg(), state_decompress_j2k::settings, and state_decompress_j2k::thread_id.
Referenced by j2k_decompress_done(), and j2k_decompress_reconfigure().

|
static |
Definition at line 570 of file cmpto_j2k.cpp.
References j2k_decompress_cleanup_common(), and state.

|
static |
Definition at line 577 of file cmpto_j2k.cpp.
References codec_is_a_rgb(), codecs, J2K, J2KR, VC_NONE, VDEC_PRIO_NA, and VDEC_PRIO_PROBE_HI.

|
static |
Definition at line 525 of file cmpto_j2k.cpp.
References DECOMPRESS_PROPERTY_ACCEPTS_CORRUPTED_FRAME, len, property, state, UNUSED, and val.
|
static |
Definition at line 230 of file cmpto_j2k.cpp.
References DEFAULT_MAX_IN_FRAMES, DEFAULT_MAX_QUEUE_SIZE, get_commandline_param(), LOG, LOG_LEVEL_INFO, MOD_NAME, and unit_evaluate_dbl().

|
static |
Definition at line 329 of file cmpto_j2k.cpp.
References CHECK_OK, cmpto_sf, codecs, cuda_devices, cuda_devices_count, state_decompress_j2k::decoder, decompress_j2k_worker(), desc, fmt, get_bits_per_component(), get_bpp(), get_codec_name(), j2k_decompress_cleanup_common(), LOG, LOG_LEVEL_ERROR, LOG_LEVEL_NOTICE, MOD_NAME, NOOP, state_decompress_j2k::out_codec, state_decompress_j2k::pitch, R12L, state_decompress_j2k::req_mem_limit, state_decompress_j2k::req_tile_limit, RGBA, set_postprocess_convert(), state_decompress_j2k::settings, state, state_decompress_j2k::thread_id, vc_get_linesize(), VIDEO_CODEC_NONE, and video_desc::width.

|
static |
Definition at line 429 of file cmpto_j2k.cpp.
References DECODER_GOT_CODEC, DECODER_NO_FRAME, pixfmt_desc::depth, get_pixdesc_desc(), J2KR, len, LOG_LEVEL_ERROR, LOG_LEVEL_VERBOSE, LOG_LEVEL_WARNING, log_msg(), pixfmt_desc::rgb, and pixfmt_desc::subsampling.
Referenced by j2k_decompress().

|
static |
Definition at line 153 of file cmpto_j2k.cpp.
References LOG_LEVEL_INFO, LOG_LEVEL_WARNING, log_msg(), log_msg_once(), and to_fourcc.
Referenced by decompress_j2k_worker(), and j2k_decompress().

|
static |
Definition at line 260 of file cmpto_j2k.cpp.
References R12L, and vc_get_datalen().

| REGISTER_MODULE | ( | j2k | , |
| & | j2k_decompress_info, | ||
| LIBRARY_CLASS_VIDEO_DECOMPRESS | , | ||
| VIDEO_DECOMPRESS_ABI_VERSION | ) |
|
static |
Callback called by the codec when codestream is no longer required.
Definition at line 423 of file cmpto_j2k.cpp.
Referenced by j2k_decompress().
|
static |
Definition at line 135 of file cmpto_j2k.cpp.
References DEBUG, get_decoder_from_to(), get_time_in_ns(), log_level, LOG_LEVEL_DEBUG, MSG, NS_TO_MS, parallel_pix_conv(), R12L, RG48, vc_copylineRG48toR12L(), and vc_get_linesize().

|
static |
Definition at line 303 of file cmpto_j2k.cpp.
References CHECK_OK, state_decompress_j2k::convert, CPU_CONV_PARAM, cuda_devices_count, get_commandline_param(), and MSG.
Referenced by j2k_decompress_reconfigure().

|
static |
Referenced by j2k_decompress_get_priority(), and j2k_decompress_reconfigure().
|
constexpr |
maximal number of concurrently decompressed frames
Definition at line 84 of file cmpto_j2k.cpp.
Referenced by j2k_decompress_init().
|
constexpr |
maximal size of queue for decompressed frames
Definition at line 82 of file cmpto_j2k.cpp.
Referenced by j2k_decompress_init().
|
constexpr |
Definition at line 85 of file cmpto_j2k.cpp.
|
constexpr |
Definition at line 80 of file cmpto_j2k.cpp.
|
static |
Definition at line 600 of file cmpto_j2k.cpp.
|
constexpr |
Definition at line 86 of file cmpto_j2k.cpp.
Referenced by j2k_decompress(), j2k_decompress_init(), and j2k_decompress_reconfigure().
| const cmpto_j2k_dec_postprocessor_run_callback_cuda r12l_postprocess_cuda |
Definition at line 273 of file cmpto_j2k.cpp.