| 1412 | | int64_t i_pos = i_percent * stream_Size( p_demux->s ) / 100; |
|---|
| 1413 | | |
|---|
| 1414 | | msg_Dbg( p_demux, "inacurate way of seeking" ); |
|---|
| 1415 | | for( i_index = 0; i_index < p_sys->i_index; i_index++ ) |
|---|
| 1416 | | { |
|---|
| 1417 | | if( p_sys->index[i_index].i_position >= i_pos) |
|---|
| 1418 | | { |
|---|
| 1419 | | break; |
|---|
| 1420 | | } |
|---|
| 1421 | | } |
|---|
| 1422 | | if( i_index == p_sys->i_index ) |
|---|
| 1423 | | { |
|---|
| 1424 | | i_index--; |
|---|
| 1425 | | } |
|---|
| 1426 | | |
|---|
| 1427 | | p_sys->in->setFilePointer( p_sys->index[i_index].i_position, |
|---|
| 1428 | | seek_beginning ); |
|---|
| 1429 | | |
|---|
| 1430 | | if( p_sys->index[i_index].i_position < i_pos ) |
|---|
| 1431 | | { |
|---|
| 1432 | | EbmlElement *el; |
|---|
| 1433 | | |
|---|
| 1434 | | msg_Warn( p_demux, "searching for cluster, could take some time" ); |
|---|
| 1435 | | |
|---|
| 1436 | | /* search a cluster */ |
|---|
| 1437 | | while( ( el = p_sys->ep->Get() ) != NULL ) |
|---|
| 1438 | | { |
|---|
| 1439 | | if( MKV_IS_ID( el, KaxCluster ) ) |
|---|
| 1440 | | { |
|---|
| 1441 | | KaxCluster *cluster = (KaxCluster*)el; |
|---|
| 1442 | | |
|---|
| 1443 | | /* add it to the index */ |
|---|
| 1444 | | IndexAppendCluster( p_demux, cluster ); |
|---|
| 1445 | | |
|---|
| 1446 | | if( (int64_t)cluster->GetElementPosition() >= i_pos ) |
|---|
| | 1408 | if (p_sys->f_duration >= 0) |
|---|
| | 1409 | { |
|---|
| | 1410 | i_date = i_percent * p_sys->f_duration * 10; |
|---|
| | 1411 | } |
|---|
| | 1412 | else |
|---|
| | 1413 | { |
|---|
| | 1414 | int64_t i_pos = i_percent * stream_Size( p_demux->s ) / 100; |
|---|
| | 1415 | |
|---|
| | 1416 | msg_Dbg( p_demux, "inacurate way of seeking" ); |
|---|
| | 1417 | for( i_index = 0; i_index < p_sys->i_index; i_index++ ) |
|---|
| | 1418 | { |
|---|
| | 1419 | if( p_sys->index[i_index].i_position >= i_pos) |
|---|
| | 1420 | { |
|---|
| | 1421 | break; |
|---|
| | 1422 | } |
|---|
| | 1423 | } |
|---|
| | 1424 | if( i_index == p_sys->i_index ) |
|---|
| | 1425 | { |
|---|
| | 1426 | i_index--; |
|---|
| | 1427 | } |
|---|
| | 1428 | |
|---|
| | 1429 | i_date = p_sys->index[i_index].i_time; |
|---|
| | 1430 | |
|---|
| | 1431 | #if 0 |
|---|
| | 1432 | if( p_sys->index[i_index].i_position < i_pos ) |
|---|
| | 1433 | { |
|---|
| | 1434 | EbmlElement *el; |
|---|
| | 1435 | |
|---|
| | 1436 | msg_Warn( p_demux, "searching for cluster, could take some time" ); |
|---|
| | 1437 | |
|---|
| | 1438 | /* search a cluster */ |
|---|
| | 1439 | while( ( el = p_sys->ep->Get() ) != NULL ) |
|---|
| | 1440 | { |
|---|
| | 1441 | if( MKV_IS_ID( el, KaxCluster ) ) |
|---|
| 1454 | | } |
|---|
| 1455 | | } |
|---|
| 1456 | | else |
|---|
| 1457 | | { |
|---|
| 1458 | | for( i_index = 0; i_index < p_sys->i_index; i_index++ ) |
|---|
| 1459 | | { |
|---|
| 1460 | | if( p_sys->index[i_index].i_time >= i_date ) |
|---|
| 1461 | | { |
|---|
| 1462 | | break; |
|---|
| 1463 | | } |
|---|
| 1464 | | } |
|---|
| 1465 | | |
|---|
| 1466 | | if( i_index > 0 ) |
|---|
| 1467 | | { |
|---|
| 1468 | | i_index--; |
|---|
| 1469 | | } |
|---|
| 1470 | | |
|---|
| 1471 | | msg_Dbg( p_demux, "seek got "I64Fd" (%d%%)", |
|---|
| 1472 | | p_sys->index[i_index].i_time, |
|---|
| 1473 | | (int)( 100 * p_sys->index[i_index].i_position / |
|---|
| 1474 | | stream_Size( p_demux->s ) ) ); |
|---|
| 1475 | | |
|---|
| 1476 | | p_sys->in->setFilePointer( p_sys->index[i_index].i_position, |
|---|
| 1477 | | seek_beginning ); |
|---|
| 1478 | | } |
|---|
| | 1457 | #endif |
|---|
| | 1458 | } |
|---|
| | 1459 | } |
|---|
| | 1460 | |
|---|
| | 1461 | for( ; i_index < p_sys->i_index; i_index++ ) |
|---|
| | 1462 | { |
|---|
| | 1463 | if( p_sys->index[i_index].i_time > i_date ) |
|---|
| | 1464 | { |
|---|
| | 1465 | break; |
|---|
| | 1466 | } |
|---|
| | 1467 | } |
|---|
| | 1468 | |
|---|
| | 1469 | if( i_index > 0 ) |
|---|
| | 1470 | { |
|---|
| | 1471 | i_index--; |
|---|
| | 1472 | } |
|---|
| | 1473 | |
|---|
| | 1474 | msg_Dbg( p_demux, "seek got "I64Fd" (%d%%)", |
|---|
| | 1475 | p_sys->index[i_index].i_time, |
|---|
| | 1476 | (int)( 100 * p_sys->index[i_index].i_position / |
|---|
| | 1477 | stream_Size( p_demux->s ) ) ); |
|---|
| | 1478 | |
|---|
| | 1479 | p_sys->in->setFilePointer( p_sys->index[i_index].i_position, |
|---|
| | 1480 | seek_beginning ); |
|---|
| | 1481 | |
|---|
| 1515 | | if( tk.fmt.i_cat == VIDEO_ES && i_block_ref1 == -1 && tk.b_search_keyframe ) |
|---|
| 1516 | | { |
|---|
| 1517 | | tk.b_search_keyframe = VLC_FALSE; |
|---|
| 1518 | | i_track_skipping--; |
|---|
| 1519 | | } |
|---|
| 1520 | | if( tk.fmt.i_cat == VIDEO_ES && !tk.b_search_keyframe ) |
|---|
| 1521 | | { |
|---|
| 1522 | | BlockDecode( p_demux, block, 0, 0 ); |
|---|
| | 1518 | if( tk.fmt.i_cat == VIDEO_ES ) |
|---|
| | 1519 | { |
|---|
| | 1520 | if( i_block_ref1 == -1 && tk.b_search_keyframe ) |
|---|
| | 1521 | { |
|---|
| | 1522 | tk.b_search_keyframe = VLC_FALSE; |
|---|
| | 1523 | i_track_skipping--; |
|---|
| | 1524 | } |
|---|
| | 1525 | if( !tk.b_search_keyframe ) |
|---|
| | 1526 | { |
|---|
| | 1527 | BlockDecode( p_demux, block, 0, 0 ); |
|---|
| | 1528 | /* es_out_Control( p_demux->out, ES_OUT_SET_PCR, block->GlobalTimecode() / (mtime_t) 1000 );*/ |
|---|
| | 1529 | } |
|---|