| 240 | } |
| 241 | |
| 242 | static uint64_t |
| 243 | PttDuration(ifo_handle_t *ifo, int ttn, int pttn, int *blocks, int *last_pgcn) |
| 244 | { |
| 245 | int pgcn, pgn; |
| 246 | pgc_t * pgc; |
| 247 | uint64_t duration = 0; |
| 248 | int cell_start, cell_end; |
| 249 | int i; |
| 250 | |
| 251 | *blocks = 0; |
| 252 | |
| 253 | // Initialize map of visited pgc's to prevent loops |
| 254 | uint32_t pgcn_map[MAX_PGCN/32]; |
| 255 | PgcWalkInit( pgcn_map ); |
| 256 | pgcn = ifo->vts_ptt_srpt->title[ttn-1].ptt[pttn-1].pgcn; |
| 257 | pgn = ifo->vts_ptt_srpt->title[ttn-1].ptt[pttn-1].pgn; |
| 258 | if ( pgcn < 1 || pgcn > ifo->vts_pgcit->nr_of_pgci_srp || pgcn >= MAX_PGCN) |
| 259 | { |
| 260 | hb_log( "invalid PGC ID %d, skipping", pgcn ); |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | if( pgn <= 0 || pgn > 99 ) |
| 265 | { |
| 266 | hb_log( "scan: pgn %d not valid, skipping", pgn ); |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | do |
| 271 | { |
| 272 | pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc; |
| 273 | if (!pgc) |
| 274 | { |
| 275 | *blocks = 0; |
| 276 | duration = 0; |
| 277 | hb_log( "scan: pgc not valid, skipping" ); |
| 278 | break; |
| 279 | } |
| 280 | |
| 281 | if (pgc->cell_playback == NULL) |
| 282 | { |
| 283 | *blocks = 0; |
| 284 | duration = 0; |
| 285 | hb_log("invalid PGC cell_playback table, skipping"); |
| 286 | break; |
| 287 | } |
| 288 | |
| 289 | if (pgn > pgc->nr_of_programs) |
| 290 | { |
| 291 | pgn = 1; |
| 292 | continue; |
| 293 | } |
| 294 | |
| 295 | duration += 90LL * dvdtime2msec( &pgc->playback_time ); |
| 296 | |
| 297 | cell_start = pgc->program_map[pgn-1] - 1; |
| 298 | cell_end = pgc->nr_of_cells - 1; |
| 299 | for(i = cell_start; i <= cell_end; i = FindNextCell(pgc, i)) |
no test coverage detected