From: Andre Noll Date: Sun, 12 Jun 2016 07:29:21 +0000 (+0200) Subject: Merge branch 'refs/heads/t/opus_cleanup' X-Git-Tag: v0.5.6~19 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=3fd8d0567ae654aed7e97e832568d3e1b98e20a2;hp=12078f149febaa15e29ecfde2884e2905cb2b34e;p=paraslash.git Merge branch 'refs/heads/t/opus_cleanup' 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. --- diff --git a/NEWS.md b/NEWS.md index b95cbb4f..d7b347e1 100644 --- 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) diff --git a/opus_common.c b/opus_common.c index 67a8841e..f4e18df9 100644 --- a/opus_common.c +++ b/opus_common.c @@ -29,8 +29,6 @@ * handler. */ -#include - #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; diff --git a/opus_common.h b/opus_common.h index 2bcf5919..2160f151 100644 --- a/opus_common.h +++ b/opus_common.h @@ -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. */ diff --git a/opusdec_filter.c b/opusdec_filter.c index 6a93f41f..28222985 100644 --- a/opusdec_filter.c +++ b/opusdec_filter.c @@ -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)