[opus] Ogg Format

Timothy B. Terriberry tterribe at xiph.org
Mon May 9 18:01:29 UTC 2016


Amit Ashara wrote:
> First Packet shall have Header Type as BOS
> All subsequent Packet (except last one_ shall have Header Type as
> Continuation
> Last Packet shall have Header Type as EOS
>
> Is this correct?

No, the header_type field is a property of a page, not a packet. In it, 
the continuation flag is used when a single packet spans multiple pages. 
This is required when a packet is larger than the maximum size of a page 
(about 64 kB), but in most uses of Opus will almost never be needed.

> The Page Segment shall have the value as 1 since only one segment will
> be available and the Segment Table will have the value 100 indicating
> that the next 100 bytes are belonging to the same stream and is one
> encoded frame
>
> Is this correct?

No. You are required to have at least three pages: one for the 
identification header (OpusHead), which must contain only that packet, 
one (or more) for the metadata header (OpusTags), which must terminate 
the page it ends on, and then one more for your 20 ms audio data packet.

In the description, you also said that the final output was 100 
halfwords (200 bytes). The value in the page segment table is the number 
of bytes, not the number of halfwords.

> If the above is true then if the Page Segment has the value 20, then the
> segment table shall look something like (assuming 100 half words is what
> is encoded evry time)
>
> 100, Data.... 20 times before the next Page Segment is started!!!

No. The segment table contains the lacing values for all packets on the 
page, followed by the data for all packets. So it would look more like:

20 (number_page_segments) 100, 100, 100 ... (20 times, the 
segment_table), data, data, data, ... (again, 20 times).

It may be easier for you to work from some examples. I'd recommend 
looking at the code in opus-tools: 
<https://git.xiph.org/?p=opus-tools.git>. This gets all of these details 
correct.


More information about the opus mailing list