diff --git a/inc/rk_mpi.h b/inc/rk_mpi.h index ac4f6959..8439db76 100644 --- a/inc/rk_mpi.h +++ b/inc/rk_mpi.h @@ -53,6 +53,7 @@ typedef enum { MPP_VIDEO_CodingDIVX3, /**< DIVX3 */ MPP_VIDEO_CodingVP6, MPP_VIDEO_CodingHEVC, /**< H.265/HEVC */ + MPP_VIDEO_CodingAVS, /**< AVS+ */ MPP_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ MPP_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ MPP_VIDEO_CodingMax = 0x7FFFFFFF diff --git a/inc/vpu_api.h b/inc/vpu_api.h index 6871b0a8..0b8e7d27 100644 --- a/inc/vpu_api.h +++ b/inc/vpu_api.h @@ -184,6 +184,7 @@ typedef enum OMX_RK_VIDEO_CODINGTYPE { OMX_RK_VIDEO_CodingDIVX3, /**< DIVX3 */ OMX_RK_VIDEO_CodingVP6, OMX_RK_VIDEO_CodingHEVC, /**< H.265/HEVC */ + OMX_RK_VIDEO_CodingAVS, /**< AVS+ */ OMX_RK_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_RK_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_RK_VIDEO_CodingMax = 0x7FFFFFFF diff --git a/mpp/codec/CMakeLists.txt b/mpp/codec/CMakeLists.txt index 639fe7ba..37943dcd 100644 --- a/mpp/codec/CMakeLists.txt +++ b/mpp/codec/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(mpp_codec codec_h264d codec_vp9d codec_h265d + codec_avsd codec_dummy_enc codec_dummy_dec mpp) diff --git a/mpp/codec/dec/CMakeLists.txt b/mpp/codec/dec/CMakeLists.txt index fbee3459..4efa884e 100644 --- a/mpp/codec/dec/CMakeLists.txt +++ b/mpp/codec/dec/CMakeLists.txt @@ -7,3 +7,12 @@ add_subdirectory(h264) add_subdirectory(h265) add_subdirectory(vp9) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/avs_impl/") +add_subdirectory(avs_impl) +endif() + +add_subdirectory(avs) + + + diff --git a/mpp/codec/dec/avs/CMakeLists.txt b/mpp/codec/dec/avs/CMakeLists.txt new file mode 100644 index 00000000..71fd5787 --- /dev/null +++ b/mpp/codec/dec/avs/CMakeLists.txt @@ -0,0 +1,35 @@ +# vim: syntax=cmake +include_directories(.) + +# avs decoder api +set(AVSD_API + + ) +set(AVSD_COMMON + + ) + +# avs decoder header +set(AVSD_HDR + + ) + +# avs decoder sourse +set(AVSD_SRC + avsd_api.c + ) + +add_library(codec_avsd STATIC + ${AVSD_API} + ${AVSD_COMMON} + ${AVSD_HDR} + ${AVSD_SRC} + ) +if(EXISTS codec_avsd_impl) + target_link_libraries(codec_avsd codec_avsd codec_avsd_impl) +else() + target_link_libraries(codec_avsd mpp) +endif() + +set_target_properties(codec_avsd PROPERTIES FOLDER "mpp/codec") + diff --git a/mpp/codec/dec/avs/avsd_api.c b/mpp/codec/dec/avs/avsd_api.c new file mode 100644 index 00000000..f9d374d2 --- /dev/null +++ b/mpp/codec/dec/avs/avsd_api.c @@ -0,0 +1,197 @@ +/* +* +* 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. +*/ + +#define MODULE_TAG "avsd_api" + +#include +#include +#include + +#include "mpp_packet.h" +#include "mpp_packet_impl.h" +#include "mpp_mem.h" +#include "mpp_log.h" +#include "mpp_env.h" + +#include "avsd_api.h" + + +RK_U32 avsd_parse_debug = 0; + +/*! +*********************************************************************** +* \brief +* alloc all buffer +*********************************************************************** +*/ + +MPP_RET avsd_init(void *ctx, ParserCfg *init) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + mpp_env_get_u32("avsd_debug", &avsd_parse_debug, 0); + + AVSD_PARSE_TRACE("In."); + + (void)ctx; + (void)init; + return ret = MPP_OK; +} + +/*! +*********************************************************************** +* \brief +* free all buffer +*********************************************************************** +*/ +MPP_RET avsd_deinit(void *ctx) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + + (void)ctx; + return ret = MPP_OK; +} + +/*! +*********************************************************************** +* \brief +* reset +*********************************************************************** +*/ +MPP_RET avsd_reset(void *ctx) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + + (void)ctx; + return ret = MPP_OK; +} + +/*! +*********************************************************************** +* \brief +* flush +*********************************************************************** +*/ +MPP_RET avsd_flush(void *ctx) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + + (void)ctx; + return ret = MPP_OK; +} + +/*! +*********************************************************************** +* \brief +* control/perform +*********************************************************************** +*/ +MPP_RET avsd_control(void *ctx, RK_S32 cmd_type, void *param) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + + (void)ctx; + (void)cmd_type; + (void)param; + + return ret = MPP_OK; +} + + +/*! +*********************************************************************** +* \brief +* prepare +*********************************************************************** +*/ +MPP_RET avsd_prepare(void *ctx, MppPacket pkt, HalDecTask *task) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + (void)ctx; + (void)pkt; + (void)task; + return ret = MPP_OK; +} + + +/*! +*********************************************************************** +* \brief +* parser +*********************************************************************** +*/ +MPP_RET avsd_parse(void *ctx, HalDecTask *in_task) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + + (void)ctx; + (void)in_task; + + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* callback +*********************************************************************** +*/ +MPP_RET avsd_callback(void *decoder, void *info) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_PARSE_TRACE("In."); + + (void)decoder; + (void)info; + + return ret = MPP_OK; +} + +/*! +*********************************************************************** +* \brief +* api struct interface +*********************************************************************** +*/ + +const ParserApi api_avsd_parser = { + "avsd_parse", + MPP_VIDEO_CodingAVS, + 200,//sizeof(AvsCodecContext), + 0, + avsd_init, + avsd_deinit, + avsd_prepare, + avsd_parse, + avsd_reset, + avsd_flush, + avsd_control, + avsd_callback, +}; + diff --git a/mpp/codec/dec/h264/CMakeLists.txt b/mpp/codec/dec/h264/CMakeLists.txt index b8e30eb3..e62efc5a 100644 --- a/mpp/codec/dec/h264/CMakeLists.txt +++ b/mpp/codec/dec/h264/CMakeLists.txt @@ -22,7 +22,7 @@ set(H264D_HDR h264d_dpb.h h264d_init.h h264d_fill.h - + h264d_rwfile.h ) @@ -39,7 +39,7 @@ set(H264D_SRC h264d_dpb.c h264d_init.c h264d_fill.c - + h264d_rwfile.c ) diff --git a/mpp/test/h264d_rwfile.c b/mpp/codec/dec/h264/h264d_rwfile.c similarity index 100% rename from mpp/test/h264d_rwfile.c rename to mpp/codec/dec/h264/h264d_rwfile.c diff --git a/mpp/test/h264d_rwfile.h b/mpp/codec/dec/h264/h264d_rwfile.h similarity index 100% rename from mpp/test/h264d_rwfile.h rename to mpp/codec/dec/h264/h264d_rwfile.h diff --git a/mpp/codec/inc/avsd_api.h b/mpp/codec/inc/avsd_api.h new file mode 100644 index 00000000..570b9270 --- /dev/null +++ b/mpp/codec/inc/avsd_api.h @@ -0,0 +1,56 @@ +/* + * Copyright 2010 Rockchip Electronics S.LSI 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. + */ + +#ifndef __AVSD_API_H__ +#define __AVSD_API_H__ + +#include "parser_api.h" + + +#define AVSD_DBG_TRACE (0x00000001) + + +extern RK_U32 avsd_parse_debug; + +#define AVSD_PARSE_TRACE(fmt, ...)\ +do {\ + if (AVSD_DBG_TRACE & avsd_parse_debug)\ + { mpp_log_f(fmt, ## __VA_ARGS__); }\ +} while (0) + + + + +#ifdef __cplusplus +extern "C" { +#endif + +extern const ParserApi api_avsd_parser; + +MPP_RET avsd_init (void *decoder, ParserCfg *cfg); +MPP_RET avsd_deinit (void *decoder); +MPP_RET avsd_reset (void *decoder); +MPP_RET avsd_flush (void *decoder); +MPP_RET avsd_control(void *decoder, RK_S32 cmd_type, void *param); +MPP_RET avsd_prepare(void *decoder, MppPacket pkt, HalDecTask *task); +MPP_RET avsd_parse (void *decoder, HalDecTask *task); +MPP_RET avsd_callback(void *decoder, void *err_info); + +#ifdef __cplusplus +} +#endif + +#endif /*__AVSD_API_H__*/ diff --git a/mpp/codec/mpp_parser.cpp b/mpp/codec/mpp_parser.cpp index aca3006a..38410c31 100644 --- a/mpp/codec/mpp_parser.cpp +++ b/mpp/codec/mpp_parser.cpp @@ -27,6 +27,8 @@ #include "h264d_api.h" #include "h265d_api.h" #include "vp9d_api.h" +#include "avsd_api.h" + // for test and demo #include "dummy_dec_api.h" @@ -37,6 +39,7 @@ static const ParserApi *parsers[] = { &api_h264d_parser, &api_vp9d_parser, &api_h265d_parser, + &api_avsd_parser, &dummy_dec_parser, }; diff --git a/mpp/hal/CMakeLists.txt b/mpp/hal/CMakeLists.txt index 9380de03..480b08dd 100644 --- a/mpp/hal/CMakeLists.txt +++ b/mpp/hal/CMakeLists.txt @@ -20,10 +20,12 @@ add_subdirectory(rkdec/h265d) add_subdirectory(rkdec/vp9d) +add_subdirectory(rkdec/avsd) + # ---------------------------------------------------------------------------- # add hardware worker implement # ---------------------------------------------------------------------------- add_subdirectory(worker/libvpu) add_subdirectory(worker/libv4l2) -target_link_libraries(mpp_hal hal_h264d hal_vp9d hal_h265d hal_dummy) \ No newline at end of file +target_link_libraries(mpp_hal hal_h264d hal_vp9d hal_h265d hal_avsd hal_dummy) \ No newline at end of file diff --git a/mpp/hal/inc/hal_avsd_api.h b/mpp/hal/inc/hal_avsd_api.h new file mode 100644 index 00000000..dc39fa76 --- /dev/null +++ b/mpp/hal/inc/hal_avsd_api.h @@ -0,0 +1,60 @@ +/* +* +* 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. +*/ + + +#ifndef __HAL_AVSD_API_H__ +#define __HAL_AVSD_API_H__ + +#include "rk_type.h" +#include "mpp_err.h" +#include "mpp_hal.h" + + + +#define AVSD_HAL_DBG_TRACE (0x00000001) + + + +extern RK_U32 avsd_hal_debug; + +#define AVSD_HAL_TRACE(fmt, ...)\ +do {\ + if (AVSD_HAL_DBG_TRACE & avsd_hal_debug)\ + { mpp_log_f(fmt, ## __VA_ARGS__); }\ +} while (0) + + +#ifdef __cplusplus +extern "C" { +#endif + +extern const MppHalApi hal_api_avsd; + +MPP_RET hal_avsd_init (void *hal, MppHalCfg *cfg); +MPP_RET hal_avsd_deinit (void *hal); +MPP_RET hal_avsd_gen_regs(void *hal, HalTaskInfo *task); +MPP_RET hal_avsd_start (void *hal, HalTaskInfo *task); +MPP_RET hal_avsd_wait (void *hal, HalTaskInfo *task); +MPP_RET hal_avsd_reset (void *hal); +MPP_RET hal_avsd_flush (void *hal); +MPP_RET hal_avsd_control (void *hal, RK_S32 cmd_type, void *param); + +#ifdef __cplusplus +} +#endif + +#endif /*__HAL_AVSD_API_H__*/ diff --git a/mpp/hal/mpp_hal.cpp b/mpp/hal/mpp_hal.cpp index 360673a7..dbded338 100644 --- a/mpp/hal/mpp_hal.cpp +++ b/mpp/hal/mpp_hal.cpp @@ -28,6 +28,8 @@ #include "hal_h264d_api.h" #include "hal_h265d_api.h" #include "hal_vp9d_api.h" +#include "hal_avsd_api.h" + // for test and demo #include "hal_dummy_dec_api.h" #include "hal_dummy_enc_api.h" @@ -39,6 +41,7 @@ static const MppHalApi *hw_apis[] = { &hal_api_h264d, &hal_api_h265d, &hal_api_vp9d, + &hal_api_avsd, &hal_api_dummy_dec, &hal_api_dummy_enc, }; diff --git a/mpp/hal/rkdec/avsd/CMakeLists.txt b/mpp/hal/rkdec/avsd/CMakeLists.txt new file mode 100644 index 00000000..b70c3a52 --- /dev/null +++ b/mpp/hal/rkdec/avsd/CMakeLists.txt @@ -0,0 +1,31 @@ +# vim: syntax=cmake + +# hal avs decoder api +set(HAL_AVSD_API + + ) + + +# hal avs header +set(HAL_AVSD_HDR + + ) + +# hal avs decoder sourse +set(HAL_AVSD_SRC + + hal_avsd_api.c + + ) + +add_library(hal_avsd STATIC + ${HAL_AVSD_API} + ${HAL_AVSD_HDR} + ${HAL_AVSD_SRC} + ) +target_link_libraries(hal_avsd + mpp + ) + +set_target_properties(hal_avsd PROPERTIES FOLDER "mpp/hal") + diff --git a/mpp/hal/rkdec/avsd/hal_avsd_api.c b/mpp/hal/rkdec/avsd/hal_avsd_api.c new file mode 100644 index 00000000..9385b9bc --- /dev/null +++ b/mpp/hal/rkdec/avsd/hal_avsd_api.c @@ -0,0 +1,191 @@ +/* +* +* 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. +*/ + + +#define MODULE_TAG "hal_avsd_api" + +#include +#include +#include + +#include "rk_type.h" +#include "vpu.h" +#include "mpp_log.h" +#include "mpp_err.h" +#include "mpp_mem.h" +#include "mpp_env.h" + +#include "hal_avsd_api.h" + + +RK_U32 avsd_hal_debug = 0; + + +/*! +*********************************************************************** +* \brief +* init +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_init(void *hal, MppHalCfg *cfg) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + mpp_env_get_u32("avsd_debug", &avsd_hal_debug, 0); + + AVSD_HAL_TRACE("In."); + + (void)hal; + (void)cfg; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* deinit +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_deinit(void *hal) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + + (void)hal; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* generate register +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_gen_regs(void *hal, HalTaskInfo *task) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + (void)hal; + (void)task; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief h +* start hard +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_start(void *hal, HalTaskInfo *task) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + + (void)hal; + (void)task; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* wait hard +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_wait(void *hal, HalTaskInfo *task) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + + (void)hal; + (void)task; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* reset +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_reset(void *hal) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + + (void)hal; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* flush +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_flush(void *hal) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + + (void)hal; + return ret = MPP_OK; +} +/*! +*********************************************************************** +* \brief +* control +*********************************************************************** +*/ +//extern "C" +MPP_RET hal_avsd_control(void *hal, RK_S32 cmd_type, void *param) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + + AVSD_HAL_TRACE("In."); + + (void)hal; + (void)cmd_type; + (void)param; + + return ret = MPP_OK; +} + + +const MppHalApi hal_api_avsd = { + "avsd_rkdec", + MPP_CTX_DEC, + MPP_VIDEO_CodingAVS, + 200,//sizeof(AvsdHalCtx_t), + 0, + hal_avsd_init, + hal_avsd_deinit, + hal_avsd_gen_regs, + hal_avsd_start, + hal_avsd_wait, + hal_avsd_reset, + hal_avsd_flush, + hal_avsd_control, +}; + diff --git a/mpp/legacy/vpu_api.cpp b/mpp/legacy/vpu_api.cpp index f334a755..77675756 100644 --- a/mpp/legacy/vpu_api.cpp +++ b/mpp/legacy/vpu_api.cpp @@ -269,6 +269,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx) mpp_log("s->videoCoding=%d, s->width=%d, s->height=%d \n", s->videoCoding, s->width, s->height); if (s->videoCoding == OMX_RK_VIDEO_CodingHEVC || s->videoCoding == OMX_RK_VIDEO_CodingVP9 + || s->videoCoding == OMX_RK_VIDEO_CodingAVS || (s->videoCoding == OMX_RK_VIDEO_CodingAVC && s->codecType == CODEC_DECODER && ((s->width > 1920) || (s->height > 1088) || use_mpp_mode))) { free(s); diff --git a/mpp/test/CMakeLists.txt b/mpp/test/CMakeLists.txt index 70437e33..63368fdd 100644 --- a/mpp/test/CMakeLists.txt +++ b/mpp/test/CMakeLists.txt @@ -16,6 +16,7 @@ macro(add_mpp_test module) target_link_libraries(${test_name} mpp_shared) set_target_properties(${test_name} PROPERTIES FOLDER "mpp/test") install(TARGETS ${test_name} RUNTIME DESTINATION ${TEST_INSTALL_DIR}) + #add_test(NAME ${test_name} COMMAND ${test_name}) endif() endmacro() @@ -23,21 +24,13 @@ endmacro() add_mpp_test(mpp_info) # h264 decoder test -option(H264D_TEST "Build mpp h264 decoder unit test" ON) -if(H264D_TEST) - set(test_name h264d_test) - add_executable(${test_name} ${test_name}.c h264d_rwfile.h h264d_rwfile.c) - target_link_libraries(${test_name} mpp_shared) - set_target_properties(${test_name} PROPERTIES FOLDER "mpp/test") - install(TARGETS ${test_name} RUNTIME DESTINATION ${TEST_INSTALL_DIR}) -endif() +include_directories(../codec/dec/h264) +add_mpp_test(h264d) # vp9 decoder test -option(VP9D_TEST "Build mpp vp9 decoder unit test" ON) -if(VP9D_TEST) - set(test_name vp9d_test) - add_executable(${test_name} ${test_name}.c) - target_link_libraries(${test_name} mpp_shared) - set_target_properties(${test_name} PROPERTIES FOLDER "mpp/test") - install(TARGETS ${test_name} RUNTIME DESTINATION ${TEST_INSTALL_DIR}) -endif() +include_directories(../codec/dec/vp9) +add_mpp_test(vp9d) + +# avs decoder test +include_directories(../codec/dec/avs) +add_mpp_test(avsd) diff --git a/mpp/test/avsd_test.c b/mpp/test/avsd_test.c new file mode 100644 index 00000000..a40c9a9c --- /dev/null +++ b/mpp/test/avsd_test.c @@ -0,0 +1,148 @@ +/* +* Copyright 2010 Rockchip Electronics S.LSI 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. +*/ + +#define MODULE_TAG "avsd_test" + + +#if defined(_WIN32) +#include "vld.h" +#endif +#include +#include "mpp_log.h" +#include "mpp_env.h" +#include "mpp_dec.h" +#include "mpp_hal.h" +#include "mpp_mem.h" +#include "mpp_packet.h" +#include "mpp_packet_impl.h" +#include "mpp_hal.h" + +#include "avsd_api.h" +#include "hal_avsd_api.h" + +#if 1 + +//!< memory malloc check +#define MEM_CHECK(ret, val, ...)\ +do{\ +if (!(val)) { \ + ret = MPP_ERR_MALLOC; \ + mpp_log("Function:%s:%d, ERROR: malloc buffer.\n", __FUNCTION__, __LINE__); \ + mpp_assert(0); goto __FAILED; \ +}} while (0) +//!< function return check +#define FUN_CHECK(val)\ +do{\ +if ((val) < 0) { \ + goto __FAILED; \ +}} while (0) + + +static MPP_RET avs_decoder_deinit(MppDec *pApi) +{ + if (pApi->frame_slots) { + mpp_buf_slot_deinit(pApi->frame_slots); + pApi->frame_slots = NULL; + } + if (pApi->parser) { + parser_deinit(pApi->parser); + pApi->parser = NULL; + } + if (pApi->hal) { + mpp_hal_deinit(pApi->hal); + pApi->hal = NULL; + } + + return MPP_OK; +} + +static MPP_RET avs_decoder_init(MppDec *pApi) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + ParserCfg parser_cfg; + MppHalCfg hal_cfg; + + pApi->coding = MPP_VIDEO_CodingAVS; + // malloc slot + FUN_CHECK(ret = mpp_buf_slot_init(&pApi->frame_slots)); + MEM_CHECK(ret, pApi->frame_slots); + // init parser part + memset(&parser_cfg, 0, sizeof(parser_cfg)); + parser_cfg.coding = pApi->coding; + parser_cfg.frame_slots = pApi->frame_slots; + parser_cfg.packet_slots = pApi->packet_slots; + FUN_CHECK(ret = parser_init(&pApi->parser, &parser_cfg)); + + // init hal part + memset(&hal_cfg, 0, sizeof(hal_cfg)); + hal_cfg.type = MPP_CTX_DEC; + hal_cfg.coding = pApi->coding; + hal_cfg.work_mode = HAL_MODE_LIBVPU; + hal_cfg.device_id = HAL_RKVDEC; + hal_cfg.frame_slots = pApi->frame_slots; + hal_cfg.packet_slots = pApi->packet_slots; + hal_cfg.task_count = parser_cfg.task_count; + FUN_CHECK(ret = mpp_hal_init(&pApi->hal, &hal_cfg)); + pApi->tasks = hal_cfg.tasks; + + return MPP_OK; +__FAILED: + avs_decoder_deinit(pApi); + + return ret; +} + + + +int main(int argc, char **argv) +{ + MPP_RET ret = MPP_ERR_UNKNOW; + MppPacket pkt = NULL; + MppDec *pApi = mpp_calloc(MppDec, 1); + HalTaskInfo *task = mpp_calloc_size(HalTaskInfo, sizeof(HalTaskInfo)); + mpp_log("+++++++ all test begin +++++++ \n"); + //!< init decoder + FUN_CHECK(ret = avs_decoder_init(pApi)); + //!< initial packet + mpp_packet_init(&pkt, NULL, 0); + //!< initial task + memset(task, 0, sizeof(HalTaskInfo)); + memset(task->dec.refer, -1, sizeof(task->dec.refer)); + //!< prepare + FUN_CHECK(ret = parser_prepare(pApi->parser, pkt, &task->dec)); + //!< free packet + mpp_packet_deinit(&pkt); + //!< parse + FUN_CHECK(ret = parser_parse(pApi->parser, &task->dec)); + //!< hal module + FUN_CHECK(ret = mpp_hal_reg_gen(pApi->hal, task)); + FUN_CHECK(ret = mpp_hal_hw_start(pApi->hal, task)); + FUN_CHECK(ret = mpp_hal_hw_wait(pApi->hal, task)); + + (void)argv; + (void)argc; + + mpp_log("+++++++ all test end +++++++ \n"); + ret = MPP_OK; +__FAILED: + avs_decoder_deinit(pApi); + MPP_FREE(pApi); + MPP_FREE(task); + + return ret; +} + +#endif \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9443b016..ddb592ae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,8 +21,8 @@ macro(add_mpp_test module) target_link_libraries(${test_name} mpp mpp_legacy utils) endif() set_target_properties(${test_name} PROPERTIES FOLDER "test") - install(TARGETS ${test_name} RUNTIME DESTINATION ${TEST_INSTALL_DIR}) - add_test(NAME ${test_name} COMMAND ${test_name}) + #install(TARGETS ${test_name} RUNTIME DESTINATION ${TEST_INSTALL_DIR}) + #add_test(NAME ${test_name} COMMAND ${test_name}) endif() endmacro() diff --git a/test/mpp_packet_test.c b/test/mpp_packet_test.c index 0ac6002b..6d803732 100644 --- a/test/mpp_packet_test.c +++ b/test/mpp_packet_test.c @@ -25,7 +25,7 @@ int main() { - MPP_RET ret; + MPP_RET ret = MPP_ERR_UNKNOW; MppPacket packet = NULL; void *data = NULL; size_t size = MPP_PACKET_TEST_SIZE;