From 93c8ddb8dd5791dc8c6eae007274487026dd4d4b Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Mon, 22 Aug 2011 14:21:23 -0400 Subject: [PATCH 4/7] rbcodec refactoring: codec_header --- apps/codecs.c | 1 + apps/rbcodecplatform.h | 46 ++++++++++++++++++++++++ lib/rbcodec/codecs/a52.c | 4 +- lib/rbcodec/codecs/a52_rm.c | 4 +- lib/rbcodec/codecs/aac.c | 4 +- lib/rbcodec/codecs/adx.c | 4 +- lib/rbcodec/codecs/aiff.c | 4 +- lib/rbcodec/codecs/aiff_enc.c | 4 +- lib/rbcodec/codecs/alac.c | 4 +- lib/rbcodec/codecs/ape.c | 4 +- lib/rbcodec/codecs/asap.c | 4 +- lib/rbcodec/codecs/atrac3_oma.c | 4 +- lib/rbcodec/codecs/atrac3_rm.c | 4 +- lib/rbcodec/codecs/au.c | 4 +- lib/rbcodec/codecs/ay.c | 4 +- lib/rbcodec/codecs/codec_crt0.c | 4 +- lib/rbcodec/codecs/codecs.h | 49 +------------------------ lib/rbcodec/codecs/cook.c | 4 +- lib/rbcodec/codecs/flac.c | 4 +- lib/rbcodec/codecs/gbs.c | 4 +- lib/rbcodec/codecs/hes.c | 4 +- lib/rbcodec/codecs/kss.c | 4 +- lib/rbcodec/codecs/lib/codeclib.h | 3 +- lib/rbcodec/codecs/libffmpegFLAC/bitstream.h | 1 - lib/rbcodec/codecs/libmad/frame.c | 1 - lib/rbcodec/codecs/libmad/frame.h | 1 - lib/rbcodec/codecs/libmusepack/mpcdec.h | 1 + lib/rbcodec/codecs/libtremor/vorbisfile.c | 1 - lib/rbcodec/codecs/libwavpack/bits.c | 1 - lib/rbcodec/codecs/mod.c | 4 +- lib/rbcodec/codecs/mp3_enc.c | 4 +- lib/rbcodec/codecs/mpa.c | 4 +- lib/rbcodec/codecs/mpc.c | 4 +- lib/rbcodec/codecs/nsf.c | 4 +- lib/rbcodec/codecs/raac.c | 4 +- lib/rbcodec/codecs/sgc.c | 4 +- lib/rbcodec/codecs/shorten.c | 4 +- lib/rbcodec/codecs/sid.c | 4 +- lib/rbcodec/codecs/smaf.c | 4 +- lib/rbcodec/codecs/spc.c | 4 +- lib/rbcodec/codecs/speex.c | 4 +- lib/rbcodec/codecs/tta.c | 4 +- lib/rbcodec/codecs/vgm.c | 4 +- lib/rbcodec/codecs/vorbis.c | 4 +- lib/rbcodec/codecs/vox.c | 4 +- lib/rbcodec/codecs/wav.c | 4 +- lib/rbcodec/codecs/wav64.c | 4 +- lib/rbcodec/codecs/wav_enc.c | 4 +- lib/rbcodec/codecs/wavpack.c | 4 +- lib/rbcodec/codecs/wavpack_enc.c | 4 +- lib/rbcodec/codecs/wma.c | 4 +- lib/rbcodec/codecs/wmapro.c | 4 +- lib/rbcodec/codecs/wmavoice.c | 4 +- lib/rbcodec/rbcodecplatform-unix.h | 11 ++++++ lib/rbcodec/test/warble.c | 14 +------- 55 files changed, 149 insertions(+), 153 deletions(-) diff --git a/apps/codecs.c b/apps/codecs.c index c2efbaa..b0ba0e6 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -51,6 +51,7 @@ #include "splash.h" #include "general.h" #include "rbpaths.h" +#include "platform.h" #define LOGF_ENABLE #include "logf.h" diff --git a/apps/rbcodecplatform.h b/apps/rbcodecplatform.h index 757380a..32881b4 100644 --- a/apps/rbcodecplatform.h +++ b/apps/rbcodecplatform.h @@ -43,4 +43,50 @@ static inline char *decode_text(encoding_t encoding, const char *in, char *out, return iso_decode(in, out, encoding, in_len); } +/* struct lc_header */ +#include "load_code.h" + +/* codec header */ +struct codec_header { + struct lc_header lc_hdr; /* must be first */ + int(*entry_point)(int reason); + int(*run_proc)(void); + struct codec_api **api; +}; + +#ifdef CODEC +#if (CONFIG_PLATFORM & PLATFORM_NATIVE) +/* plugin_* is correct, codecs use the plugin linker script */ +extern unsigned char plugin_start_addr[]; +extern unsigned char plugin_end_addr[]; +/* decoders */ +#define CODEC_HEADER \ + const struct codec_header __header \ + __attribute__ ((section (".header")))= { \ + { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ + plugin_start_addr, plugin_end_addr }, codec_start, \ + codec_run, &ci }; +/* encoders */ +#define CODEC_ENC_HEADER \ + const struct codec_header __header \ + __attribute__ ((section (".header")))= { \ + { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ + plugin_start_addr, plugin_end_addr }, codec_start, \ + codec_run, &ci }; + +#else /* def SIMULATOR */ +/* decoders */ +#define CODEC_HEADER \ + const struct codec_header __header \ + __attribute__((visibility("default"))) = { \ + { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ + codec_start, codec_run, &ci }; +/* encoders */ +#define CODEC_ENC_HEADER \ + const struct codec_header __header = { \ + { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ + codec_start, codec_run, &ci }; +#endif /* SIMULATOR */ +#endif /* CODEC */ + #endif diff --git a/lib/rbcodec/codecs/a52.c b/lib/rbcodec/codecs/a52.c index 4cd293e..0df59e1 100644 --- a/lib/rbcodec/codecs/a52.c +++ b/lib/rbcodec/codecs/a52.c @@ -116,7 +116,7 @@ static void a52_decode_data(uint8_t *start, uint8_t *end) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -132,7 +132,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { size_t n; unsigned char *filebuf; diff --git a/lib/rbcodec/codecs/a52_rm.c b/lib/rbcodec/codecs/a52_rm.c index c5d55d6..50fdd62 100644 --- a/lib/rbcodec/codecs/a52_rm.c +++ b/lib/rbcodec/codecs/a52_rm.c @@ -125,7 +125,7 @@ static void a52_decode_data(uint8_t *start, uint8_t *end) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -141,7 +141,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { size_t n; uint8_t *filebuf; diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c index 52e08c7..06f15a2 100644 --- a/lib/rbcodec/codecs/aac.c +++ b/lib/rbcodec/codecs/aac.c @@ -33,7 +33,7 @@ CODEC_HEADER #define FAAD_BYTE_BUFFER_SIZE (2048-12) /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -45,7 +45,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { /* Note that when dealing with QuickTime/MPEG4 files, terminology is * a bit confusing. Files with sound are split up in chunks, where diff --git a/lib/rbcodec/codecs/adx.c b/lib/rbcodec/codecs/adx.c index 1318aff..ce7667b 100644 --- a/lib/rbcodec/codecs/adx.c +++ b/lib/rbcodec/codecs/adx.c @@ -45,7 +45,7 @@ static const long cutoff = 500; static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -57,7 +57,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { int channels; int sampleswritten, i; diff --git a/lib/rbcodec/codecs/aiff.c b/lib/rbcodec/codecs/aiff.c index a8185b4..764b098 100644 --- a/lib/rbcodec/codecs/aiff.c +++ b/lib/rbcodec/codecs/aiff.c @@ -62,7 +62,7 @@ static const struct pcm_codec *get_codec(uint32_t formattag) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -73,7 +73,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { struct pcm_format format; uint32_t bytesdone, decodedsamples; diff --git a/lib/rbcodec/codecs/aiff_enc.c b/lib/rbcodec/codecs/aiff_enc.c index fc44196..9ce4e48 100644 --- a/lib/rbcodec/codecs/aiff_enc.c +++ b/lib/rbcodec/codecs/aiff_enc.c @@ -360,7 +360,7 @@ static bool init_encoder(void) } /* init_encoder */ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { if (!init_encoder()) @@ -375,7 +375,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { /* main encoding loop */ while (ci->get_command(NULL) != CODEC_ACTION_HALT) diff --git a/lib/rbcodec/codecs/alac.c b/lib/rbcodec/codecs/alac.c index b6852f5..674431a 100644 --- a/lib/rbcodec/codecs/alac.c +++ b/lib/rbcodec/codecs/alac.c @@ -32,7 +32,7 @@ CODEC_HEADER static int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -44,7 +44,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { size_t n; demux_res_t demux_res; diff --git a/lib/rbcodec/codecs/ape.c b/lib/rbcodec/codecs/ape.c index 8f95a01..4121bbc 100644 --- a/lib/rbcodec/codecs/ape.c +++ b/lib/rbcodec/codecs/ape.c @@ -127,7 +127,7 @@ static void ape_resume(struct ape_ctx_t* ape_ctx, size_t resume_offset, } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -138,7 +138,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { struct ape_ctx_t ape_ctx; uint32_t samplesdone; diff --git a/lib/rbcodec/codecs/asap.c b/lib/rbcodec/codecs/asap.c index 19b39a4..a665e7b 100644 --- a/lib/rbcodec/codecs/asap.c +++ b/lib/rbcodec/codecs/asap.c @@ -30,7 +30,7 @@ static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ static ASAP_State asap IBSS_ATTR; /* asap codec state */ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { /* Nothing to do */ return CODEC_OK; @@ -38,7 +38,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { int n_bytes; int song; diff --git a/lib/rbcodec/codecs/atrac3_oma.c b/lib/rbcodec/codecs/atrac3_oma.c index 50f7c8f..307b891 100644 --- a/lib/rbcodec/codecs/atrac3_oma.c +++ b/lib/rbcodec/codecs/atrac3_oma.c @@ -34,7 +34,7 @@ CODEC_HEADER static ATRAC3Context q IBSS_ATTR; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { /* Nothing to do */ return CODEC_OK; @@ -42,7 +42,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { static size_t buff_size; int datasize, res, frame_counter, total_frames, seek_frame_offset; diff --git a/lib/rbcodec/codecs/atrac3_rm.c b/lib/rbcodec/codecs/atrac3_rm.c index 9975074..ab6fa7b 100644 --- a/lib/rbcodec/codecs/atrac3_rm.c +++ b/lib/rbcodec/codecs/atrac3_rm.c @@ -42,7 +42,7 @@ static void init_rm(RMContext *rmctx) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { /* Nothing to do */ return CODEC_OK; @@ -50,7 +50,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { static size_t buff_size; int datasize, res, consumed, i, time_offset; diff --git a/lib/rbcodec/codecs/au.c b/lib/rbcodec/codecs/au.c index ef30835..b57893a 100644 --- a/lib/rbcodec/codecs/au.c +++ b/lib/rbcodec/codecs/au.c @@ -106,7 +106,7 @@ static int convert_au_format(unsigned int encoding, struct pcm_format *fmt) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -117,7 +117,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { struct pcm_format format; uint32_t bytesdone, decodedsamples; diff --git a/lib/rbcodec/codecs/ay.c b/lib/rbcodec/codecs/ay.c index 33b38e5..8b71c2f 100644 --- a/lib/rbcodec/codecs/ay.c +++ b/lib/rbcodec/codecs/ay.c @@ -26,7 +26,7 @@ static void set_codec_track(int t, int multitrack) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -44,7 +44,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/codec_crt0.c b/lib/rbcodec/codecs/codec_crt0.c index 3387627..a2052bb 100644 --- a/lib/rbcodec/codecs/codec_crt0.c +++ b/lib/rbcodec/codecs/codec_crt0.c @@ -27,13 +27,13 @@ struct codec_api *ci DATA_ATTR; extern unsigned char plugin_bss_start[]; extern unsigned char plugin_end_addr[]; -extern enum codec_status codec_main(enum codec_entry_call_reason reason); +extern int codec_main(int reason); /* stub, the entry point is called via its reference in __header to * avoid warning with certain compilers */ int _start(void) {return 0;} -enum codec_status codec_start(enum codec_entry_call_reason reason) +int codec_start(int reason) { #if (CONFIG_PLATFORM & PLATFORM_NATIVE) if (reason == CODEC_LOAD) diff --git a/lib/rbcodec/codecs/codecs.h b/lib/rbcodec/codecs/codecs.h index 75a6e67..6bc8397 100644 --- a/lib/rbcodec/codecs/codecs.h +++ b/lib/rbcodec/codecs/codecs.h @@ -31,7 +31,6 @@ #include #include "strlcpy.h" #include "config.h" -#include "system.h" #include "metadata.h" #include "audio.h" #ifdef RB_PROFILE @@ -81,7 +80,6 @@ new function which are "waiting" at the end of the function table) */ #define CODEC_MIN_API_VERSION 43 -/* reasons for calling codec main entrypoint */ enum codec_entry_call_reason { CODEC_LOAD = 0, CODEC_UNLOAD @@ -224,49 +222,6 @@ struct codec_api { the API gets incompatible */ }; -/* codec header */ -struct codec_header { - struct lc_header lc_hdr; /* must be first */ - enum codec_status(*entry_point)(enum codec_entry_call_reason reason); - enum codec_status(*run_proc)(void); - struct codec_api **api; -}; - -#ifdef CODEC -#if (CONFIG_PLATFORM & PLATFORM_NATIVE) -/* plugin_* is correct, codecs use the plugin linker script */ -extern unsigned char plugin_start_addr[]; -extern unsigned char plugin_end_addr[]; -/* decoders */ -#define CODEC_HEADER \ - const struct codec_header __header \ - __attribute__ ((section (".header")))= { \ - { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr }, codec_start, \ - codec_run, &ci }; -/* encoders */ -#define CODEC_ENC_HEADER \ - const struct codec_header __header \ - __attribute__ ((section (".header")))= { \ - { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr }, codec_start, \ - codec_run, &ci }; - -#else /* def SIMULATOR */ -/* decoders */ -#define CODEC_HEADER \ - const struct codec_header __header \ - __attribute__((visibility("default"))) = { \ - { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ - codec_start, codec_run, &ci }; -/* encoders */ -#define CODEC_ENC_HEADER \ - const struct codec_header __header = { \ - { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ - codec_start, codec_run, &ci }; -#endif /* SIMULATOR */ -#endif /* CODEC */ - /* create full codec path from root filenames in audio_formats[] assumes buffer size is MAX_PATH */ void codec_get_full_path(char *path, const char *codec_root_fn); @@ -282,7 +237,7 @@ int codec_halt(void); int codec_close(void); /* defined by the codec */ -enum codec_status codec_start(enum codec_entry_call_reason reason); -enum codec_status codec_run(void); +int codec_start(int reason); +int codec_run(void); #endif /* _CODECS_H_ */ diff --git a/lib/rbcodec/codecs/cook.c b/lib/rbcodec/codecs/cook.c index 4a47e74..57b13c0 100644 --- a/lib/rbcodec/codecs/cook.c +++ b/lib/rbcodec/codecs/cook.c @@ -39,7 +39,7 @@ static void init_rm(RMContext *rmctx) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { /* Nothing to do */ return CODEC_OK; @@ -47,7 +47,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { static size_t buff_size; int datasize, res, consumed, i, time_offset; diff --git a/lib/rbcodec/codecs/flac.c b/lib/rbcodec/codecs/flac.c index a5521b5..886c42a 100644 --- a/lib/rbcodec/codecs/flac.c +++ b/lib/rbcodec/codecs/flac.c @@ -418,7 +418,7 @@ static bool flac_seek_offset(FLACContext* fc, uint32_t offset) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -429,7 +429,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { int8_t *buf; FLACContext fc; diff --git a/lib/rbcodec/codecs/gbs.c b/lib/rbcodec/codecs/gbs.c index 743a1d4..3d96871 100644 --- a/lib/rbcodec/codecs/gbs.c +++ b/lib/rbcodec/codecs/gbs.c @@ -25,7 +25,7 @@ static void set_codec_track(int t) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -43,7 +43,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/hes.c b/lib/rbcodec/codecs/hes.c index 9e35fe7..9c69d8b 100644 --- a/lib/rbcodec/codecs/hes.c +++ b/lib/rbcodec/codecs/hes.c @@ -25,7 +25,7 @@ static void set_codec_track(int t) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -43,7 +43,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/kss.c b/lib/rbcodec/codecs/kss.c index 71605c4..2f714d4 100644 --- a/lib/rbcodec/codecs/kss.c +++ b/lib/rbcodec/codecs/kss.c @@ -25,7 +25,7 @@ static void set_codec_track(int t) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -43,7 +43,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/lib/codeclib.h b/lib/rbcodec/codecs/lib/codeclib.h index d0f985b..fb5d682 100644 --- a/lib/rbcodec/codecs/lib/codeclib.h +++ b/lib/rbcodec/codecs/lib/codeclib.h @@ -22,8 +22,7 @@ #ifndef __CODECLIB_H__ #define __CODECLIB_H__ -#include -#include +#include "platform.h" #include "config.h" #include "codecs.h" #include "mdct.h" diff --git a/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h index 1333b9f..70a04e1 100644 --- a/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h +++ b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h @@ -11,7 +11,6 @@ #ifndef BUILD_STANDALONE #include - #include #else #include #define IBSS_ATTR diff --git a/lib/rbcodec/codecs/libmad/frame.c b/lib/rbcodec/codecs/libmad/frame.c index 9f1188b..c48d359 100644 --- a/lib/rbcodec/codecs/libmad/frame.c +++ b/lib/rbcodec/codecs/libmad/frame.c @@ -28,7 +28,6 @@ # include "bit.h" # include "stream.h" # include "frame.h" -# include "timer.h" # include "layer12.h" # include "layer3.h" # include "codeclib.h" diff --git a/lib/rbcodec/codecs/libmad/frame.h b/lib/rbcodec/codecs/libmad/frame.h index b1c6e02..a8eb2b5 100644 --- a/lib/rbcodec/codecs/libmad/frame.h +++ b/lib/rbcodec/codecs/libmad/frame.h @@ -23,7 +23,6 @@ # define LIBMAD_FRAME_H # include "fixed.h" -# include "timer.h" # include "stream.h" enum mad_layer { diff --git a/lib/rbcodec/codecs/libmusepack/mpcdec.h b/lib/rbcodec/codecs/libmusepack/mpcdec.h index 85536e7..24523f9 100644 --- a/lib/rbcodec/codecs/libmusepack/mpcdec.h +++ b/lib/rbcodec/codecs/libmusepack/mpcdec.h @@ -39,6 +39,7 @@ #pragma once #endif +#include "platform.h" #include "reader.h" #include "streaminfo.h" #include "config.h" diff --git a/lib/rbcodec/codecs/libtremor/vorbisfile.c b/lib/rbcodec/codecs/libtremor/vorbisfile.c index 5721178..cdc1853 100644 --- a/lib/rbcodec/codecs/libtremor/vorbisfile.c +++ b/lib/rbcodec/codecs/libtremor/vorbisfile.c @@ -21,7 +21,6 @@ #include #include #include -#include "system.h" #include "ivorbiscodec.h" #include "ivorbisfile.h" diff --git a/lib/rbcodec/codecs/libwavpack/bits.c b/lib/rbcodec/codecs/libwavpack/bits.c index 0f0e79c..6d81b22 100644 --- a/lib/rbcodec/codecs/libwavpack/bits.c +++ b/lib/rbcodec/codecs/libwavpack/bits.c @@ -15,7 +15,6 @@ // the malloc() system is provided. #include "wavpack.h" -#include "system.h" #include diff --git a/lib/rbcodec/codecs/mod.c b/lib/rbcodec/codecs/mod.c index 2d13f93..4b807e4 100644 --- a/lib/rbcodec/codecs/mod.c +++ b/lib/rbcodec/codecs/mod.c @@ -1282,7 +1282,7 @@ int synthrender(int32_t *renderbuffer, int samplecount) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Make use of 44.1khz */ @@ -1297,7 +1297,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { size_t n; unsigned char *modfile; diff --git a/lib/rbcodec/codecs/mp3_enc.c b/lib/rbcodec/codecs/mp3_enc.c index 2f5528f..21f0aea 100644 --- a/lib/rbcodec/codecs/mp3_enc.c +++ b/lib/rbcodec/codecs/mp3_enc.c @@ -2585,7 +2585,7 @@ static bool enc_init(void) } /* enc_init */ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { if (!enc_init()) @@ -2600,7 +2600,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { /* main encoding loop */ while(ci->get_command(NULL) != CODEC_ACTION_HALT) diff --git a/lib/rbcodec/codecs/mpa.c b/lib/rbcodec/codecs/mpa.c index c9e2131..7dfd9fc 100644 --- a/lib/rbcodec/codecs/mpa.c +++ b/lib/rbcodec/codecs/mpa.c @@ -299,7 +299,7 @@ static inline void mad_synth_thread_unwait_pcm(void) #endif /* MPA_SYNTH_ON_COP */ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Create a decoder instance */ @@ -321,7 +321,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { size_t size; int file_end; diff --git a/lib/rbcodec/codecs/mpc.c b/lib/rbcodec/codecs/mpc.c index 7388799..fb00351 100644 --- a/lib/rbcodec/codecs/mpc.c +++ b/lib/rbcodec/codecs/mpc.c @@ -53,7 +53,7 @@ static mpc_int32_t get_size_impl(mpc_reader *reader) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* musepack's sample representation is 18.14 @@ -65,7 +65,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { mpc_int64_t samplesdone; uint32_t frequency; /* 0.1 kHz accuracy */ diff --git a/lib/rbcodec/codecs/nsf.c b/lib/rbcodec/codecs/nsf.c index b6a749a..2980117 100644 --- a/lib/rbcodec/codecs/nsf.c +++ b/lib/rbcodec/codecs/nsf.c @@ -28,7 +28,7 @@ static void set_codec_track(int t, int multitrack) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -46,7 +46,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/raac.c b/lib/rbcodec/codecs/raac.c index 0ef7e71..756402d 100644 --- a/lib/rbcodec/codecs/raac.c +++ b/lib/rbcodec/codecs/raac.c @@ -39,7 +39,7 @@ static RMContext rmctx; static RMPacket pkt; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -51,7 +51,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { static NeAACDecFrameInfo frame_info; NeAACDecHandle decoder; diff --git a/lib/rbcodec/codecs/sgc.c b/lib/rbcodec/codecs/sgc.c index dc0374c..f424daa 100644 --- a/lib/rbcodec/codecs/sgc.c +++ b/lib/rbcodec/codecs/sgc.c @@ -30,7 +30,7 @@ static void set_codec_track(int t) { } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -58,7 +58,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/shorten.c b/lib/rbcodec/codecs/shorten.c index db66991..20dae64 100644 --- a/lib/rbcodec/codecs/shorten.c +++ b/lib/rbcodec/codecs/shorten.c @@ -37,7 +37,7 @@ static int32_t offset1[MAX_OFFSET_SIZE] IBSS_ATTR; static int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -49,7 +49,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { ShortenContext sc; uint32_t samplesdone; diff --git a/lib/rbcodec/codecs/sid.c b/lib/rbcodec/codecs/sid.c index fed1e8a..5b2a86d 100644 --- a/lib/rbcodec/codecs/sid.c +++ b/lib/rbcodec/codecs/sid.c @@ -1231,7 +1231,7 @@ static int nSamplesPerCall = 882; /* This is PAL SID single speed (44100/50Hz) static int nSamplesToRender = 0; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Make use of 44.1khz */ @@ -1246,7 +1246,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { size_t filesize; unsigned short load_addr, init_addr, play_addr; diff --git a/lib/rbcodec/codecs/smaf.c b/lib/rbcodec/codecs/smaf.c index 9211daa..583b175 100644 --- a/lib/rbcodec/codecs/smaf.c +++ b/lib/rbcodec/codecs/smaf.c @@ -333,7 +333,7 @@ static uint8_t *read_buffer(size_t *realsize) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -344,7 +344,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t decodedsamples; size_t n; diff --git a/lib/rbcodec/codecs/spc.c b/lib/rbcodec/codecs/spc.c index 8974b8b..80106d8 100644 --- a/lib/rbcodec/codecs/spc.c +++ b/lib/rbcodec/codecs/spc.c @@ -524,7 +524,7 @@ static int play_track( void ) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { if (!spc_emu_start()) @@ -542,7 +542,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { DEBUGF("SPC: next_track\n"); if (codec_init()) diff --git a/lib/rbcodec/codecs/speex.c b/lib/rbcodec/codecs/speex.c index c01bcfd..2abd8ac 100644 --- a/lib/rbcodec/codecs/speex.c +++ b/lib/rbcodec/codecs/speex.c @@ -368,7 +368,7 @@ static void *process_header(spx_ogg_packet *op, } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { /* Nothing to do */ return CODEC_OK; @@ -376,7 +376,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { int error = CODEC_ERROR; diff --git a/lib/rbcodec/codecs/tta.c b/lib/rbcodec/codecs/tta.c index c75f2b0..ab305e3 100644 --- a/lib/rbcodec/codecs/tta.c +++ b/lib/rbcodec/codecs/tta.c @@ -34,7 +34,7 @@ CODEC_HEADER static int32_t samples[PCM_BUFFER_LENGTH * 2] IBSS_ATTR; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -45,7 +45,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { tta_info info; unsigned int decodedsamples; diff --git a/lib/rbcodec/codecs/vgm.c b/lib/rbcodec/codecs/vgm.c index b931f8a..616c0c8 100644 --- a/lib/rbcodec/codecs/vgm.c +++ b/lib/rbcodec/codecs/vgm.c @@ -26,7 +26,7 @@ static uint32_t songlen=0; /* used size of the song buffer */ /****************** rockbox interface ******************/ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* we only render 16 bits */ @@ -44,7 +44,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { blargg_err_t err; uint8_t *buf; diff --git a/lib/rbcodec/codecs/vorbis.c b/lib/rbcodec/codecs/vorbis.c index e02d459..02f407b 100644 --- a/lib/rbcodec/codecs/vorbis.c +++ b/lib/rbcodec/codecs/vorbis.c @@ -104,7 +104,7 @@ static bool vorbis_set_codec_parameters(OggVorbis_File *vf) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { if (codec_init()) @@ -116,7 +116,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { ov_callbacks callbacks; OggVorbis_File vf; diff --git a/lib/rbcodec/codecs/vox.c b/lib/rbcodec/codecs/vox.c index bf274c6..edd8b6f 100644 --- a/lib/rbcodec/codecs/vox.c +++ b/lib/rbcodec/codecs/vox.c @@ -44,7 +44,7 @@ static uint8_t *read_buffer(size_t *realsize) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -55,7 +55,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t decodedsamples; size_t n; diff --git a/lib/rbcodec/codecs/wav.c b/lib/rbcodec/codecs/wav.c index d43961a..6351064 100644 --- a/lib/rbcodec/codecs/wav.c +++ b/lib/rbcodec/codecs/wav.c @@ -151,7 +151,7 @@ static uint8_t *read_buffer(size_t *realsize) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -162,7 +162,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t decodedsamples; size_t n; diff --git a/lib/rbcodec/codecs/wav64.c b/lib/rbcodec/codecs/wav64.c index c763e6f..cb761f8 100644 --- a/lib/rbcodec/codecs/wav64.c +++ b/lib/rbcodec/codecs/wav64.c @@ -159,7 +159,7 @@ static uint8_t *read_buffer(size_t *realsize) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -170,7 +170,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t decodedsamples; size_t n; diff --git a/lib/rbcodec/codecs/wav_enc.c b/lib/rbcodec/codecs/wav_enc.c index e4afeaf..1eceb49 100644 --- a/lib/rbcodec/codecs/wav_enc.c +++ b/lib/rbcodec/codecs/wav_enc.c @@ -346,7 +346,7 @@ static bool init_encoder(void) } /* init_encoder */ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { if (!init_encoder()) @@ -361,7 +361,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { /* main encoding loop */ while(ci->get_command(NULL) != CODEC_ACTION_HALT) diff --git a/lib/rbcodec/codecs/wavpack.c b/lib/rbcodec/codecs/wavpack.c index 32f09d5..0969753 100644 --- a/lib/rbcodec/codecs/wavpack.c +++ b/lib/rbcodec/codecs/wavpack.c @@ -36,7 +36,7 @@ static int32_t read_callback (void *buffer, int32_t bytes) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -47,7 +47,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { WavpackContext *wpc; char error [80]; diff --git a/lib/rbcodec/codecs/wavpack_enc.c b/lib/rbcodec/codecs/wavpack_enc.c index 730cf07..70edea9 100644 --- a/lib/rbcodec/codecs/wavpack_enc.c +++ b/lib/rbcodec/codecs/wavpack_enc.c @@ -390,7 +390,7 @@ static bool init_encoder(void) } /* init_encoder */ /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* initialize params and config */ @@ -406,7 +406,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { /* main encoding loop */ while(ci->get_command(NULL) != CODEC_ACTION_HALT) diff --git a/lib/rbcodec/codecs/wma.c b/lib/rbcodec/codecs/wma.c index c327faf..f4fa96e 100644 --- a/lib/rbcodec/codecs/wma.c +++ b/lib/rbcodec/codecs/wma.c @@ -29,7 +29,7 @@ CODEC_HEADER static WMADecodeContext wmadec; /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -40,7 +40,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t elapsedtime; asf_waveformatex_t wfx; diff --git a/lib/rbcodec/codecs/wmapro.c b/lib/rbcodec/codecs/wmapro.c index 17e311c..59b4a12 100644 --- a/lib/rbcodec/codecs/wmapro.c +++ b/lib/rbcodec/codecs/wmapro.c @@ -30,7 +30,7 @@ static int32_t *dec[2]; /* pointers to the output buffers in WMAProDecodeCtx in /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -41,7 +41,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t elapsedtime; asf_waveformatex_t wfx; /* Holds the stream properties */ diff --git a/lib/rbcodec/codecs/wmavoice.c b/lib/rbcodec/codecs/wmavoice.c index 64c8cd1..0b4f60a 100644 --- a/lib/rbcodec/codecs/wmavoice.c +++ b/lib/rbcodec/codecs/wmavoice.c @@ -52,7 +52,7 @@ static void init_codec_ctx(AVCodecContext *avctx, asf_waveformatex_t *wfx) } /* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) +int codec_main(int reason) { if (reason == CODEC_LOAD) { /* Generic codec initialisation */ @@ -63,7 +63,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason) } /* this is called for each file to process */ -enum codec_status codec_run(void) +int codec_run(void) { uint32_t elapsedtime; asf_waveformatex_t wfx; /* Holds the stream properties */ diff --git a/lib/rbcodec/rbcodecplatform-unix.h b/lib/rbcodec/rbcodecplatform-unix.h index 80796b9..e60a106 100644 --- a/lib/rbcodec/rbcodecplatform-unix.h +++ b/lib/rbcodec/rbcodecplatform-unix.h @@ -51,6 +51,17 @@ static inline off_t filesize(int fd) { } while (0) #endif +struct rbcodec_codec_header { + int(*entry_point)(int reason); + int(*run_proc)(void); + struct codec_api **api; +}; + +#define CODEC_HEADER \ + const struct rbcodec_codec_header __header \ + __attribute__((visibility("default"))) = { \ + codec_start, codec_run, &ci }; + /* Character encoding conversion */ typedef enum { ENCODING_NONE, diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c index 1eb52d7..dccba13 100644 --- a/lib/rbcodec/test/warble.c +++ b/lib/rbcodec/test/warble.c @@ -729,20 +729,8 @@ static void decode_file(const char *input_fn) fprintf(stderr, "error: dlopen failed: %s\n", dlerror()); exit(1); } - struct codec_header *c_hdr = NULL; + struct rbcodec_codec_header *c_hdr = NULL; c_hdr = dlsym(dlcodec, "__header"); - if (c_hdr->lc_hdr.magic != CODEC_MAGIC) { - fprintf(stderr, "error: %s invalid: incorrect magic\n", str); - exit(1); - } - if (c_hdr->lc_hdr.target_id != TARGET_ID) { - fprintf(stderr, "error: %s invalid: incorrect target id\n", str); - exit(1); - } - if (c_hdr->lc_hdr.api_version != CODEC_API_VERSION) { - fprintf(stderr, "error: %s invalid: incorrect API version\n", str); - exit(1); - } /* Run the codec */ *c_hdr->api = &ci; -- 1.7.6