Minor adjustment to CRC API
This commit is contained in:
parent
e0cc0d7f5b
commit
5dd680b942
4 changed files with 6 additions and 8 deletions
|
@ -202,7 +202,7 @@ dvb_proc_table(th_dvb_mux_instance_t *tdmi, th_dvb_table_t *tdt, uint8_t *sec,
|
|||
|
||||
/* It seems some hardware (or is it the dvb API?) does not
|
||||
honour the DMX_CHECK_CRC flag, so we check it again */
|
||||
if(chkcrc && crc32(sec, r))
|
||||
if(chkcrc && crc32(sec, r, 0xffffffff))
|
||||
return;
|
||||
|
||||
r -= 3;
|
||||
|
|
|
@ -63,7 +63,7 @@ psi_section_reassemble0(psi_section_t *ps, const uint8_t *data,
|
|||
|
||||
excess = ps->ps_offset - tsize;
|
||||
|
||||
if(crc && crc32(ps->ps_data, tsize))
|
||||
if(crc && crc32(ps->ps_data, tsize, 0xffffffff))
|
||||
return -1;
|
||||
|
||||
cb(ps->ps_data, tsize - (crc ? 4 : 0), opaque);
|
||||
|
@ -163,14 +163,14 @@ psi_append_crc32(uint8_t *buf, int offset, int maxlen)
|
|||
if(offset + 4 > maxlen)
|
||||
return -1;
|
||||
|
||||
crc = crc32(buf, offset);
|
||||
crc = crc32(buf, offset, 0xffffffff);
|
||||
|
||||
buf[offset + 0] = crc >> 24;
|
||||
buf[offset + 1] = crc >> 16;
|
||||
buf[offset + 2] = crc >> 8;
|
||||
buf[offset + 3] = crc;
|
||||
|
||||
assert(crc32(buf, offset + 4) == 0);
|
||||
assert(crc32(buf, offset + 4, 0xffffffff) == 0);
|
||||
|
||||
return offset + 4;
|
||||
}
|
||||
|
|
|
@ -839,6 +839,6 @@ int tvh_socket(int domain, int type, int protocol);
|
|||
|
||||
void hexdump(const char *pfx, const uint8_t *data, int len);
|
||||
|
||||
uint32_t crc32(uint8_t *data, size_t datalen);
|
||||
uint32_t crc32(uint8_t *data, size_t datalen, uint32_t crc);
|
||||
|
||||
#endif /* TV_HEAD_H */
|
||||
|
|
|
@ -51,10 +51,8 @@ static uint32_t crc_tab[256] = {
|
|||
};
|
||||
|
||||
uint32_t
|
||||
crc32(uint8_t *data, size_t datalen)
|
||||
crc32(uint8_t *data, size_t datalen, uint32_t crc)
|
||||
{
|
||||
uint32_t crc = 0xffffffff;
|
||||
|
||||
while(datalen--)
|
||||
crc = (crc << 8) ^ crc_tab[((crc >> 24) ^ *data++) & 0xff];
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue