Browse Source

Add ts_crc32_section_check()

Georgi Chorbadzhiyski 9 years ago
parent
commit
b9b83ab99d
2 changed files with 15 additions and 0 deletions
  1. 1
    0
      tsfuncs.h
  2. 14
    0
      tsfuncs_crc.c

+ 1
- 0
tsfuncs.h View File

@@ -235,6 +235,7 @@ void	ts_pes_es_dump							(struct ts_pes *pes);
235 235
 // CRC
236 236
 uint32_t        ts_crc32      (uint8_t *data, int data_size);
237 237
 uint32_t		ts_crc32_section			(struct ts_section_header *section_header);
238
+int				ts_crc32_section_check		(struct ts_section_header *section_header, char *table);
238 239
 
239 240
 // Misc
240 241
 int				dec2bcd						(int dec);

+ 14
- 0
tsfuncs_crc.c View File

@@ -43,3 +43,17 @@ u_int32_t ts_crc32_section(struct ts_section_header *section_header) {
43 43
 	// +3 to include the first 3 bytes before section_length field
44 44
 	return ts_crc32(section_header->section_data, section_header->section_length + 3);
45 45
 }
46
+
47
+int ts_crc32_section_check(struct ts_section_header *section_header, char *table) {
48
+	// +3 to include the first 3 bytes before section_length field
49
+	uint32_t check_crc = ts_crc32(section_header->section_data, section_header->section_length + 3);
50
+
51
+	if (check_crc != 0) {
52
+		ts_LOGf("!!! Wrong %s table CRC! It should be 0 but it is 0x%08x (CRC in data is 0x%08x)\n",
53
+			table,
54
+			check_crc,
55
+			section_header->CRC);
56
+		return 0;
57
+	}
58
+	return 1;
59
+}

Loading…
Cancel
Save