-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use ogg_page_granulepos to get number of samples written for Ogg FLAC
The granule position of the Ogg page will tell us how many audio frames are included in the page that we receive from libogg. Therefore, to count the number of frames per page, we simply check the granule position and subtract it from the granule position of the previous page. A signed 64-bit integer type is used for the granule position, as libogg also uses one as the return type of ogg_page_granulepos. An unsigned 32-bit integer is sufficient to contain the number of frames, as the granule position of a page is determined by the last complete packet in that page, the number of frames in each packet is limited by the 32-bit unsigned integer type internally in libflac, and an Ogg page, at most 65,307 bytes, can only contain at most ~20 million frames (tested experimentally with pure silence with maximum compression level).
- Loading branch information
Showing
2 changed files
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters