shithub: opusfile

Download patch

ref: 21322357d4f8731cac3f6d8075f5331f0e462034
parent: 1886f65bc94fbd4779da2b9ac6e9898133031f43
author: Timothy B. Terriberry <[email protected]>
date: Sat Sep 29 03:17:33 EDT 2012

Clean-up for alternate configurations.

* s/op_read_stereo_float/op_read_float_stereo/ for the fixed-point
   API.
* Fix compiler warnings exposed when optimizations are enabled.
* Fix opusfile_example to work with --enable-fixed-point
   --disable-float
* Fix seeking_example to not re-define OP_FIXED_POINT if it's
   already been defined.

--- a/examples/opusfile_example.c
+++ b/examples/opusfile_example.c
@@ -24,6 +24,14 @@
 #endif
 #include <opusfile.h>
 
+#if defined(OP_FIXED_POINT)
+typedef opus_int16 op_sample;
+# define op_read_native_stereo op_read_stereo
+#else
+typedef float op_sample;
+# define op_read_native_stereo op_read_float_stereo
+#endif
+
 int main(int _argc,const char **_argv){
   OggOpusFile *of;
   ogg_int64_t  pcm_offset;
@@ -85,9 +93,9 @@
   }
   for(;;){
     ogg_int64_t next_pcm_offset;
-    float       pcm[120*48*2];
+    op_sample   pcm[120*48*2];
     int         li;
-    ret=op_read_float_stereo(of,pcm,sizeof(pcm)/sizeof(*pcm));
+    ret=op_read_native_stereo(of,pcm,sizeof(pcm)/sizeof(*pcm));
     if(ret<0){
       fprintf(stderr,"Error decoding '%s': %i\n",_argv[1],ret);
       ret=EXIT_FAILURE;
--- a/examples/seeking_example.c
+++ b/examples/seeking_example.c
@@ -26,7 +26,9 @@
 #include <opusfile.h>
 
 /*Use shorts, they're smaller.*/
-#define OP_FIXED_POINT (1)
+#if !defined(OP_FIXED_POINT)
+# define OP_FIXED_POINT (1)
+#endif
 
 #if defined(OP_FIXED_POINT)
 
@@ -436,8 +438,8 @@
     fprintf(stderr,")...\n");
     max_seeks=0;
     for(i=0;i<NSEEK_TESTS;i++){
-      long nseeks_tmp;
       ogg_int64_t pcm_offset2;
+      long        nseeks_tmp;
       nseeks_tmp=nreal_seeks;
       pcm_offset=(ogg_int64_t)(rand()/(double)RAND_MAX*pcm_length);
       fprintf(stderr,"\r\t%3i [PCM position %li]...                ",
--- a/src/http.c
+++ b/src/http.c
@@ -258,7 +258,9 @@
     hostport=userinfo_end+1;
   }
   else{
-    user=NULL;
+    /*We shouldn't have to initialize user_end, but gcc is too dumb to figure
+       out that user!=NULL below means we didn't take this else branch.*/
+    user=user_end=NULL;
     pass=NULL;
     hostport=authority;
   }
@@ -1251,6 +1253,10 @@
   int              ret;
   if(_proxy_host!=NULL&&OP_UNLIKELY(_proxy_port>65535U))return OP_EINVAL;
   last_host=NULL;
+  /*We shouldn't have to initialize last_port, but gcc is too dumb to figure
+     out that last_host!=NULL implies we've already taken one trip through the
+     loop.*/
+  last_port=0;
   ret=op_parse_url(&_stream->url,_url);
   if(OP_UNLIKELY(ret<0))return ret;
   for(nredirs=0;nredirs<OP_REDIRECT_LIMIT;nredirs++){
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -712,6 +712,11 @@
   if(_og==NULL)_og=&og;
   serialno=_of->os.serialno;
   cur_page_gp=-1;
+  op_count=0;
+  /*We shouldn't have to initialize total_duration, but gcc is too dumb to
+     figure out that op_count>0 implies we've been through the whole loop at
+     least once.*/
+  total_duration=0;
   do{
     /*We should get a page unless the file is truncated or mangled.
       Otherwise there are no audio data packets in the whole logical stream.*/
@@ -2553,6 +2558,7 @@
  op_sample *_src,int _nsamples,int _nchannels){
   float *dst;
   int    i;
+  _of=_of;
   dst=(float *)_dst;
   if(OP_UNLIKELY(_nsamples*_nchannels>_dst_sz))_nsamples=_dst_sz/_nchannels;
   _dst_sz=_nsamples*_nchannels;
@@ -2586,7 +2592,7 @@
   return op_short2float_filter(_of,dst,_dst_sz,_src,_nsamples,2);
 }
 
-int op_read_stereo_float(OggOpusFile *_of,opus_int16 *_pcm,int _buf_size){
+int op_read_float_stereo(OggOpusFile *_of,float *_pcm,int _buf_size){
   return op_read_native_filter(_of,_pcm,_buf_size,
    op_short2float_stereo_filter,NULL);
 }