WIP: bitmap decoding

Ticket: OW#????
Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2016-01-13 18:56:21 +01:00
parent cdbc142e72
commit d1975ce201
3 changed files with 78 additions and 0 deletions

View File

@ -1008,6 +1008,30 @@ void gprs_rlcmac_pdch::rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *ack_nac
return;
}
#endif
int num_blocks;
uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
char show_bits[RLC_EGPRS_MAX_WS + 1];
bitvec bits;
int bsn_begin, bsn_end;
bits.data = bits_data;
bits.data_len = sizeof(bits_data);
bits.cur_bit = 0;
num_blocks = Decoding::decode_egprs_acknack_bits(
&ack_nack->EGPRS_AckNack.Desc, &bits,
&bsn_begin, &bsn_end, &tbf->m_window);
for (int i = 0; i < num_blocks; i++) {
show_bits[i] = bitvec_get_bit_pos(&bits, i) ? 'R' : 'I';
}
show_bits[num_blocks] = 0;
LOGP(DRLCMAC, LOGL_DEBUG,
"EGPRS DL ACK bitmap: BSN %d to %d - 1 (%d blocks): %s\n",
bsn_begin, bsn_end, num_blocks, show_bits);
if (ack_nack->EGPRS_AckNack.Desc.URBB_LENGTH == 0 &&
!ack_nack->EGPRS_AckNack.Desc.Exist_CRBB)
{

View File

@ -493,3 +493,51 @@ const uint8_t *Decoding::rlc_get_data_aligned(
Decoding::rlc_copy_to_aligned_buffer(rlc, data_block_idx, src, buffer);
return buffer;
}
int Decoding::decode_egprs_acknack_bits(const EGPRS_AckNack_Desc_t *desc,
bitvec *bits, int *bsn_begin, int *bsn_end, gprs_rlc_dl_window *window)
{
int urbb_len = desc->URBB_LENGTH;
int crbb_len = 0;
int num_blocks;
struct bitvec urbb;
if (desc->Exist_CRBB)
crbb_len = desc->CRBB_LENGTH;
num_blocks = urbb_len + crbb_len;
if (num_blocks == 0) {
*bsn_begin = desc->STARTING_SEQUENCE_NUMBER;
*bsn_end = window->mod_sns(*bsn_begin - 1);
return num_blocks;
}
/* first bit refers to V(Q) and thus is always zero (and not
* transmitted) */
bitvec_set_bit(bits, ZERO);
num_blocks += 1;
*bsn_begin = window->mod_sns(desc->STARTING_SEQUENCE_NUMBER - 1);
*bsn_end = window->mod_sns(*bsn_begin + num_blocks);
if (crbb_len > 0) {
/*
decode_t4_rle(bits, desc->CRBB, desc->CRBB_LENGTH, desc->CRBB_STARTING_COLOR_CODE);
*/
}
urbb.cur_bit = 0;
urbb.data = (uint8_t *)desc->URBB;
urbb.data_len = sizeof(desc->URBB);
for (int i = urbb_len; i > 0; i--) {
/* Set bit at the appropriate position (see 3GPP TS 04.60 12.3.1) */
int is_ack = bitvec_get_bit_pos(&urbb, i-1);
bitvec_set_bit(bits, is_ack ? ONE : ZERO);
}
return num_blocks;
}

View File

@ -24,6 +24,8 @@
#include <stdint.h>
struct bitvec;
class Decoding {
public:
struct RlcData {
@ -51,4 +53,8 @@ public:
const struct gprs_rlc_data_info *rlc,
unsigned int data_block_idx,
const uint8_t *src, uint8_t *buffer);
static int decode_egprs_acknack_bits(
const EGPRS_AckNack_Desc_t *desc,
struct bitvec *bits, int *bsn_begin, int *bsn_end,
struct gprs_rlc_dl_window *window);
};