summaryrefslogtreecommitdiff
path: root/apps/codecs/libwmapro
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwmapro')
-rw-r--r--apps/codecs/libwmapro/SOURCES9
-rw-r--r--apps/codecs/libwmapro/bitstream.c2
-rw-r--r--apps/codecs/libwmapro/dsputil.h2
-rw-r--r--apps/codecs/libwmapro/fft.c4
-rw-r--r--apps/codecs/libwmapro/get_bits.h2
-rw-r--r--apps/codecs/libwmapro/libavutil/internal.h10
-rw-r--r--apps/codecs/libwmapro/libavutil/log.c4
-rw-r--r--apps/codecs/libwmapro/libavutil/mathematics.c8
-rw-r--r--apps/codecs/libwmapro/libwmapro.make18
-rw-r--r--apps/codecs/libwmapro/mdct_tablegen.h4
-rw-r--r--apps/codecs/libwmapro/put_bits.h10
-rw-r--r--apps/codecs/libwmapro/wma.c4
-rw-r--r--apps/codecs/libwmapro/wmaprodec.c33
-rw-r--r--apps/codecs/libwmapro/wmaprodec.h6
14 files changed, 81 insertions, 35 deletions
diff --git a/apps/codecs/libwmapro/SOURCES b/apps/codecs/libwmapro/SOURCES
new file mode 100644
index 0000000000..da2d2860d8
--- /dev/null
+++ b/apps/codecs/libwmapro/SOURCES
@@ -0,0 +1,9 @@
1wmaprodec.c
2wma.c
3dsputil.c
4mdct.c
5fft.c
6bitstream.c
7libavutil/log.c
8libavutil/mem.c
9libavutil/mathematics.c
diff --git a/apps/codecs/libwmapro/bitstream.c b/apps/codecs/libwmapro/bitstream.c
index 47234e10e1..deb1d631e2 100644
--- a/apps/codecs/libwmapro/bitstream.c
+++ b/apps/codecs/libwmapro/bitstream.c
@@ -296,7 +296,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
296 av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); 296 av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes);
297#endif 297#endif
298 298
299 assert(symbols_size <= 2 || !symbols); 299 //assert(symbols_size <= 2 || !symbols);
300 j = 0; 300 j = 0;
301#define COPY(condition)\ 301#define COPY(condition)\
302 for (i = 0; i < nb_codes; i++) {\ 302 for (i = 0; i < nb_codes; i++) {\
diff --git a/apps/codecs/libwmapro/dsputil.h b/apps/codecs/libwmapro/dsputil.h
index d1816e66ba..80bc3ab262 100644
--- a/apps/codecs/libwmapro/dsputil.h
+++ b/apps/codecs/libwmapro/dsputil.h
@@ -443,7 +443,7 @@ typedef struct DSPContext {
443 * @param v2 second input vector, difference output, 16-byte aligned 443 * @param v2 second input vector, difference output, 16-byte aligned
444 * @param len length of vectors, multiple of 4 444 * @param len length of vectors, multiple of 4
445 */ 445 */
446 void (*butterflies_float)(float *restrict v1, float *restrict v2, int len); 446 void (*butterflies_float)(float * v1, float * v2, int len);
447 447
448 /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767] 448 /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767]
449 * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */ 449 * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
diff --git a/apps/codecs/libwmapro/fft.c b/apps/codecs/libwmapro/fft.c
index bc1b4f1796..b0e6e11cd3 100644
--- a/apps/codecs/libwmapro/fft.c
+++ b/apps/codecs/libwmapro/fft.c
@@ -102,11 +102,11 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
102 102
103 s->fft_permute = ff_fft_permute_c; 103 s->fft_permute = ff_fft_permute_c;
104 s->fft_calc = ff_fft_calc_c; 104 s->fft_calc = ff_fft_calc_c;
105#if CONFIG_MDCT 105//#if CONFIG_MDCT
106 s->imdct_calc = ff_imdct_calc_c; 106 s->imdct_calc = ff_imdct_calc_c;
107 s->imdct_half = ff_imdct_half_c; 107 s->imdct_half = ff_imdct_half_c;
108 s->mdct_calc = ff_mdct_calc_c; 108 s->mdct_calc = ff_mdct_calc_c;
109#endif 109//#endif
110 s->exptab1 = NULL; 110 s->exptab1 = NULL;
111 s->split_radix = 1; 111 s->split_radix = 1;
112#if 0 112#if 0
diff --git a/apps/codecs/libwmapro/get_bits.h b/apps/codecs/libwmapro/get_bits.h
index c325778d67..a21d05210f 100644
--- a/apps/codecs/libwmapro/get_bits.h
+++ b/apps/codecs/libwmapro/get_bits.h
@@ -28,7 +28,7 @@
28 28
29#include <stdint.h> 29#include <stdint.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <assert.h> 31//#include <assert.h>
32#include "libavutil/bswap.h" 32#include "libavutil/bswap.h"
33#include "libavutil/common.h" 33#include "libavutil/common.h"
34#include "libavutil/intreadwrite.h" 34#include "libavutil/intreadwrite.h"
diff --git a/apps/codecs/libwmapro/libavutil/internal.h b/apps/codecs/libwmapro/libavutil/internal.h
index 2b8da1d8c2..97087e462a 100644
--- a/apps/codecs/libwmapro/libavutil/internal.h
+++ b/apps/codecs/libwmapro/libavutil/internal.h
@@ -33,7 +33,7 @@
33#include <limits.h> 33#include <limits.h>
34#include <stdint.h> 34#include <stdint.h>
35#include <stddef.h> 35#include <stddef.h>
36#include <assert.h> 36//#include <assert.h>
37//#include "config.h" 37//#include "config.h"
38#include "attributes.h" 38#include "attributes.h"
39//#include "timer.h" 39//#include "timer.h"
@@ -142,8 +142,8 @@
142#endif 142#endif
143 143
144/* avoid usage of dangerous/inappropriate system functions */ 144/* avoid usage of dangerous/inappropriate system functions */
145#undef malloc 145//#undef malloc
146#define malloc please_use_av_malloc 146//#define malloc please_use_av_malloc
147#undef free 147#undef free
148#define free please_use_av_free 148#define free please_use_av_free
149#undef realloc 149#undef realloc
@@ -163,8 +163,8 @@
163#undef exit 163#undef exit
164#define exit exit_is_forbidden 164#define exit exit_is_forbidden
165#ifndef LIBAVFORMAT_BUILD 165#ifndef LIBAVFORMAT_BUILD
166#undef printf 166//#undef printf
167#define printf please_use_av_log_instead_of_printf 167//#define printf please_use_av_log_instead_of_printf
168#undef fprintf 168#undef fprintf
169#define fprintf please_use_av_log_instead_of_fprintf 169#define fprintf please_use_av_log_instead_of_fprintf
170#undef puts 170#undef puts
diff --git a/apps/codecs/libwmapro/libavutil/log.c b/apps/codecs/libwmapro/libavutil/log.c
index 166e724b07..6cbe0da8b8 100644
--- a/apps/codecs/libwmapro/libavutil/log.c
+++ b/apps/codecs/libwmapro/libavutil/log.c
@@ -54,10 +54,10 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
54 return; 54 return;
55 } 55 }
56 if(count>0){ 56 if(count>0){
57 fprintf(stderr, " Last message repeated %d times\n", count); 57 //fprintf(stderr, " Last message repeated %d times\n", count);
58 count=0; 58 count=0;
59 } 59 }
60 fputs(line, stderr); 60 //fputs(line, stderr);
61 strcpy(prev, line); 61 strcpy(prev, line);
62} 62}
63 63
diff --git a/apps/codecs/libwmapro/libavutil/mathematics.c b/apps/codecs/libwmapro/libavutil/mathematics.c
index 04f3e870d1..7af0104516 100644
--- a/apps/codecs/libwmapro/libavutil/mathematics.c
+++ b/apps/codecs/libwmapro/libavutil/mathematics.c
@@ -23,7 +23,7 @@
23 * miscellaneous math routines and tables 23 * miscellaneous math routines and tables
24 */ 24 */
25 25
26#include <assert.h> 26//#include <assert.h>
27#include <stdint.h> 27#include <stdint.h>
28#include <limits.h> 28#include <limits.h>
29#include "mathematics.h" 29#include "mathematics.h"
@@ -76,9 +76,9 @@ int64_t av_gcd(int64_t a, int64_t b){
76 76
77int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ 77int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
78 int64_t r=0; 78 int64_t r=0;
79 assert(c > 0); 79 //assert(c > 0);
80 assert(b >=0); 80 //assert(b >=0);
81 assert(rnd >=0 && rnd<=5 && rnd!=4); 81 //assert(rnd >=0 && rnd<=5 && rnd!=4);
82 82
83 if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); 83 if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
84 84
diff --git a/apps/codecs/libwmapro/libwmapro.make b/apps/codecs/libwmapro/libwmapro.make
new file mode 100644
index 0000000000..9177eafb20
--- /dev/null
+++ b/apps/codecs/libwmapro/libwmapro.make
@@ -0,0 +1,18 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9
10# libwmapro
11WMAPROLIB := $(CODECDIR)/libwmapro.a
12WMAPROLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwmapro/SOURCES)
13WMAPROLIB_OBJ := $(call c2obj, $(WMAPROLIB_SRC))
14OTHER_SRC += $(WMAPROLIB_SRC)
15
16$(WMAPROLIB): $(WMAPROLIB_OBJ)
17 $(SILENT)$(shell rm -f $@)
18 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
diff --git a/apps/codecs/libwmapro/mdct_tablegen.h b/apps/codecs/libwmapro/mdct_tablegen.h
index 9f130aa6b5..998f86f283 100644
--- a/apps/codecs/libwmapro/mdct_tablegen.h
+++ b/apps/codecs/libwmapro/mdct_tablegen.h
@@ -20,7 +20,7 @@
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */ 21 */
22 22
23#include <assert.h> 23//#include <assert.h>
24// do not use libavutil/mathematics.h since this is compiled both 24// do not use libavutil/mathematics.h since this is compiled both
25// for the host and the target and config.h is only valid for the target 25// for the host and the target and config.h is only valid for the target
26#include <math.h> 26#include <math.h>
@@ -53,7 +53,7 @@ av_cold void ff_sine_window_init(float *window, int n) {
53} 53}
54 54
55av_cold void ff_init_ff_sine_windows(int index) { 55av_cold void ff_init_ff_sine_windows(int index) {
56 assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); 56 //assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows));
57#if !CONFIG_HARDCODED_TABLES 57#if !CONFIG_HARDCODED_TABLES
58 ff_sine_window_init(ff_sine_windows[index], 1 << index); 58 ff_sine_window_init(ff_sine_windows[index], 1 << index);
59#endif 59#endif
diff --git a/apps/codecs/libwmapro/put_bits.h b/apps/codecs/libwmapro/put_bits.h
index c0139661a5..9f66256b79 100644
--- a/apps/codecs/libwmapro/put_bits.h
+++ b/apps/codecs/libwmapro/put_bits.h
@@ -28,7 +28,7 @@
28 28
29#include <stdint.h> 29#include <stdint.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <assert.h> 31//#include <assert.h>
32#include "libavutil/bswap.h" 32#include "libavutil/bswap.h"
33#include "libavutil/common.h" 33#include "libavutil/common.h"
34#include "libavutil/intreadwrite.h" 34#include "libavutil/intreadwrite.h"
@@ -153,7 +153,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
153 int bit_left; 153 int bit_left;
154 154
155 // printf("put_bits=%d %x\n", n, value); 155 // printf("put_bits=%d %x\n", n, value);
156 assert(n <= 31 && value < (1U << n)); 156 //assert(n <= 31 && value < (1U << n));
157 157
158 bit_buf = s->bit_buf; 158 bit_buf = s->bit_buf;
159 bit_left = s->bit_left; 159 bit_left = s->bit_left;
@@ -264,7 +264,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
264 264
265static inline void put_sbits(PutBitContext *pb, int n, int32_t value) 265static inline void put_sbits(PutBitContext *pb, int n, int32_t value)
266{ 266{
267 assert(n >= 0 && n <= 31); 267 //assert(n >= 0 && n <= 31);
268 268
269 put_bits(pb, n, value & ((1<<n)-1)); 269 put_bits(pb, n, value & ((1<<n)-1));
270} 270}
@@ -304,12 +304,12 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s)
304 */ 304 */
305static inline void skip_put_bytes(PutBitContext *s, int n) 305static inline void skip_put_bytes(PutBitContext *s, int n)
306{ 306{
307 assert((put_bits_count(s)&7)==0); 307 //assert((put_bits_count(s)&7)==0);
308#ifdef ALT_BITSTREAM_WRITER 308#ifdef ALT_BITSTREAM_WRITER
309 FIXME may need some cleaning of the buffer 309 FIXME may need some cleaning of the buffer
310 s->index += n<<3; 310 s->index += n<<3;
311#else 311#else
312 assert(s->bit_left==32); 312 //assert(s->bit_left==32);
313 s->buf_ptr += n; 313 s->buf_ptr += n;
314#endif 314#endif
315} 315}
diff --git a/apps/codecs/libwmapro/wma.c b/apps/codecs/libwmapro/wma.c
index 5306634c7c..4b36c84aad 100644
--- a/apps/codecs/libwmapro/wma.c
+++ b/apps/codecs/libwmapro/wma.c
@@ -23,8 +23,8 @@
23#include "wma.h" 23#include "wma.h"
24//#include "wmadata.h" 24//#include "wmadata.h"
25 25
26#undef NDEBUG 26//#undef NDEBUG
27#include <assert.h> 27//#include <assert.h>
28#if 0 28#if 0
29/* XXX: use same run/length optimization as mpeg decoders */ 29/* XXX: use same run/length optimization as mpeg decoders */
30//FIXME maybe split decode / encode or pass flag 30//FIXME maybe split decode / encode or pass flag
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c
index 88d317d5f6..e72919434c 100644
--- a/apps/codecs/libwmapro/wmaprodec.c
+++ b/apps/codecs/libwmapro/wmaprodec.c
@@ -93,13 +93,11 @@
93#include "wmaprodata.h" 93#include "wmaprodata.h"
94#include "dsputil.h" 94#include "dsputil.h"
95#include "wma.h" 95#include "wma.h"
96#include "wmaprodec.h"
96 97
97/* Some defines to make it compile */ 98/* Some defines to make it compile */
98#define AVERROR_INVALIDDATA -1 99#define AVERROR_INVALIDDATA -1
99#define AVERROR_PATCHWELCOME -2 100#define AVERROR_PATCHWELCOME -2
100#ifndef M_PI
101#define M_PI 3.14159265358979323846 /* pi */
102#endif
103#define av_log_ask_for_sample(...) 101#define av_log_ask_for_sample(...)
104 102
105/** current decoder limitations */ 103/** current decoder limitations */
@@ -238,8 +236,8 @@ typedef struct WMAProDecodeCtx {
238 */ 236 */
239static void av_cold dump_context(WMAProDecodeCtx *s) 237static void av_cold dump_context(WMAProDecodeCtx *s)
240{ 238{
241#define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b); 239#define PRINT(a, b) printf(" %s = %d\n", a, b);
242#define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b); 240#define PRINT_HEX(a, b) printf(" %s = %x\n", a, b);
243 241
244 PRINT("ed sample bit depth", s->bits_per_sample); 242 PRINT("ed sample bit depth", s->bits_per_sample);
245 PRINT_HEX("ed decode flags", s->decode_flags); 243 PRINT_HEX("ed decode flags", s->decode_flags);
@@ -255,7 +253,7 @@ static void av_cold dump_context(WMAProDecodeCtx *s)
255 *@param avctx codec context 253 *@param avctx codec context
256 *@return 0 on success, < 0 otherwise 254 *@return 0 on success, < 0 otherwise
257 */ 255 */
258static av_cold int decode_end(AVCodecContext *avctx) 256av_cold int decode_end(AVCodecContext *avctx)
259{ 257{
260 WMAProDecodeCtx *s = avctx->priv_data; 258 WMAProDecodeCtx *s = avctx->priv_data;
261 int i; 259 int i;
@@ -271,8 +269,10 @@ static av_cold int decode_end(AVCodecContext *avctx)
271 *@param avctx codec context 269 *@param avctx codec context
272 *@return 0 on success, -1 otherwise 270 *@return 0 on success, -1 otherwise
273 */ 271 */
274static av_cold int decode_init(AVCodecContext *avctx) 272av_cold int decode_init(AVCodecContext *avctx)
275{ 273{
274 avctx->priv_data = malloc(sizeof(WMAProDecodeCtx));
275 memset(avctx->priv_data, 0, sizeof(WMAProDecodeCtx));
276 WMAProDecodeCtx *s = avctx->priv_data; 276 WMAProDecodeCtx *s = avctx->priv_data;
277 uint8_t *edata_ptr = avctx->extradata; 277 uint8_t *edata_ptr = avctx->extradata;
278 unsigned int channel_mask; 278 unsigned int channel_mask;
@@ -454,7 +454,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
454 sin64[i] = sin(i*M_PI / 64.0); 454 sin64[i] = sin(i*M_PI / 64.0);
455#if 0 455#if 0
456 if (avctx->debug & FF_DEBUG_BITSTREAM) 456 if (avctx->debug & FF_DEBUG_BITSTREAM)
457 dump_context(s);
458#endif 457#endif
459 458
460 avctx->channel_layout = channel_mask; 459 avctx->channel_layout = channel_mask;
@@ -1379,7 +1378,7 @@ static int decode_frame(WMAProDecodeCtx *s)
1379 if (len != (get_bits_count(gb) - s->frame_offset) + 2) { 1378 if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
1380 /** FIXME: not sure if this is always an error */ 1379 /** FIXME: not sure if this is always an error */
1381 av_log(s->avctx, AV_LOG_ERROR, "frame[%i] would have to skip %i bits\n", 1380 av_log(s->avctx, AV_LOG_ERROR, "frame[%i] would have to skip %i bits\n",
1382 s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1); 1381 (int)s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1);
1383 s->packet_loss = 1; 1382 s->packet_loss = 1;
1384 return 0; 1383 return 0;
1385 } 1384 }
@@ -1465,7 +1464,7 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len,
1465 *@param avpkt input packet 1464 *@param avpkt input packet
1466 *@return number of bytes that were read from the input buffer 1465 *@return number of bytes that were read from the input buffer
1467 */ 1466 */
1468static int decode_packet(AVCodecContext *avctx, 1467int decode_packet(AVCodecContext *avctx,
1469 void *data, int *data_size, AVPacket* avpkt) 1468 void *data, int *data_size, AVPacket* avpkt)
1470{ 1469{
1471 WMAProDecodeCtx *s = avctx->priv_data; 1470 WMAProDecodeCtx *s = avctx->priv_data;
@@ -1549,6 +1548,20 @@ static int decode_packet(AVCodecContext *avctx,
1549 *data_size = (int8_t *)s->samples - (int8_t *)data; 1548 *data_size = (int8_t *)s->samples - (int8_t *)data;
1550 s->packet_offset = get_bits_count(gb) & 7; 1549 s->packet_offset = get_bits_count(gb) & 7;
1551 1550
1551/* Convert the pcm samples to signed 16-bit integers. This is the format that
1552 * the rockbox simulator works with. */
1553#ifdef ROCKBOX
1554 float* fptr = data;
1555 int32_t* ptr = data;
1556 int x;
1557 for(x = 0; x < *data_size; x++)
1558 {
1559 fptr[x] *= ((float)(INT32_MAX));
1560 ptr[x] = (int32_t)fptr[x];
1561
1562 }
1563#endif
1564
1552 return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; 1565 return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
1553} 1566}
1554 1567
diff --git a/apps/codecs/libwmapro/wmaprodec.h b/apps/codecs/libwmapro/wmaprodec.h
new file mode 100644
index 0000000000..045481b529
--- /dev/null
+++ b/apps/codecs/libwmapro/wmaprodec.h
@@ -0,0 +1,6 @@
1#include "avcodec.h"
2
3av_cold int decode_end(AVCodecContext *avctx);
4av_cold int decode_init(AVCodecContext *avctx);
5int decode_packet(AVCodecContext *avctx,
6 void *data, int *data_size, AVPacket* avpkt);