- CacheSize+=descr_len;
- __u8 *d = new __u8[descr_len];
- memcpy(d, descr, descr_len);
- descriptors[crc] = descriptorPair(1, d);
+ switch (descr[0])
+ {
+ case EXTENDED_EVENT_DESCRIPTOR:
+ case SHORT_EVENT_DESCRIPTOR:
+ case LINKAGE_DESCRIPTOR:
+ case COMPONENT_DESCRIPTOR:
+ {
+ __u32 crc = 0;
+ int cnt=0;
+ while(cnt++ < descr_len)
+ crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ data[ptr++]) & 0xFF];
+
+ descriptorMap::iterator it =
+ descriptors.find(crc);
+ if ( it == descriptors.end() )
+ {
+ CacheSize+=descr_len;
+ __u8 *d = new __u8[descr_len];
+ memcpy(d, descr, descr_len);
+ descriptors[crc] = descriptorPair(1, d);
+ }
+ else
+ ++it->second.first;
+ *pdescr++=crc;
+ break;
+ }
+ default: // do not cache all other descriptors
+ ptr += descr_len;
+ break;
+ }
+ size -= descr_len;