Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

rockbox: add a crc32 reverse polynomial function

This uses the reverse of the polynomial used by the current crc_32
function. The code for this was derived from the implementation used
by tinf. This version is space optimized and should be a good way to
reduce code duplication in other parts of rockbox that use the same
crc32 algorithm. This is mainly of use in areas where DEFLATE is in
use.

Change-Id: I918da5b4ea4dc441c0e7e6b5007abcc2da463bcb

+33
+1
apps/plugin.c
··· 792 792 #ifdef PLUGIN_USE_IRAM 793 793 audio_hard_stop, 794 794 #endif 795 + crc_32r, 795 796 796 797 /* new stuff at the end, sort into place next time 797 798 the API gets incompatible */
+1
apps/plugin.h
··· 919 919 #ifdef PLUGIN_USE_IRAM 920 920 void (*audio_hard_stop)(void); 921 921 #endif 922 + uint32_t (*crc_32r)(const void *src, uint32_t len, uint32_t crc32); 922 923 923 924 /* new stuff at the end, sort into place next time 924 925 the API gets incompatible */
+30
firmware/common/crc32.c
··· 61 61 return crc32; 62 62 } 63 63 64 + 65 + /* crc_32r (derived from tinf crc32 which was taken from zlib) 66 + * CRC32 algorithm taken from the zlib source, which is 67 + * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler 68 + */ 69 + 70 + /* Tool function to calculate a CRC32 (reversed polynomial) across some buffer */ 71 + /* third argument is either the starting value or value from last piece */ 72 + uint32_t crc_32r(const void *src, uint32_t len, uint32_t crc32) 73 + { 74 + const unsigned char* buf = src; 75 + 76 + /* reversed polynomial from other crc32 function -- 0xEDB88320 */ 77 + static const unsigned crc32_lookup[16] = 78 + { 79 + 0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC, 80 + 0x76DC4190, 0x6B6B51F4, 0x4DB26158, 0x5005713C, 81 + 0xEDB88320, 0xF00F9344, 0xD6D6A3E8, 0xCB61B38C, 82 + 0x9B64C2B0, 0x86D3D2D4, 0xA00AE278, 0xBDBDF21C 83 + }; 84 + 85 + for(uint32_t i = 0; i < len; i++) 86 + { 87 + crc32 ^= buf[i]; 88 + crc32 = crc32_lookup[crc32 & 0x0F] ^ (crc32 >> 4); 89 + crc32 = crc32_lookup[crc32 & 0x0F] ^ (crc32 >> 4); 90 + } 91 + 92 + return crc32; 93 + }
+1
firmware/include/crc32.h
··· 24 24 #define _CRC32_H 25 25 26 26 uint32_t crc_32(const void *src, uint32_t len, uint32_t crc32); 27 + uint32_t crc_32r(const void *src, uint32_t len, uint32_t crc32); 27 28 28 29 #endif 29 30