[FFmpeg-devel] [RFC][PATCH 1/3] lavu: Add av_crc2() and av_crc_init2()

Michael Niedermayer michaelni at gmx.at
Sun Jan 27 17:55:10 CET 2013


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

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130127/a9aaa8bb/attachment.asc>


More information about the ffmpeg-devel mailing list