OpenRTMFP / Cumulus

CumulusServer is a complete open source and cross-platform RTMFP server extensible by way of scripting
http://groups.google.com/group/openrtmfp-cumulus
GNU General Public License v3.0
593 stars 221 forks source link

BinaryWriter::write7BitLongValue(UInt64) can get 10 bytes? #72

Closed Poechant closed 12 years ago

Poechant commented 12 years ago

Hi Sir,

void BinaryWriter::write7BitLongValue(UInt64 value) {
    UInt8 shift = (Util::Get7BitValueSize(value)-1)*7;
    bool max = shift>=63; // Can give 10 bytes!
if(max)
    ++shift;

while(shift>=7) {
    write8(0x80 | ((value>>shift)&0x7F));
    shift -= 7;
}
write8(max ? value&0xFF : value&0x7F);
}

I don't understand that... Why not 49 bytes as (8 - 1) * 7?

Looking forward your reply :)

cumulusdev commented 12 years ago

It's not an issue? :-)

10 is the longer that can take data in memory, why do you want that one 64bit number (8 bytes) takes 49 bytes???

Poechant commented 12 years ago

Oh, sorry, it's a wrong type. I mean (8 - 1) * 7 = 49 bits, just like (4 - 1) * 7 = 21 bits in case of the 32bit value.

cumulusdev commented 12 years ago

Ok, yes, it can take 10 bytes and not 8 bytes because the maximum value allows by a UInt64 type is possible. 8_8=64 bits (on 8 bytes so) 7_9+1 = 64 bits (on 10 bytes so)

2012/4/27 Poechant < reply@reply.github.com

Oh, sorry, it's a wrong type. I mean (8 - 1) * 7 = 49 bits, just like (4 - 1) * 7 = 21 bits in case of the 32bit value.


Reply to this email directly or view it on GitHub: https://github.com/OpenRTMFP/Cumulus/issues/72#issuecomment-5372058

Poechant commented 12 years ago

Thanks :)