Changeset 12077fd171905b6c9c958986d69d071a302d83b8
- Timestamp:
- 20/12/04 08:44:39
(4 years ago)
- Author:
- Rocky Bernstein <rocky@videolan.org>
- git-committer:
- Rocky Bernstein <rocky@videolan.org> 1103528679 +0000
- git-parent:
[6ba6c14fd5e810734e4170bbb95b1a731525212c]
- git-author:
- Rocky Bernstein <rocky@videolan.org> 1103528679 +0000
- Message:
Improve entry navigation and title update.
Next/Prev chapter don't work yet, nor does entry detection when random
seeking.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r6ba6c14 |
r12077fd |
|
| 1 | 1 | /***************************************************************************** |
|---|
| 2 | | * vcd.c : VCD input module for vlc |
|---|
| 3 | | * using libcdio, libvcd and libvcdinfo. vlc-specific things tend |
|---|
| 4 | | * to go here. |
|---|
| | 2 | * vcd.c : VCD input module for vlc using libcdio, libvcd and libvcdinfo. |
|---|
| | 3 | * vlc-specific things tend to go here. |
|---|
| 5 | 4 | ***************************************************************************** |
|---|
| 6 | 5 | * Copyright (C) 2000, 2003, 2004 VideoLAN |
|---|
| … | … | |
| 9 | 8 | * Authors: Rocky Bernstein <rocky@panix.com> |
|---|
| 10 | 9 | * Some code is based on the non-libcdio VCD plugin (as there really |
|---|
| 11 | | * isn't real documentation yet.) |
|---|
| | 10 | * isn't real developer documentation yet on how to write a |
|---|
| | 11 | * navigable plugin.) |
|---|
| 12 | 12 | * |
|---|
| 13 | 13 | * This program is free software; you can redistribute it and/or modify |
|---|
| … | … | |
| 155 | 155 | block_t *p_block; |
|---|
| 156 | 156 | int i_blocks = VCD_BLOCKS_ONCE; |
|---|
| 157 | | int i_index; |
|---|
| 158 | 157 | int i_read; |
|---|
| 159 | 158 | byte_t p_last_sector[ M2F2_SECTOR_SIZE ]; |
|---|
| … | … | |
| 177 | 176 | } |
|---|
| 178 | 177 | |
|---|
| 179 | | for ( i_index = 0 ; i_index < i_blocks ; i_index++ ) |
|---|
| | 178 | for ( i_read = 0 ; i_read < i_blocks ; i_read++ ) |
|---|
| 180 | 179 | { |
|---|
| 181 | 180 | |
|---|
| … | … | |
| 204 | 203 | byte_t * p_buf = (byte_t *) p_block->p_buffer; |
|---|
| 205 | 204 | |
|---|
| 206 | | p_buf += (i_index*M2F2_SECTOR_SIZE); |
|---|
| | 205 | p_buf += (i_read*M2F2_SECTOR_SIZE); |
|---|
| 207 | 206 | memset(p_buf, 0, M2F2_SECTOR_SIZE); |
|---|
| 208 | 207 | p_buf += 2; |
|---|
| … | … | |
| 224 | 223 | p_vcd->i_lsn, |
|---|
| 225 | 224 | (byte_t *) p_block->p_buffer |
|---|
| 226 | | + (i_index*M2F2_SECTOR_SIZE) ) < 0 ) |
|---|
| | 225 | + (i_read*M2F2_SECTOR_SIZE) ) < 0 ) |
|---|
| 227 | 226 | { |
|---|
| 228 | 227 | LOG_ERR ("could not read sector %lu", |
|---|
| … | … | |
| 240 | 239 | if ( VCDINFO_ITEM_TYPE_ENTRY == p_vcd->play_item.type ) |
|---|
| 241 | 240 | { |
|---|
| 242 | | const input_title_t *t = p_vcd->p_title[p_access->info.i_title]; |
|---|
| 243 | | |
|---|
| 244 | | if( t->i_seekpoint > 0 && |
|---|
| 245 | | p_access->info.i_seekpoint + 1 < t->i_seekpoint && |
|---|
| 246 | | p_access->info.i_pos + i_read * M2F2_SECTOR_SIZE >= |
|---|
| 247 | | t->seekpoint[p_access->info.i_seekpoint+1]->i_byte_offset ) |
|---|
| | 241 | unsigned int i_entry = p_vcd->play_item.num+1; |
|---|
| | 242 | |
|---|
| | 243 | if (p_vcd->i_lsn >= vcdinfo_get_entry_lba(p_vcd->vcd, i_entry)) |
|---|
| 248 | 244 | { |
|---|
| 249 | 245 | const track_t i_track = p_vcd->i_track; |
|---|
| 250 | | const unsigned int i_entry = ++p_vcd->play_item.num; |
|---|
| 251 | | msg_Dbg( p_access, "seekpoint change" ); |
|---|
| | 246 | p_vcd->play_item.num = i_entry; |
|---|
| | 247 | dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "entry change" ); |
|---|
| 252 | 248 | VCDSetOrigin( p_access, |
|---|
| 253 | | vcdinfo_get_track_lsn(p_vcd->vcd, i_track), |
|---|
| 254 | | vcdinfo_get_entry_lsn(p_vcd->vcd, i_entry), |
|---|
| 255 | | vcdinfo_get_track_lsn(p_vcd->vcd, i_track+1), |
|---|
| | 249 | vcdinfo_get_track_lba(p_vcd->vcd, i_track), |
|---|
| | 250 | vcdinfo_get_entry_lba(p_vcd->vcd, i_entry), |
|---|
| | 251 | vcdinfo_get_track_lba(p_vcd->vcd, i_track+1), |
|---|
| 256 | 252 | i_track, &(p_vcd->play_item) ); |
|---|
| 257 | 253 | } |
|---|
| … | … | |
| 259 | 255 | } |
|---|
| 260 | 256 | |
|---|
| 261 | | if ( i_index != i_blocks ) /* this should not happen */ |
|---|
| | 257 | if ( i_read != i_blocks ) /* this should not happen */ |
|---|
| 262 | 258 | { |
|---|
| 263 | 259 | if ( VCDReadSector( VLC_OBJECT(p_access), p_vcd->vcd, |
|---|
| … | … | |
| 312 | 308 | } |
|---|
| 313 | 309 | |
|---|
| | 310 | dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK), |
|---|
| | 311 | "orig %lu, cur: %lu, offset: %lld, entry %d", |
|---|
| | 312 | (long unsigned int) p_vcd->origin_lsn, |
|---|
| | 313 | (long unsigned int) p_vcd->i_lsn, i_pos, |
|---|
| | 314 | i_entry ); |
|---|
| | 315 | |
|---|
| 314 | 316 | /* Find seekpoint */ |
|---|
| 315 | 317 | for( i_seekpoint = 0; i_seekpoint < t->i_seekpoint; i_seekpoint++ ) |
|---|
| … | … | |
| 322 | 324 | if( i_seekpoint != p_access->info.i_seekpoint ) |
|---|
| 323 | 325 | { |
|---|
| 324 | | msg_Dbg( p_access, "seekpoint change" ); |
|---|
| | 326 | dbg_print( (INPUT_DBG_SEEK), "seekpoint change %lu", |
|---|
| | 327 | (long unsigned int) i_seekpoint ); |
|---|
| 325 | 328 | p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT; |
|---|
| 326 | 329 | p_access->info.i_seekpoint = i_seekpoint; |
|---|
| 327 | 330 | } |
|---|
| 328 | 331 | |
|---|
| 329 | | dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK), |
|---|
| 330 | | "orig %lu, cur: %lu, offset: %lld, entry %d", |
|---|
| 331 | | (long unsigned int) p_vcd->origin_lsn, |
|---|
| 332 | | (long unsigned int) p_vcd->i_lsn, i_pos, |
|---|
| 333 | | i_entry ); |
|---|
| 334 | | |
|---|
| 335 | 332 | } |
|---|
| 336 | 333 | return VLC_SUCCESS; |
|---|
| … | … | |
| 368 | 365 | vcdinfo_track_get_entry( p_vcd->vcd, i_track); |
|---|
| 369 | 366 | |
|---|
| 370 | | /* Valid tracks go from 1...i_tracks-1, because track 0 is |
|---|
| 371 | | unplayable. */ |
|---|
| | 367 | /* Valid MPEG tracks go from 1...i_tracks. */ |
|---|
| 372 | 368 | |
|---|
| 373 | | if (i_track == 0 || i_track >= p_vcd->i_tracks) { |
|---|
| | 369 | if (i_track == 0 || i_track > p_vcd->i_tracks) { |
|---|
| 374 | 370 | LOG_ERR ("Invalid track number %d", i_track ); |
|---|
| 375 | 371 | return VLC_EGENERIC; |
|---|
| … | … | |
| 377 | 373 | p_vcd->in_still = VLC_FALSE; |
|---|
| 378 | 374 | VCDSetOrigin( p_access, |
|---|
| 379 | | vcdinfo_get_track_lsn(p_vcd->vcd, i_track), |
|---|
| 380 | | vcdinfo_get_entry_lsn(p_vcd->vcd, i_entry), |
|---|
| 381 | | vcdinfo_get_track_lsn(p_vcd->vcd, i_track+1), |
|---|
| | 375 | vcdinfo_get_track_lba(p_vcd->vcd, i_track), |
|---|
| | 376 | vcdinfo_get_entry_lba(p_vcd->vcd, i_entry), |
|---|
| | 377 | vcdinfo_get_track_lba(p_vcd->vcd, i_track+1), |
|---|
| 382 | 378 | i_track, &itemid ); |
|---|
| 383 | 379 | break; |
|---|
| … | … | |
| 473 | 469 | p_vcd->in_still = VLC_FALSE; |
|---|
| 474 | 470 | VCDSetOrigin( p_access, |
|---|
| 475 | | vcdinfo_get_entry_lsn(p_vcd->vcd, i_track), |
|---|
| 476 | | vcdinfo_get_entry_lsn(p_vcd->vcd, i_entry), |
|---|
| 477 | | vcdinfo_get_entry_lsn(p_vcd->vcd, i_track+1), |
|---|
| | 471 | vcdinfo_get_entry_lba(p_vcd->vcd, i_track), |
|---|
| | 472 | vcdinfo_get_entry_lba(p_vcd->vcd, i_entry), |
|---|
| | 473 | vcdinfo_get_entry_lba(p_vcd->vcd, i_track+1), |
|---|
| 478 | 474 | i_track, &itemid ); |
|---|
| 479 | 475 | } |
|---|
| … | … | |
| 536 | 532 | snprintf(psz_entry, sizeof(psz_entry), "%s%02d", _("Entry "), i ); |
|---|
| 537 | 533 | |
|---|
| 538 | | p_vcd->p_entries[i] = vcdinfo_get_entry_lsn(p_vcd->vcd, i); |
|---|
| | 534 | p_vcd->p_entries[i] = vcdinfo_get_entry_lba(p_vcd->vcd, i); |
|---|
| 539 | 535 | |
|---|
| 540 | 536 | s->psz_name = strdup(psz_entry); |
|---|
| 541 | 537 | s->i_byte_offset = |
|---|
| 542 | | (p_vcd->p_entries[i] - vcdinfo_get_track_lsn(p_vcd->vcd, i_track)) |
|---|
| | 538 | (p_vcd->p_entries[i] - vcdinfo_get_track_lba(p_vcd->vcd, i_track)) |
|---|
| 543 | 539 | * M2F2_SECTOR_SIZE; |
|---|
| 544 | 540 | |
|---|
| | 541 | dbg_print( INPUT_DBG_MRL, |
|---|
| | 542 | "%s, lsn %d, byte_offset %ld\n", |
|---|
| | 543 | s->psz_name, p_vcd->p_entries[i], |
|---|
| | 544 | (unsigned long int) s->i_byte_offset); |
|---|
| 545 | 545 | TAB_APPEND( p_vcd->p_title[i_track-1]->i_seekpoint, |
|---|
| 546 | 546 | p_vcd->p_title[i_track-1]->seekpoint, s ); |
|---|
| | 547 | |
|---|
| 547 | 548 | } else |
|---|
| 548 | 549 | msg_Warn( p_access, "wrong track number found in entry points" ); |
|---|
| … | … | |
| 847 | 848 | |
|---|
| 848 | 849 | p_access->info.i_title = i_track-1; |
|---|
| 849 | | p_access->info.i_seekpoint = p_itemid->num; |
|---|
| 850 | 850 | p_access->info.i_size = p_vcd->p_title[i_title]->i_size; |
|---|
| 851 | 851 | p_access->info.i_pos = ( i_lsn - origin_lsn ) * M2F2_SECTOR_SIZE; |
|---|
| … | … | |
| 1265 | 1265 | vlc_input_title_Duplicate( p_vcd->p_title[i] ); |
|---|
| 1266 | 1266 | } |
|---|
| 1267 | | |
|---|
| 1268 | | |
|---|
| 1269 | | return VLC_SUCCESS; |
|---|
| 1270 | 1267 | } |
|---|
| 1271 | 1268 | break; |
|---|
| … | … | |
| 1288 | 1285 | |
|---|
| 1289 | 1286 | VCDSetOrigin(p_access, |
|---|
| 1290 | | vcdinfo_get_track_lsn(p_vcd->vcd, i_track), |
|---|
| 1291 | | vcdinfo_get_entry_lsn(p_vcd->vcd, i_entry), |
|---|
| 1292 | | vcdinfo_get_track_lsn(p_vcd->vcd, i_track+1), |
|---|
| | 1287 | vcdinfo_get_track_lba(p_vcd->vcd, i_track), |
|---|
| | 1288 | vcdinfo_get_entry_lba(p_vcd->vcd, i_entry), |
|---|
| | 1289 | vcdinfo_get_track_lba(p_vcd->vcd, i_track+1), |
|---|
| 1293 | 1290 | i_track, &itemid ); |
|---|
| 1294 | 1291 | } |
|---|
| … | … | |
| 1304 | 1301 | { |
|---|
| 1305 | 1302 | track_t i_track = p_access->info.i_title+1; |
|---|
| 1306 | | lsn_t track_lsn = vcdinfo_get_track_lsn(p_vcd->vcd, i_track); |
|---|
| 1307 | | |
|---|
| 1308 | | p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT; |
|---|
| 1309 | | p_access->info.i_seekpoint = i; |
|---|
| 1310 | 1303 | |
|---|
| 1311 | 1304 | /* FIXME! For now we are assuming titles are only |
|---|
| 1312 | | tracks and that track == title+1 */ |
|---|
| 1313 | | |
|---|
| 1314 | | p_vcd->i_lsn = track_lsn |
|---|
| 1315 | | + (t->seekpoint[i]->i_byte_offset / M2F2_SECTOR_SIZE); |
|---|
| 1316 | | |
|---|
| 1317 | | p_access->info.i_pos = (int64_t)(p_vcd->i_lsn - track_lsn) |
|---|
| 1318 | | * M2F2_SECTOR_SIZE; |
|---|
| | 1305 | tracks and that track == title+1 and we the play |
|---|
| | 1306 | item is entries (not tracks or lids). |
|---|
| | 1307 | We need to generalize all of this. |
|---|
| | 1308 | */ |
|---|
| | 1309 | |
|---|
| | 1310 | p_vcd->play_item.num = i; |
|---|
| | 1311 | p_vcd->play_item.type = VCDINFO_ITEM_TYPE_ENTRY; |
|---|
| | 1312 | |
|---|
| | 1313 | VCDSetOrigin( p_access, |
|---|
| | 1314 | vcdinfo_get_track_lba(p_vcd->vcd, i_track), |
|---|
| | 1315 | vcdinfo_get_entry_lba(p_vcd->vcd, i), |
|---|
| | 1316 | vcdinfo_get_track_lba(p_vcd->vcd, i_track+1), |
|---|
| | 1317 | i_track, &(p_vcd->play_item) ); |
|---|
| 1319 | 1318 | } |
|---|
| 1320 | 1319 | return VLC_SUCCESS; |
|---|
| r6ba6c14 |
r12077fd |
|
| 342 | 342 | } |
|---|
| 343 | 343 | |
|---|
| 344 | | snprintf(psz_mrl, psz_mrl_max, "%s%s@%c%u", VCD_MRL_PREFIX, psz_source, |
|---|
| | 344 | snprintf(psz_mrl, psz_mrl_max, "%s%s@%c%3u", VCD_MRL_PREFIX, psz_source, |
|---|
| 345 | 345 | c_type, itemid->num); |
|---|
| 346 | 346 | |
|---|