Browse Source

16 bit fixes

master
Jeroen Vreeken 4 years ago
parent
commit
75127bd90e
2 changed files with 39 additions and 0 deletions
  1. +28
    -0
      dml_stream_client_codec2.c
  2. +11
    -0
      trx_dv.c

+ 28
- 0
dml_stream_client_codec2.c View File

@ -144,6 +144,10 @@ static int data_cb(void *arg, void *data, size_t datasize)
case 'U':
nr = codecdata;
break;
case 's':
case 'S':
nr = codecdata/2;
break;
default:
if (prev_mode != mode) {
if (dec)
@ -170,6 +174,30 @@ static int data_cb(void *arg, void *data, size_t datasize)
case 'U':
ulaw_decode(samples, data8 + 8, nr);
break;
case 's': {
int i;
union {
uint8_t d8[2];
uint16_t s;
} d2s;
for (i = 0; i < nr; i++) {
d2s.d8[0] = data8[i*2+0];
d2s.d8[1] = data8[i*2+1];
samples[i] = le16toh(d2s.s);
}
}
case 'S': {
int i;
union {
uint8_t d8[2];
uint16_t s;
} d2s;
for (i = 0; i < nr; i++) {
d2s.d8[0] = data8[i*2+0];
d2s.d8[1] = data8[i*2+1];
samples[i] = be16toh(d2s.s);
}
}
default:
if (dec) {
int bpf = codec2_bits_per_frame(dec);


+ 11
- 0
trx_dv.c View File

@ -192,6 +192,14 @@ int trx_dv_send(uint8_t from[6], uint8_t to[6], int mode, uint8_t *dv, size_t si
type = htons(ETH_P_ULAW);
max_size = 320;
break;
case 's':
type = htons(ETH_P_LE16);
max_size = 640;
break;
case 'S':
type = htons(ETH_P_BE16);
max_size = 640;
break;
default:
return -1;
}
@ -281,6 +289,9 @@ int trx_dv_duration(size_t size, int mode)
case 'A':
case 'U':
return size / 8;
case 's':
case 'S':
return size / 16;
default:
return -1;
}


Loading…
Cancel
Save