]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'refs/heads/t/opus_cleanup'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 12 Jun 2016 07:29:21 +0000 (09:29 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 12 Jun 2016 07:32:09 +0000 (09:32 +0200)
Was cooking for two months.

* refs/heads/t/opus_cleanup:
  opus: Make opus_common.[ch] independent of ogg.h.
  opus: Use uint16_t for preskip and gain.

NEWS.md
opus_common.c
opus_common.h
opusdec_filter.c

diff --git a/NEWS.md b/NEWS.md
index b95cbb4fc85f8e6d06333466c74004f49122a118..d7b347e155065bf48e3d08edc2ae0246a9ebc3dd 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -22,6 +22,7 @@ not mentioned here have accumulated and are also part of the release.
 - Cleanup of the wma decoder and bitstream code.
 - Improved wide-character support and fixes related to signal handling.
 - para_gui no longer reports 100% playing time at the stream start.
+- Opus cleanups.
 
 Download: [tarball](./releases/paraslash-git.tar.bz2)
 
index 67a8841e8b8ce7fe172043a144332cb1db4c577f..f4e18df915d657e43e9f9e583313ef962471a62a 100644 (file)
@@ -29,8 +29,6 @@
  * handler.
  */
 
-#include <ogg/ogg.h>
-
 #include "para.h"
 #include "error.h"
 #include "opus_common.h"
@@ -53,7 +51,7 @@ static int read_chars(struct packet *p, unsigned char *str, int nb_chars)
        return 1;
 }
 
-static int read_uint32(struct packet *p, ogg_uint32_t *val)
+static int read_uint32(struct packet *p, uint32_t *val)
 {
        if (p->pos > p->maxlen - 4)
                return 0;
@@ -62,7 +60,7 @@ static int read_uint32(struct packet *p, ogg_uint32_t *val)
        return 1;
 }
 
-static int read_uint16(struct packet *p, ogg_uint16_t *val)
+static int read_uint16(struct packet *p, uint16_t *val)
 {
        if (p->pos > p->maxlen - 2)
                return 0;
@@ -89,7 +87,6 @@ int opus_parse_header(const char *packet, int len, struct opus_header *h)
        char str[9];
        struct packet p;
        unsigned char ch, channel_mapping;
-       ogg_uint16_t shortval;
 
        p.data = packet;
        p.maxlen = len;
@@ -113,16 +110,14 @@ int opus_parse_header(const char *packet, int len, struct opus_header *h)
        if (h->channels == 0)
                return -E_OPUS_HEADER;
 
-       if (!read_uint16(&p, &shortval))
+       if (!read_uint16(&p, &h->preskip))
                return -E_OPUS_HEADER;
-       h->preskip = shortval;
 
        if (!read_uint32(&p, &h->input_sample_rate))
                return -E_OPUS_HEADER;
 
-       if (!read_uint16(&p, &shortval))
+       if (!read_uint16(&p, &h->gain))
                return -E_OPUS_HEADER;
-       h->gain = (short)shortval;
 
        if (!read_chars(&p, &ch, 1))
                return -E_OPUS_HEADER;
index 2bcf5919f934622278dc2f9ba85b0516cf1d3767..2160f15192f30a8f1b5fde0be38fcd127a89681a 100644 (file)
@@ -16,11 +16,11 @@ struct opus_header {
        /** 1..255 */
        int channels;
        /** Number of bytes to skip from the beginning. */
-       int preskip;
+       uint16_t preskip;
        /** Sample rate of the input stream, used by the audio format handler. */
-       ogg_uint32_t input_sample_rate;
+       uint32_t input_sample_rate;
        /** In dB, should be zero whenever possible. */
-       int gain;
+       uint16_t gain;
        /** Number of logical streams (usually 1). */
        int nb_streams;
        /** Number of streams to decode as 2 channel streams. */
index 6a93f41f6b25f9e9d36b58726708861a52ed6b89..282229855d0d97519f886483c249d8e3f4b00b4f 100644 (file)
@@ -70,7 +70,7 @@ struct opusdec_context {
        ogg_page ogg_page;
        bool eos;
        int channels;
-       int preskip;
+       uint16_t preskip;
        bool have_opus_stream;
        bool have_more;
        ogg_int32_t opus_serialno;
@@ -142,9 +142,10 @@ static int opusdec_init(ogg_packet *op, struct opusdec_context *ctx)
 static void opusdec_add_output(short *pcm, int frames_available,
                struct btr_node *btrn, struct opusdec_context *ctx)
 {
-       int tmp_skip, num_frames, bytes;
+       int num_frames, bytes;
+       uint16_t tmp_skip;
 
-       tmp_skip = PARA_MIN(ctx->preskip, frames_available);
+       tmp_skip = PARA_MIN((int)ctx->preskip, frames_available);
        ctx->preskip -= tmp_skip;
        num_frames = frames_available - tmp_skip;
        if (num_frames <= 0)