shithub: opus-tools

Download patch

ref: f47ff049ae8f960ff75a3a916cf553378f21cba6
parent: 7dbf0598a3e50244aceab404cfcc38209270df3c
author: Jean-Marc Valin <jean-marc.valin@usherbrooke.ca>
date: Wed Aug 3 05:22:45 EDT 2011

s/pregap/preskip/

--- a/src/opus_header.c
+++ b/src/opus_header.c
@@ -4,10 +4,19 @@
 
 /* Header contents:
   - "OpusHead" (64 bits)
-  - Sampling rate (32 bits, max 192)
-  - Channel mapping (bool in byte)
+  - version number (8 bits)
+  - Sampling rate (32 bits)
+  - multistream (8bits, 0=single stream (mono/stereo) 1=multistream, 2..255: multistream with mapping)
   - Channels (8 bits)
-  - Pre-gap (16 bits)
+  - Pre-skip (16 bits)
+  
+  if (multistream)
+     - N = number of streams (8 bits)
+     - N times:
+          - stereo flag (8 bits, 0=mono, 1=stereo)
+          - channel for left (8 bits)
+          - if stereo:
+             - channel for right (8 bits)
 */
 
 typedef struct {
@@ -114,7 +123,7 @@
    h->channels = ch;
    if (!read_uint16(&p, &shortval))
       return 0;
-   h->pregap = shortval;
+   h->preskip = shortval;
    
    /* Multi-stream support */
    if (h->multi_stream!=0)
@@ -168,7 +177,7 @@
    ch = h->channels;
    if (!write_chars(&p, &ch, 1))
       return 0;
-   if (!write_uint16(&p, h->pregap))
+   if (!write_uint16(&p, h->preskip))
       return 0;
    
    /* Multi-stream support */
--- a/src/opus_header.h
+++ b/src/opus_header.h
@@ -8,7 +8,7 @@
    opus_uint32 sample_rate;
    int multi_stream;
    int channels;
-   int pregap;
+   int preskip;
    int nb_streams;
    unsigned char mapping[256][3];
 } OpusHeader;
--- a/src/opusdec.c
+++ b/src/opusdec.c
@@ -285,7 +285,7 @@
    printf ("Copyright (C) 2008-2011 Jean-Marc Valin\n");
 }
 
-static OpusDecoder *process_header(ogg_packet *op, opus_int32 *rate, int *channels, int *pregap, int quiet)
+static OpusDecoder *process_header(ogg_packet *op, opus_int32 *rate, int *channels, int *preskip, int quiet)
 {
    OpusDecoder *st;
    OpusHeader header;
@@ -306,7 +306,7 @@
 
    if (!*rate)
       *rate = header.sample_rate;
-   *pregap = header.pregap;
+   *preskip = header.preskip;
    st = opus_decoder_create(48000, header.channels);
    if (!st)
    {
@@ -387,7 +387,7 @@
    int channels=-1;
    int rate=0;
    int wav_format=0;
-   int pregap=0;
+   int preskip=0;
    int opus_serialno = -1;
    SpeexResamplerState *resampler=NULL;
 
@@ -539,7 +539,7 @@
             /*If first packet, process as OPUS header*/
             if (packet_count==0)
             {
-               st = process_header(&op, &rate, &channels, &pregap, quiet);
+               st = process_header(&op, &rate, &channels, &preskip, quiet);
                if (!st)
                   exit(1);
                if (rate != 48000)
@@ -602,15 +602,15 @@
                      /*printf ("packet %d %d\n", packet_no, skip_samples);*/
                      /*fprintf (stderr, "packet %d %d %d\n", packet_no, skip_samples, lookahead);*/
 
-                     new_frame_size = frame_size - pregap;
-                     frame_offset = pregap;
+                     new_frame_size = frame_size - preskip;
+                     frame_offset = preskip;
                      if (new_frame_size>0)
                      {
                         audio_write(out+frame_offset*channels, channels, new_frame_size, fout, resampler);
                         audio_size+=sizeof(short)*new_frame_size*channels;
-                        pregap = 0;
+                        preskip = 0;
                      } else {
-                        pregap -= frame_size;
+                        preskip -= frame_size;
                      }
                   }
                }
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -466,7 +466,7 @@
    comment_init(&comments, &comments_length, vendor_string);
 
    header.channels = chan;
-   header.pregap = 0;
+   header.preskip = 0;
    header.multi_stream = 0;
    header.sample_rate = rate;