UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
ldgm.cpp File Reference
#include "config_unix.h"
#include "config_win32.h"
#include <cerrno>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "debug.h"
#include "host.h"
#include "ldgm.h"
#include "lib_common.h"
#include "ldgm/src/ldgm-session.h"
#include "ldgm/src/ldgm-session-cpu.h"
#include "ldgm/src/ldgm-session-gpu.h"
#include "ldgm/matrix-gen/matrix-generator.h"
#include "ldgm/matrix-gen/ldpc-matrix.h"
#include "rtp/rtp.h"
#include "rtp/rtp_callback.h"
#include "transmit.h"
#include "utils/color_out.h"
#include "video.h"
Include dependency graph for ldgm.cpp:

Go to the source code of this file.

Classes

struct  configuration_t
 

Macros

#define DEFAULT_C   5
 
#define DEFAULT_K   512
 
#define DEFAULT_M   384
 
#define JPEG60_SIZE   (144 * 1000)
 
#define JPEG80_SIZE   (177 * 1000)
 
#define JPEG90_SIZE   (217 * 1000)
 
#define MAX_C   63
 
#define MAX_K   (1<<13) - 1
 
#define MIN_C   2
 
#define MINIMAL_VALUE   64
 
#define MOD_NAME   "[ldgm] "
 
#define PCT10   10.0
 
#define PCT2   2.0
 
#define PCT5   5.0
 
#define UNCOMPRESSED_SIZE   (1920 * 1080 * 2)
 
#define WANT_MKDIR
 

Typedefs

typedef double loss_t
 

Enumerations

enum  packet_type_t { STD1500 = 1500 , JUMBO9000 = 9000 }
 

Functions

 ADD_TO_PARAM ("ldgm-device", "* ldgm-device={CPU|GPU}\n" " specify whether use CPU or GPU for LDGM\n")
 
static void check_packet_size (size_t len, int k)
 
static bool file_exists (char *filename)
 
static void usage (void)
 

Variables

loss_t losses []
 
const configuration_t suggested_configurations []
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

Definition in file ldgm.cpp.

Macro Definition Documentation

◆ DEFAULT_C

#define DEFAULT_C   5

Definition at line 142 of file ldgm.cpp.

Referenced by ldgm::ldgm(), and usage().

◆ DEFAULT_K

#define DEFAULT_K   512

Definition at line 140 of file ldgm.cpp.

Referenced by ldgm::ldgm(), and usage().

◆ DEFAULT_M

#define DEFAULT_M   384

Definition at line 141 of file ldgm.cpp.

Referenced by ldgm::ldgm(), and usage().

◆ JPEG60_SIZE

#define JPEG60_SIZE   (144 * 1000)

Definition at line 108 of file ldgm.cpp.

◆ JPEG80_SIZE

#define JPEG80_SIZE   (177 * 1000)

Definition at line 109 of file ldgm.cpp.

◆ JPEG90_SIZE

#define JPEG90_SIZE   (217 * 1000)

Definition at line 110 of file ldgm.cpp.

◆ MAX_C

#define MAX_C   63

Definition at line 144 of file ldgm.cpp.

Referenced by ldgm::ldgm(), and usage().

◆ MAX_K

#define MAX_K   (1<<13) - 1

Definition at line 145 of file ldgm.cpp.

Referenced by ldgm::ldgm(), rs::rs(), rs::rs(), rs::encode(), rs::encode(), and usage().

◆ MIN_C

#define MIN_C   2

Definition at line 143 of file ldgm.cpp.

Referenced by ldgm::ldgm(), and usage().

◆ MINIMAL_VALUE

#define MINIMAL_VALUE   64

reasonable minimum (seems that 32 crashes sometimes)

Todo
Check why doesn't lower values work out

Definition at line 138 of file ldgm.cpp.

Referenced by ldgm::ldgm(), and usage().

◆ MOD_NAME

#define MOD_NAME   "[ldgm] "

Definition at line 79 of file ldgm.cpp.

◆ PCT10

#define PCT10   10.0

Definition at line 98 of file ldgm.cpp.

◆ PCT2

#define PCT2   2.0

Definition at line 96 of file ldgm.cpp.

◆ PCT5

#define PCT5   5.0

Definition at line 97 of file ldgm.cpp.

◆ UNCOMPRESSED_SIZE

#define UNCOMPRESSED_SIZE   (1920 * 1080 * 2)

Definition at line 112 of file ldgm.cpp.

◆ WANT_MKDIR

#define WANT_MKDIR

Definition at line 38 of file ldgm.cpp.

Typedef Documentation

◆ loss_t

typedef double loss_t

Definition at line 99 of file ldgm.cpp.

Enumeration Type Documentation

◆ packet_type_t

Enumerator
STD1500 
JUMBO9000 

Definition at line 81 of file ldgm.cpp.

81 {
82 STD1500 = 1500,
83 JUMBO9000 = 9000,
packet_type_t
Definition ldgm.cpp:81
@ STD1500
Definition ldgm.cpp:82
@ JUMBO9000
Definition ldgm.cpp:83

Function Documentation

◆ ADD_TO_PARAM()

ADD_TO_PARAM ( "ldgm-device" )

◆ check_packet_size()

static void check_packet_size ( size_t len,
int k )
static

Definition at line 403 of file ldgm.cpp.

404{
405 enum { SHMEM_SIZE = 48 * 1024 };
406 static bool printed = false;
407 if (printed) {
408 return;
409 }
410 const size_t packet_size = len / k + 4;
411 if (packet_size < SHMEM_SIZE) {
412 return;
413 }
414
415 printed = true;
416 const char *dev = get_commandline_param("ldgm-device");
417 if (dev == nullptr|| strcasecmp(dev, "GPU") != 0) {
418 return;
419 }
420 MSG(WARNING,
421 "Packet size is %zu B, which may exceed GPU memory, which is "
422 "usually %d.\nYou can try to increase the parameter K.\n",
423 packet_size, SHMEM_SIZE);
424}
int void size_t * len
#define MSG(l, fmt,...)
Definition debug.h:96
const char * get_commandline_param(const char *key)
Definition host.cpp:894

References get_commandline_param(), len, and MSG.

Here is the call graph for this function:

◆ file_exists()

static bool file_exists ( char * filename)
static

Definition at line 150 of file ldgm.cpp.

151{
152 struct stat sb;
153 if (stat(filename, &sb)) {
154 perror("stat");
155 return false;
156 }
157
158 return true;
159}

Referenced by ldgm::set_params().

◆ usage()

static void usage ( void )
static

Definition at line 258 of file ldgm.cpp.

258 {
259 color_printf(TBOLD("LDGM") " usage:\n");
260 color_printf("\t" TBOLD(TRED("-f ldgm") "[:<k>:<m>[:c]]" " | " TRED("-f ldgm:<expected_loss>%%")) "\n");
261 printf("\nwhere:\n");
263 "\t" TBOLD("<k>") " - matrix width\n"
264 "\t" TBOLD("<m>") " - matrix height\n"
265 "\t" TBOLD("<c>") " - number of ones per column\n"
266 "\t\tthe bigger ratio m/k, the better correction (but also "
267 "needed bandwidth)\n"
268 "\t\tk,m should be in interval [%d, %d]; c in [%d, %d]\n"
269 "\t\tdefault: k = %d, m = %d, c = %d\n"
270 "\t" TBOLD("<expected_loss>") " - expected maximal loss "
271 TBOLD("per frame") " in percent\n"
272 "\t\t(including '%%'-sign)¹\n"
273 "\n",
275 DEFAULT_C);
277 "¹ Please note that there are only a few presets for FullHD "
278 "video\n"
279 "that will work correctly for JPEG and uncompressed, see wiki:\n"
280 "<https://github.com/CESNET/UltraGrid/wiki/FEC-Settings#ldgm>\n\n");
281}
int color_printf(const char *format,...)
#define TRED(x)
Definition color_out.h:75
#define TBOLD(x)
Definition color_out.h:70
#define DEFAULT_M
Definition ldgm.cpp:141
#define DEFAULT_C
Definition ldgm.cpp:142
#define MAX_C
Definition ldgm.cpp:144
#define MINIMAL_VALUE
Definition ldgm.cpp:138
#define DEFAULT_K
Definition ldgm.cpp:140
#define MIN_C
Definition ldgm.cpp:143
#define MAX_K
Definition ldgm.cpp:145

References color_printf(), DEFAULT_C, DEFAULT_K, DEFAULT_M, MAX_C, MAX_K, MIN_C, MINIMAL_VALUE, TBOLD, and TRED.

Here is the call graph for this function:

Variable Documentation

◆ losses

loss_t losses[]
Initial value:
= {
std::numeric_limits<double>::min(),
}
#define PCT5
Definition ldgm.cpp:97
#define PCT10
Definition ldgm.cpp:98
#define PCT2
Definition ldgm.cpp:96

Definition at line 101 of file ldgm.cpp.

101 {
102 std::numeric_limits<double>::min(),
103 PCT2,
104 PCT5,
105 PCT10,
106};

Referenced by ldgm::ldgm().

◆ suggested_configurations

const configuration_t suggested_configurations[]
Initial value:
= {
{ STD1500, JPEG60_SIZE, PCT2, 750, 120, 5 },
{ STD1500, JPEG60_SIZE, PCT5, 1500, 450, 6 },
{ STD1500, JPEG60_SIZE, PCT10, 1000, 500, 7 },
{ STD1500, JPEG80_SIZE, PCT2, 1500, 240, 5 },
{ STD1500, JPEG80_SIZE, PCT5, 1250, 375, 6 },
{ STD1500, JPEG80_SIZE, PCT10, 1500, 750, 8 },
{ STD1500, JPEG90_SIZE, PCT2, 1500, 240, 6 },
{ STD1500, JPEG90_SIZE, PCT5, 1500, 450, 6 },
{ STD1500, JPEG90_SIZE, PCT10, 1500, 750, 8 },
{ JUMBO9000, UNCOMPRESSED_SIZE, PCT2, 1500, 180, 5 },
{ JUMBO9000, UNCOMPRESSED_SIZE, PCT5, 1000, 300, 6 },
{ JUMBO9000, UNCOMPRESSED_SIZE, PCT10, 1000, 500, 7 },
{ STD1500, UNCOMPRESSED_SIZE, PCT2, 1500, 250, 5 },
{ STD1500, UNCOMPRESSED_SIZE, PCT5, 1500, 650, 6 },
{ STD1500, UNCOMPRESSED_SIZE, PCT10, 1500, 1500, 8 },
}
#define UNCOMPRESSED_SIZE
Definition ldgm.cpp:112
#define JPEG90_SIZE
Definition ldgm.cpp:110
#define JPEG60_SIZE
Definition ldgm.cpp:108
#define JPEG80_SIZE
Definition ldgm.cpp:109

Definition at line 114 of file ldgm.cpp.

114 {
115 // JPEG 60
116 { STD1500, JPEG60_SIZE, PCT2, 750, 120, 5 },
117 { STD1500, JPEG60_SIZE, PCT5, 1500, 450, 6 },
118 { STD1500, JPEG60_SIZE, PCT10, 1000, 500, 7 },
119 // JPEG 80
120 { STD1500, JPEG80_SIZE, PCT2, 1500, 240, 5 },
121 { STD1500, JPEG80_SIZE, PCT5, 1250, 375, 6 },
122 { STD1500, JPEG80_SIZE, PCT10, 1500, 750, 8 },
123 // JPEG 90
124 { STD1500, JPEG90_SIZE, PCT2, 1500, 240, 6 },
125 { STD1500, JPEG90_SIZE, PCT5, 1500, 450, 6 },
126 { STD1500, JPEG90_SIZE, PCT10, 1500, 750, 8 },
127
128 // uncompressed
129 { JUMBO9000, UNCOMPRESSED_SIZE, PCT2, 1500, 180, 5 },
130 { JUMBO9000, UNCOMPRESSED_SIZE, PCT5, 1000, 300, 6 },
131 { JUMBO9000, UNCOMPRESSED_SIZE, PCT10, 1000, 500, 7 },
132
133 { STD1500, UNCOMPRESSED_SIZE, PCT2, 1500, 250, 5 },
134 { STD1500, UNCOMPRESSED_SIZE, PCT5, 1500, 650, 6 },
135 { STD1500, UNCOMPRESSED_SIZE, PCT10, 1500, 1500, 8 },
136};

Referenced by ldgm::ldgm().