From eba256b154c7fda81c5ec293112858f3a413e3de Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Tue, 17 Jun 2025 19:44:55 +0800 Subject: [PATCH] refactor[base]: Refactor C++ mpp_enc_cfg to C Signed-off-by: Herman Chen Signed-off-by: Chandler Chen Signed-off-by: Hongjin Li Change-Id: Ie60f680329ac6a861c7f7124955a35968fb82823 --- inc/rk_venc_cfg.h | 15 +- kmpp/kmpp.c | 2 +- mpp/base/CMakeLists.txt | 4 +- mpp/base/inc/mpp_enc_cfg_impl.h | 20 +- mpp/base/{mpp_cfg.cpp => mpp_cfg.c} | 15 +- mpp/base/{mpp_enc_cfg.cpp => mpp_enc_cfg.c} | 219 +++++++++----------- mpp/base/test/mpp_enc_cfg_test.c | 21 +- mpp/codec/enc/h264/h264e_api_v2.c | 3 +- mpp/codec/enc/h265/h265e_api.c | 3 +- mpp/codec/enc/jpeg/jpege_api_v2.c | 3 +- mpp/codec/enc/vp8/vp8e_api_v2.c | 3 +- mpp/codec/mpp_enc_impl.cpp | 3 +- mpp/codec/mpp_enc_v2.cpp | 3 +- mpp/inc/mpp_cfg.h | 15 +- mpp/inc/mpp_enc_cfg.h | 16 +- 15 files changed, 127 insertions(+), 218 deletions(-) rename mpp/base/{mpp_cfg.cpp => mpp_cfg.c} (89%) rename mpp/base/{mpp_enc_cfg.cpp => mpp_enc_cfg.c} (83%) diff --git a/inc/rk_venc_cfg.h b/inc/rk_venc_cfg.h index 9f84952a..16c808ea 100644 --- a/inc/rk_venc_cfg.h +++ b/inc/rk_venc_cfg.h @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2015 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2015 Rockchip Electronics Co., Ltd. */ #ifndef __RK_VENC_CFG_H__ diff --git a/kmpp/kmpp.c b/kmpp/kmpp.c index f2362d6c..ceee5110 100644 --- a/kmpp/kmpp.c +++ b/kmpp/kmpp.c @@ -457,7 +457,7 @@ static MPP_RET control(Kmpp *ctx, MpiCmd cmd, MppParam param) switch (cmd) { case MPP_ENC_SET_CFG : case MPP_ENC_GET_CFG : { - size = sizeof(MppEncCfgImpl); + size = sizeof(MppEncCfgSet); } break; case MPP_ENC_SET_HEADER_MODE : case MPP_ENC_SET_SEI_CFG : { diff --git a/mpp/base/CMakeLists.txt b/mpp/base/CMakeLists.txt index b710019e..3dd9a953 100644 --- a/mpp/base/CMakeLists.txt +++ b/mpp/base/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(mpp_base OBJECT mpp_enc_refs.cpp mpp_enc_ref.cpp - mpp_enc_cfg.cpp + mpp_enc_cfg.c mpp_dec_cfg.c mpp_sys_cfg.cpp mpp_sys_cfg_st.cpp @@ -24,7 +24,7 @@ add_library(mpp_base OBJECT mpp_bitread.c mpp_bitput.c mpp_cfg_io.c - mpp_cfg.cpp + mpp_cfg.c mpp_2str.c mpp_dec_hdr_meta.c ) diff --git a/mpp/base/inc/mpp_enc_cfg_impl.h b/mpp/base/inc/mpp_enc_cfg_impl.h index 85307151..616c0bc1 100644 --- a/mpp/base/inc/mpp_enc_cfg_impl.h +++ b/mpp/base/inc/mpp_enc_cfg_impl.h @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2015 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2015 Rockchip Electronics Co., Ltd. */ #ifndef __MPP_ENC_CFG_IMPL_H__ @@ -21,9 +10,4 @@ extern RK_U8 uuid_refresh_cfg[16]; -typedef struct MppEncCfgImpl_t { - RK_S32 size; - MppEncCfgSet cfg; -} MppEncCfgImpl; - #endif /*__MPP_ENC_CFG_IMPL_H__*/ diff --git a/mpp/base/mpp_cfg.cpp b/mpp/base/mpp_cfg.c similarity index 89% rename from mpp/base/mpp_cfg.cpp rename to mpp/base/mpp_cfg.c index a53cc9dc..3f095f51 100644 --- a/mpp/base/mpp_cfg.cpp +++ b/mpp/base/mpp_cfg.c @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2020 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2020 Rockchip Electronics Co., Ltd. */ #define MODULE_TAG "mpp_cfg" diff --git a/mpp/base/mpp_enc_cfg.cpp b/mpp/base/mpp_enc_cfg.c similarity index 83% rename from mpp/base/mpp_enc_cfg.cpp rename to mpp/base/mpp_enc_cfg.c index 91a9c083..4ae4b791 100644 --- a/mpp/base/mpp_enc_cfg.cpp +++ b/mpp/base/mpp_enc_cfg.c @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2015 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2015 Rockchip Electronics Co., Ltd. */ #define MODULE_TAG "mpp_enc_cfg" @@ -25,60 +14,44 @@ #include "mpp_time.h" #include "mpp_debug.h" #include "mpp_common.h" -#include "mpp_thread.h" +#include "mpp_singleton.h" #include "mpp_cfg.h" #include "mpp_trie.h" #include "mpp_enc_cfg_impl.h" -#define MPP_ENC_CFG_DBG_FUNC (0x00000001) -#define MPP_ENC_CFG_DBG_INFO (0x00000002) -#define MPP_ENC_CFG_DBG_SET (0x00000004) -#define MPP_ENC_CFG_DBG_GET (0x00000008) +#define ENC_CFG_DBG_FUNC (0x00000001) +#define ENC_CFG_DBG_INFO (0x00000002) +#define ENC_CFG_DBG_SET (0x00000004) +#define ENC_CFG_DBG_GET (0x00000008) -#define mpp_enc_cfg_dbg(flag, fmt, ...) _mpp_dbg_f(mpp_enc_cfg_debug, flag, fmt, ## __VA_ARGS__) +#define enc_cfg_dbg(flag, fmt, ...) _mpp_dbg_f(mpp_enc_cfg_debug, flag, fmt, ## __VA_ARGS__) -#define mpp_enc_cfg_dbg_func(fmt, ...) mpp_enc_cfg_dbg(MPP_ENC_CFG_DBG_FUNC, fmt, ## __VA_ARGS__) -#define mpp_enc_cfg_dbg_info(fmt, ...) mpp_enc_cfg_dbg(MPP_ENC_CFG_DBG_INFO, fmt, ## __VA_ARGS__) -#define mpp_enc_cfg_dbg_set(fmt, ...) mpp_enc_cfg_dbg(MPP_ENC_CFG_DBG_SET, fmt, ## __VA_ARGS__) -#define mpp_enc_cfg_dbg_get(fmt, ...) mpp_enc_cfg_dbg(MPP_ENC_CFG_DBG_GET, fmt, ## __VA_ARGS__) +#define enc_cfg_dbg_func(fmt, ...) enc_cfg_dbg(ENC_CFG_DBG_FUNC, fmt, ## __VA_ARGS__) +#define enc_cfg_dbg_info(fmt, ...) enc_cfg_dbg(ENC_CFG_DBG_INFO, fmt, ## __VA_ARGS__) +#define enc_cfg_dbg_set(fmt, ...) enc_cfg_dbg(ENC_CFG_DBG_SET, fmt, ## __VA_ARGS__) +#define enc_cfg_dbg_get(fmt, ...) enc_cfg_dbg(ENC_CFG_DBG_GET, fmt, ## __VA_ARGS__) -RK_U32 mpp_enc_cfg_debug = 0; +#define get_srv_enc_cfg_f() \ + ({ \ + MppEncCfgSrv *__tmp; \ + if (srv_enc_cfg) { \ + __tmp = srv_enc_cfg; \ + } else { \ + mpp_enc_cfg_srv_init(); \ + __tmp = srv_enc_cfg; \ + if (!__tmp) \ + mpp_err("mpp enc cfg srv not init at %s\n", __FUNCTION__); \ + } \ + __tmp; \ + }) -class MppEncCfgService -{ -private: - MppEncCfgService(); - ~MppEncCfgService(); - MppEncCfgService(const MppEncCfgService &); - MppEncCfgService &operator=(const MppEncCfgService &); +typedef struct MppEncCfgSrv_t { + MppTrie trie; +} MppEncCfgSrv; - MppCfgInfoHead mHead; - MppMutex mLock; - MppTrie mTrie; - RK_S32 mCfgSize; - -public: - static MppEncCfgService *get() { - static MppEncCfgService instance; - MppEncCfgService *ret; - - mpp_mutex_lock(&instance.mLock); - ret = &instance; - mpp_mutex_unlock(&instance.mLock); - - return ret; - } - - MppTrieInfo *get_info(const char *name); - MppTrieInfo *get_info_first(); - MppTrieInfo *get_info_next(MppTrieInfo *node); - - RK_S32 get_node_count() { return mHead.node_count; }; - RK_S32 get_info_count() { return mHead.info_count; }; - RK_S32 get_info_size() { return mHead.info_size; }; - RK_S32 get_cfg_size() { return mCfgSize; }; -}; +static MppEncCfgSrv *srv_enc_cfg = NULL; +static RK_U32 mpp_enc_cfg_debug = 0; #define EXPAND_AS_TRIE(base, name, cfg_type, flag, field_change, field_data) \ do { \ @@ -89,7 +62,7 @@ public: (RK_U32)((long)&(((MppEncCfgSet *)0)->field_change.field_data)), \ sizeof((((MppEncCfgSet *)0)->field_change.field_data)), \ }; \ - mpp_trie_add_info(mTrie, #base":"#name, &tmp, sizeof(tmp)); \ + mpp_trie_add_info(srv->trie, #base":"#name, &tmp, sizeof(tmp)); \ } while (0); #define ENTRY_TABLE(ENTRY) \ @@ -290,59 +263,61 @@ public: ENTRY(tune, skip32_wgt, S32, MPP_ENC_TUNE_CFG_CHANGE_SKIP32_WGT, tune, skip32_wgt) \ ENTRY(tune, speed, S32, MPP_ENC_TUNE_CFG_CHANGE_SPEED, tune, speed) -MppEncCfgService::MppEncCfgService() : - mTrie(NULL) +static void mpp_enc_cfg_srv_init() { - rk_s32 ret; + MppEncCfgSrv *srv = srv_enc_cfg; - mpp_env_get_u32("mpp_enc_cfg_debug", &mpp_enc_cfg_debug, 0); + mpp_env_get_u32("mpp_enc_cfg_debug", &mpp_enc_cfg_debug, mpp_enc_cfg_debug); - ret = mpp_trie_init(&mTrie, "MppEncCfg"); - if (ret) { - mpp_err_f("failed to init enc cfg set trie ret %d\n", ret); + if (srv) + return ; + + srv = mpp_calloc(MppEncCfgSrv, 1); + if (!srv) { + mpp_err_f("failed to allocate enc cfg set service\n"); return ; } - ENTRY_TABLE(EXPAND_AS_TRIE) + srv_enc_cfg = srv; - mpp_trie_add_info(mTrie, NULL, NULL, 0); + mpp_trie_init(&srv->trie, "MppEncCfg"); + if (srv->trie) { + ENTRY_TABLE(EXPAND_AS_TRIE) - mHead.node_count = mpp_trie_get_node_count(mTrie); - mHead.info_count = mpp_trie_get_info_count(mTrie); - mHead.info_size = mpp_trie_get_buf_size(mTrie); - mpp_mutex_init(&mLock); - - mpp_enc_cfg_dbg_func("node cnt: %d\n", mHead.node_count); -} - -MppEncCfgService::~MppEncCfgService() -{ - if (mTrie) { - mpp_trie_deinit(mTrie); - mTrie = NULL; + mpp_trie_add_info(srv->trie, NULL, NULL, 0); } - mpp_mutex_destroy(&mLock); + + enc_cfg_dbg_func("info cnt %d node cnt %d size %d\n", + mpp_trie_get_info_count(srv->trie), + mpp_trie_get_node_count(srv->trie), + mpp_trie_get_buf_size(srv->trie)); } -MppTrieInfo *MppEncCfgService::get_info(const char *name) +static void mpp_enc_cfg_srv_deinit() { - return mpp_trie_get_info(mTrie, name); + MppEncCfgSrv *srv = srv_enc_cfg; + + if (!srv) + return ; + + if (srv->trie) { + mpp_trie_deinit(srv->trie); + srv->trie = NULL; + } + + MPP_FREE(srv_enc_cfg); } -MppTrieInfo *MppEncCfgService::get_info_first() +MPP_SINGLETON(MPP_SGLN_ENC_CFG, mpp_enc_cfg, mpp_enc_cfg_srv_init, mpp_enc_cfg_srv_deinit) + +static MppTrieInfo *service_get_info(const char *name) { - if (NULL == mTrie) + MppEncCfgSrv *srv = get_srv_enc_cfg_f(); + + if (!srv) return NULL; - return mpp_trie_get_info_first(mTrie); -} - -MppTrieInfo *MppEncCfgService::get_info_next(MppTrieInfo *node) -{ - if (NULL == mTrie) - return NULL; - - return mpp_trie_get_info_next(mTrie, node); + return mpp_trie_get_info(srv->trie, name); } static void mpp_enc_cfg_set_default(MppEncCfgSet *cfg) @@ -368,24 +343,25 @@ static void mpp_enc_cfg_set_default(MppEncCfgSet *cfg) MPP_RET mpp_enc_cfg_init(MppEncCfg *cfg) { - MppEncCfgImpl *p = NULL; + MppEncCfgSet *p = NULL; - if (NULL == cfg) { + if (!cfg) { mpp_err_f("invalid NULL input config\n"); return MPP_ERR_NULL_PTR; } mpp_env_get_u32("mpp_enc_cfg_debug", &mpp_enc_cfg_debug, 0); - p = mpp_calloc(MppEncCfgImpl, 1); - if (NULL == p) { + p = mpp_calloc(MppEncCfgSet, 1); + if (!p) { mpp_err_f("create encoder config failed %p\n", p); *cfg = NULL; return MPP_ERR_NOMEM; } - p->size = sizeof(p->cfg); - mpp_enc_cfg_set_default(&p->cfg); + /* NOTE: compatible to old struct size */ + p->size = sizeof(*p) - sizeof(p->size); + mpp_enc_cfg_set_default(p); *cfg = p; @@ -394,7 +370,7 @@ MPP_RET mpp_enc_cfg_init(MppEncCfg *cfg) MPP_RET mpp_enc_cfg_deinit(MppEncCfg cfg) { - if (NULL == cfg) { + if (!cfg) { mpp_err_f("invalid NULL input config\n"); return MPP_ERR_NULL_PTR; } @@ -407,18 +383,20 @@ MPP_RET mpp_enc_cfg_deinit(MppEncCfg cfg) #define ENC_CFG_SET_ACCESS(func_name, in_type, cfg_type) \ MPP_RET func_name(MppEncCfg cfg, const char *name, in_type val) \ { \ - if (NULL == cfg || NULL == name) { \ + MppEncCfgSet *p = (MppEncCfgSet *)cfg; \ + MppTrieInfo *node; \ + MppCfgInfo *info; \ + if (!p || !name) { \ mpp_err_f("invalid input cfg %p name %p\n", cfg, name); \ return MPP_ERR_NULL_PTR; \ } \ - MppEncCfgImpl *p = (MppEncCfgImpl *)cfg; \ - MppTrieInfo *node = MppEncCfgService::get()->get_info(name); \ - MppCfgInfo *info = (MppCfgInfo *)mpp_trie_info_ctx(node); \ + node = service_get_info(name); \ + info = (MppCfgInfo *)mpp_trie_info_ctx(node); \ if (CHECK_CFG_INFO(info, name, CFG_FUNC_TYPE_##cfg_type)) { \ return MPP_NOK; \ } \ - mpp_enc_cfg_dbg_set("name %s type %s\n", mpp_trie_info_name(node), strof_cfg_type(info->data_type)); \ - MPP_RET ret = MPP_CFG_SET_##cfg_type(info, &p->cfg, val); \ + enc_cfg_dbg_set("name %s type %s\n", mpp_trie_info_name(node), strof_cfg_type(info->data_type)); \ + MPP_RET ret = MPP_CFG_SET_##cfg_type(info, p, val); \ return ret; \ } @@ -432,18 +410,20 @@ ENC_CFG_SET_ACCESS(mpp_enc_cfg_set_st, void *, St); #define ENC_CFG_GET_ACCESS(func_name, in_type, cfg_type) \ MPP_RET func_name(MppEncCfg cfg, const char *name, in_type *val) \ { \ - if (NULL == cfg || NULL == name) { \ + MppEncCfgSet *p = (MppEncCfgSet *)cfg; \ + MppTrieInfo *node; \ + MppCfgInfo *info; \ + if (!p || !name) { \ mpp_err_f("invalid input cfg %p name %p\n", cfg, name); \ return MPP_ERR_NULL_PTR; \ } \ - MppEncCfgImpl *p = (MppEncCfgImpl *)cfg; \ - MppTrieInfo *node = MppEncCfgService::get()->get_info(name); \ - MppCfgInfo *info = (MppCfgInfo *)mpp_trie_info_ctx(node); \ + node = service_get_info(name); \ + info = (MppCfgInfo *)mpp_trie_info_ctx(node); \ if (CHECK_CFG_INFO(info, name, CFG_FUNC_TYPE_##cfg_type)) { \ return MPP_NOK; \ } \ - mpp_enc_cfg_dbg_set("name %s type %s\n", mpp_trie_info_name(node), strof_cfg_type(info->data_type)); \ - MPP_RET ret = MPP_CFG_GET_##cfg_type(info, &p->cfg, val); \ + enc_cfg_dbg_set("name %s type %s\n", mpp_trie_info_name(node), strof_cfg_type(info->data_type)); \ + MPP_RET ret = MPP_CFG_GET_##cfg_type(info, p, val); \ return ret; \ } @@ -456,11 +436,15 @@ ENC_CFG_GET_ACCESS(mpp_enc_cfg_get_st, void , St); void mpp_enc_cfg_show(void) { - MppEncCfgService *srv = MppEncCfgService::get(); - MppTrieInfo *root = srv->get_info_first(); + MppEncCfgSrv *srv = get_srv_enc_cfg_f(); + MppTrieInfo *root; + + if (!srv) + return; mpp_log("dumping valid configure string start\n"); + root = mpp_trie_get_info_first(srv->trie); if (root) { MppTrieInfo *node = root; @@ -476,10 +460,11 @@ void mpp_enc_cfg_show(void) } else { mpp_log("%-25s size - %d\n", mpp_trie_info_name(node), node->ctx_len); } - } while ((node = srv->get_info_next(node))); + } while ((node = mpp_trie_get_info_next(srv->trie, node))); } mpp_log("dumping valid configure string done\n"); mpp_log("total cfg count %d with %d node size %d\n", - srv->get_info_count(), srv->get_node_count(), srv->get_info_size()); + mpp_trie_get_info_count(srv->trie), mpp_trie_get_node_count(srv->trie), + mpp_trie_get_buf_size(srv->trie)); } diff --git a/mpp/base/test/mpp_enc_cfg_test.c b/mpp/base/test/mpp_enc_cfg_test.c index aac3ef54..a595231c 100644 --- a/mpp/base/test/mpp_enc_cfg_test.c +++ b/mpp/base/test/mpp_enc_cfg_test.c @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2015 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2015 Rockchip Electronics Co., Ltd. */ #define MODULE_TAG "mpp_enc_cfg_test" @@ -57,10 +46,10 @@ int main() -1, -1, -1, -1, }; - MppEncCfgImpl *impl = (MppEncCfgImpl *)cfg; + MppEncCfgSet *impl = (MppEncCfgSet *)cfg; mpp_log("before set: rc mode %d bps_target %d\n", - impl->cfg.rc.rc_mode, impl->cfg.rc.bps_target); + impl->rc.rc_mode, impl->rc.bps_target); start = mpp_time(); ret = mpp_enc_cfg_set_u32(cfg, "rc:mode", rc_mode); @@ -71,7 +60,7 @@ int main() mpp_log("set s32 time %lld us\n", end - start); mpp_log("after set: rc mode %d bps_target %d\n", - impl->cfg.rc.rc_mode, impl->cfg.rc.bps_target); + impl->rc.rc_mode, impl->rc.bps_target); rc_mode = 0; bps_target = 0; diff --git a/mpp/codec/enc/h264/h264e_api_v2.c b/mpp/codec/enc/h264/h264e_api_v2.c index 692bee79..44371dcc 100644 --- a/mpp/codec/enc/h264/h264e_api_v2.c +++ b/mpp/codec/enc/h264/h264e_api_v2.c @@ -607,8 +607,7 @@ static MPP_RET h264e_proc_cfg(void *ctx, MpiCmd cmd, void *param) switch (cmd) { case MPP_ENC_SET_CFG : { - MppEncCfgImpl *impl = (MppEncCfgImpl *)param; - MppEncCfgSet *src = &impl->cfg; + MppEncCfgSet *src = (MppEncCfgSet *)param; if (src->prep.change) ret |= h264e_proc_prep_cfg(&cfg->prep, &src->prep); diff --git a/mpp/codec/enc/h265/h265e_api.c b/mpp/codec/enc/h265/h265e_api.c index 259391ce..f3ecdd48 100644 --- a/mpp/codec/enc/h265/h265e_api.c +++ b/mpp/codec/enc/h265/h265e_api.c @@ -693,8 +693,7 @@ static MPP_RET h265e_proc_cfg(void *ctx, MpiCmd cmd, void *param) switch (cmd) { case MPP_ENC_SET_CFG : { - MppEncCfgImpl *impl = (MppEncCfgImpl *)param; - MppEncCfgSet *src = &impl->cfg; + MppEncCfgSet *src = (MppEncCfgSet *)param; if (src->prep.change) { ret |= h265e_proc_prep_cfg(&cfg->prep, &src->prep); diff --git a/mpp/codec/enc/jpeg/jpege_api_v2.c b/mpp/codec/enc/jpeg/jpege_api_v2.c index a69acd52..b216178c 100644 --- a/mpp/codec/enc/jpeg/jpege_api_v2.c +++ b/mpp/codec/enc/jpeg/jpege_api_v2.c @@ -383,8 +383,7 @@ static MPP_RET jpege_proc_cfg(void *ctx, MpiCmd cmd, void *param) switch (cmd) { case MPP_ENC_SET_CFG : { - MppEncCfgImpl *impl = (MppEncCfgImpl *)param; - MppEncCfgSet *src = &impl->cfg; + MppEncCfgSet *src = (MppEncCfgSet *)param; if (src->prep.change) { ret |= jpege_proc_prep_cfg(&cfg->prep, &src->prep); diff --git a/mpp/codec/enc/vp8/vp8e_api_v2.c b/mpp/codec/enc/vp8/vp8e_api_v2.c index 0677ce02..ab730438 100644 --- a/mpp/codec/enc/vp8/vp8e_api_v2.c +++ b/mpp/codec/enc/vp8/vp8e_api_v2.c @@ -294,8 +294,7 @@ static MPP_RET vp8e_proc_cfg(void *ctx, MpiCmd cmd, void *param) MPP_RET ret = MPP_OK; Vp8eCtx *p = (Vp8eCtx *)ctx; MppEncCfgSet *cfg = p->cfg; - MppEncCfgImpl *impl = (MppEncCfgImpl *)param; - MppEncCfgSet *src = &impl->cfg; + MppEncCfgSet *src = (MppEncCfgSet *)param; vp8e_dbg_fun("enter ctx %p cmd %x param %p\n", ctx, cmd, param); switch (cmd) { diff --git a/mpp/codec/mpp_enc_impl.cpp b/mpp/codec/mpp_enc_impl.cpp index f8d79310..552081af 100644 --- a/mpp/codec/mpp_enc_impl.cpp +++ b/mpp/codec/mpp_enc_impl.cpp @@ -1018,8 +1018,7 @@ MPP_RET mpp_enc_proc_cfg(MppEncImpl *enc, MpiCmd cmd, void *param) switch (cmd) { case MPP_ENC_SET_CFG : { - MppEncCfgImpl *impl = (MppEncCfgImpl *)param; - MppEncCfgSet *src = &impl->cfg; + MppEncCfgSet *src = (MppEncCfgSet *)param; RK_U32 change = src->base.change; MPP_RET ret_tmp = MPP_OK; diff --git a/mpp/codec/mpp_enc_v2.cpp b/mpp/codec/mpp_enc_v2.cpp index 14f3deea..b33f0af1 100644 --- a/mpp/codec/mpp_enc_v2.cpp +++ b/mpp/codec/mpp_enc_v2.cpp @@ -345,8 +345,7 @@ MPP_RET mpp_enc_control_v2(MppEnc ctx, MpiCmd cmd, void *param) switch (cmd) { case MPP_ENC_GET_CFG : { - MppEncCfgImpl *p = (MppEncCfgImpl *)param; - MppEncCfgSet *cfg = &p->cfg; + MppEncCfgSet *cfg = (MppEncCfgSet *)param; enc_dbg_ctrl("get all config\n"); memcpy(cfg, &enc->cfg, sizeof(enc->cfg)); diff --git a/mpp/inc/mpp_cfg.h b/mpp/inc/mpp_cfg.h index b3d6eb0c..b5efa802 100644 --- a/mpp/inc/mpp_cfg.h +++ b/mpp/inc/mpp_cfg.h @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2020 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2020 Rockchip Electronics Co., Ltd. */ #ifndef __MPP_CFG_H__ diff --git a/mpp/inc/mpp_enc_cfg.h b/mpp/inc/mpp_enc_cfg.h index 4c829edf..75d935ad 100644 --- a/mpp/inc/mpp_enc_cfg.h +++ b/mpp/inc/mpp_enc_cfg.h @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2015 Rockchip Electronics Co. LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2015 Rockchip Electronics Co., Ltd. */ #ifndef __MPP_ENC_CFG_H__ @@ -29,6 +18,7 @@ * For normal user rc and prep config are enough. */ typedef struct MppEncCfgSet_t { + RK_S32 size; MppEncBaseCfg base; // esential config