diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-15 21:30:30 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-11-15 21:38:23 +0100 |
commit | cddd15ba5c9cd2e92d2f2942e0fc40bf3bf56115 (patch) | |
tree | b61ebf35cd95163d026ac7450a57d476d8f4ea3a /libavformat/matroskaenc.c | |
parent | d03eea36b2c329241f63c8aca2d6adbb6ea81d9c (diff) | |
download | ffmpeg-cddd15ba5c9cd2e92d2f2942e0fc40bf3bf56115.tar.gz |
avformat/matroska: simplify signed int access code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 8db4795d8c..3f466d0eaa 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -205,22 +205,14 @@ static void put_ebml_uint(AVIOContext *pb, unsigned int elementid, uint64_t val) static void put_ebml_sint(AVIOContext *pb, unsigned int elementid, int64_t val) { int i, bytes = 1; - uint64_t uval = (val < 0 ? (-val - 1) << 1 : val << 1); - while (uval>>=8) bytes++; + uint64_t tmp = 2*(val < 0 ? val^-1 : val); - /* make unsigned */ - if (val >= 0) { - uval = val; - } else { - uval = 0x80 << (bytes - 1); - uval += val; - uval |= 0x80 << (bytes - 1); - } + while (tmp>>=8) bytes++; put_ebml_id(pb, elementid); put_ebml_num(pb, bytes, 0); for (i = bytes - 1; i >= 0; i--) - avio_w8(pb, (uint8_t)(uval >> i*8)); + avio_w8(pb, (uint8_t)(val >> i*8)); } static void put_ebml_float(AVIOContext *pb, unsigned int elementid, double val) |