Re: How do I seek to seek to specific samples using libvorbis?

"Madison Link" <[email protected]> Tue, 19 May 2015 14:55:25 -0600
Newsgroups gmane.comp.multimedia.ogg.vorbis.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.

--===============1224324899==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0004_01D09243.D7A9D4C0"

This is a multi-part message in MIME format.

------=_NextPart_000_0004_01D09243.D7A9D4C0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Thanks.

 

If decoding from the last packet on the previous page works, I may have to
do that. But I was hoping to avoid it. Yes, I may be seeking a lot. A packet
spanning multiple pages shouldn't be a problem for me, because I'm only
adding index points that represent the beginning of a packet. But does this
actually happen for Vorbis? (Aside from large header packets) The large
blocks I've encountered seem to be 1024 samples per channel. Even with
8-channel audio, uncompressed floating-point PCM sound, such a packet would
only take up 129 segments on the segment table.

 

Madison

 

 

From: Jordan Verner [mailto:[email protected]] 

Sent: Tuesday, May 19, 2015 12:20 PM

To: Madison Link

Subject: RE: [Vorbis] How do I seek to seek to specific samples using
libvorbis?

 

What I did was performed a binary search in my ogg vorbis file, in order to
find the page proceeding the page containing the desired sample (you can
determine this using the granule position). Next, I used ogg_page_packets()
to determine how many packets complete on that page, skip to the final
packet by calling ogg_stream_packetout N times and just ignoring the result.
Then decode the page's final packet. This should mean that the next sample
you decode will actually be the one the granule position says it is. Then
you have to calculate an offset between the sample you're at and the one you
want, decode that many and discard them. In practice this seems to work but
leaves a lot to be desired. You could be decoding up to an entire page of
audio (slow if you seek a lot), and there's an off chance that a complex and
rare case involving a packet spanning three or more pages could still throw
you off. I think it could be possible to do it with only decoding two extra
packets if you can calculate where you'll end up based on blocksize values
and window overlapping rules, but it's not well explained. The spec leaves a
lot to be desired.

 


------=_NextPart_000_0004_01D09243.D7A9D4C0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"place"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"City"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:Arial;
	color:windowtext;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thanks.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>If decoding from the last packet on the previous page =
works,
I may have to do that. But I was hoping to avoid it. Yes, I may be =
seeking a
lot. A packet spanning multiple pages shouldn't be a problem for me, =
because
I'm only adding index points that represent the beginning of a packet. =
But does
this actually happen for Vorbis? (Aside from large header packets) The =
large
blocks I've encountered seem to be 1024 samples per channel. Even with
8-channel audio, uncompressed floating-point PCM sound, such a packet =
would
only take up 129 segments on the segment =
table.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><st1:City w:st=3D"on"><st1:place w:st=3D"on"><font =
size=3D2
  face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>Madison</span></font></st1:p=
lace></st1:City><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'><o:p></o:p></span></font></p=
>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>From: Jordan Verner [mailto:[email protected]] =
<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Sent: Tuesday, May 19, 2015 12:20 =
PM<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>To: Madison Link<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Subject: RE: [Vorbis] How do I seek to seek to =
specific
samples using libvorbis?<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>What I did was performed a binary search in my ogg =
vorbis
file, in order to find the page proceeding the page containing the =
desired
sample (you can determine this using the granule position). Next, I used
ogg_page_packets() to determine how many packets complete on that page, =
skip to
the final packet by calling ogg_stream_packetout N times and just =
ignoring the
result. Then decode the page's final packet. This should mean that the =
next
sample you decode will actually be the one the granule position says it =
is.
Then you have to calculate an offset between the sample you're at and =
the one
you want, decode that many and discard them. In practice this seems to =
work but
leaves a lot to be desired. You could be decoding up to an entire page =
of audio
(slow if you seek a lot), and there's an off chance that a complex and =
rare
case involving a packet spanning three or more pages could still throw =
you off.
I think it could be possible to do it with only decoding two extra =
packets if
you can calculate where you'll end up based on blocksize values and =
window
overlapping rules, but it's not well explained. The spec leaves a lot to =
be
desired.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>&nbsp;<o:p></o:p></span></font></p>

</div>

</body>

</html>

------=_NextPart_000_0004_01D09243.D7A9D4C0--


--===============1224324899==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Vorbis mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/vorbis

--===============1224324899==--