Transmit: correctly split packets

Correctly split packets for different pixel formats - previously there
was preset 48 B boundary which was least common multiple for then
present pixel formats (v210 has 16, RGB 3). However, R12L is not covered
since it uses block of 36 bytes.

From now on, we are splitting the packets according to the needed
boundary of pixel format (or arbitrarily for compressed). As a side effect,
the packets may be slightly bigger up to MTU size.
This commit is contained in:
Martin Pulec
2019-01-22 17:19:14 +01:00
parent c8f0232ea7
commit a0cc3db591
2 changed files with 12 additions and 4 deletions

View File

@@ -245,6 +245,11 @@ static inline int posix_memalign(void **memptr, size_t alignment, size_t size)
} }
#endif // POSIX_MEMALIGN #endif // POSIX_MEMALIGN
#endif // defined HAVE_MACOSX && OS_VERSION_MAJOR <= 9 #endif // defined HAVE_MACOSX && OS_VERSION_MAJOR <= 9
#undef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#undef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
]) ])
# @param $1 name of the module # @param $1 name of the module

View File

@@ -445,7 +445,7 @@ static uint32_t format_interl_fps_hdr_row(enum interlacing_t interlacing, double
return htonl(tmp); return htonl(tmp);
} }
static inline int get_data_len(bool with_fec, int mtu, int hdrs_len, static inline int get_data_len(bool with_fec, int mtu, int hdrs_len,
int fec_symbol_size, int *fec_symbol_offset) int fec_symbol_size, int *fec_symbol_offset, int pf_block_size)
{ {
int data_len; int data_len;
data_len = mtu - hdrs_len; data_len = mtu - hdrs_len;
@@ -461,7 +461,8 @@ static inline int get_data_len(bool with_fec, int mtu, int hdrs_len,
} }
} }
} else { } else {
data_len = (data_len / 48) * 48; pf_block_size = MAX(pf_block_size, 1); // compressed formats have usually 0
data_len = (data_len / pf_block_size) * pf_block_size;
} }
return data_len; return data_len;
} }
@@ -590,7 +591,8 @@ tx_send_base(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session,
int packet_count = 0; int packet_count = 0;
do { do {
pos += get_data_len(frame->fec_params.type != FEC_NONE, tx->mtu, hdrs_len, pos += get_data_len(frame->fec_params.type != FEC_NONE, tx->mtu, hdrs_len,
fec_symbol_size, &fec_symbol_offset); fec_symbol_size, &fec_symbol_offset,
get_pf_block_size(frame->color_spec));
packet_count += 1; packet_count += 1;
} while (pos < (unsigned int) tile->data_len); } while (pos < (unsigned int) tile->data_len);
if(tx->fec_scheme == FEC_MULT) { if(tx->fec_scheme == FEC_MULT) {
@@ -641,7 +643,8 @@ tx_send_base(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session,
data = tile->data + pos; data = tile->data + pos;
data_len = get_data_len(frame->fec_params.type != FEC_NONE, tx->mtu, hdrs_len, data_len = get_data_len(frame->fec_params.type != FEC_NONE, tx->mtu, hdrs_len,
fec_symbol_size, &fec_symbol_offset); fec_symbol_size, &fec_symbol_offset,
get_pf_block_size(frame->color_spec));
if (pos + data_len >= (unsigned int) tile->data_len) { if (pos + data_len >= (unsigned int) tile->data_len) {
if (send_m) { if (send_m) {
m = 1; m = 1;