| 1717 | } |
| 1718 | |
| 1719 | static void hb_stream_duration(hb_stream_t *stream, hb_title_t *inTitle) |
| 1720 | { |
| 1721 | struct pts_pos ptspos[NDURSAMPLES]; |
| 1722 | struct pts_pos *pp = ptspos; |
| 1723 | int i; |
| 1724 | |
| 1725 | fseeko(stream->file_handle, 0, SEEK_END); |
| 1726 | uint64_t fsize = ftello(stream->file_handle); |
| 1727 | uint64_t fincr = fsize / NDURSAMPLES; |
| 1728 | uint64_t fpos = fincr / 2; |
| 1729 | for ( i = NDURSAMPLES; --i >= 0; fpos += fincr ) |
| 1730 | { |
| 1731 | *pp++ = hb_sample_pts(stream, fpos); |
| 1732 | } |
| 1733 | uint64_t dur = compute_stream_rate( ptspos, pp - ptspos ) * (double)fsize; |
| 1734 | inTitle->duration = dur; |
| 1735 | dur /= 90000; |
| 1736 | inTitle->hours = dur / 3600; |
| 1737 | inTitle->minutes = ( dur % 3600 ) / 60; |
| 1738 | inTitle->seconds = dur % 60; |
| 1739 | |
| 1740 | rewind(stream->file_handle); |
| 1741 | } |
| 1742 | |
| 1743 | /*********************************************************************** |
| 1744 | * hb_stream_read |
no test coverage detected