@@ -27,7 +27,45 @@ namespace libdbc {
2727 } else {
2828 const auto & signal = m_signals.at (bs.index );
2929 if (signal.is_bigendian ) {
30-
30+ switch (bs.size ) {
31+ case 1 :
32+ v = static_cast <double >(bitstream_reader_read_bit (&reader)); break ;
33+ case 8 :
34+ if (signal.is_signed )
35+ v = static_cast <double >(static_cast <int8_t >(bitstream_reader_read_u8 (&reader)));
36+ else
37+ v = static_cast <double >(bitstream_reader_read_u8 (&reader));
38+ break ;
39+ case 16 :
40+ if (signal.is_signed )
41+ v = static_cast <double >(static_cast <int16_t >(bitstream_reader_read_u16 (&reader)));
42+ else
43+ v = static_cast <double >(bitstream_reader_read_u16 (&reader));
44+ break ;
45+ case 32 :
46+ if (signal.is_signed )
47+ v = static_cast <double >(static_cast <int32_t >(bitstream_reader_read_u32 (&reader)));
48+ else
49+ v = static_cast <double >(bitstream_reader_read_u32 (&reader));
50+ break ;
51+ case 64 :
52+ if (signal.is_signed )
53+ v = static_cast <double >(static_cast <int64_t >(bitstream_reader_read_u64 (&reader)));
54+ else
55+ v = static_cast <double >(bitstream_reader_read_u64 (&reader));
56+ break ;
57+ default : {
58+ // TODO: possible to implement bigendian and sign?
59+ uint64_t value = 0 ;
60+ for (uint32_t i=0 ; i < bs.size ; i++) {
61+ value |= bitstream_reader_read_bit (&reader) << i;
62+ }
63+ v = static_cast <double >(value);
64+ break ;
65+ }
66+ }
67+ } else {
68+ // little endian
3169 switch (bs.size ) {
3270 case 1 : v = static_cast <double >(bitstream_reader_read_bit (&reader)); break ;
3371 case 8 : v = static_cast <double >(bitstream_reader_read_u8 (&reader)); break ;
@@ -76,45 +114,6 @@ namespace libdbc {
76114 break ;
77115 }
78116 }
79- } else {
80- // little endian
81- switch (bs.size ) {
82- case 1 :
83- v = static_cast <double >(bitstream_reader_read_bit (&reader)); break ;
84- case 8 :
85- if (signal.is_signed )
86- v = static_cast <double >(static_cast <int8_t >(bitstream_reader_read_u8 (&reader)));
87- else
88- v = static_cast <double >(bitstream_reader_read_u8 (&reader));
89- break ;
90- case 16 :
91- if (signal.is_signed )
92- v = static_cast <double >(static_cast <int16_t >(bitstream_reader_read_u16 (&reader)));
93- else
94- v = static_cast <double >(bitstream_reader_read_u16 (&reader));
95- break ;
96- case 32 :
97- if (signal.is_signed )
98- v = static_cast <double >(static_cast <int32_t >(bitstream_reader_read_u32 (&reader)));
99- else
100- v = static_cast <double >(bitstream_reader_read_u32 (&reader));
101- break ;
102- case 64 :
103- if (signal.is_signed )
104- v = static_cast <double >(static_cast <int64_t >(bitstream_reader_read_u64 (&reader)));
105- else
106- v = static_cast <double >(bitstream_reader_read_u64 (&reader));
107- break ;
108- default : {
109- // TODO: possible to implement bigendian and sign?
110- uint64_t value = 0 ;
111- for (uint32_t i=0 ; i < bs.size ; i++) {
112- value |= bitstream_reader_read_bit (&reader) << i;
113- }
114- v = static_cast <double >(value);
115- break ;
116- }
117- }
118117 }
119118
120119 values.push_back (v * signal.factor + signal.offset );
0 commit comments