Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
EnTerr
Level 8

Build in a CRC32()?

I am trashing around looking for a way to generate image files in situ and PNG format does not seem that bad, were it not for having to calculate CRC32. Unfortunately DIY CRC in BRS feels slow like polishing stones in a rock tumbler. So i am throwing in a suggestion/request in the hat, to give us the function:
function crc32(crc=&hFFFFFFFF as Integer) as Integer
    Compute CRC-32, the 32-bit checksum of data, starting with an initial crc. This is consistent with the ZIP file checksum.
Here I presume it will be member of ifByteArray and calculate the crc of the underlying byte array. That seemed natural (doing it on String not good because of \0) but can be some place else of course - in that case will need to receive as arguments additionally: buffer, start position and end/length. In proposed format, when crc of part of buffer is needed - that can be done with slicing toHexString/fromHexString, which is not too painful - and then chained if needed by passing different start crc. I think the default start value for crc32 is all-ones (~0).

I don't know how compelling this sounds but: CRC32 is used in many places - right now i can think of PNG, ZIP/gzip/bzip2, MPEG2 - and will be easy/clean to implement (i.e. can use C library function and won't depend/affect anything else B/S)
0 Kudos