| 1104 | } |
| 1105 | |
| 1106 | static int next_packet( BLURAY *bd, uint8_t *pkt ) |
| 1107 | { |
| 1108 | int result; |
| 1109 | |
| 1110 | while ( 1 ) |
| 1111 | { |
| 1112 | result = bd_read( bd, pkt, 192 ); |
| 1113 | if ( result < 0 ) |
| 1114 | { |
| 1115 | return -1; |
| 1116 | } |
| 1117 | if ( result < 192 ) |
| 1118 | { |
| 1119 | return 0; |
| 1120 | } |
| 1121 | // Sync byte is byte 4. 0-3 are timestamp. |
| 1122 | if (pkt[4] == 0x47) |
| 1123 | { |
| 1124 | return 1; |
| 1125 | } |
| 1126 | // lost sync - back up to where we started then try to re-establish. |
| 1127 | uint64_t pos = bd_tell(bd); |
| 1128 | uint64_t pos2 = align_to_next_packet(bd, pkt); |
| 1129 | if (pos2 < 0) |
| 1130 | { |
| 1131 | return -1; |
| 1132 | } |
| 1133 | else if (pos2 == 0) |
| 1134 | { |
| 1135 | hb_log("next_packet: eof while re-establishing sync @ %"PRIu64"", pos ); |
| 1136 | return 0; |
| 1137 | } |
| 1138 | hb_log("next_packet: sync lost @ %"PRIu64", regained after %"PRIu64" bytes", |
| 1139 | pos, pos2 ); |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | static int title_info_compare_mpls(const void *va, const void *vb) |
| 1144 | { |
no test coverage detected