Index: webrtc/modules/rtp_rtcp/source/byte_io.h |
diff --git a/webrtc/modules/rtp_rtcp/source/byte_io.h b/webrtc/modules/rtp_rtcp/source/byte_io.h |
index 2617806dd941205c813a0b0c535f949429a6c97e..4ac47898baf1ee34f7e2226f9676210e5e6b4db5 100644 |
--- a/webrtc/modules/rtp_rtcp/source/byte_io.h |
+++ b/webrtc/modules/rtp_rtcp/source/byte_io.h |
@@ -88,13 +88,8 @@ class ByteReader { |
static T SignExtend(const T val) { |
uint8_t msb = static_cast<uint8_t>(val >> ((B - 1) * 8)); |
if (msb & 0x80) { |
- // Sign extension is -1 (all ones) shifted left B bytes. |
- // The "B % sizeof(T)"-part is there to avoid compiler warning for |
- // shifting the whole size of the data type. |
- T sign_extend = (sizeof(T) == B ? 0 : |
- (static_cast<T>(-1L) << ((B % sizeof(T)) * 8))); |
- |
- return val | sign_extend; |
+ T used_bits_mask = (1 << (B * 8)) - 1; |
+ return ~used_bits_mask | val; |
stefan-webrtc
2015/07/08 12:01:50
I think this deserves a comment. :)
sprang_webrtc
2015/07/08 12:57:03
Done.
|
} |
return val; |
} |