diff options
Diffstat (limited to 'apps/codecs/libcook')
| -rw-r--r-- | apps/codecs/libcook/Makefile.test | 4 | ||||
| -rw-r--r-- | apps/codecs/libcook/SOURCES | 3 | ||||
| -rw-r--r-- | apps/codecs/libcook/bitstream.c | 85 | ||||
| -rw-r--r-- | apps/codecs/libcook/bitstream.h | 21 | ||||
| -rw-r--r-- | apps/codecs/libcook/bswap.h | 173 | ||||
| -rw-r--r-- | apps/codecs/libcook/cook.c | 15 | ||||
| -rw-r--r-- | apps/codecs/libcook/cook.h | 4 | ||||
| -rw-r--r-- | apps/codecs/libcook/cook_fixpoint.h | 53 | ||||
| -rw-r--r-- | apps/codecs/libcook/cookdata_fixpoint.h | 6 | ||||
| -rw-r--r-- | apps/codecs/libcook/libcook.make | 18 | ||||
| -rw-r--r-- | apps/codecs/libcook/main.c | 25 |
11 files changed, 212 insertions, 195 deletions
diff --git a/apps/codecs/libcook/Makefile.test b/apps/codecs/libcook/Makefile.test index 493ab8f..c8a3236 100644 --- a/apps/codecs/libcook/Makefile.test +++ b/apps/codecs/libcook/Makefile.test @@ -1,4 +1,4 @@ -CFLAGS = -Wall -O3 +CFLAGS = -Wall -O3 -DTEST -D"DEBUGF=printf" OBJS = main.o bitstream.o cook.o ../librm/rm.o cooktest: $(OBJS) gcc -o cooktest $(OBJS) @@ -7,4 +7,4 @@ cooktest: $(OBJS) $(CC) $(CFLAGS) -c -o $@ $< clean: - rm -f cooktest $(OBJS) *~ + rm -f cooktest $(OBJS) *~ output.wav diff --git a/apps/codecs/libcook/SOURCES b/apps/codecs/libcook/SOURCES new file mode 100644 index 0000000..7b2cd96 --- /dev/null +++ b/apps/codecs/libcook/SOURCES @@ -0,0 +1,3 @@ +cook.c +bitstream.c +../librm/rm.c diff --git a/apps/codecs/libcook/bitstream.c b/apps/codecs/libcook/bitstream.c index 4bc706f..1375134 100644 --- a/apps/codecs/libcook/bitstream.c +++ b/apps/codecs/libcook/bitstream.c @@ -22,13 +22,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file libavcodec/bitstream.c - * bitstream api. - */ - #include "bitstream.h" +#ifdef ROCKBOX +#undef DEBUGF +#define DEBUGF(...) +#endif + const uint8_t ff_log2_run[32]={ 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, @@ -46,24 +46,6 @@ const uint8_t ff_log2_run[32]={ * and should correctly use static arrays */ -#if 0 -attribute_deprecated av_alloc_size(2) -static void *ff_realloc_static(void *ptr, unsigned int size); - -static void *ff_realloc_static(void *ptr, unsigned int size) -{ - return av_realloc(ptr, size); -} - -void align_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - put_bits(s,( - s->index) & 7,0); -#else - put_bits(s,s->bit_left & 7,0); -#endif -} -#endif void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) { @@ -75,30 +57,6 @@ void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) put_bits(pbc, 8, 0); } -#if 0 -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) -{ - const uint16_t *srcw= (const uint16_t*)src; - int words= length>>4; - int bits= length&15; - int i; - - if(length==0) return; - - if(CONFIG_SMALL || words < 16 || put_bits_count(pb)&7){ - for(i=0; i<words; i++) put_bits(pb, 16, AV_RB16(&srcw[i])); - }else{ - for(i=0; put_bits_count(pb)&31; i++) - put_bits(pb, 8, src[i]); - flush_put_bits(pb); - memcpy(pbBufPtr(pb), src+i, 2*words-i); - skip_put_bytes(pb, 2*words-i); - } - - put_bits(pb, bits, AV_RB16(&srcw[words])>>(16-bits)); -} -#endif - /* VLC decoding */ //#define DEBUG_VLC @@ -127,8 +85,7 @@ static int alloc_table(VLC *vlc, int size, int use_static) vlc->table_size += size; if (vlc->table_size > vlc->table_allocated) { if(use_static>1){ - printf("init_vlc() used with too little memory : table_size > allocated_memory\n"); - abort(); //cant do anything, init_vlc() is used with too little memory + DEBUGF("init_vlc() used with too little memory : table_size > allocated_memory\n"); } if (!vlc->table) @@ -151,7 +108,7 @@ static int build_table(VLC *vlc, int table_nb_bits, table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size, flags & (INIT_VLC_USE_STATIC|INIT_VLC_USE_NEW_STATIC)); #ifdef DEBUG_VLC - printf("new table index=%d size=%d code_prefix=%x n=%d\n", + DEBUGF("new table index=%d size=%d code_prefix=%x n=%d\n", table_index, table_size, code_prefix, n_prefix); #endif if (table_index < 0) @@ -175,15 +132,15 @@ static int build_table(VLC *vlc, int table_nb_bits, else GET_DATA(symbol, symbols, i, symbols_wrap, symbols_size); #if defined(DEBUG_VLC) && 0 - printf("i=%d n=%d code=0x%x\n", i, n, code); + DEBUGF("i=%d n=%d code=0x%x\n", i, n, code); #endif /* if code matches the prefix, it is in the table */ n -= n_prefix; if(flags & INIT_VLC_LE) - code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (1 << n_prefix)-1); + code_prefix2= code & (n_prefix>=32 ? (int)0xffffffff : (1 << n_prefix)-1); else code_prefix2= code >> n; - if (n > 0 && code_prefix2 == code_prefix) { + if (n > 0 && code_prefix2 == (int)code_prefix) { if (n <= table_nb_bits) { /* no need to add another table */ j = (code << (table_nb_bits - n)) & (table_size - 1); @@ -192,11 +149,11 @@ static int build_table(VLC *vlc, int table_nb_bits, if(flags & INIT_VLC_LE) j = (code >> n_prefix) + (k<<n); #ifdef DEBUG_VLC - printf("%4x: code=%d n=%d\n", + DEBUGF("%4x: code=%d n=%d\n", j, i, n); #endif if (table[j][1] /*bits*/ != 0) { - printf("incorrect codes\n"); + DEBUGF("incorrect codes\n"); return -1; } table[j][1] = n; //bits @@ -207,7 +164,7 @@ static int build_table(VLC *vlc, int table_nb_bits, n -= table_nb_bits; j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1); #ifdef DEBUG_VLC - printf("%4x: n=%d (subtable)\n", + DEBUGF("%4x: n=%d (subtable)\n", j, n); #endif /* compute table size */ @@ -282,7 +239,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, if(vlc->table_size && vlc->table_size == vlc->table_allocated){ return 0; }else if(vlc->table_size){ - abort(); // fatal error, we are called on a partially initialized table + return -1; // fatal error, we are called on a partially initialized table } }else if(!(flags & INIT_VLC_USE_STATIC)) { vlc->table = NULL; @@ -296,7 +253,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, } #ifdef DEBUG_VLC - printf("build table nb_codes=%d\n", nb_codes); + DEBUGF("build table nb_codes=%d\n", nb_codes); #endif if (build_table(vlc, nb_bits, nb_codes, @@ -304,20 +261,16 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, 0, 0, flags) < 0) { - free(&vlc->table); + //free(&vlc->table); return -1; } /* Changed the following condition to be true if table_size > table_allocated. * * This would be more sensible for static tables since we want warnings for * * memory shortages only. */ +#ifdef TEST if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size > vlc->table_allocated) - printf("needed %d had %d\n", vlc->table_size, vlc->table_allocated); + DEBUGF("needed %d had %d\n", vlc->table_size, vlc->table_allocated); +#endif return 0; } - -void free_vlc(VLC *vlc) -{ - free(&vlc->table); -} - diff --git a/apps/codecs/libcook/bitstream.h b/apps/codecs/libcook/bitstream.h index 085d0a1..9be8e65 100644 --- a/apps/codecs/libcook/bitstream.h +++ b/apps/codecs/libcook/bitstream.h @@ -18,15 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file libavcodec/bitstream.h - * bitstream api header. - */ +#ifndef BITSTREAM_H +#define BITSTREAM_H -#ifndef AVCODEC_BITSTREAM_H -#define AVCODEC_BITSTREAM_H - -#include <stdint.h> +#include <inttypes.h> #include <stdlib.h> #include <assert.h> #include <string.h> @@ -51,7 +46,7 @@ //#define ALT_BITSTREAM_WRITER //#define ALIGNED_BITSTREAM_WRITER #if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) -# if ARCH_ARM +# if defined(ARCH_ARM) # define A32_BITSTREAM_READER # else # define ALT_BITSTREAM_READER @@ -62,7 +57,7 @@ extern const uint8_t ff_reverse[256]; -#if ARCH_X86 +#if defined(ARCH_X86) // avoid +32 for shift optimization (gcc should do that ...) static inline int32_t NEG_SSR32( int32_t a, int8_t s){ __asm__ ("sarl %1, %0\n\t" @@ -226,7 +221,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) } else { bit_buf<<=bit_left; bit_buf |= value >> (n - bit_left); -#if !HAVE_FAST_UNALIGNED +#if !defined(HAVE_FAST_UNALIGNED) if (3 & (intptr_t) s->buf_ptr) { AV_WB32(s->buf_ptr, bit_buf); } else @@ -736,6 +731,7 @@ static inline unsigned int show_bits_long(GetBitContext *s, int n){ } } +#if 0 static inline int check_marker(GetBitContext *s, const char *msg) { int bit= get_bits1(s); @@ -744,6 +740,7 @@ static inline int check_marker(GetBitContext *s, const char *msg) return bit; } +#endif /** * init GetBitContext. @@ -963,4 +960,4 @@ static inline int decode210(GetBitContext *gb){ return 2 - get_bits1(gb); } -#endif /* AVCODEC_BITSTREAM_H */ +#endif /* BITSTREAM_H */ diff --git a/apps/codecs/libcook/bswap.h b/apps/codecs/libcook/bswap.h index 443cd1c..b083d10 100644 --- a/apps/codecs/libcook/bswap.h +++ b/apps/codecs/libcook/bswap.h @@ -1,86 +1,137 @@ -/* - * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - /** - * @file libavutil/bswap.h - * byte swapping routines + * @file bswap.h + * byte swap. */ -#ifndef AVUTIL_BSWAP_H -#define AVUTIL_BSWAP_H - -#include <stdint.h> -//#include "ffmpeg_config.h" -//#include "common.h" - -#if ARCH_ARM -# include "arm/bswap.h" -#elif ARCH_BFIN -# include "bfin/bswap.h" -#elif ARCH_SH4 -# include "sh4/bswap.h" -#elif ARCH_X86 -# include "x86/bswap.h" -#endif +#ifndef __BSWAP_H__ +#define __BSWAP_H__ + +#ifdef HAVE_BYTESWAP_H +#include <byteswap.h> +#else -#ifndef bswap_16 -static inline uint16_t bswap_16(uint16_t x) +#ifdef ROCKBOX +#include "codecs.h" + +/* rockbox' optimised inline functions */ +#define bswap_16(x) swap16(x) +#define bswap_32(x) swap32(x) + +static inline uint64_t ByteSwap64(uint64_t x) { - x= (x>>8) | (x<<8); - return x; + union { + uint64_t ll; + struct { + uint32_t l,h; + } l; + } r; + r.l.l = bswap_32 (x); + r.l.h = bswap_32 (x>>32); + return r.ll; } -#endif +#define bswap_64(x) ByteSwap64(x) -#ifndef bswap_32 -static inline uint32_t bswap_32(uint32_t x) +#elif defined(ARCH_X86) +static inline unsigned short ByteSwap16(unsigned short x) { - x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); - x= (x>>16) | (x<<16); + __asm("xchgb %b0,%h0" : + "=q" (x) : + "0" (x)); return x; } +#define bswap_16(x) ByteSwap16(x) + +static inline unsigned int ByteSwap32(unsigned int x) +{ +#if __CPU__ > 386 + __asm("bswap %0": + "=r" (x) : +#else + __asm("xchgb %b0,%h0\n" + " rorl $16,%0\n" + " xchgb %b0,%h0": + "=q" (x) : #endif + "0" (x)); + return x; +} +#define bswap_32(x) ByteSwap32(x) -#ifndef bswap_64 -static inline uint64_t bswap_64(uint64_t x) +static inline unsigned long long int ByteSwap64(unsigned long long int x) { -#if 0 - x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); - x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); - return (x>>32) | (x<<32); + register union { __extension__ uint64_t __ll; + uint32_t __l[2]; } __x; + asm("xchgl %0,%1": + "=r"(__x.__l[0]),"=r"(__x.__l[1]): + "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); + return __x.__ll; +} +#define bswap_64(x) ByteSwap64(x) + +#elif defined(ARCH_SH4) + +static inline uint16_t ByteSwap16(uint16_t x) { + __asm__("swap.b %0,%0":"=r"(x):"0"(x)); + return x; +} + +static inline uint32_t ByteSwap32(uint32_t x) { + __asm__( + "swap.b %0,%0\n" + "swap.w %0,%0\n" + "swap.b %0,%0\n" + :"=r"(x):"0"(x)); + return x; +} + +#define bswap_16(x) ByteSwap16(x) +#define bswap_32(x) ByteSwap32(x) + +static inline uint64_t ByteSwap64(uint64_t x) +{ + union { + uint64_t ll; + struct { + uint32_t l,h; + } l; + } r; + r.l.l = bswap_32 (x); + r.l.h = bswap_32 (x>>32); + return r.ll; +} +#define bswap_64(x) ByteSwap64(x) + #else - union { + +#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) + + +// code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. +#define bswap_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) + +static inline uint64_t ByteSwap64(uint64_t x) +{ + union { uint64_t ll; - uint32_t l[2]; + uint32_t l[2]; } w, r; w.ll = x; r.l[0] = bswap_32 (w.l[1]); r.l[1] = bswap_32 (w.l[0]); return r.ll; -#endif } -#endif +#define bswap_64(x) ByteSwap64(x) + +#endif /* !ARCH_X86 */ + +#endif /* !HAVE_BYTESWAP_H */ -// be2me ... big-endian to machine-endian -// le2me ... little-endian to machine-endian +// be2me ... BigEndian to MachineEndian +// le2me ... LittleEndian to MachineEndian -#ifdef WORDS_BIGENDIAN +#ifdef ROCKBOX_BIG_ENDIAN #define be2me_16(x) (x) #define be2me_32(x) (x) #define be2me_64(x) (x) @@ -96,4 +147,4 @@ static inline uint64_t bswap_64(uint64_t x) #define le2me_64(x) (x) #endif -#endif /* AVUTIL_BSWAP_H */ +#endif /* __BSWAP_H__ */ diff --git a/apps/codecs/libcook/cook.c b/apps/codecs/libcook/cook.c index 8caa399..ba5fbab 100644 --- a/apps/codecs/libcook/cook.c +++ b/apps/codecs/libcook/cook.c @@ -21,7 +21,7 @@ */ /** - * @file libavcodec/cook.c + * @file cook.c * Cook compatible decoder. Bastardization of the G.722.1 standard. * This decoder handles RealNetworks, RealAudio G2 data. * Cook is identified by the codec name cook in RM files. @@ -60,16 +60,15 @@ #define SUBBAND_SIZE 20 #define MAX_SUBPACKETS 5 //#define COOKDEBUG -#if 0 -#define DEBUGF(message,args ...) printf -#else +#ifndef COOKDEBUG +#undef DEBUGF #define DEBUGF(...) -#endif +#endif /** * Random bit stream generator. */ -static int inline cook_random(COOKContext *q) +static inline int cook_random(COOKContext *q) { q->random_state = q->random_state * 214013 + 2531011; /* typical RNG numbers */ @@ -200,7 +199,7 @@ static void decode_gain_info(GetBitContext *gb, int *gaininfo) i = 0; while (n--) { int index = get_bits(gb, 3); - int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1; + int gain = get_bits1(gb) ? (int)get_bits(gb, 4) - 7 : -1; while (i <= index) gaininfo[i++] = gain; } @@ -789,7 +788,7 @@ int cook_decode_init(RMContext *rmctx, COOKContext *q) return -1; - if(q->block_align >= UINT_MAX/2) + if(rmctx->block_align >= UINT16_MAX/2) return -1; q->gains1.now = q->gain_1; diff --git a/apps/codecs/libcook/cook.h b/apps/codecs/libcook/cook.h index ca98207..03d6d32 100644 --- a/apps/codecs/libcook/cook.h +++ b/apps/codecs/libcook/cook.h @@ -22,7 +22,7 @@ #ifndef _COOK_H #define _COOK_H -#include <stdint.h> +#include <inttypes.h> #include "bitstream.h" #include "../librm/rm.h" #include "cookdata_fixpoint.h" @@ -99,4 +99,4 @@ int cook_decode_init(RMContext *rmctx, COOKContext *q); int cook_decode_frame(RMContext *rmctx,COOKContext *q, int16_t *outbuffer, int *data_size, const uint8_t *inbuffer, int buf_size); -#endif +#endif /*_COOK_H */ diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index 0f12b13..e416bc4 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h @@ -54,29 +54,6 @@ static const FIXPU* cplscales[5] = { }; /** - * Initialise fixed point implementation. - * Nothing to do for fixed point. - * - * @param q pointer to the COOKContext - */ -static inline int init_cook_math(COOKContext *q) -{ - return 0; -} - -/** - * Free resources used by floating point implementation. - * Nothing to do for fixed point. - * - * @param q pointer to the COOKContext - */ -static inline void free_cook_math(COOKContext *q) -{ - return; -} - - -/** * Fixed point multiply by power of two. * * @param x fix point value @@ -167,7 +144,7 @@ static void scalar_dequant_math(COOKContext *q, int index, } } - +#ifdef TEST /** * The modulated lapped transform, this takes transform coefficients * and transforms them into timedomain samples. @@ -205,7 +182,35 @@ static inline void imlt_math(COOKContext *q, FIXP *in) q->mono_mdct_output[n + i] = fixp_mult_su(tmp, sincos_lookup[j]); } while (++i < n); } +#else +#include <codecs/lib/codeclib.h> + +static inline void imlt_math(COOKContext *q, FIXP *in) +{ + const int n = q->samples_per_channel; + const int step = 4 << (10 - av_log2(n)); + int i = 0, j = step>>1; + + mdct_backward(2 * n, in, q->mono_mdct_output); + do { + FIXP tmp = q->mono_mdct_output[i]; + + q->mono_mdct_output[i] = + fixp_mult_su(-q->mono_mdct_output[n + i], sincos_lookup[j]); + q->mono_mdct_output[n + i] = fixp_mult_su(tmp, sincos_lookup[j+1]); + j += step; + } while (++i < n/2); + do { + FIXP tmp = q->mono_mdct_output[i]; + + j -= step; + q->mono_mdct_output[i] = + fixp_mult_su(-q->mono_mdct_output[n + i], sincos_lookup[j+1]); + q->mono_mdct_output[n + i] = fixp_mult_su(tmp, sincos_lookup[j]); + } while (++i < n); +} +#endif /** * Perform buffer overlapping. diff --git a/apps/codecs/libcook/cookdata_fixpoint.h b/apps/codecs/libcook/cookdata_fixpoint.h index b394c46..7a9440c 100644 --- a/apps/codecs/libcook/cookdata_fixpoint.h +++ b/apps/codecs/libcook/cookdata_fixpoint.h @@ -26,7 +26,7 @@ * fixed point data types and constants */ -#include <stdint.h> +#include <inttypes.h> typedef int32_t FIXP; /* Fixed point variable type */ typedef uint16_t FIXPU; /* Fixed point fraction 0<=x<1 */ @@ -39,11 +39,11 @@ typedef FIXP REAL_T; typedef struct { } realvars_t; - +#ifdef TEST #define cPI1_8 0xec83 /* 1pi/8 2^16 */ #define cPI2_8 0xb505 /* 2pi/8 2^16 */ #define cPI3_8 0x61f8 /* 3pi/8 2^16 */ - +#endif static const FIXPU sincos_lookup[2050] = { /* x_i = 2^16 sin(i 2pi/8192), 2^16 cos(i 2pi/8192); i=0..1024 */ 0x0000, 0xffff, 0x0032, 0xffff, 0x0065, 0xffff, 0x0097, 0xffff, diff --git a/apps/codecs/libcook/libcook.make b/apps/codecs/libcook/libcook.make new file mode 100644 index 0000000..0783691 --- /dev/null +++ b/apps/codecs/libcook/libcook.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id:$ +# + +# libcook +COOKLIB := $(CODECDIR)/libcook.a +COOKLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libcook/SOURCES) +COOKLIB_OBJ := $(call c2obj, $(COOKLIB_SRC)) +OTHER_SRC += $(COOKLIB_SRC) + +$(COOKLIB): $(COOKLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
\ No newline at end of file diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c index 87f6584..fd20f98 100644 --- a/apps/codecs/libcook/main.c +++ b/apps/codecs/libcook/main.c @@ -29,13 +29,6 @@ #include "cook.h" //#define DUMP_RAW_FRAMES -#ifndef DEBUGF -# if 0 -# define DEBUGF(message,args ...) printf -# else -# define DEBUGF(...) -# endif -#endif #define DATA_HEADER_SIZE 18 /* size of DATA chunk header in a rm file */ static unsigned char wav_header[44]={ @@ -151,8 +144,8 @@ int main(int argc, char *argv[]) /* copy the input rm file to a memory buffer */ uint8_t * filebuf = (uint8_t *)calloc((int)filesize(fd),sizeof(uint8_t)); - read(fd,filebuf,filesize(fd)); - + res = read(fd,filebuf,filesize(fd)); + fd_dec = open_wav("output.wav"); if (fd_dec < 0) { DEBUGF("Error creating output file\n"); @@ -166,27 +159,25 @@ int main(int argc, char *argv[]) sps= rmctx.block_align; h = rmctx.sub_packet_h; cook_decode_init(&rmctx,&q); - DEBUGF("nb_frames = %d\n",nb_frames); - + /* change the buffer pointer to point at the first audio frame */ advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE); while(packet_count) { - rm_get_packet_membuf(&filebuf, &rmctx, &pkt); - DEBUGF("total frames = %d packet count = %d output counter = %d \n",rmctx.audio_pkt_cnt*(fs/sps), packet_count,rmctx.audio_pkt_cnt); + rm_get_packet(&filebuf, &rmctx, &pkt); + //DEBUGF("total frames = %d packet count = %d output counter = %d \n",rmctx.audio_pkt_cnt*(fs/sps), packet_count,rmctx.audio_pkt_cnt); for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) { /* output raw audio frames that are sent to the decoder into separate files */ - #ifdef DUMP_RAW_FRAMES +#ifdef DUMP_RAW_FRAMES snprintf(filename,sizeof(filename),"dump%d.raw",++x); fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND); write(fd_out,pkt.frames[i],sps); close(fd_out); - #endif - +#endif nb_frames = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i] , rmctx.block_align); rmctx.frame_number++; - write(fd_dec,outbuf,datasize); + res = write(fd_dec,outbuf,datasize); } packet_count -= rmctx.audio_pkt_cnt; rmctx.audio_pkt_cnt = 0; |