[FFmpeg-devel] [RFC][PATCH 1/3] lavu: Add av_crc2() and av_crc_init2()
James Almer
jamrial at gmail.com
Sun Jan 27 18:52:14 CET 2013
On 27/01/13 1:55 PM, Michael Niedermayer wrote:
> On Sun, Jan 27, 2013 at 03:52:13AM -0300, James Almer wrote:
>> Functionally the same as av_crc() and av_crc_init(), but
>> supporting CRCs of up to 64 bits.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
> [...]
>> @@ -90,6 +98,12 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id)
>> uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
>> const uint8_t *buffer, size_t length)
>> {
>> + return (uint32_t)av_crc2(ctx, crc, buffer, length);
>> +}
>> +
>> +uint64_t av_crc2(const AVCRC *ctx, uint64_t crc,
>> + const uint8_t *buffer, size_t length)
>> +{
>> const uint8_t *end = buffer + length;
>>
>> #if !CONFIG_SMALL
>> @@ -101,8 +115,9 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
>> crc ^= av_le2ne32(*(const uint32_t *) buffer); buffer += 4;
>> crc = ctx[3 * 256 + ( crc & 0xFF)] ^
>> ctx[2 * 256 + ((crc >> 8 ) & 0xFF)] ^
>> + (crc >> 32) ^
>> ctx[1 * 256 + ((crc >> 16) & 0xFF)] ^
>> - ctx[0 * 256 + ((crc >> 24) )];
>> + ctx[0 * 256 + ((crc >> 24) & 0xFF)];
>> }
>> }
>> #endif
>
> use of 64bit variables to calculate 32bit crcs would likely cause a
> significant performance loss on 32bit architectures
Should I instead create completely separate functions exclusively for CRC64
then?
Doing so would also deal with Paul's concerns about changing the variable
types for a few structs.
Regards.
More information about the ffmpeg-devel
mailing list