| 1477 | } |
| 1478 | |
| 1479 | static hb_buffer_t * hb_ps_stream_getVideo( |
| 1480 | hb_stream_t *stream, |
| 1481 | hb_pes_info_t *pi) |
| 1482 | { |
| 1483 | hb_buffer_t *buf = hb_buffer_init(HB_DVD_READ_BUFFER_SIZE); |
| 1484 | hb_pes_info_t pes_info; |
| 1485 | // how many blocks we read while searching for a video PES header |
| 1486 | int blksleft = 2048; |
| 1487 | |
| 1488 | while (--blksleft >= 0) |
| 1489 | { |
| 1490 | buf->size = 0; |
| 1491 | int len = hb_ps_read_packet( stream, buf ); |
| 1492 | if ( len == 0 ) |
| 1493 | { |
| 1494 | // EOF |
| 1495 | break; |
| 1496 | } |
| 1497 | if ( !hb_parse_ps( stream, buf->data, buf->size, &pes_info ) ) |
| 1498 | continue; |
| 1499 | |
| 1500 | int idx; |
| 1501 | if ( pes_info.stream_id == 0xbd ) |
| 1502 | { |
| 1503 | idx = index_of_ps_stream( stream, pes_info.stream_id, |
| 1504 | pes_info.bd_substream_id ); |
| 1505 | } |
| 1506 | else |
| 1507 | { |
| 1508 | idx = index_of_ps_stream( stream, pes_info.stream_id, |
| 1509 | pes_info.stream_id_ext ); |
| 1510 | } |
| 1511 | if ( idx >= 0 && stream->pes.list[idx].stream_kind == V ) |
| 1512 | { |
| 1513 | if ( pes_info.pts != AV_NOPTS_VALUE ) |
| 1514 | { |
| 1515 | *pi = pes_info; |
| 1516 | return buf; |
| 1517 | } |
| 1518 | } |
| 1519 | } |
| 1520 | hb_buffer_close( &buf ); |
| 1521 | return NULL; |
| 1522 | } |
| 1523 | |
| 1524 | /*********************************************************************** |
| 1525 | * hb_stream_duration |
no test coverage detected