Partially fixed packet splitting

This partially reverts a0cc3db5.

Fixes command: uv -t testcard:1920:1080:25:RGBA --param decoder-use-codec=UYVY -d sdl

The selection of correct split is quite tricky because even though 4 is
suffiecient for RGBA, using the UYVY decoder increases the size to 8
because the line-decoder obviously needs to process 2 pixels (aligned
at 2-pixel boundry). So the sender has no prior knowledge which
splitting the receiver requires.

Currently it is only a workaround using LCM from a value 48 (suitable
for RG48->R12L conversion) and pixel format block size.
This commit is contained in:
Martin Pulec
2020-07-15 08:59:09 +02:00
parent a6c0aae5d0
commit 13b448514a

View File

@@ -445,6 +445,33 @@ static uint32_t format_interl_fps_hdr_row(enum interlacing_t interlacing, double
tmp |= fi << 13;
return htonl(tmp);
}
static auto gcd(int a, int b)
{
// Everything divides 0
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
// base case
if (a == b) {
return a;
}
// a is greater
if (a > b) {
return gcd(a-b, b);
}
return gcd(a, b-a);
}
static auto lcm(int a, int b) {
return a * b / gcd(a, b);
}
static inline int get_data_len(bool with_fec, int mtu, int hdrs_len,
int fec_symbol_size, int *fec_symbol_offset, int pf_block_size)
{
@@ -462,7 +489,13 @@ static inline int get_data_len(bool with_fec, int mtu, int hdrs_len,
}
}
} else {
pf_block_size = MAX(pf_block_size, 1); // compressed formats have usually 0
if (pf_block_size == 0) {
pf_block_size = 1; // compressed formats have usually 0
} else {
pf_block_size = lcm(pf_block_size, 48); // 6/8 -> RGB/A convertible to UYVY (multiple of 2 pixs)
// 48 -> RG48 to R12L
// @todo figure out better solution
}
data_len = (data_len / pf_block_size) * pf_block_size;
}
return data_len;