shithub: opus-tools

Download patch

ref: 45fcaf8ec39b14bd700b15eed52373c5bb947dd5
parent: e8ad940085b3e9fe070f338765a54c15438de781
author: Jean-Marc Valin <[email protected]>
date: Mon Aug 1 08:01:00 EDT 2011

Remove the rest of skeleton support from opusenc

--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -69,8 +69,8 @@
    return written;
 }
 
-#define MAX_FRAME_SIZE 2048
-#define MAX_FRAME_BYTES 1275
+#define MAX_FRAME_SIZE (960*2*3)
+#define MAX_FRAME_BYTES 1276
 #define IMIN(a,b) ((a) < (b) ? (a) : (b))   /**< Minimum int value.   */
 #define IMAX(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum int value.   */
 
@@ -174,7 +174,6 @@
    printf (" --framesize n      Frame size (Default: 960)\n");
    printf (" --nopf             Do not use the prefilter/postfilter\n");
    printf (" --independent      Encode frames independently (implies nopf)\n");
-   printf (" --skeleton         Outputs ogg skeleton metadata (may cause incompatibilities)\n");
    printf (" --comment          Add the given string as an extra comment. This may be\n");
    printf ("                     used multiple times\n");
    printf (" --author           Author of this track\n");
@@ -209,7 +208,6 @@
    unsigned char bits[MAX_FRAME_BYTES];
    int with_cbr = 0;
    int with_cvbr = 0;
-   int with_skeleton = 0;
    int total_bytes = 0;
    int peak_bytes = 0;
    struct option long_options[] =
@@ -221,7 +219,6 @@
       {"nopf", no_argument, NULL, 0},
       {"independent", no_argument, NULL, 0},
       {"framesize", required_argument, NULL, 0},
-      {"skeleton",no_argument,NULL, 0},
       {"help", no_argument, NULL, 0},
       {"quiet", no_argument, NULL, 0},
       {"le", no_argument, NULL, 0},
@@ -245,7 +242,6 @@
    int fmt=16;
    int lsb=1;
    ogg_stream_state os;
-   ogg_stream_state so; /* ogg stream for skeleton bitstream */
    ogg_page 		 og;
    ogg_packet 		 op;
    int bytes_written=0, ret, result;
@@ -285,9 +281,6 @@
          } else if (strcmp(long_options[option_index].name,"cvbr")==0)
          {
             with_cvbr=1;
-         } else if (strcmp(long_options[option_index].name,"skeleton")==0)
-         {
-            with_skeleton=1;
          } else if (strcmp(long_options[option_index].name,"help")==0)
          {
             usage();
@@ -380,11 +373,6 @@
       fprintf(stderr,"Error: stream init failed\n");
       exit(1);
    }
-   if (with_skeleton && ogg_stream_init(&so, rand())==-1)
-   {
-      fprintf(stderr,"Error: stream init failed\n");
-      exit(1);
-   }
 
    if (strcmp(inFile, "-")==0)
    {
@@ -500,10 +488,6 @@
       close_out=1;
    }
 
-   if (with_skeleton) {
-      fprintf (stderr, "Warning: Enabling skeleton output may cause some decoders to fail.\n");
-   }
-
    /*Write header*/
    {
       unsigned char header_data[100];
@@ -607,8 +591,8 @@
       op.granulepos = (id+1)*frame_size-lookahead;
       if (op.granulepos>total_samples)
          op.granulepos = total_samples;
-      /*printf ("granulepos: %d %d %d %d %d %d\n", (int)op.granulepos, id, nframes, lookahead, 5, 6);*/
       op.packetno = 2+id;
+      /*printf ("granulepos: %d %d %d\n", (int)op.granulepos, op.packetno, op.bytes);*/
       ogg_stream_packetin(&os, &op);
 
       /*Write all new pages (most likely 0 or 1)*/
--- a/src/wav_io.c
+++ b/src/wav_io.c
@@ -45,6 +45,7 @@
    opus_int16 balign;
    int skip_bytes;
    int i;
+   int ret;
 
    ch[4]=0;
 #if 0
@@ -65,10 +66,10 @@
       return -1;
    }
 #endif
-   fread(ch, 1, 4, file);
+   ret = fread(ch, 1, 4, file);
    while (strcmp(ch, "fmt ")!=0)
    {
-      fread(&itmp, 4, 1, file);
+      ret = fread(&itmp, 4, 1, file);
       itmp = le_int(itmp);
       /*fprintf (stderr, "skip=%d\n", itmp);*/
       /*strange way of seeking, but it works even for pipes*/
@@ -75,7 +76,7 @@
       for (i=0;i<itmp;i++)
          fgetc(file);
       /*fseek(file, itmp, SEEK_CUR);*/
-      fread(ch, 1, 4, file);
+      ret = fread(ch, 1, 4, file);
       if (feof(file))
       {
          fprintf (stderr, "Corrupted WAVE file: no \"fmt \"\n");
@@ -88,12 +89,12 @@
       return -1;
       }*/
    
-   fread(&itmp, 4, 1, file);
+   ret = fread(&itmp, 4, 1, file);
    itmp = le_int(itmp);
    skip_bytes=itmp-16;
    /*fprintf (stderr, "skip=%d\n", skip_bytes);*/
    
-   fread(&stmp, 2, 1, file);
+   ret = fread(&stmp, 2, 1, file);
    stmp = le_short(stmp);
    if (stmp!=1)
    {
@@ -101,7 +102,7 @@
       return -1;
    }
 
-   fread(&stmp, 2, 1, file);
+   ret = fread(&stmp, 2, 1, file);
    stmp = le_short(stmp);
    *channels = stmp;
    
@@ -111,17 +112,17 @@
       return -1;
    }
 
-   fread(&itmp, 4, 1, file);
+   ret = fread(&itmp, 4, 1, file);
    itmp = le_int(itmp);
    *rate = itmp;
 
-   fread(&itmp, 4, 1, file);
+   ret = fread(&itmp, 4, 1, file);
    bpersec = le_int(itmp);
 
-   fread(&stmp, 2, 1, file);
+   ret = fread(&stmp, 2, 1, file);
    balign = le_short(stmp);
 
-   fread(&stmp, 2, 1, file);
+   ret = fread(&stmp, 2, 1, file);
    stmp = le_short(stmp);
    if (stmp!=16 && stmp!=8)
    {
@@ -150,16 +151,16 @@
 
    /*fseek(file, skip_bytes, SEEK_CUR);*/
 
-   fread(ch, 1, 4, file);
+   ret = fread(ch, 1, 4, file);
    while (strcmp(ch, "data")!=0)
    {
-      fread(&itmp, 4, 1, file);
+      ret = fread(&itmp, 4, 1, file);
       itmp = le_int(itmp);
       /*strange way of seeking, but it works even for pipes*/
       for (i=0;i<itmp;i++)
          fgetc(file);
       /*fseek(file, itmp, SEEK_CUR);*/
-      fread(ch, 1, 4, file);
+      ret = fread(ch, 1, 4, file);
       if (feof(file))
       {
          fprintf (stderr, "Corrupted WAVE file: no \"data\"\n");
@@ -168,7 +169,7 @@
    }
 
    /*Ignore this for now*/
-   fread(&itmp, 4, 1, file);
+   ret = fread(&itmp, 4, 1, file);
    itmp = le_int(itmp);
 
    *size=itmp;