diff options
Diffstat (limited to 'apps/codecs/libwmapro')
| -rw-r--r-- | apps/codecs/libwmapro/SOURCES | 9 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/bitstream.c | 2 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/dsputil.h | 2 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/fft.c | 4 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/get_bits.h | 2 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/libavutil/internal.h | 10 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/libavutil/log.c | 4 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/libavutil/mathematics.c | 8 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/libwmapro.make | 18 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/mdct_tablegen.h | 4 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/put_bits.h | 10 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/wma.c | 4 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/wmaprodec.c | 33 | ||||
| -rw-r--r-- | apps/codecs/libwmapro/wmaprodec.h | 6 |
14 files changed, 81 insertions, 35 deletions
diff --git a/apps/codecs/libwmapro/SOURCES b/apps/codecs/libwmapro/SOURCES new file mode 100644 index 0000000..da2d286 --- /dev/null +++ b/apps/codecs/libwmapro/SOURCES @@ -0,0 +1,9 @@ +wmaprodec.c +wma.c +dsputil.c +mdct.c +fft.c +bitstream.c +libavutil/log.c +libavutil/mem.c +libavutil/mathematics.c diff --git a/apps/codecs/libwmapro/bitstream.c b/apps/codecs/libwmapro/bitstream.c index 47234e1..deb1d63 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, av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); #endif - assert(symbols_size <= 2 || !symbols); + //assert(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) {\ diff --git a/apps/codecs/libwmapro/dsputil.h b/apps/codecs/libwmapro/dsputil.h index d1816e6..80bc3ab 100644 --- a/apps/codecs/libwmapro/dsputil.h +++ b/apps/codecs/libwmapro/dsputil.h @@ -443,7 +443,7 @@ typedef struct DSPContext { * @param v2 second input vector, difference output, 16-byte aligned * @param len length of vectors, multiple of 4 */ - void (*butterflies_float)(float *restrict v1, float *restrict v2, int len); + void (*butterflies_float)(float * v1, float * v2, int len); /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767] * 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 bc1b4f1..b0e6e11 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) s->fft_permute = ff_fft_permute_c; s->fft_calc = ff_fft_calc_c; -#if CONFIG_MDCT +//#if CONFIG_MDCT s->imdct_calc = ff_imdct_calc_c; s->imdct_half = ff_imdct_half_c; s->mdct_calc = ff_mdct_calc_c; -#endif +//#endif s->exptab1 = NULL; s->split_radix = 1; #if 0 diff --git a/apps/codecs/libwmapro/get_bits.h b/apps/codecs/libwmapro/get_bits.h index c325778..a21d052 100644 --- a/apps/codecs/libwmapro/get_bits.h +++ b/apps/codecs/libwmapro/get_bits.h @@ -28,7 +28,7 @@ #include <stdint.h> #include <stdlib.h> -#include <assert.h> +//#include <assert.h> #include "libavutil/bswap.h" #include "libavutil/common.h" #include "libavutil/intreadwrite.h" diff --git a/apps/codecs/libwmapro/libavutil/internal.h b/apps/codecs/libwmapro/libavutil/internal.h index 2b8da1d..97087e4 100644 --- a/apps/codecs/libwmapro/libavutil/internal.h +++ b/apps/codecs/libwmapro/libavutil/internal.h @@ -33,7 +33,7 @@ #include <limits.h> #include <stdint.h> #include <stddef.h> -#include <assert.h> +//#include <assert.h> //#include "config.h" #include "attributes.h" //#include "timer.h" @@ -142,8 +142,8 @@ #endif /* avoid usage of dangerous/inappropriate system functions */ -#undef malloc -#define malloc please_use_av_malloc +//#undef malloc +//#define malloc please_use_av_malloc #undef free #define free please_use_av_free #undef realloc @@ -163,8 +163,8 @@ #undef exit #define exit exit_is_forbidden #ifndef LIBAVFORMAT_BUILD -#undef printf -#define printf please_use_av_log_instead_of_printf +//#undef printf +//#define printf please_use_av_log_instead_of_printf #undef fprintf #define fprintf please_use_av_log_instead_of_fprintf #undef puts diff --git a/apps/codecs/libwmapro/libavutil/log.c b/apps/codecs/libwmapro/libavutil/log.c index 166e724..6cbe0da 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) return; } if(count>0){ - fprintf(stderr, " Last message repeated %d times\n", count); + //fprintf(stderr, " Last message repeated %d times\n", count); count=0; } - fputs(line, stderr); + //fputs(line, stderr); strcpy(prev, line); } diff --git a/apps/codecs/libwmapro/libavutil/mathematics.c b/apps/codecs/libwmapro/libavutil/mathematics.c index 04f3e87..7af0104 100644 --- a/apps/codecs/libwmapro/libavutil/mathematics.c +++ b/apps/codecs/libwmapro/libavutil/mathematics.c @@ -23,7 +23,7 @@ * miscellaneous math routines and tables */ -#include <assert.h> +//#include <assert.h> #include <stdint.h> #include <limits.h> #include "mathematics.h" @@ -76,9 +76,9 @@ int64_t av_gcd(int64_t a, int64_t b){ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ int64_t r=0; - assert(c > 0); - assert(b >=0); - assert(rnd >=0 && rnd<=5 && rnd!=4); + //assert(c > 0); + //assert(b >=0); + //assert(rnd >=0 && rnd<=5 && rnd!=4); if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); diff --git a/apps/codecs/libwmapro/libwmapro.make b/apps/codecs/libwmapro/libwmapro.make new file mode 100644 index 0000000..9177eaf --- /dev/null +++ b/apps/codecs/libwmapro/libwmapro.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libwmapro +WMAPROLIB := $(CODECDIR)/libwmapro.a +WMAPROLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwmapro/SOURCES) +WMAPROLIB_OBJ := $(call c2obj, $(WMAPROLIB_SRC)) +OTHER_SRC += $(WMAPROLIB_SRC) + +$(WMAPROLIB): $(WMAPROLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(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 9f130aa..998f86f 100644 --- a/apps/codecs/libwmapro/mdct_tablegen.h +++ b/apps/codecs/libwmapro/mdct_tablegen.h @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <assert.h> +//#include <assert.h> // do not use libavutil/mathematics.h since this is compiled both // for the host and the target and config.h is only valid for the target #include <math.h> @@ -53,7 +53,7 @@ av_cold void ff_sine_window_init(float *window, int n) { } av_cold void ff_init_ff_sine_windows(int index) { - assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); + //assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); #if !CONFIG_HARDCODED_TABLES ff_sine_window_init(ff_sine_windows[index], 1 << index); #endif diff --git a/apps/codecs/libwmapro/put_bits.h b/apps/codecs/libwmapro/put_bits.h index c013966..9f66256 100644 --- a/apps/codecs/libwmapro/put_bits.h +++ b/apps/codecs/libwmapro/put_bits.h @@ -28,7 +28,7 @@ #include <stdint.h> #include <stdlib.h> -#include <assert.h> +//#include <assert.h> #include "libavutil/bswap.h" #include "libavutil/common.h" #include "libavutil/intreadwrite.h" @@ -153,7 +153,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) int bit_left; // printf("put_bits=%d %x\n", n, value); - assert(n <= 31 && value < (1U << n)); + //assert(n <= 31 && value < (1U << n)); bit_buf = s->bit_buf; bit_left = s->bit_left; @@ -264,7 +264,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) static inline void put_sbits(PutBitContext *pb, int n, int32_t value) { - assert(n >= 0 && n <= 31); + //assert(n >= 0 && n <= 31); put_bits(pb, n, value & ((1<<n)-1)); } @@ -304,12 +304,12 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s) */ static inline void skip_put_bytes(PutBitContext *s, int n) { - assert((put_bits_count(s)&7)==0); + //assert((put_bits_count(s)&7)==0); #ifdef ALT_BITSTREAM_WRITER FIXME may need some cleaning of the buffer s->index += n<<3; #else - assert(s->bit_left==32); + //assert(s->bit_left==32); s->buf_ptr += n; #endif } diff --git a/apps/codecs/libwmapro/wma.c b/apps/codecs/libwmapro/wma.c index 5306634..4b36c84 100644 --- a/apps/codecs/libwmapro/wma.c +++ b/apps/codecs/libwmapro/wma.c @@ -23,8 +23,8 @@ #include "wma.h" //#include "wmadata.h" -#undef NDEBUG -#include <assert.h> +//#undef NDEBUG +//#include <assert.h> #if 0 /* XXX: use same run/length optimization as mpeg decoders */ //FIXME maybe split decode / encode or pass flag diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c index 88d317d..e729194 100644 --- a/apps/codecs/libwmapro/wmaprodec.c +++ b/apps/codecs/libwmapro/wmaprodec.c @@ -93,13 +93,11 @@ #include "wmaprodata.h" #include "dsputil.h" #include "wma.h" +#include "wmaprodec.h" /* Some defines to make it compile */ #define AVERROR_INVALIDDATA -1 #define AVERROR_PATCHWELCOME -2 -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif #define av_log_ask_for_sample(...) /** current decoder limitations */ @@ -238,8 +236,8 @@ typedef struct WMAProDecodeCtx { */ static void av_cold dump_context(WMAProDecodeCtx *s) { -#define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b); -#define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b); +#define PRINT(a, b) printf(" %s = %d\n", a, b); +#define PRINT_HEX(a, b) printf(" %s = %x\n", a, b); PRINT("ed sample bit depth", s->bits_per_sample); PRINT_HEX("ed decode flags", s->decode_flags); @@ -255,7 +253,7 @@ static void av_cold dump_context(WMAProDecodeCtx *s) *@param avctx codec context *@return 0 on success, < 0 otherwise */ -static av_cold int decode_end(AVCodecContext *avctx) +av_cold int decode_end(AVCodecContext *avctx) { WMAProDecodeCtx *s = avctx->priv_data; int i; @@ -271,8 +269,10 @@ static av_cold int decode_end(AVCodecContext *avctx) *@param avctx codec context *@return 0 on success, -1 otherwise */ -static av_cold int decode_init(AVCodecContext *avctx) +av_cold int decode_init(AVCodecContext *avctx) { + avctx->priv_data = malloc(sizeof(WMAProDecodeCtx)); + memset(avctx->priv_data, 0, sizeof(WMAProDecodeCtx)); WMAProDecodeCtx *s = avctx->priv_data; uint8_t *edata_ptr = avctx->extradata; unsigned int channel_mask; @@ -454,7 +454,6 @@ static av_cold int decode_init(AVCodecContext *avctx) sin64[i] = sin(i*M_PI / 64.0); #if 0 if (avctx->debug & FF_DEBUG_BITSTREAM) - dump_context(s); #endif avctx->channel_layout = channel_mask; @@ -1379,7 +1378,7 @@ static int decode_frame(WMAProDecodeCtx *s) if (len != (get_bits_count(gb) - s->frame_offset) + 2) { /** FIXME: not sure if this is always an error */ av_log(s->avctx, AV_LOG_ERROR, "frame[%i] would have to skip %i bits\n", - s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1); + (int)s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1); s->packet_loss = 1; return 0; } @@ -1465,7 +1464,7 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, *@param avpkt input packet *@return number of bytes that were read from the input buffer */ -static int decode_packet(AVCodecContext *avctx, +int decode_packet(AVCodecContext *avctx, void *data, int *data_size, AVPacket* avpkt) { WMAProDecodeCtx *s = avctx->priv_data; @@ -1549,6 +1548,20 @@ static int decode_packet(AVCodecContext *avctx, *data_size = (int8_t *)s->samples - (int8_t *)data; s->packet_offset = get_bits_count(gb) & 7; +/* Convert the pcm samples to signed 16-bit integers. This is the format that + * the rockbox simulator works with. */ +#ifdef ROCKBOX + float* fptr = data; + int32_t* ptr = data; + int x; + for(x = 0; x < *data_size; x++) + { + fptr[x] *= ((float)(INT32_MAX)); + ptr[x] = (int32_t)fptr[x]; + + } +#endif + return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; } diff --git a/apps/codecs/libwmapro/wmaprodec.h b/apps/codecs/libwmapro/wmaprodec.h new file mode 100644 index 0000000..045481b --- /dev/null +++ b/apps/codecs/libwmapro/wmaprodec.h @@ -0,0 +1,6 @@ +#include "avcodec.h" + +av_cold int decode_end(AVCodecContext *avctx); +av_cold int decode_init(AVCodecContext *avctx); +int decode_packet(AVCodecContext *avctx, + void *data, int *data_size, AVPacket* avpkt); |