From 4f7f69c1ae2d94cda1071da48e5b94e4e777af46 Mon Sep 17 00:00:00 2001 From: ChenHengming Date: Thu, 11 Aug 2016 10:16:44 +0000 Subject: [PATCH] [mpp]: fix compile error on windows git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1191 6e48237b-75ef-9749-8fc9-41990f28c85a --- mpp/codec/dec/jpeg/jpegd_parser.c | 2 +- mpp/codec/enc/h264/src/h264e_api.c | 2 ++ mpp/hal/rkenc/h264e/hal_h264e_api.c | 4 +++ mpp/hal/rkenc/h264e/test/h264e_hal_test.c | 42 +++++++++++++---------- mpp/legacy/vpu_api.cpp | 17 +++++++++ mpp/legacy/vpu_api_legacy.cpp | 9 ++--- mpp/test/jpegd_test.c | 2 +- osal/inc/mpp_common.h | 6 ++++ test/mpi_enc_test.c | 4 +-- 9 files changed, 61 insertions(+), 27 deletions(-) diff --git a/mpp/codec/dec/jpeg/jpegd_parser.c b/mpp/codec/dec/jpeg/jpegd_parser.c index 6e14fefc..71bc35e7 100644 --- a/mpp/codec/dec/jpeg/jpegd_parser.c +++ b/mpp/codec/dec/jpeg/jpegd_parser.c @@ -1166,7 +1166,7 @@ MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task) RK_U32 pkt_length = 0; RK_U32 copy_length = 0; void *pPacket = NULL; - void *pPos = NULL; + RK_U8 *pPos = NULL; task->valid = 0; diff --git a/mpp/codec/enc/h264/src/h264e_api.c b/mpp/codec/enc/h264/src/h264e_api.c index dbbc4bcc..ad55a64d 100644 --- a/mpp/codec/enc/h264/src/h264e_api.c +++ b/mpp/codec/enc/h264/src/h264e_api.c @@ -16,6 +16,8 @@ #define MODULE_TAG "h264e_api" +#include + #include "mpp_env.h" #include "mpp_log.h" #include "mpp_common.h" diff --git a/mpp/hal/rkenc/h264e/hal_h264e_api.c b/mpp/hal/rkenc/h264e/hal_h264e_api.c index 6105002f..8df9c346 100644 --- a/mpp/hal/rkenc/h264e/hal_h264e_api.c +++ b/mpp/hal/rkenc/h264e/hal_h264e_api.c @@ -18,7 +18,11 @@ #include #include +#ifdef RKPLATFORM #include +#endif + +#include "mpp_common.h" #include "vpu.h" #include "mpp_hal.h" #include "mpp_env.h" diff --git a/mpp/hal/rkenc/h264e/test/h264e_hal_test.c b/mpp/hal/rkenc/h264e/test/h264e_hal_test.c index 388c27f3..47ca0c9c 100644 --- a/mpp/hal/rkenc/h264e/test/h264e_hal_test.c +++ b/mpp/hal/rkenc/h264e/test/h264e_hal_test.c @@ -20,11 +20,15 @@ #include #include #include -#include -#include "mpp_common.h" +#ifdef RKPLATFORM +#include +#endif + #include "mpp_log.h" #include "mpp_mem.h" +#include "mpp_time.h" +#include "mpp_common.h" #include "mpp_frame.h" #include "hal_h264e_api.h" @@ -115,7 +119,7 @@ static RK_U32 h264e_rkv_revert_csp(h264e_hal_csp_info csp_info) dst_fmt = cswap? MPP_FMT_ABGR8888 : MPP_FMT_ARGB8888; else dst_fmt = MPP_FMT_BUTT; - + break; } default: { @@ -177,7 +181,7 @@ static RK_U32 h264e_vpu_revert_csp(RK_U32 csp) case H264E_VPU_CSP_BGR444: { dst_fmt = MPP_FMT_BGR444; break; - } + } case H264E_VPU_CSP_RGB888: { dst_fmt = MPP_FMT_RGB888; break; @@ -193,7 +197,7 @@ static RK_U32 h264e_vpu_revert_csp(RK_U32 csp) case H264E_VPU_CSP_BGR101010: { dst_fmt = MPP_FMT_BGR101010; break; - } + } default: { h264e_hal_log_err("invalid csp %d", csp); dst_fmt = MPP_FMT_BUTT; @@ -1062,7 +1066,7 @@ static MPP_RET get_rkv_dbg_info(h264e_hal_rkv_dbg_info *info, h264e_syntax *syn, H264E_HAL_FSCAN(fp, "%x\n", info->swreg73_osd_indx_tab_i[k]); H264E_HAL_FSCAN(fp, "%x\n", info->swreg77.bsbw_addr); - + H264E_HAL_FSCAN(fp, "%x\n", syn->keyframe_max_interval); fgets(temp, 512, fp); @@ -1077,7 +1081,7 @@ static MPP_RET get_rkv_dbg_info(h264e_hal_rkv_dbg_info *info, h264e_syntax *syn, syn->qp = info->swreg10.pic_qp; syn->frame_num = info->swreg60.frm_num; syn->input_image_format = info->swreg14.src_cfmt; - syn->transform8x8_mode = info->swreg59.trns_8x8; + syn->transform8x8_mode = info->swreg59.trns_8x8; } h264e_hal_debug_leave(); @@ -1109,7 +1113,7 @@ static MPP_RET get_rkv_syntax_in( h264e_syntax *syn, MppBuffer *hw_in_buf, MppBu char temp[512] = {0}; RK_S32 data = 0; h264e_hal_csp_info csp_info; - + if (!fgets(temp, 512, fp)) return MPP_EOS_STREAM_REACHED; @@ -1131,7 +1135,7 @@ static MPP_RET get_rkv_syntax_in( h264e_syntax *syn, MppBuffer *hw_in_buf, MppBu H264E_HAL_FSCAN(fp, "%d\n", syn->frame_num); H264E_HAL_FSCAN(fp, "%d\n", syn->cabac_init_idc); - + H264E_HAL_FSCAN(fp, "%d\n", syn->idr_pic_id); H264E_HAL_FSCAN(fp, "%d\n", syn->pic_order_cnt_lsb); @@ -1254,12 +1258,12 @@ MPP_RET h264e_hal_vpu_test() MppBuffer hw_input_buf[3] = {NULL}; //Y, U, V MppBuffer hw_output_strm_buf = NULL; RK_U32 frame_luma_stride = 0; - struct timeval t0; + RK_S64 t0; RK_U8 *input_sw_buf = mpp_malloc(RK_U8, MAX_FRAME_TOTAL_SIZE); mpp_packet_init(&extra_info_pkt, (void *)extra_info_buf, H264E_MAX_PACKETED_PARAM_SIZE); - + get_vpu_syntax_in(&syntax_data, hw_input_buf, hw_output_strm_buf); fseek(fp_golden_syntax_in, 0L, SEEK_SET); @@ -1315,8 +1319,8 @@ MPP_RET h264e_hal_vpu_test() /* run hardware */ - gettimeofday(&t0, NULL); - mpp_log("hal_h264e_start time : %d ", ((long)t0.tv_sec) * 1000 + (long)t0.tv_usec / 1000); + t0 = mpp_time(); + mpp_log("hal_h264e_start time : %lld ", (RK_S64)(t0 / 1000)); hal_h264e_start(&ctx, &task_info); hal_h264e_wait(&ctx, &task_info); @@ -1374,7 +1378,7 @@ MPP_RET h264e_hal_rkv_test() MppBuffer hw_input_buf_mul[RKV_H264E_LINKTABLE_FRAME_NUM] = {NULL}; MppBuffer hw_output_strm_buf_mul[RKV_H264E_LINKTABLE_FRAME_NUM] = {NULL}; RK_U32 frame_luma_stride = 0; - struct timeval t0; + RK_S64 t0; mpp_packet_init(&extra_info_pkt, (void *)extra_info_buf, H264E_MAX_PACKETED_PARAM_SIZE); @@ -1382,7 +1386,7 @@ MPP_RET h264e_hal_rkv_test() get_rkv_syntax_in(&syntax_data[0], hw_input_buf_mul, hw_output_strm_buf_mul); fseek(fp_golden_syntax_in, 0L, SEEK_SET); - + frame_luma_stride = ((syntax_data[0].pic_luma_width + 15) & (~15)) * ((syntax_data[0].pic_luma_height + 15) & (~15)); h264e_hal_test_init(&ctx, &task_info, syntax_data); @@ -1443,8 +1447,8 @@ MPP_RET h264e_hal_rkv_test() /* run hardware */ - gettimeofday(&t0, NULL); - mpp_log("hal_h264e_start time : %d ", ((long)t0.tv_sec) * 1000 + (long)t0.tv_usec / 1000); + t0 = mpp_time(); + mpp_log("hal_h264e_start time : %lld ", (RK_S64)(t0 / 1000)); hal_h264e_start(&ctx, &task_info); hal_h264e_wait(&ctx, &task_info); @@ -1458,7 +1462,7 @@ MPP_RET h264e_hal_rkv_test() __test_end: mpp_packet_deinit(&extra_info_pkt); - + hal_h264e_deinit(&ctx); h264e_hal_test_deinit(&ctx, &task_info); @@ -1484,7 +1488,7 @@ int main(int argc, char **argv) h264e_hal_test_cfg test_cfg; mpp_log("******* h264e hal test start *******"); - + if (MPP_OK != h264e_hal_test_parse_options(argc, argv, &test_cfg)) { mpp_err("parse opitons failed, test is ended early"); goto __test_end; diff --git a/mpp/legacy/vpu_api.cpp b/mpp/legacy/vpu_api.cpp index 81dcbc29..10b00e5a 100644 --- a/mpp/legacy/vpu_api.cpp +++ b/mpp/legacy/vpu_api.cpp @@ -257,6 +257,23 @@ RK_S32 close_orign_vpu(VpuCodecContext **ctx) } return MPP_NOK; } +#else +RK_S32 check_orign_vpu() +{ + return (MPP_NOK); +} + +RK_S32 open_orign_vpu(VpuCodecContext **ctx) +{ + (void)ctx; + return MPP_NOK; +} + +RK_S32 close_orign_vpu(VpuCodecContext **ctx) +{ + (void)ctx; + return MPP_NOK; +} #endif /* diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index 33d1a076..0d90b7c6 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -16,7 +16,7 @@ #define MODULE_TAG "vpu_api_legacy" -#ifndef _WIN32 +#ifdef RKPLATFORM #include #endif #include "string.h" @@ -24,6 +24,7 @@ #include "mpp_log.h" #include "mpp_mem.h" #include "mpp_env.h" +#include "mpp_time.h" #include "mpp_common.h" #include "vpu_api_legacy.h" @@ -463,7 +464,7 @@ RK_S32 VpuApiLegacy::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, MppBufferInfo outputCommit; RK_U32 use_fd_flag = 1; -#ifndef _WIN32 +#ifdef RKPLATFORM if (fcntl(aEncInStrm->bufPhyAddr, F_GETFL, NULL) == -1) use_fd_flag = 0; #endif @@ -548,7 +549,7 @@ RK_S32 VpuApiLegacy::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, } if (task == NULL) { mpp_log("mpi dequeue from MPP_PORT_INPUT fail, task equal with NULL!"); - usleep(3000); + msleep(3); } else break; } while (1); @@ -606,7 +607,7 @@ RK_S32 VpuApiLegacy::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, break; } - usleep(3000); + msleep(3); } while (1); } else { mpp_err("mpi pointer is NULL, failed!"); diff --git a/mpp/test/jpegd_test.c b/mpp/test/jpegd_test.c index 7e6a49de..de09e1d4 100644 --- a/mpp/test/jpegd_test.c +++ b/mpp/test/jpegd_test.c @@ -445,7 +445,7 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) mpp_packet_get_data(curtask->input_packet), mpp_packet_get_size(curtask->input_packet)); - mpp_err("%s Line %d, (*input_packet):%p, length:%d", __func__, __LINE__, + mpp_err("%s Line %d, (*input_packet):%p, length:%d", __FUNCTION__, __LINE__, mpp_packet_get_data(curtask->input_packet), mpp_packet_get_size(curtask->input_packet)); DemoCtx.pkt_buf = buffer; diff --git a/osal/inc/mpp_common.h b/osal/inc/mpp_common.h index d29d216c..5a606c53 100644 --- a/osal/inc/mpp_common.h +++ b/osal/inc/mpp_common.h @@ -128,6 +128,12 @@ #define chdir _chdir #define mkdir _mkdir #define access _access + +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ + #elif defined(__MINGW32CE__) #define fseeko fseeko64 #else diff --git a/test/mpi_enc_test.c b/test/mpi_enc_test.c index 136aa586..11c0d05d 100644 --- a/test/mpi_enc_test.c +++ b/test/mpi_enc_test.c @@ -162,7 +162,7 @@ int mpi_enc_test(MpiEncTestCmd *cmd) mpp_cfg.width = width; mpp_cfg.height = height; mpp_cfg.format = fmt; - mpp_cfg.rc_mode = 1; + mpp_cfg.rc_mode = 0; mpp_cfg.skip_cnt = 0; mpp_cfg.fps_in = 30; mpp_cfg.fps_out = 30; @@ -238,7 +238,7 @@ int mpi_enc_test(MpiEncTestCmd *cmd) } if (task == NULL) { mpp_log("mpi dequeue from MPP_PORT_INPUT fail, task equal with NULL!"); - usleep(3000); + msleep(3); } else { MppFrame frame_out = NULL;