123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- /*
- * Copyright (c) 2019 Actions Semiconductor Co., Ltd
- *
- * SPDX-License-Identifier: Apache-2.0
- */
- /**
- * @file codec config interface
- */
- #include <media_service.h>
- #include <string.h>
- #include <section_overlay.h>
- typedef struct
- {
- uint8_t format;
- uint8_t codec_type;
- bool hw_acceleration;
- uint32_t overlay_id;
- void *ops;
- const char *dsp_dec_lib;
- const char *dsp_effect_lib;
- } codec_config_info_t;
- const codec_config_info_t codec_config[] =
- {
- #ifdef CONFIG_ACTIONS_DECODER
- #ifdef CONFIG_DECODER_AAC
- {
- .format = AAC_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADAAC,
- #ifdef CONFIG_DECODER_AAC_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_aac,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_M4A
- {
- .format = M4A_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADAAC,
- #ifdef CONFIG_DECODER_M4A_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_aac,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_ACT
- {
- .format = ACT_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = 0, //OVERLAY_ID_LIBADACT,
- #ifdef CONFIG_DECODER_ACT_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_act,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_APE
- {
- .format = APE_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADAPE,
- #ifdef CONFIG_DECODER_APE_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_ape,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_CVSD
- {
- .format = CVSD_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = 0,//OVERLAY_ID_LIBADCVS,
- #ifdef CONFIG_DECODER_CVSD_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- //.dsp_effect_lib = "PREPRO.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- //.ops = as_decoder_ops_cvsd,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_FLAC
- {
- .format = FLA_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADFLA,
- #ifdef CONFIG_DECODER_FLAC_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_flac,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_MP3
- {
- .format = MP3_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADMP3,
- #ifdef CONFIG_DECODER_MP3_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_mp3,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_WAV
- {
- .format = WAV_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADWAV,
- #ifdef CONFIG_DECODER_WAV_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_wav,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_WMA
- {
- .format = WMA_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = OVERLAY_ID_LIBADWMA,
- #ifdef CONFIG_DECODER_WMA_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_decoder_ops_wma,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_PCM
- {
- .format = PCM_TYPE,
- .codec_type = CODEC_DEC,
- .hw_acceleration = true,
- .overlay_id = 0,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- },
- #endif
- #ifdef CONFIG_DECODER_SBC
- {
- .format = SBC_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = 0, //OVERLAY_ID_LIBADSBC,
- #ifdef CONFIG_DECODER_SBC_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- //.ops = as_decoder_ops_sbc,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_MSBC
- {
- .format = MSBC_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = 0, //OVERLAY_ID_LIBADSBC,
- #ifdef CONFIG_DECODER_MSBC_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- //.dsp_effect_lib = "PREPRO.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- //.ops = as_decoder_ops_sbc,
- #endif
- },
- #endif
- #ifdef CONFIG_DECODER_NAV
- {
- .format = NAV_TYPE,
- .codec_type = CODEC_DEC,
- .overlay_id = 0,
- #ifdef CONFIG_DECODER_NAV_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "audioble.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- //.ops = as_encoder_ops_nav,
- #endif
- },
- #endif
- #endif
- #ifdef CONFIG_ACTIONS_ENCODER
- #ifdef CONFIG_ENCODER_CVSD
- {
- .format = CVSD_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = 0,//OVERLAY_ID_LIBAECVS,
- #ifdef CONFIG_ENCODER_CVSD_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = "PREPRO.dsp",
- #else
- .hw_acceleration = false,
- //.ops = as_encoder_ops_cvsd,
- #endif
- },
- #endif
- #ifdef CONFIG_ENCODER_MP3
- {
- .format = MP3_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = OVERLAY_ID_LIBAEMP3,
- #ifdef CONFIG_ENCODER_MP3_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_encoder_ops_mp2,
- #endif
- },
- #endif
- #ifdef CONFIG_ENCODER_OPUS
- {
- .format = OPUS_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = OVERLAY_ID_LIBAEOPU,
- #ifdef CONFIG_ENCODER_OPUS_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "aeOPUS.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_encoder_ops_opus,
- #endif
- },
- #endif
- #ifdef CONFIG_ENCODER_WAV
- {
- .format = WAV_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = 0,//OVERLAY_ID_LIBAEWAV,
- #ifdef CONFIG_ENCODER_WAV_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- .ops = as_encoder_ops_wav,
- #endif
- },
- #endif
- #ifdef CONFIG_ENCODER_PCM
- {
- .format = PCM_TYPE,
- .codec_type = CODEC_ENC,
- .hw_acceleration = true,
- .overlay_id = 0,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- },
- #endif
- #ifdef CONFIG_ENCODER_SBC
- {
- .format = SBC_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = 0,
- #ifdef CONFIG_ENCODER_SBC_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- //.ops = as_encoder_ops_sbc,
- #endif
- },
- #endif
- #ifdef CONFIG_ENCODER_MSBC
- {
- .format = MSBC_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = 0,
- #ifdef CONFIG_ENCODER_MSBC_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "adMUSIC.dsp",
- .dsp_effect_lib = "PREPRO.dsp",
- #else
- .hw_acceleration = false,
- //.ops = as_encoder_ops_sbc,
- #endif
- },
- #endif
- #ifdef CONFIG_ENCODER_NAV
- {
- .format = NAV_TYPE,
- .codec_type = CODEC_ENC,
- .overlay_id = 0,
- #ifdef CONFIG_ENCODER_NAV_HW_ACCELERATION
- .hw_acceleration = true,
- .ops = NULL,
- .dsp_dec_lib = "audioble.dsp",
- .dsp_effect_lib = NULL,
- #else
- .hw_acceleration = false,
- //.ops = as_encoder_ops_nav,
- #endif
- },
- #endif
- #endif
- };
- int codec_get_overlay_id(enum media_type format, enum codec_type type)
- {
- int i;
- for (i = 0; i < ARRAY_SIZE(codec_config); i++) {
- if (format == codec_config[i].format
- && type == codec_config[i].codec_type) {
- return codec_config[i].overlay_id;
- }
- }
- return -1;
- }
- void *codec_get_ops(enum media_type format, enum codec_type type)
- {
- int i;
- for (i = 0; i < ARRAY_SIZE(codec_config); i++) {
- if (format == codec_config[i].format
- && type == codec_config[i].codec_type) {
- return codec_config[i].ops;
- }
- }
- return NULL;
- }
- bool codec_support_hw_acceleration(enum media_type format, enum codec_type type)
- {
- int i;
- for (i = 0; i < ARRAY_SIZE(codec_config); i++) {
- if (format == codec_config[i].format
- && type == codec_config[i].codec_type) {
- return codec_config[i].hw_acceleration;
- }
- }
- return false;
- }
- const char *codec_get_hw_acceleration_dec_lib(enum media_type format, enum codec_type type)
- {
- int i;
- for (i = 0; i < ARRAY_SIZE(codec_config); i++) {
- if (format == codec_config[i].format
- && type == codec_config[i].codec_type) {
- return codec_config[i].dsp_dec_lib;
- }
- }
- return NULL;
- }
- const char *codec_get_hw_acceleration_effect_lib(enum media_type format, enum codec_type type)
- {
- int i;
- for (i = 0; i < ARRAY_SIZE(codec_config); i++) {
- if (format == codec_config[i].format
- && type == codec_config[i].codec_type) {
- return codec_config[i].dsp_effect_lib;
- }
- }
- return NULL;
- }
|