Browse Source

Fix for MPTS streams.

Without this if the input is MPTS, tsdecrypt incorrectly tries to
decrypt (and brokes) services that do not belong to the chosen
input services. An additional extra is that with this decrypting
a service in MPTS is a lot quicker since lots of unneeded work is
avoided.
Francesco Schiavarelli 12 years ago
parent
commit
f5667e75fb
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      process.c

+ 7
- 4
process.c View File

128
 	for (i = 0; i < batch_sz; i++) {
128
 	for (i = 0; i < batch_sz; i++) {
129
 		uint8_t *ts_packet = data + (i * 188);
129
 		uint8_t *ts_packet = data + (i * 188);
130
 
130
 
131
-		int scramble_idx = ts_packet_get_scrambled(ts_packet);
132
-		if (scramble_idx > 1) {
131
+		uint16_t pid = ts_packet_get_pid(ts_packet);
132
+		if (pidmap_get(&ts->pidmap, pid) && ts_packet_is_scrambled(ts_packet)) {
133
 			if (ts->key.is_valid_cw) {
133
 			if (ts->key.is_valid_cw) {
134
+				int scramble_idx = ts_packet_get_scrambled(ts_packet);
134
 				uint8_t payload_ofs = ts_packet_get_payload_offset(ts_packet);
135
 				uint8_t payload_ofs = ts_packet_get_payload_offset(ts_packet);
135
 				if (scramble_idx == 2) { // scramble_idx 2 == even key
136
 				if (scramble_idx == 2) { // scramble_idx 2 == even key
136
 					even_pcks[even_packets].data = ts_packet + payload_ofs;
137
 					even_pcks[even_packets].data = ts_packet + payload_ofs;
366
 				}
367
 				}
367
 			}
368
 			}
368
 		} else {
369
 		} else {
369
-			decode_packet(ts, ts_packet);
370
+			int allowed_pid = pidmap_get(&ts->pidmap, pid);
371
+			if (allowed_pid) // PAT or allowed PIDs
372
+				decode_packet(ts, ts_packet);
370
 			if (ts->pid_filter) {
373
 			if (ts->pid_filter) {
371
-				if (pidmap_get(&ts->pidmap, pid)) // PAT or allowed PIDs
374
+				if (allowed_pid) // PAT or allowed PIDs
372
 					output_write(ts, ts_packet, 188);
375
 					output_write(ts, ts_packet, 188);
373
 			} else {
376
 			} else {
374
 				output_write(ts, ts_packet, 188);
377
 				output_write(ts, ts_packet, 188);

Loading…
Cancel
Save