[Vorbis-dev] libvorbis without encapulsation

Miscellaneous accounts-misc at holbrook.no
Mon Feb 6 08:37:29 UTC 2017


Using libvorbis (1.3.5) I wish to extract the raw vorbis packets. 

I've built some simple code on the excellent libvorbis API overview on
the xiph.org site, but the example relies on the ogg_packet struct for
final output and input to decoder, and shows now examples on how to do
without it.

Taking a look at the vorbis_bitstream_flush() function, which in the
overview is the last step before output, it seems that there is an
oggpack_buffer in an array of buffers internal to vorbis_block:

(*vorbis_block.internal)(vorbis_block.internal)->packetblob[PACKETBLOBS 
/ 2]

(PACKETBLOBS = 15, the macro is not commented, so don't know what this
is).

This is the output of a encoder pass from gdb:

(gdb) p *vbi
$3 = {pcmdelay = 0x647140, ampmax = -58.0271301, blocktype = 0,
packetblob = {0x6473c0, 0x647500, 0x647640, 0x647780, 0x6478c0, 
    0x647a00, 0x647b40, 0x7fffffffdeb8, 0x647d90, 0x647ed0, 0x648010,
0x648150, 0x648290, 0x6483d0, 0x648510}}

The stack address is the "oggpack_buffer index" in question. I can't
find this address anywhere else (on the surface):

vorbis_block:
(gdb) p vblk 
$4 = {pcm = 0x643770, opb = {endbyte = 117, endbit = 0, 
    buffer = 0x647c80
"\354*\020\003QQi~\352\306\061\356TޮSD\271\235g\257\267է\273_/;\255\231
\232Xk^;2-
\352\352X{\275\246\365\f\a\255W6\371f_=a~\302\337\365\343׆?Jj\210\262\3
71\245\367u\266z\257\325\334T\355\365\200\327T\346\a%\255r\313\361PF\23
1\016\311\323\353\032U\177\247W9\344ĴU\262\tc\321\360\234)ǔ_z)", ptr =
0x647cf5 "", storage = 256}, lW = 0, W = 0, nW = 0, pcmend = 512, mode
= 0, 
  eofflag = 0, granulepos = 0, sequence = 3, vd = 0x7fffffffde20,
localstore = 0x64a380, localtop = 64, localalloc = 64, 
  totaluse = 7376, reap = 0x64a360, glue_bits = 0, time_bits = 0,
floor_bits = 0, res_bits = 0, internal = 0x647330}

vorbis_dsp_state:
(gdb) p vdsps
$10 = {analysisp = 1, vi = 0x7fffffffdde0, pcm = 0x642750, pcmret =
0x642770, pcm_storage = 221012, pcm_current = 55376, 
  pcm_returned = 0, preextrapolate = 1, eofflag = 0, lW = 0, W = 0, nW
= 0, centerW = 512, granulepos = 256, sequence = 4, 
  glue_bits = 0, time_bits = 0, floor_bits = 0, res_bits = 0,
backend_state = 0x608790}

=====

oggpack_buffer comes from ogg/ogg.h, so I guess it may add some things
not native to "pure" vorbis.

Am I to understand that I am dependent on the ogg library to get data
in and out? And if not, where can I get the data along with the minimal
metadata I need? (bytes, granulepos?)




More information about the Vorbis-dev mailing list