Make fixepoint.c as a shared library (libfixedpoint.a).

Change-Id: Icc10d6e85f890c432f191233a4d64e09f00be43d
Reviewed-on: http://gerrit.rockbox.org/456
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
This commit is contained in:
Michael Sevakis 2013-04-16 17:47:58 -04:00
parent 8829e909b4
commit 95e23defb0
28 changed files with 91 additions and 101 deletions

View File

@ -163,7 +163,6 @@ radio/radioart.c
#if INPUT_SRC_CAPS != 0
audio_path.c
#endif /* INPUT_SRC_CAPS != 0 */
fixedpoint.c
pcmbuf.c
codec_thread.c
playback.c

View File

@ -20,7 +20,7 @@
**************************************************************************/
#include "plugin.h"
#include "time.h"
#include "lib/fixedpoint.h"
#include "fixedpoint.h"
#include "lib/pluginlib_actions.h"

View File

@ -22,10 +22,10 @@
****************************************************************************/
#include "plugin.h"
#include "fixedpoint.h"
#include "lib/xlcd.h"
#include "lib/pluginlib_actions.h"
#include "lib/fixedpoint.h"
#include "lib/playback_control.h"
#include "lib/highscore.h"

View File

@ -19,9 +19,9 @@
*
****************************************************************************/
#include "fixedpoint.h"
#include "clock_draw_analog.h"
#include "lib/xlcd.h"
#include "lib/fixedpoint.h"
#include "clock_bitmaps.h"
#include "clock_bitmap_strings.h"

View File

@ -21,6 +21,7 @@
*
***************************************************************************/
#include "plugin.h"
#include "fixedpoint.h"
#include "lib/playergfx.h"
#include "lib/pluginlib_exit.h"
#if LCD_DEPTH > 1
@ -31,7 +32,6 @@
#include "lib/mylcd.h" /* MYLCD_CFG_GREYLIB or MYLCD_CFG_PGFX */
#endif
#include "lib/xlcd.h"
#include "lib/fixedpoint.h"
/* Loops that the values are displayed */
#define DISP_TIME 30

View File

@ -3,7 +3,7 @@
#include <inttypes.h>
#include <math.h>
#include "lib/fixedpoint.h"
#include "fixedpoint.h"
#define Q_MUL(a, b, bits) (( (int64_t) (a) * (int64_t) (b) ) >> (bits))
#define Q15_MUL(a, b) Q_MUL(a,b,15)

View File

@ -22,10 +22,10 @@
****************************************************************************/
#include "plugin.h"
#include "fixedpoint.h"
#include "lib/helper.h"
#include "lib/pluginlib_actions.h"
#include "lib/fixedpoint.h"
#ifndef HAVE_LCD_COLOR
#include "lib/grey.h"

View File

@ -4,7 +4,6 @@ helper.c
md5.c
jhash.c
configfile.c
fixedpoint.c
playback_control.c
rgb_hsv.c
highscore.c

View File

@ -1 +0,0 @@
#include "../../fixedpoint.c"

View File

@ -1,26 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2006 Jens Arnold
*
* Fixed point library for plugins
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _FIXEDPOINT_H_PLUGINS
#define _FIXEDPOINT_H_PLUGINS
#include "../../../firmware/include/fixedpoint.h"
#endif /* _FIXEDPOINT_H_PLUGINS */

View File

@ -22,13 +22,11 @@
****************************************************************************/
#include "plugin.h"
#include "fixedpoint.h"
#include "lib/helper.h"
#include "lib/pluginlib_exit.h"
#include "lib/xlcd.h"
#include "lib/configfile.h"
#include "fixedpoint.h"
#include "lib/fixedpoint.h"
#include "lib/osd.h"
/* variable button definitions */

View File

@ -25,6 +25,7 @@
****************************************************************************/
#include "plugin.h"
#include "fixedpoint.h"
#include "lib/helper.h"
#include "lib/pluginlib_actions.h"
#include "lib/pluginlib_exit.h"
@ -32,7 +33,6 @@
#ifndef HAVE_LCD_COLOR
#include "lib/grey.h"
#endif
#include "lib/fixedpoint.h"
/******************************* Globals ***********************************/

View File

@ -53,7 +53,7 @@ else
PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
endif
PLUGIN_LIBS := $(PLUGINLIB) $(PLUGINBITMAPLIB) $(SETJMPLIB)
PLUGIN_LIBS := $(PLUGINLIB) $(PLUGINBITMAPLIB) $(SETJMPLIB) $(FIXEDPOINTLIB)
# include <dir>.make from each subdir (yay!)
$(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))

View File

@ -18,7 +18,7 @@
*
**************************************************************************/
#include "plugin.h"
#include "lib/fixedpoint.h"
#include "fixedpoint.h"
#include "lib/playback_control.h"

View File

@ -9,5 +9,7 @@
SRC += $(call preprocess,$(APPSDIR)/SOURCES)
CORE_GCSECTIONS = yes
# don't build rombox.ucl
ARCHOSROM=

View File

@ -20,7 +20,6 @@
* KIND, either express or implied.
*
****************************************************************************/
#include "fixedpoint.h"
#include <stdlib.h>
#include <stdbool.h>
@ -143,8 +142,6 @@ long fp_sincos(unsigned long phase, long *cos)
return y;
}
#if defined(PLUGIN) || defined(CODEC)
/**
* Fixed point square root via Newton-Raphson.
* @param x square root argument.
@ -207,10 +204,7 @@ unsigned long isqrt(unsigned long x)
return g;
}
#endif /* PLUGIN or CODEC */
#if defined(PLUGIN)
/**
* Fixed point sinus using a lookup table
* don't forget to divide the result by 16384 to get the actual sinus value
@ -325,10 +319,7 @@ long fp16_exp(int x)
return y;
}
#endif /* PLUGIN */
#if (!defined(PLUGIN) && !defined(CODEC))
/** MODIFIED FROM replaygain.c */
#define FP_MUL_FRAC(x, y) fp_mul(x, y, fracbits)
@ -407,12 +398,10 @@ long fp_exp10(long x, unsigned int fracbits)
return FP_MUL_FRAC(k, xp);
}
#if 0 /* useful code, but not currently used */
/** FIXED POINT LOG10
* Return log10(x) as FP integer. Argument is FP integer.
*/
static long fp_log10(long n, unsigned int fracbits)
long fp_log10(long n, unsigned int fracbits)
{
/* Calculate log2 of argument */
@ -453,15 +442,12 @@ static long fp_log10(long n, unsigned int fracbits)
return FP_MUL_FRAC(log2, (FP28_LOG10OF2 >> (28 - fracbits)));
}
/** CONVERT FACTOR TO DECIBELS */
long fp_decibels(unsigned long factor, unsigned int fracbits)
{
/* decibels = 20 * log10(factor) */
return FP_MUL_FRAC((20L << fracbits), fp_log10(factor, fracbits));
}
#endif /* unused code */
/** CONVERT DECIBELS TO FACTOR */
long fp_factor(long decibels, unsigned int fracbits)
@ -469,4 +455,3 @@ long fp_factor(long decibels, unsigned int fracbits)
/* factor = 10 ^ (decibels / 20) */
return fp_exp10(FP_DIV_FRAC(decibels, (20L << fracbits)), fracbits);
}
#endif /* !PLUGIN and !CODEC */

View File

@ -107,10 +107,19 @@ unsigned long isqrt(unsigned long x);
*/
long fp_exp10(long x, unsigned int fracbits);
/** FIXED POINT LOG10
* Return log10(x) as FP integer. Argument is FP integer.
*/
long fp_log10(long n, unsigned int fracbits);
/* fracbits in range 12 - 22 work well. Higher is better for
* calculating dB, lower is better for calculating factor.
*/
/* long fp_decibels(unsigned long factor, unsigned int fracbits); */
/** CONVERT FACTOR TO DECIBELS */
long fp_decibels(unsigned long factor, unsigned int fracbits);
/** CONVERT DECIBELS TO FACTOR */
long fp_factor(long decibels, unsigned int fracbits);
#endif /* FIXEDPOINT_H */

View File

@ -0,0 +1,36 @@
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
FIXEDPOINTLIB := $(BUILDDIR)/lib/libfixedpoint.a
FIXEDPOINTLIB_DIR := $(ROOTDIR)/lib/fixedpoint
FIXEDPOINTLIB_SRC := $(FIXEDPOINTLIB_DIR)/fixedpoint.c
FIXEDPOINTLIB_OBJ := $(call c2obj, $(FIXEDPOINTLIB_SRC))
INCLUDES += -I$(FIXEDPOINTLIB_DIR)
OTHER_SRC += $(FIXEDPOINTLIB_SRC)
# If not SOFTWARECODECS, then only plugins depend upon us
ifdef SOFTWARECODECS
CORE_LIBS += $(FIXEDPOINTLIB)
CORE_GCSECTIONS := yes
endif
FIXEDPOINTLIB_FLAGS := $(CFLAGS)
# Do not use '-ffunction-sections' and '-fdata-sections' when compiling sdl-sim
ifneq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim)
FIXEDPOINTLIB_FLAGS += -ffunction-sections -fdata-sections
endif
$(FIXEDPOINTLIB_OBJ): $(FIXEDPOINTLIB_SRC)
$(SILENT)mkdir -p $(dir $@)
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \
$(FIXEDPOINTLIB_FLAGS) -c $< -o $@
$(FIXEDPOINTLIB): $(FIXEDPOINTLIB_OBJ)
$(SILENT)$(shell rm -f $@)
$(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null

View File

@ -23,7 +23,7 @@
#include "codeclib.h"
#include "inttypes.h"
#include "math.h"
#include "lib/fixedpoint.h"
#include "fixedpoint.h"
CODEC_HEADER

View File

@ -19,7 +19,7 @@ include $(RBCODECLIB_DIR)/codecs/lib/libcodec.make
OTHER_INC += -I$(RBCODECLIB_DIR)/codecs/lib
# extra libraries
CODEC_LIBS := $(CODECLIB)
CODEC_LIBS := $(CODECLIB) $(FIXEDPOINTLIB)
# the codec libraries
include $(RBCODECLIB_DIR)/codecs/demac/libdemac.make

View File

@ -1,6 +1,5 @@
#if CONFIG_CODEC == SWCODEC /* software codec platforms */
codeclib.c
fixedpoint.c
ffmpeg_bitstream.c
mdct_lookup.c

View File

@ -1 +0,0 @@
#include "../../../apps/fixedpoint.c"

View File

@ -1,26 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2006 Jens Arnold
*
* Fixed point library for codecs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _FIXEDPOINT_H_CODECS
#define _FIXEDPOINT_H_CODECS
#include "../../../../firmware/include/fixedpoint.h"
#endif /* _FIXEDPOINT_H_CODECS */

View File

@ -15,7 +15,9 @@ RBCODECLIB := $(BUILDDIR)/lib/librbcodec.a
INCLUDES += -I$(RBCODECLIB_DIR) -I$(RBCODECLIB_DIR)/codecs \
-I$(RBCODECLIB_DIR)/dsp -I$(RBCODECLIB_DIR)/metadata
OTHER_SRC += $(RBCODECLIB_SRC)
CORE_LIBS += $(RBCODECLIB)
# libfixedpoint must go after in lib list but be made first
CORE_LIBS := $(RBCODECLIB) $(CORE_LIBS)
$(RBCODECLIB): $(RBCODECLIB_OBJ)
$(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null

View File

@ -2,5 +2,4 @@ warble.c
../../../firmware/common/strlcpy.c
../../../firmware/common/unicode.c
../../../firmware/common/structec.c
../../../apps/fixedpoint.c
../../../uisimulator/common/io.c

View File

@ -1,5 +1,4 @@
database.c
../../apps/fixedpoint.c
../../apps/misc.c
../../apps/tagcache.c
../../firmware/common/crc32.c

View File

@ -35,10 +35,13 @@ INCLUDES += -I$(ROOTDIR)/apps/gui \
-I$(ROOTDIR)/lib/rbcodec/dsp \
-I$(APPSDIR) \
-I$(BUILDDIR)
ifdef SOFTWARECODECS
OTHERLIBS := $(FIXEDPOINTLIB)
endif
.SECONDEXPANSION: # $$(OBJ) is not populated until after this
$(BUILDDIR)/$(BINARY): $$(DATABASE_OBJ)
$(BUILDDIR)/$(BINARY): $$(DATABASE_OBJ) $(OTHERLIBS)
$(call PRINTS,LD $(BINARY))
$(SILENT)$(HOSTCC) -o $@ $+
$(SILENT)$(HOSTCC) $(call a2lnk $(OTHERLIBS)) -o $@ $+

View File

@ -17,6 +17,7 @@ INCLUDES = -I$(BUILDDIR) -I$(BUILDDIR)/lang $(TARGET_INC)
CFLAGS = $(INCLUDES) $(DEFINES) $(GCCOPTS)
PPCFLAGS = $(filter-out -g -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix
ASMFLAGS = -D__ASSEMBLER__ # work around gcc 3.4.x bug with -std=gnu99, only meant for .S files
CORE_LDOPTS = $(GLOBAL_LDOPTS) # linker ops specifically for core build
TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
$(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
@ -90,10 +91,15 @@ ifndef APP_TYPE
endif
endif
ifeq (,$(findstring bootloader,$(APPSDIR)))
ifeq (,$(findstring checkwps,$(APP_TYPE)))
include $(ROOTDIR)/lib/fixedpoint/fixedpoint.make
endif
endif
ifneq (,$(findstring bootloader,$(APPSDIR)))
include $(APPSDIR)/bootloader.make
else ifneq (,$(findstring bootbox,$(APPSDIR)))
BOOTBOXLDOPTS = -Wl,--gc-sections
include $(APPSDIR)/bootbox.make
else ifneq (,$(findstring checkwps,$(APP_TYPE)))
include $(APPSDIR)/checkwps.make
@ -104,10 +110,10 @@ else ifneq (,$(findstring warble,$(APP_TYPE)))
include $(ROOTDIR)/lib/rbcodec/test/warble.make
include $(ROOTDIR)/lib/tlsf/libtlsf.make
include $(ROOTDIR)/lib/rbcodec/rbcodec.make
else
else # core
include $(APPSDIR)/apps.make
include $(ROOTDIR)/lib/rbcodec/rbcodec.make
include $(APPSDIR)/lang/lang.make
include $(ROOTDIR)/lib/rbcodec/rbcodec.make
ifdef ENABLEDPLUGINS
include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
@ -132,6 +138,14 @@ else
endif # bootloader
# One or more subdir makefiles requested --gc-sections?
ifdef CORE_GCSECTIONS
# Do not use '--gc-sections' when compiling sdl-sim
ifneq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim)
CORE_LDOPTS += -Wl,--gc-sections
endif
endif # CORE_GCSECTIONS
OBJ := $(SRC:.c=.o)
OBJ := $(OBJ:.S=.o)
OBJ += $(BMP:.bmp=.o)
@ -205,16 +219,16 @@ $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LI
-L$(BUILDDIR)/firmware -lfirmware \
-L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
-L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
-lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
-T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
-lgcc -T$(LINKRAM) \
$(CORE_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
$(BUILDDIR)/rombox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKROM)
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
-L$(BUILDDIR)/firmware -lfirmware \
-L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
-L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
-lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
-T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
-lgcc -T$(LINKROM) \
$(CORE_LDOPTS) -Wl,-Map,$(BUILDDIR)/rombox.map
$(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
$(call PRINTS,OC $(@F))$(call objcopy,$<,$@)