Fiddle with bit swabbing stuff.
Investigate 32 bit crash (incorrect arg to inline function call). Warning - only tested on 32 bit PC, need to regression test on 64 bit. git-svn-id: http://op25.osmocom.org/svn/trunk@129 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
1f475eefed
commit
c8b6064cf7
|
@ -37,16 +37,16 @@ abstract_data_unit::~abstract_data_unit()
|
|||
uint16_t
|
||||
abstract_data_unit::data_size() const
|
||||
{
|
||||
return (7 + frame_size_decoded()) >> 3;
|
||||
return (7 + frame_size_max()) >> 3;
|
||||
}
|
||||
|
||||
void
|
||||
abstract_data_unit::extend(dibit d)
|
||||
{
|
||||
if(frame_size_encoded() <= frame_size_now()) {
|
||||
if(frame_size_max() <= frame_size()) {
|
||||
ostringstream msg;
|
||||
msg << "cannot extend frame " << endl;
|
||||
msg << "(size now: " << frame_size_now() << ", expected size: " << frame_size_encoded() << ")" << endl;
|
||||
msg << "(size now: " << frame_size() << ", expected size: " << frame_size_max() << ")" << endl;
|
||||
msg << "func: " << __PRETTY_FUNCTION__ << endl;
|
||||
msg << "file: " << __FILE__ << endl;
|
||||
msg << "line: " << __LINE__ << endl;
|
||||
|
@ -62,7 +62,7 @@ abstract_data_unit::decode(size_t msg_sz, uint8_t *msg, imbe_decoder& imbe, floa
|
|||
if(!is_complete()) {
|
||||
ostringstream msg;
|
||||
msg << "cannot decode frame body - frame is not complete" << endl;
|
||||
msg << "(size now: " << frame_size_now() << ", expected size: " << frame_size_encoded() << ")" << endl;
|
||||
msg << "(size now: " << frame_size() << ", expected size: " << frame_size_max() << ")" << endl;
|
||||
msg << "func: " << __PRETTY_FUNCTION__ << endl;
|
||||
msg << "file: " << __FILE__ << endl;
|
||||
msg << "line: " << __LINE__ << endl;
|
||||
|
@ -85,7 +85,7 @@ abstract_data_unit::decode(size_t msg_sz, uint8_t *msg, imbe_decoder& imbe, floa
|
|||
bool
|
||||
abstract_data_unit::is_complete() const
|
||||
{
|
||||
return d_frame_body.size() >= frame_size_encoded();
|
||||
return d_frame_body.size() >= frame_size_max();
|
||||
}
|
||||
|
||||
abstract_data_unit::abstract_data_unit(const_bit_vector& frame_body) :
|
||||
|
@ -107,34 +107,17 @@ abstract_data_unit::decode_audio(const_bit_vector& frame_body, imbe_decoder& imb
|
|||
size_t
|
||||
abstract_data_unit::decode_body(const_bit_vector& frame_body, size_t msg_sz, uint8_t *msg)
|
||||
{
|
||||
memset(msg, 0x00, msg_sz);
|
||||
const uint16_t *int_sched = interleaving();
|
||||
if(int_sched) {
|
||||
const uint16_t frame_encoded_sz = frame_size_encoded();
|
||||
for(uint16_t i = 0; i < frame_encoded_sz; ++i) {
|
||||
msg[i / 8] ^= (frame_body[int_sched[i]] ? 1 : 0) << (7 - (i % 8));
|
||||
}
|
||||
} else {
|
||||
swab(frame_body, 0, frame_body.size(), msg, 0);
|
||||
}
|
||||
return msg_sz;
|
||||
return swab(frame_body, 0, frame_body.size(), msg);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
abstract_data_unit::frame_size_decoded() const
|
||||
abstract_data_unit::frame_size_max() const
|
||||
{
|
||||
return frame_size_encoded();
|
||||
return frame_size_max();
|
||||
}
|
||||
|
||||
uint16_t
|
||||
abstract_data_unit::frame_size_now() const
|
||||
abstract_data_unit::frame_size() const
|
||||
{
|
||||
return d_frame_body.size();
|
||||
}
|
||||
|
||||
const uint16_t*
|
||||
abstract_data_unit::interleaving() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,16 +116,6 @@ protected:
|
|||
*/
|
||||
virtual size_t decode_body(const_bit_vector& frame_body, size_t msg_sz, uint8_t *msg);
|
||||
|
||||
/**
|
||||
* Returns the expected size (in bits) of the de-interleaved and
|
||||
* error-corrected data unit. For variable-length data this
|
||||
* should return UINT16_MAX until the actual length of this frame
|
||||
* is known.
|
||||
*
|
||||
* \return The expected size (in bits) of this data_unit when decoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_decoded() const;
|
||||
|
||||
/**
|
||||
* Returns the expected size (in bits) of this data_unit. For
|
||||
* variable-length data this should return UINT16_MAX until the
|
||||
|
@ -133,24 +123,14 @@ protected:
|
|||
*
|
||||
* \return The expected size (in bits) of this data_unit when encoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_encoded() const = 0;
|
||||
virtual uint16_t frame_size_max() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the current size (in bits) of this data_unit.
|
||||
*
|
||||
* \return The current size (in bits) of this data_unit.
|
||||
*/
|
||||
virtual uint16_t frame_size_now() const;
|
||||
|
||||
/**
|
||||
* Return the interleaving vector (an array of frame_size_encoded()
|
||||
* elements). The vector specifies where each bit of a decoded bit
|
||||
* frame resides in an encoded frame.
|
||||
*
|
||||
* \return A (possibly NULL) pointer to the bit de-interleaving
|
||||
* vector.
|
||||
*/
|
||||
virtual const uint16_t *interleaving() const;
|
||||
virtual uint16_t frame_size() const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -55,226 +55,7 @@ hdu::apply_rs_correction(bit_vector& frame)
|
|||
}
|
||||
|
||||
uint16_t
|
||||
hdu::frame_size_encoded() const
|
||||
hdu::frame_size_max() const
|
||||
{
|
||||
return 792;
|
||||
}
|
||||
|
||||
#if 0
|
||||
const uint16_t*
|
||||
hdu::interleaving() const
|
||||
{
|
||||
static const uint16_t int_sched[] = {
|
||||
/*
|
||||
0 FS(47)
|
||||
1 FS(46)
|
||||
2 FS(45)
|
||||
3 FS(44)
|
||||
4 FS(43)
|
||||
5 FS(42)
|
||||
6 FS(41)
|
||||
7 FS(40)
|
||||
8 FS(39)
|
||||
9 FS(38)
|
||||
10 FS(37)
|
||||
11 FS(36)
|
||||
12 FS(35)
|
||||
13 FS(34)
|
||||
14 FS(33)
|
||||
15 FS(32)
|
||||
16 FS(31)
|
||||
17 FS(30)
|
||||
18 FS(29)
|
||||
19 FS(28)
|
||||
20 FS(27)
|
||||
21 FS(26)
|
||||
22 FS(25)
|
||||
23 FS(24)
|
||||
24 FS(23)
|
||||
25 FS(22)
|
||||
26 FS(21)
|
||||
27 FS(20)
|
||||
28 FS(19)
|
||||
29 FS(18)
|
||||
30 FS(17)
|
||||
31 FS(16)
|
||||
32 FS(15)
|
||||
33 FS(14)
|
||||
34 FS(13)
|
||||
35 FS(12)
|
||||
36 FS(11)
|
||||
37 FS(10)
|
||||
38 FS(9)
|
||||
39 FS(8)
|
||||
40 FS(7)
|
||||
41 FS(6)
|
||||
42 FS(5)
|
||||
43 FS(4)
|
||||
44 FS(3)
|
||||
45 FS(2)
|
||||
46 FS(1)
|
||||
47 FS(0)
|
||||
48 NAC(11)
|
||||
49 NAC(10)
|
||||
50 NAC(9)
|
||||
51 NAC(8)
|
||||
52 NAC(7)
|
||||
53 NAC(6)
|
||||
54 NAC(5)
|
||||
55 NAC(4)
|
||||
56 NAC(3)
|
||||
57 NAC(2)
|
||||
58 NAC(1)
|
||||
59 NAC(0)
|
||||
60 DUID(3)
|
||||
61 DUID(2)
|
||||
62 DUID(1)
|
||||
63 DUID(0)
|
||||
114 MI(71)
|
||||
115 MI(70)
|
||||
116 MI(69)
|
||||
117 MI(68)
|
||||
118 MI(67)
|
||||
119 MI(66)
|
||||
132 MI(65)
|
||||
133 MI(64)
|
||||
134 MI(63)
|
||||
135 MI(62)
|
||||
136 MI(61)
|
||||
137 MI(60)
|
||||
152 MI(59)
|
||||
153 MI(58)
|
||||
154 MI(57)
|
||||
155 MI(56)
|
||||
156 MI(55)
|
||||
157 MI(54)
|
||||
170 MI(53)
|
||||
171 MI(52)
|
||||
172 MI(51)
|
||||
173 MI(50)
|
||||
174 MI(49)
|
||||
175 MI(48)
|
||||
188 MI(47)
|
||||
189 MI(46)
|
||||
190 MI(45)
|
||||
191 MI(44)
|
||||
192 MI(43)
|
||||
193 MI(42)
|
||||
206 MI(41)
|
||||
207 MI(40)
|
||||
208 MI(39)
|
||||
209 MI(38)
|
||||
210 MI(37)
|
||||
211 MI(36)
|
||||
226 MI(35)
|
||||
227 MI(34)
|
||||
228 MI(33)
|
||||
229 MI(32)
|
||||
230 MI(31)
|
||||
231 MI(30)
|
||||
244 MI(29)
|
||||
245 MI(28)
|
||||
246 MI(27)
|
||||
247 MI(26)
|
||||
248 MI(25)
|
||||
249 MI(24)
|
||||
262 MI(23)
|
||||
263 MI(22)
|
||||
264 MI(21)
|
||||
265 MI(20)
|
||||
266 MI(19)
|
||||
267 MI(18)
|
||||
280 MI(17)
|
||||
281 MI(16)
|
||||
282 MI(15)
|
||||
283 MI(14)
|
||||
284 MI(13)
|
||||
285 MI(12)
|
||||
300 MI(11)
|
||||
301 MI(10)
|
||||
302 MI(9)
|
||||
303 MI(8)
|
||||
304 MI(7)
|
||||
305 MI(6)
|
||||
318 MI(5)
|
||||
319 MI(4)
|
||||
320 MI(3)
|
||||
321 MI(2)
|
||||
322 MI(1)
|
||||
323 MI(0)
|
||||
336 MFID(7)
|
||||
337 MFID(6)
|
||||
338 MFID(5)
|
||||
339 MFID(4)
|
||||
340 MFID(3)
|
||||
341 MFID(2)
|
||||
354 MFID(1)
|
||||
355 MFID(0)
|
||||
356 ALGID(7)
|
||||
357 ALGID(6)
|
||||
360 ALGID(5)
|
||||
361 ALGID(4)
|
||||
374 ALGID(3)
|
||||
375 ALGID(2)
|
||||
376 ALGID(1)
|
||||
377 ALGID(0)
|
||||
378 KID(15)
|
||||
379 KID(14)
|
||||
392 KID(13)
|
||||
393 KID(12)
|
||||
394 KID(11)
|
||||
395 KID(10)
|
||||
396 KID(9)
|
||||
397 KID(8)
|
||||
410 KID(7)
|
||||
411 KID(6)
|
||||
412 KID(5)
|
||||
413 KID(4)
|
||||
414 KID(3)
|
||||
415 KID(2)
|
||||
428 KID(1)
|
||||
429 KID(0)
|
||||
432 TGID(15)
|
||||
433 TGID(14)
|
||||
434 TGID(13)
|
||||
435 TGID(12)
|
||||
448 TGID(11)
|
||||
449 TGID(10)
|
||||
450 TGID(9)
|
||||
451 TGID(8)
|
||||
452 TGID(7)
|
||||
453 TGID(6)
|
||||
466 TGID(5)
|
||||
467 TGID(4)
|
||||
468 TGID(3)
|
||||
469 TGID(2)
|
||||
470 TGID(1)
|
||||
471 TGID(0)
|
||||
|
||||
70 SS(1)
|
||||
71 SS(0)
|
||||
142 SS(1)
|
||||
143 SS(0)
|
||||
214 SS(1)
|
||||
215 SS(0)
|
||||
286 SS(1)
|
||||
287 SS(0)
|
||||
358 SS(1)
|
||||
359 SS(0)
|
||||
430 SS(1)
|
||||
431 SS(0)
|
||||
502 SS(1)
|
||||
503 SS(0)
|
||||
574 SS(1)
|
||||
575 SS(0)
|
||||
646 SS(1)
|
||||
647 SS(0)
|
||||
718 SS(1)
|
||||
719 SS(0)
|
||||
790 SS(1)
|
||||
791 SS(0)
|
||||
*/
|
||||
};
|
||||
return sched;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -80,7 +80,7 @@ protected:
|
|||
*
|
||||
* \return The expected size (in bits) of this data_unit when encoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_encoded() const;
|
||||
virtual uint16_t frame_size_max() const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ ldu1::decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe, float_queue
|
|||
}
|
||||
|
||||
uint16_t
|
||||
ldu1::frame_size_encoded() const
|
||||
ldu1::frame_size_max() const
|
||||
{
|
||||
return 1728;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
|||
*
|
||||
* \return The expected size (in bits) of this data_unit when encoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_encoded() const;
|
||||
virtual uint16_t frame_size_max() const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ ldu2::decode_audio(const_bit_vector& frame_body, imbe_decoder& imbe, float_queue
|
|||
}
|
||||
|
||||
uint16_t
|
||||
ldu2::frame_size_encoded() const
|
||||
ldu2::frame_size_max() const
|
||||
{
|
||||
return 1728;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
*
|
||||
* \return The expected size (in bits) of this data_unit when encoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_encoded() const;
|
||||
virtual uint16_t frame_size_max() const;
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_LDU2_H */
|
||||
|
|
|
@ -79,7 +79,7 @@ op25_decoder_ff::general_work(int nof_output_items, gr_vector_int& nof_input_ite
|
|||
receive_symbol(d);
|
||||
}
|
||||
consume(0, nof_input_items[0]);
|
||||
|
||||
|
||||
for(int i = 0; i < nof_output_items; ++i) {
|
||||
float *out = reinterpret_cast<float*>(&output_items[i]);
|
||||
std::fill(&out[0], &out[nof_output_items], 0.0); // audio silence - for now
|
||||
|
@ -193,11 +193,11 @@ op25_decoder_ff::receive_symbol(dibit d)
|
|||
swab(d_frame_hdr, 112, 71, b, 16);
|
||||
swab(d_frame_hdr, 69, 63, b, 57);
|
||||
b = d_bch.decode(b);
|
||||
/**
|
||||
swab(b, 57, d_frame_hdr, 69, 63);
|
||||
swab(b, 16, d_frame_hdr, 112, 71);
|
||||
swab(b, 0, d_frame_hdr, 63, 47);
|
||||
**/
|
||||
#if __x86_64
|
||||
unswab(b, 57, d_frame_hdr, 69, 63);
|
||||
unswab(b, 16, d_frame_hdr, 112, 71);
|
||||
unswab(b, 0, d_frame_hdr, 63, 47);
|
||||
#endif
|
||||
d_data_unit = data_unit::make_data_unit(d_frame_hdr);
|
||||
if(d_data_unit) {
|
||||
d_state = READING;
|
||||
|
|
|
@ -37,7 +37,7 @@ pdu::correct_errors(bit_vector& frame_body)
|
|||
}
|
||||
|
||||
uint16_t
|
||||
pdu::frame_size_encoded() const
|
||||
pdu::frame_size_max() const
|
||||
{
|
||||
const size_t HEADER_BLOCK_SIZE = 312;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
|||
*
|
||||
* \return The expected size (in bits) of this data_unit when encoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_encoded() const;
|
||||
virtual uint16_t frame_size_max() const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -10,77 +10,80 @@ typedef std::vector<bool> bit_vector;
|
|||
typedef const std::vector<bool> const_bit_vector;
|
||||
|
||||
/**
|
||||
* Swab bits from bitset in[begin,end) to octet vector out at position
|
||||
* where. Packing of out starts with the MSB.
|
||||
* Swab bits from in[begin, end) to out[where,...).
|
||||
*
|
||||
* \param in A const reference to the bitset.
|
||||
* \param in A uint64_t representing a set of bits.
|
||||
* \param begin The offset of the first bit to copy.
|
||||
* \param end The offset of the end bit.
|
||||
* \param out Pointer to octet array into which bits are written.
|
||||
* \param where The starting point for writing bits.
|
||||
*/
|
||||
template<size_t N> void
|
||||
swab(const std::bitset<N>& in, int begin, int end, uint8_t *out, int where)
|
||||
{
|
||||
for(int i = begin, j = 0; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[where + (j / 8)] ^= in[i] << (7 - (j % 8));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swab bits from bitset in[begin,end) to bit_vector at position where.
|
||||
*
|
||||
* \param in A const reference to the bitset.
|
||||
* \param begin The offset of the first bit to copy.
|
||||
* \param end The offset of the end bit.
|
||||
* \param out The bit_vector into which bits are written.
|
||||
* \param end The offset of the end bit (this bit is not copied).
|
||||
* \param out The bit_vector into which bits are copied.
|
||||
* \param where The starting point for writing bits.
|
||||
*/
|
||||
inline void
|
||||
swab(uint64_t in, int begin, int end, bit_vector& out, int where)
|
||||
{
|
||||
for(int i = begin, j = where; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[j] = (in & (1 << i) ? 1 : 0);
|
||||
}
|
||||
for(int i = begin; i != end; (begin < end ? ++i : --i)) {
|
||||
out[where++] = (in & (1 << i) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swab bits from bit_vector in[begin,end) to bvec at position where.
|
||||
* Swab bits from in[begin, end) to out[where,...).
|
||||
*
|
||||
* \param in A const reference to the bitset.
|
||||
* \param in A const_bit_vector reference to the source.
|
||||
* \param begin The offset of the first bit to copy.
|
||||
* \param end The offset of the end bit.
|
||||
* \param out A bvec into which bits are written.
|
||||
* \param end The offset of the end bit (this bit is not copied).
|
||||
* \param out A bvec into which bits are copied.
|
||||
* \param where The starting point for writing bits.
|
||||
*/
|
||||
inline void
|
||||
swab(const_bit_vector& in, int begin, int end, itpp::bvec& out, int where)
|
||||
{
|
||||
for(int i = begin, j = where; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[j] = in[i];
|
||||
}
|
||||
for(int i = begin; i != end; (begin < end ? ++i : --i)) {
|
||||
out[where++] = in[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swab bits from bit_vector in[begin,end) to octet vector out at
|
||||
* position where. Packing of out starts with the MSB.
|
||||
* Swabs a bit_vector in[begin,end) to an octet buffer.
|
||||
*
|
||||
* \param in A const reference to the bit_vector.
|
||||
* \param begin The offset of the first bit to copy.
|
||||
* \param end The offset of the end bit.
|
||||
* \param out Pointer to octet array into which bits are written.
|
||||
* \param where The starting point for writing bits.
|
||||
* \param end The offset of the end bit (this bit is not copied).
|
||||
* \param out Address of the octet buffer to write into.
|
||||
* \return The number of octers written.
|
||||
*/
|
||||
inline void
|
||||
swab(const_bit_vector& in, int begin, int end, uint8_t *out, int where)
|
||||
inline size_t
|
||||
swab(const_bit_vector& in, int begin, int end, uint8_t *out)
|
||||
{
|
||||
for(int i = begin, j = 0; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[where + (j / 8)] ^= in[i] << (7 - (j % 8));
|
||||
}
|
||||
const size_t out_sz = (7 + abs(end - begin)) / 8;
|
||||
memset(out, 0, out_sz);
|
||||
for(int i = begin, j = 0; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[j / 8] ^= in[i] << (7 - (j % 8));
|
||||
}
|
||||
return out_sz;
|
||||
}
|
||||
/**
|
||||
* Swabs a bitset<N> in[begin,end) to an octet buffer.
|
||||
*
|
||||
* \param in A const reference to the bitset.
|
||||
* \param begin The offset of the first bit to copy.
|
||||
* \param end The offset of the end bit (this bit is not copied).
|
||||
* \param out Address of the octet buffer to write into.
|
||||
* \return The number of octers written.
|
||||
*/
|
||||
template <size_t N> size_t
|
||||
swab(const std::bitset<N>& in, int begin, int end, uint8_t *out)
|
||||
{
|
||||
const size_t out_sz = (7 + abs(end - begin)) / 8;
|
||||
memset(out, 0, out_sz);
|
||||
for(int i = begin, j = 0; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[j / 8] ^= in[i] << (7 - (j % 8));
|
||||
}
|
||||
return out_sz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swab bits to out[begin,end) from bvec at position where.
|
||||
* Swab bits from bvec in[where] in to out[begin,end).
|
||||
*
|
||||
* \param in A const reference to the bvec.
|
||||
* \param begin The offset of the first bit to copy.
|
||||
|
@ -89,11 +92,11 @@ swab(const_bit_vector& in, int begin, int end, uint8_t *out, int where)
|
|||
* \param where The starting point for writing bits.
|
||||
*/
|
||||
inline void
|
||||
swab(const itpp::bvec& in, int where, bit_vector& out, int begin, int end)
|
||||
unswab(const itpp::bvec& in, int where, bit_vector& out, int begin, int end)
|
||||
{
|
||||
for(int i = begin, j = where; i != end; (begin < end ? ++i : --i), ++j) {
|
||||
out[i] = in[j];
|
||||
}
|
||||
for(int i = begin; i != end; (begin < end ? ++i : --i)) {
|
||||
out[i] = in[where++];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,17 +105,16 @@ swab(const itpp::bvec& in, int where, bit_vector& out, int begin, int end)
|
|||
* \param in The input const_bit_vector.
|
||||
* \param begin The offset of the first bit to extract (the MSB).
|
||||
* \param end The offset of the end bit.
|
||||
* \return
|
||||
* \return A uint64_t containing the value
|
||||
*/
|
||||
inline uint64_t
|
||||
extract(const_bit_vector& in, int begin, int end)
|
||||
{
|
||||
uint64_t x = 0LL;
|
||||
for(int i = begin; i != end; (begin < end ? ++i : --i)) {
|
||||
x = (x << 1) | (in[i] ? 1 : 0);
|
||||
}
|
||||
return x;
|
||||
uint64_t x = 0LL;
|
||||
for(int i = begin; i != end; (begin < end ? ++i : --i)) {
|
||||
x = (x << 1) | (in[i] ? 1 : 0);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
#endif // INCLUDED_SWAB_H
|
||||
|
|
|
@ -72,7 +72,7 @@ tdu::apply_rs_correction(bit_vector& frame)
|
|||
}
|
||||
|
||||
uint16_t
|
||||
tdu::frame_size_encoded() const
|
||||
tdu::frame_size_max() const
|
||||
{
|
||||
return d_has_link_control ? 432 : 144;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ protected:
|
|||
*
|
||||
* \return The expected size (in bits) of this data_unit when encoded.
|
||||
*/
|
||||
virtual uint16_t frame_size_encoded() const;
|
||||
virtual uint16_t frame_size_max() const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ vc55_imbe_decoder::vc55_imbe_decoder()
|
|||
}
|
||||
}
|
||||
} else {
|
||||
perror("open(dev, O_WRONLY | O_NOCTTY)");
|
||||
perror("open(dev, O_WRONLY | O_NOCTTY)"); // a warning, not an error
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,8 @@ vc55_imbe_decoder::decode(voice_codeword& in_out, audio_output& out)
|
|||
uint8_t packet[20];
|
||||
packet[0] = 0x56;
|
||||
packet[1] = 0xf0;
|
||||
swab(in_out, 0, 144, packet, 2);
|
||||
|
||||
swab(in_out, 0, 144, &packet[2]);
|
||||
if(-1 == write(d_fd, packet, sizeof(packet))) {
|
||||
perror("write(d_fd, packet, sizeof(packet))");
|
||||
close(d_fd);
|
||||
|
|
Reference in New Issue