![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
CUDA implementation of DXT compression. More...

Go to the source code of this file.
Classes | |
| struct | uvec2 |
| struct | uvec3 |
| struct | vec2 |
| struct | vec3 |
Typedefs | |
| typedef unsigned int | u32 |
| typedef u32 | UINT |
Functions | |
| static __device__ vec2 | abs (const vec2 &v) |
| static __device__ float | clamp (const float &v, float min_val, float max_val) |
| static __device__ vec2 | clamp (const vec2 &v, float min_val, float max_val) |
| static __device__ float | colorDistance (vec2 c0, vec2 c1) |
| static __device__ vec3 | ConvertRGBToYCoCg (vec3 color) |
| int | cuda_rgb_to_dxt1 (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_yuv422_to_yuv444 (const void *src, void *out, int pix_count, cuda_wrapper_stream_t str) |
| 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) |
| static __device__ float | dot (const vec3 &a, const vec3 &b) |
| template<int DXT_TYPE> | |
| __device__ void | dxt_encode (void *out, const int block_idx, float r[16], float g[16], float b[16]) |
| Encodes and saves the block. | |
| template<> | |
| __device__ void | dxt_encode< 1 > (void *out, const int block_idx, float r[16], float g[16], float b[16]) |
| Encodes the block into DXT1 format and saves it into output buffer. | |
| template<> | |
| __device__ void | dxt_encode< 6 > (void *out, const int block_idx, float r[16], float g[16], float b[16]) |
| template<bool YUV_TO_RGB, bool VERTICAL_MIRRORING, int DXT_TYPE> | |
| static __global__ void | dxt_kernel (const void *src, void *out, int size_x, int size_y) |
| template<bool YUV_TO_RGB, int DXT_TYPE> | |
| static int | dxt_launch (const void *src, void *out, int sx, int sy, cudaStream_t str) |
| Compute grid size and launch DXT kernel. | |
| static __device__ UINT | EmitAlphaEndPointsYCoCgDXT5 (float mincol, float maxcol) |
| static __device__ uvec2 | EmitAlphaIndicesYCoCgDXT5 (vec3 block[16], float minAlpha, float maxAlpha) |
| static __device__ UINT | EmitEndPointsYCoCgDXT5 (float &mincol_r, float &mincol_g, float &maxcol_r, float &maxcol_g, UINT scale) |
| static __device__ UINT | EmitIndicesYCoCgDXT5 (vec3 block[16], vec2 mincol, vec2 maxcol) |
| static __device__ u32 | encode_endpoint (float &r, float &g, float &b) |
| Encodes color palette endpoint into 565 code and adjusts input values. | |
| static __device__ void | FindMinMaxColorsBox (vec3 block[16], vec3 &mincol, vec3 &maxcol) |
| static __device__ void | InsetCoCgBBox (vec2 &mincol, vec2 &maxcol) |
| static __device__ void | InsetYBBox (float &mincol, float &maxcol) |
| static __device__ vec3 | lerp (const vec3 &a, const vec3 &b, const float q) |
| static __device__ vec2 | max (const vec2 &a, const vec2 &b) |
| static __device__ vec3 | max (const vec3 &a, const vec3 &b) |
| static __device__ vec2 | min (const vec2 &a, const vec2 &b) |
| static __device__ vec3 | min (const vec3 &a, const vec3 &b) |
| static __device__ vec3 | round (const vec3 &v) |
| static __device__ UINT | ScaleYCoCg (vec2 minColor, vec2 maxColor) |
| static __device__ bool | SelectYCoCgDiagonal (const vec3 block[16], vec2 minColor, vec2 maxColor) |
| template<typename T > | |
| static __device__ void | swap (T &a, T &b) |
| Swaps two referenced values. | |
| static __global__ void | yuv422_to_yuv444_kernel (const void *src, void *out, int pix_count) |
| static __device__ void | yuv_to_rgb (float &r, float &g, float &b) |
| Transform YUV to RGB. | |
Variables | |
| static __device__ const float | offset = 128.0 / 255.0 |
| typedef unsigned int u32 |
Definition at line 12 of file cuda_dxt.cu.
Definition at line 13 of file cuda_dxt.cu.
Definition at line 118 of file cuda_dxt.cu.
References vec2::g, and vec2::r.
Referenced by ldgm::ldgm(), downshift_with_dither(), main(), misc_test_color_coeff_range(), pbuf_process_stats(), AudioDriftFixer::scale_buffer_delta(), ScaleYCoCg(), set_audio_delay(), tx_update(), and AudioDriftFixer::update().
|
static |
Definition at line 110 of file cuda_dxt.cu.
Referenced by fill_full_to_limited_lut(), fill_limited_to_full_lut(), InsetCoCgBBox(), and InsetYBBox().
Definition at line 154 of file cuda_dxt.cu.
References dot().
Referenced by EmitIndicesYCoCgDXT5().

Definition at line 141 of file cuda_dxt.cu.
References vec3::b, vec2::g, offset, and vec2::r.
Referenced by dxt_encode< 6 >().
| int cuda_rgb_to_dxt1 | ( | const void * | src, |
| void * | out, | ||
| int | size_x, | ||
| int | size_y, | ||
| cuda_wrapper_stream_t | stream ) |
CUDA DXT1 compression (only RGB without alpha).
| src | Pointer to top-left source pixel in device-memory buffer. 8bit RGB samples are expected (no alpha and no padding). (Pointer must be aligned to multiples of 16 bytes.) |
| out | Pointer to output buffer in device memory. (Must be aligned to multiples of 8 bytes.) |
| size_x | Width of the input image (must be divisible by 4). |
| size_y | Height of the input image (must be divisible by 4). |
| stream | CUDA stream to run in, or 0 for default stream. |
Definition at line 782 of file cuda_dxt.cu.
References dxt_launch().
Referenced by main(), and worker_thread().

| int cuda_rgb_to_dxt6 | ( | const void * | src, |
| void * | out, | ||
| int | size_x, | ||
| int | size_y, | ||
| cuda_wrapper_stream_t | stream ) |
CUDA DXT6 (DXT5-YcOcG) compression (only RGB without alpha).
| src | Pointer to top-left source pixel in device-memory buffer. 8bit RGB samples are expected (no alpha and no padding). (Pointer must be aligned to multiples of 16 bytes.) |
| out | Pointer to output buffer in device memory. (Must be aligned to multiples of 8 bytes.) |
| size_x | Width of the input image (must be divisible by 4). |
| size_y | Height of the input image (must be divisible by 4). (Input is read bottom up if negative) |
| stream | CUDA stream to run in, or 0 for default stream. |
Definition at line 816 of file cuda_dxt.cu.
References dxt_launch().
Referenced by main(), and worker_thread().

| int cuda_yuv422_to_yuv444 | ( | const void * | src, |
| void * | out, | ||
| int | pix_count, | ||
| cuda_wrapper_stream_t | str ) |
Definition at line 762 of file cuda_dxt.cu.
References cudaSuccess, and yuv422_to_yuv444_kernel().

| int cuda_yuv_to_dxt1 | ( | const void * | src, |
| void * | out, | ||
| int | size_x, | ||
| int | size_y, | ||
| cuda_wrapper_stream_t | stream ) |
CUDA DXT1 compression (only RGB without alpha). Converts input from YUV to RGB color space.
| src | Pointer to top-left source pixel in device-memory buffer. 8bit RGB samples are expected (no alpha and no padding). (Pointer must be aligned to multiples of 16 bytes.) |
| out | Pointer to output buffer in device memory. (Must be aligned to multiples of 8 bytes.) |
| size_x | Width of the input image (must be divisible by 4). |
| size_y | Height of the input image (must be divisible by 4). |
| stream | CUDA stream to run in, or 0 for default stream. |
Definition at line 799 of file cuda_dxt.cu.
References dxt_launch().

| int cuda_yuv_to_dxt6 | ( | const void * | src, |
| void * | out, | ||
| int | size_x, | ||
| int | size_y, | ||
| cuda_wrapper_stream_t | stream ) |
Definition at line 821 of file cuda_dxt.cu.
References dxt_launch().

| __device__ void dxt_encode | ( | void * | out, |
| const int | block_idx, | ||
| float | r[16], | ||
| float | g[16], | ||
| float | b[16] ) |
Encodes and saves the block.
Referenced by dxt_kernel().
| __device__ void dxt_encode< 1 > | ( | void * | out, |
| const int | block_idx, | ||
| float | r[16], | ||
| float | g[16], | ||
| float | b[16] ) |
Encodes the block into DXT1 format and saves it into output buffer.
Definition at line 513 of file cuda_dxt.cu.
References encode_endpoint(), max, min, and swap().

| __device__ void dxt_encode< 6 > | ( | void * | out, |
| const int | block_idx, | ||
| float | r[16], | ||
| float | g[16], | ||
| float | b[16] ) |
Encodes the block into DXT6 format (DXT5-YcOcG) and saves it into output buffer
Definition at line 472 of file cuda_dxt.cu.
References vec3::b, ConvertRGBToYCoCg(), EmitAlphaEndPointsYCoCgDXT5(), EmitAlphaIndicesYCoCgDXT5(), EmitEndPointsYCoCgDXT5(), EmitIndicesYCoCgDXT5(), FindMinMaxColorsBox(), uvec2::g, vec2::g, vec3::gb(), InsetYBBox(), uvec2::r, vec2::r, ScaleYCoCg(), and SelectYCoCgDiagonal().

|
static |
DXT compression - each thread compresses one 4x4 DXT block. Alpha-color palette mode is not used (always emmits 4color palette code).
Definition at line 623 of file cuda_dxt.cu.
References dxt_encode(), and yuv_to_rgb().
Referenced by dxt_launch().

|
static |
Compute grid size and launch DXT kernel.
Definition at line 736 of file cuda_dxt.cu.
References cudaSuccess, and dxt_kernel().
Referenced by cuda_rgb_to_dxt1(), cuda_rgb_to_dxt6(), cuda_yuv_to_dxt1(), and cuda_yuv_to_dxt6().

|
static |
Definition at line 350 of file cuda_dxt.cu.
References uvec2::g, and uvec2::r.
Referenced by dxt_encode< 6 >().
|
static |
Definition at line 360 of file cuda_dxt.cu.
References uvec2::g, uvec2::r, and vec2::r.
Referenced by dxt_encode< 6 >().
|
static |
Definition at line 272 of file cuda_dxt.cu.
References uvec2::g, vec2::g, InsetCoCgBBox(), offset, uvec2::r, vec2::r, and round().
Referenced by dxt_encode< 6 >().

Definition at line 315 of file cuda_dxt.cu.
References colorDistance(), and lerp().
Referenced by dxt_encode< 6 >().

|
static |
Encodes color palette endpoint into 565 code and adjusts input values.
Definition at line 424 of file cuda_dxt.cu.
Referenced by dxt_encode< 1 >().
Definition at line 159 of file cuda_dxt.cu.
Referenced by dxt_encode< 6 >().
Definition at line 182 of file cuda_dxt.cu.
References clamp().
Referenced by EmitEndPointsYCoCgDXT5().

|
static |
Definition at line 176 of file cuda_dxt.cu.
References clamp().
Referenced by dxt_encode< 6 >().

Definition at line 126 of file cuda_dxt.cu.
Referenced by EmitIndicesYCoCgDXT5().
Definition at line 122 of file cuda_dxt.cu.
References vec3::b, vec2::g, and vec2::r.
Referenced by delay_init(), EmitEndPointsYCoCgDXT5(), format_interl_fps_hdr_row(), generate_audio_sine(), get_ebu_signal(), get_framerate_d(), get_framerate_n(), get_framerate_test_free(), get_refresh_rate(), gl_reconfigure_screen(), glfw_resize_window(), and DecklinkAudioSummary::set_buffer_average().
Definition at line 241 of file cuda_dxt.cu.
References abs(), vec2::g, max, offset, and vec2::r.
Referenced by dxt_encode< 6 >().

|
static |
Definition at line 260 of file cuda_dxt.cu.
References vec2::g, vec3::gb(), and vec2::r.
Referenced by dxt_encode< 6 >().

|
static |
Swaps two referenced values.
Definition at line 456 of file cuda_dxt.cu.
Referenced by dxt_encode< 1 >(), gl_process_frames(), and vidcap_deltacast_dvi_grab().
|
static |
Definition at line 697 of file cuda_dxt.cu.
Referenced by cuda_yuv422_to_yuv444().
|
static |
Transform YUV to RGB.
Definition at line 444 of file cuda_dxt.cu.
Referenced by dxt_kernel().
|
static |
Definition at line 139 of file cuda_dxt.cu.
Referenced by audio_tx_send_standard(), ConvertRGBToYCoCg(), rs::decode(), decode_audio_frame(), decode_video_frame(), draw_line(), EmitEndPointsYCoCgDXT5(), frame_decode_int(), frame_encode_int(), frame_encode_int_big(), frame_encode_staircase(), libavcodec_compress(), packet_counter_register_packet(), pw_frame_to_uv_frame_memcpy(), packet_counter::register_packet(), audio_frame2::replace(), ScaleYCoCg(), vidcap_state_aja::SetupHDMI(), vidcap_state_aja::SetupVideo(), ts_add_nsec(), tv_add_usec(), video_pattern_generator_create(), and wav_seek().