summaryrefslogtreecommitdiff
path: root/apps/codecs/libwmavoice
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwmavoice')
-rw-r--r--apps/codecs/libwmavoice/SOURCES17
-rw-r--r--apps/codecs/libwmavoice/libwmavoice.make37
-rw-r--r--apps/codecs/libwmavoice/wmavoice.c33
-rw-r--r--apps/codecs/libwmavoice/wmavoice.h7
4 files changed, 89 insertions, 5 deletions
diff --git a/apps/codecs/libwmavoice/SOURCES b/apps/codecs/libwmavoice/SOURCES
new file mode 100644
index 0000000000..c98821c42a
--- /dev/null
+++ b/apps/codecs/libwmavoice/SOURCES
@@ -0,0 +1,17 @@
1acelp_filters.c
2acelp_vectors.c
3avfft.c
4bitstream.c
5celp_filters.c
6celp_math.c
7dct.c
8fft.c
9lsp.c
10mdct.c
11rdft.c
12utils.c
13wmavoice.c
14libavutil/log.c
15libavutil/lzo.c
16libavutil/mem.c
17libavutil/mathematics.c
diff --git a/apps/codecs/libwmavoice/libwmavoice.make b/apps/codecs/libwmavoice/libwmavoice.make
new file mode 100644
index 0000000000..0497e18e1b
--- /dev/null
+++ b/apps/codecs/libwmavoice/libwmavoice.make
@@ -0,0 +1,37 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id: libwmavoice.make 27586 2010-07-27 06:48:15Z nls $
8#
9
10# libwmavoice
11WMAVOICELIB := $(CODECDIR)/libwmavoice.a
12WMAVOICELIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwmavoice/SOURCES)
13WMAVOICELIB_OBJ := $(call c2obj, $(WMAVOICELIB_SRC))
14OTHER_SRC += $(WMAVOICELIB_SRC)
15
16$(WMAVOICELIB): $(WMAVOICELIB_OBJ)
17 $(SILENT)$(shell rm -f $@)
18 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
19
20WMAVOICEFLAGS = -I$(APPSDIR)/codecs/libwmavoice $(filter-out -O%,$(CODECFLAGS))
21
22ifeq ($(CPU),coldfire)
23 WMAVOICEFLAGS += -O2
24else
25 WMAVOICEFLAGS += -O1
26endif
27
28ifeq ($(APP_TYPE),sdl-sim)
29# wmavoice needs libm in the simulator
30$(CODECDIR)/wmavoice.codec: $(CODECDIR)/wmavoice.o
31 $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/wmavoice.elf \
32 $(filter %.o, $^) \
33 $(filter %.a, $+) \
34 -lgcc -lm $(CODECLDFLAGS)
35 $(SILENT)cp $(CODECDIR)/wmavoice.elf $@
36endif
37
diff --git a/apps/codecs/libwmavoice/wmavoice.c b/apps/codecs/libwmavoice/wmavoice.c
index 39bcb0e04e..f8bd6d656e 100644
--- a/apps/codecs/libwmavoice/wmavoice.c
+++ b/apps/codecs/libwmavoice/wmavoice.c
@@ -26,7 +26,7 @@
26 */ 26 */
27 27
28#include <math.h> 28#include <math.h>
29#include "avcodec.h" 29#include "wmavoice.h"
30#include "get_bits.h" 30#include "get_bits.h"
31#include "put_bits.h" 31#include "put_bits.h"
32#include "wmavoice_data.h" 32#include "wmavoice_data.h"
@@ -286,6 +286,10 @@ typedef struct {
286 */ 286 */
287} WMAVoiceContext; 287} WMAVoiceContext;
288 288
289/* global decode context */
290static WMAVoiceContext globWMAVoiceCtx;
291
292
289/** 293/**
290 * Set up the variable bit mode (VBM) tree from container extradata. 294 * Set up the variable bit mode (VBM) tree from container extradata.
291 * @param gb bit I/O context. 295 * @param gb bit I/O context.
@@ -330,9 +334,10 @@ static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25])
330/** 334/**
331 * Set up decoder with parameters from demuxer (extradata etc.). 335 * Set up decoder with parameters from demuxer (extradata etc.).
332 */ 336 */
333static av_cold int wmavoice_decode_init(AVCodecContext *ctx) 337av_cold int wmavoice_decode_init(AVCodecContext *ctx)
334{ 338{
335 int n, flags, pitch_range, lsp16_flag; 339 int n, flags, pitch_range, lsp16_flag;
340 ctx->priv_data = &globWMAVoiceCtx;
336 WMAVoiceContext *s = ctx->priv_data; 341 WMAVoiceContext *s = ctx->priv_data;
337 342
338 /** 343 /**
@@ -1743,7 +1748,7 @@ static int synth_superframe(AVCodecContext *ctx,
1743 * the wild yet. */ 1748 * the wild yet. */
1744 if (!get_bits1(gb)) { 1749 if (!get_bits1(gb)) {
1745 av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1); 1750 av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1);
1746 return -1; 1751 return ERROR_WMAPRO_IN_WMAVOICE;
1747 } 1752 }
1748 1753
1749 /* (optional) nr. of samples in superframe; always <= 480 and >= 0 */ 1754 /* (optional) nr. of samples in superframe; always <= 480 and >= 0 */
@@ -1893,7 +1898,7 @@ static void copy_bits(PutBitContext *pb,
1893 * 1898 *
1894 * For more information about frames, see #synth_superframe(). 1899 * For more information about frames, see #synth_superframe().
1895 */ 1900 */
1896static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, 1901int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
1897 int *data_size, AVPacket *avpkt) 1902 int *data_size, AVPacket *avpkt)
1898{ 1903{
1899 WMAVoiceContext *s = ctx->priv_data; 1904 WMAVoiceContext *s = ctx->priv_data;
@@ -1936,6 +1941,15 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
1936 s->sframe_cache_size += s->spillover_nbits; 1941 s->sframe_cache_size += s->spillover_nbits;
1937 if ((res = synth_superframe(ctx, data, data_size)) == 0 && 1942 if ((res = synth_superframe(ctx, data, data_size)) == 0 &&
1938 *data_size > 0) { 1943 *data_size > 0) {
1944 /* convert the float values to int32 for rockbox */
1945 int i;
1946 int32_t *iptr = data;
1947 float *fptr = data;
1948 for(i = 0; i < *data_size/sizeof(float); i++)
1949 {
1950 fptr[i] *= (float)(INT32_MAX);
1951 iptr[i] = (int32_t)fptr[i];
1952 }
1939 cnt += s->spillover_nbits; 1953 cnt += s->spillover_nbits;
1940 s->skip_bits_next = cnt & 7; 1954 s->skip_bits_next = cnt & 7;
1941 return cnt >> 3; 1955 return cnt >> 3;
@@ -1957,12 +1971,21 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
1957 } else if (*data_size > 0) { 1971 } else if (*data_size > 0) {
1958 int cnt = get_bits_count(gb); 1972 int cnt = get_bits_count(gb);
1959 s->skip_bits_next = cnt & 7; 1973 s->skip_bits_next = cnt & 7;
1974 /* convert the float values to int32 for rockbox */
1975 int i;
1976 int32_t *iptr = data;
1977 float *fptr = data;
1978 for(i = 0; i < *data_size/sizeof(float); i++)
1979 {
1980 fptr[i] *= (float)(INT32_MAX);
1981 iptr[i] = (int32_t)fptr[i];
1982 }
1960 return cnt >> 3; 1983 return cnt >> 3;
1961 } else if ((s->sframe_cache_size = pos) > 0) { 1984 } else if ((s->sframe_cache_size = pos) > 0) {
1962 /* rewind bit reader to start of last (incomplete) superframe... */ 1985 /* rewind bit reader to start of last (incomplete) superframe... */
1963 init_get_bits(gb, avpkt->data, size << 3); 1986 init_get_bits(gb, avpkt->data, size << 3);
1964 skip_bits_long(gb, (size << 3) - pos); 1987 skip_bits_long(gb, (size << 3) - pos);
1965 assert(get_bits_left(gb) == pos); 1988 //assert(get_bits_left(gb) == pos);
1966 1989
1967 /* ...and cache it for spillover in next packet */ 1990 /* ...and cache it for spillover in next packet */
1968 init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE); 1991 init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE);
diff --git a/apps/codecs/libwmavoice/wmavoice.h b/apps/codecs/libwmavoice/wmavoice.h
new file mode 100644
index 0000000000..33ec72b4e2
--- /dev/null
+++ b/apps/codecs/libwmavoice/wmavoice.h
@@ -0,0 +1,7 @@
1#include "avcodec.h"
2
3#define ERROR_WMAPRO_IN_WMAVOICE -0x162
4
5av_cold int wmavoice_decode_init(AVCodecContext *ctx);
6int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
7 int *data_size, AVPacket *avpkt);