From 373dc625f82b47096893add42c4472e4a57ab7eb Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 9 Feb 2022 22:23:03 +0100 Subject: Moved third-party libraries to a separate subdirectory --- contrib/vorbis/doc/vorbisfile/seekexample.html | 152 +++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 contrib/vorbis/doc/vorbisfile/seekexample.html (limited to 'contrib/vorbis/doc/vorbisfile/seekexample.html') diff --git a/contrib/vorbis/doc/vorbisfile/seekexample.html b/contrib/vorbis/doc/vorbisfile/seekexample.html new file mode 100644 index 0000000..897403d --- /dev/null +++ b/contrib/vorbis/doc/vorbisfile/seekexample.html @@ -0,0 +1,152 @@ + + + +vorbisfile - Example Code + + + + + + + + + +

Vorbisfile documentation

vorbisfile version 1.3.2 - 20101101

+ +

Example Code: seeking

+ +

+The following is a run-through of the seeking example program supplied +with vorbisfile - seeking_test.c. +This program tests the vorbisfile ov_time_seek function by seeking to random points within the file. + +

+First, relevant headers, including vorbis-specific "codec.h" and "vorbisfile.h" have to be included. + +

+ + + + +
+

+#include <stdlib.h>
+#include <stdio.h>
+#include "vorbis/codec.h"
+#include "vorbis/vorbisfile.h"
+
+
+ +

Inside main(), we declare our primary OggVorbis_File structure. We also declare other helpful variables to track our progress within the file. +

+ + + + +
+

+int main(){
+  OggVorbis_File ov;
+  int i;
+
+
+ +

This example takes its input on stdin which is in 'text' mode by default under Windows; this will corrupt the input data unless set to binary mode. This applies only to Windows. +

+ + + + +
+

+#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */
+  _setmode( _fileno( stdin ), _O_BINARY );
+#endif
+
+
+ +

ov_open() must be +called to initialize the OggVorbis_File structure with default values. +ov_open_callbacks() also checks to ensure that we're reading Vorbis format and not something else. + +

+ + + + +
+

+  if(ov_open_callbacks(stdin,&ov,NULL,-1, OV_CALLBACKS_NOCLOSE)<0){
+    printf("Could not open input as an OggVorbis file.\n\n");
+    exit(1);
+  }
+
+
+
+ +

+First we check to make sure the stream is seekable using ov_seekable. + +

Then we seek to 100 random spots in the bitstream using ov_time_seek with randomly generated values. + +

+ + + + +
+

+  
+  /* print details about each logical bitstream in the input */
+  if(ov_seekable(&ov)){
+    double length=ov_time_total(&ov,-1);
+    printf("testing seeking to random places in %g seconds....\n",length);
+    for(i=0;i<100;i++){
+      double val=(double)rand()/RAND_MAX*length;
+      ov_time_seek(&ov,val);
+      printf("\r\t%d [%gs]...     ",i,val);
+      fflush(stdout);
+    }
+    
+    printf("\r                                   \nOK.\n\n");
+  }else{
+    printf("Standard input was not seekable.\n");
+  }
+  
+
+
+

+When we're done seeking, we need to call ov_clear() to release the bitstream. + +

+ + + + +
+

+  ov_clear(&ov);
+  return 0;
+}
+
+
+ +

+The full source for seeking_test.c can be found with the vorbis +distribution in seeking_test.c. + +

+


+ + + + + + + + +

copyright © 2000-2010 Xiph.Org

Ogg Vorbis

Vorbisfile documentation

vorbisfile version 1.3.2 - 20101101

+ + + + -- cgit v1.1