forked from len0rd/rockbox
codecs: Update libspeex from 1.2beta3 to 1.2rc1
This is a relatively minor bump, but it's the first step towards bringing this current. Change-Id: Iab6c9b0c77f0ba705280434ea74b513364719499
This commit is contained in:
parent
8ef20383b1
commit
547b6a570d
21 changed files with 1406 additions and 1001 deletions
|
@ -1,22 +1,22 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: speex_header.c
|
||||
Describes the Speex header
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
@ -47,7 +47,7 @@
|
|||
/** Convert little endian */
|
||||
static inline spx_int32_t le_int(spx_int32_t i)
|
||||
{
|
||||
#ifdef ROCKBOX
|
||||
#ifdef ROCKBOX
|
||||
return letoh32(i);
|
||||
#elif !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
|
||||
spx_uint32_t ui, ret;
|
||||
|
@ -86,7 +86,7 @@ typedef struct SpeexHeader {
|
|||
*/
|
||||
|
||||
#ifndef SPEEX_DISABLE_ENCODER
|
||||
void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const SpeexMode *m)
|
||||
EXPORT void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const SpeexMode *m)
|
||||
{
|
||||
int i;
|
||||
const char *h="Speex ";
|
||||
|
@ -101,10 +101,10 @@ void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const Spe
|
|||
header->speex_version[i]=SPEEX_VERSION[i];
|
||||
for (;i<SPEEX_HEADER_VERSION_LENGTH;i++)
|
||||
header->speex_version[i]=0;
|
||||
|
||||
|
||||
header->speex_version_id = 1;
|
||||
header->header_size = sizeof(SpeexHeader);
|
||||
|
||||
|
||||
header->rate = rate;
|
||||
header->mode = m->modeID;
|
||||
header->mode_bitstream_version = m->bitstream_version;
|
||||
|
@ -114,20 +114,20 @@ void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const Spe
|
|||
header->bitrate = -1;
|
||||
speex_mode_query(m, SPEEX_MODE_FRAME_SIZE, &header->frame_size);
|
||||
header->vbr = 0;
|
||||
|
||||
|
||||
header->frames_per_packet = 0;
|
||||
header->extra_headers = 0;
|
||||
header->reserved1 = 0;
|
||||
header->reserved2 = 0;
|
||||
}
|
||||
|
||||
char *speex_header_to_packet(SpeexHeader *header, int *size)
|
||||
EXPORT char *speex_header_to_packet(SpeexHeader *header, int *size)
|
||||
{
|
||||
SpeexHeader *le_header;
|
||||
le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader));
|
||||
|
||||
|
||||
SPEEX_COPY(le_header, header, 1);
|
||||
|
||||
|
||||
/*Make sure everything is now little-endian*/
|
||||
ENDIAN_SWITCH(le_header->speex_version_id);
|
||||
ENDIAN_SWITCH(le_header->header_size);
|
||||
|
@ -147,7 +147,7 @@ char *speex_header_to_packet(SpeexHeader *header, int *size)
|
|||
#endif /* SPEEX_DISABLE_ENCODER */
|
||||
|
||||
static SpeexHeader global_le_header; /* Avoid malloc */
|
||||
SpeexHeader *speex_packet_to_header(char *packet, int size)
|
||||
EXPORT SpeexHeader *speex_packet_to_header(char *packet, int size)
|
||||
{
|
||||
int i;
|
||||
SpeexHeader *le_header = &global_le_header;
|
||||
|
@ -158,18 +158,18 @@ SpeexHeader *speex_packet_to_header(char *packet, int size)
|
|||
speex_notify("This doesn't look like a Speex file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*FIXME: Do we allow larger headers?*/
|
||||
if (size < (int)sizeof(SpeexHeader))
|
||||
{
|
||||
speex_notify("Speex header too small");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); */
|
||||
|
||||
|
||||
SPEEX_COPY(le_header, (SpeexHeader*)packet, 1);
|
||||
|
||||
|
||||
/*Make sure everything is converted correctly from little-endian*/
|
||||
ENDIAN_SWITCH(le_header->speex_version_id);
|
||||
ENDIAN_SWITCH(le_header->header_size);
|
||||
|
@ -183,6 +183,25 @@ SpeexHeader *speex_packet_to_header(char *packet, int size)
|
|||
ENDIAN_SWITCH(le_header->frames_per_packet);
|
||||
ENDIAN_SWITCH(le_header->extra_headers);
|
||||
|
||||
if (le_header->mode >= SPEEX_NB_MODES || le_header->mode < 0)
|
||||
{
|
||||
speex_notify("Invalid mode specified in Speex header");
|
||||
speex_free (le_header);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (le_header->nb_channels>2)
|
||||
le_header->nb_channels = 2;
|
||||
if (le_header->nb_channels<1)
|
||||
le_header->nb_channels = 1;
|
||||
|
||||
return le_header;
|
||||
|
||||
}
|
||||
|
||||
#if 0 /* Unused by rockbox */
|
||||
EXPORT void speex_header_free(void *ptr)
|
||||
{
|
||||
speex_free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue