Browse Source

Add column parameter to ts_hex_dump

Georgi Chorbadzhiyski 8 years ago
parent
commit
5eacf80cd8
4 changed files with 9 additions and 9 deletions
  1. 1 1
      tsfuncs.h
  2. 3 3
      tsfuncs_descriptors.c
  3. 3 3
      tsfuncs_misc.c
  4. 2 2
      tsfuncs_pes.c

+ 1 - 1
tsfuncs.h View File

@@ -246,7 +246,7 @@ int				ts_crc32_section_check		(struct ts_section_header *section_header, char *
246 246
 int				dec2bcd						(int dec);
247 247
 int				bcd2dec						(int bcd);
248 248
 void			ts_compare_data   			(char *prefix, uint8_t *a, uint8_t *b, int size);
249
-char *			ts_hex_dump      			(uint8_t *d, int size);
249
+char *			ts_hex_dump      			(uint8_t *d, int size, int col);
250 250
 void			ts_print_bytes				(char *prefix, uint8_t *d, int size);
251 251
 char *			init_dvb_string_utf8		(char *text);
252 252
 char *			init_dvb_string_iso_8859_5	(char *text);

+ 3 - 3
tsfuncs_descriptors.c View File

@@ -48,7 +48,7 @@ void ts_descriptor_dump(uint8_t *desc_data, int desc_data_len) {
48 48
 
49 49
 		switch (tag) {
50 50
 			case  2: { // Video stream descriptor
51
-				char *dump = ts_hex_dump(data, this_length);
51
+				char *dump = ts_hex_dump(data, this_length, 0);
52 52
 				ts_LOGf("%sTag 0x%02x (%02d), sz: %d, Video stream descriptor: %s\n", pad, tag, tag, this_length, dump);
53 53
 				free(dump);
54 54
 				struct {
@@ -120,7 +120,7 @@ void ts_descriptor_dump(uint8_t *desc_data, int desc_data_len) {
120 120
 				break;
121 121
 			}
122 122
 			case  3: { // Audio stream descriptor
123
-				char *dump = ts_hex_dump(data, this_length);
123
+				char *dump = ts_hex_dump(data, this_length, 0);
124 124
 				ts_LOGf("%sTag 0x%02x (%02d), sz: %d, Audio stream descriptor: %s\n", pad, tag, tag, this_length, dump);
125 125
 				free(dump);
126 126
 				struct {
@@ -475,7 +475,7 @@ void ts_descriptor_dump(uint8_t *desc_data, int desc_data_len) {
475 475
 			}
476 476
 */
477 477
 			default: {
478
-				char *dump = ts_hex_dump(data, this_length);
478
+				char *dump = ts_hex_dump(data, this_length, 0);
479 479
 				ts_LOGf("%s*** Unknown Tag 0x%02x (%02d), sz: %d, data: %s\n", pad, tag, tag, this_length, dump);
480 480
 				free(dump);
481 481
 				break;

+ 3 - 3
tsfuncs_misc.c View File

@@ -15,13 +15,13 @@ int bcd2dec(int bcd) {
15 15
 	return ((bcd>>4) * 10) + bcd % 16;
16 16
 }
17 17
 
18
-char *ts_hex_dump(uint8_t *d, int size) {
18
+char *ts_hex_dump(uint8_t *d, int size, int col) {
19 19
 	int i;
20 20
 	char *buf = calloc(1, size * 6);
21 21
 	if (!buf)
22 22
 		return NULL;
23 23
 	for (i=0;i<size;i++) {
24
-		if (size > 188 && (i % 16 == 15))
24
+		if (col && (i % col == col - 1))
25 25
 			sprintf(buf+(i*3), "%02x\n", d[i]);
26 26
 		else
27 27
 			sprintf(buf+(i*3), "%02x ", d[i]);
@@ -30,7 +30,7 @@ char *ts_hex_dump(uint8_t *d, int size) {
30 30
 }
31 31
 
32 32
 void ts_print_bytes(char *prefix, uint8_t *d, int size) {
33
-	char *buf = ts_hex_dump(d, size);
33
+	char *buf = ts_hex_dump(d, size, 0);
34 34
 	ts_LOGf("%s -> %s\n", prefix, buf);
35 35
 	free(buf);
36 36
 }

+ 2 - 2
tsfuncs_pes.c View File

@@ -540,12 +540,12 @@ void ts_pes_dump(struct ts_pes *pes) {
540 540
 		pes->es_data_size
541 541
 	);
542 542
 
543
-	char *phex = ts_hex_dump(pes->pes_data, min(32, pes->pes_data_pos));
543
+	char *phex = ts_hex_dump(pes->pes_data, min(32, pes->pes_data_pos), 0);
544 544
 	ts_LOGf("  - PES dump   : %s...\n", phex);
545 545
 	free(phex);
546 546
 
547 547
 	if (pes->es_data) {
548
-		char *hex = ts_hex_dump(pes->es_data, min(32, pes->es_data_size));
548
+		char *hex = ts_hex_dump(pes->es_data, min(32, pes->es_data_size), 0);
549 549
 		ts_LOGf("  - ES dump    : %s...\n", hex);
550 550
 		free(hex);
551 551
 	}