[utils]: add show_options to utils

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@316 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2015-09-28 22:31:52 +00:00
parent c6d93bd1b9
commit bed52a856e
6 changed files with 37 additions and 41 deletions

View File

@@ -14,9 +14,9 @@ if(H265D_TEST)
set_target_properties(openhevcwrapper PROPERTIES
IMPORTED_LOCATION
"${OPENHEVCSO}/libLibOpenHevcWrapper.so")
target_link_libraries(h265d_parser_test openhevcwrapper m h265d_parse osal h265d_hal mpp_codec mpp)
target_link_libraries(h265d_parser_test openhevcwrapper m h265d_parse osal h265d_hal mpp_codec mpp utils)
else()
target_link_libraries(h265d_parser_test mpp)
target_link_libraries(h265d_parser_test mpp utils)
endif()
endif()

View File

@@ -28,6 +28,7 @@
#include "h265d_api.h"
#include "hal_h265d_api.h"
#include "utils.h"
#include "mpp_log.h"
#include <string.h>
#include <stdlib.h>
@@ -57,11 +58,6 @@ typedef enum VPU_API_DEMO_RET {
ERROR_VPU_DECODE = PARSER_DEMO_ERROR_BASE - 90,
} PARSER_API_DEMO_RET;
typedef struct ParserCmd {
RK_U8* name;
RK_U8* argname;
RK_U8* help;
} ParserCmd_t;
typedef struct parserDemoCmdContext {
RK_U32 width;
@@ -75,15 +71,14 @@ typedef struct parserDemoCmdContext {
RK_S64 record_start_ms;
} ParserDemoCmdContext_t;
static ParserCmd_t parserCmd[] = {
{(RK_U8*)"i", (RK_U8*)"input_file", (RK_U8*)"input bitstream file"},
{(RK_U8*)"o", (RK_U8*)"output_file", (RK_U8*)"output bitstream file, "},
{(RK_U8*)"w", (RK_U8*)"width", (RK_U8*)"the width of input bitstream"},
{(RK_U8*)"h", (RK_U8*)"height", (RK_U8*)"the height of input bitstream"},
{(RK_U8*)"vframes", (RK_U8*)"number", (RK_U8*)"set the number of video frames to record"},
{(RK_U8*)"ss", (RK_U8*)"time_off", (RK_U8*)"set the start time offset, use Ms as the unit."},
{(RK_U8*)"d", (RK_U8*)"disable", (RK_U8*)"disable the debug output info."},
static OptionInfo parserCmd[] = {
{"i", "input_file", "input bitstream file"},
{"o", "output_file", "output bitstream file, "},
{"w", "width", "the width of input bitstream"},
{"h", "height", "the height of input bitstream"},
{"vframes", "number", "set the number of video frames to record"},
{"ss", "time_off", "set the start time offset, use Ms as the unit."},
{"d", "disable", "disable the debug output info."},
};
static void show_usage()
@@ -96,15 +91,8 @@ static void show_usage()
static RK_S32 show_help()
{
RK_U32 i = 0;
RK_U32 n = sizeof(parserCmd) / sizeof(ParserCmd_t);
mpp_log("usage: parserDemo [options] input_file, \n\n");
for (i = 0; i < n; i++) {
mpp_log("-%s %s\t\t%s\n",
parserCmd[i].name, parserCmd[i].argname, parserCmd[i].help);
}
show_options(parserCmd);
return 0;
}

View File

@@ -13,7 +13,7 @@ macro(add_mpp_test module)
option(${test_tag} "Build mpp ${module} unit test" ON)
if(${test_tag})
add_executable(${test_name} ${test_name}.c)
target_link_libraries(${test_name} mpp mpp_legacy)
target_link_libraries(${test_name} mpp mpp_legacy utils)
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})

View File

@@ -24,6 +24,7 @@
#include "mpp_time.h"
#include "vpu_api.h"
#include "utils.h"
static RK_U32 VPU_API_DEMO_DEBUG_DISABLE = 0;
@@ -50,12 +51,6 @@ typedef enum VPU_API_DEMO_RET {
ERROR_VPU_DECODE = VPU_DEMO_ERROR_BASE - 90,
} VPU_API_DEMO_RET;
typedef struct VpuApiCmd {
char* name;
char* argname;
char* help;
} VpuApiCmd_t;
typedef struct VpuApiDemoCmdContext {
RK_U32 width;
RK_U32 height;
@@ -75,7 +70,7 @@ typedef struct VpuApiEncInput {
RK_U32 capability;
} VpuApiEncInput;
static VpuApiCmd_t vpuApiCmd[] = {
static OptionInfo vpuApiCmd[] = {
{"i", "input_file", "input bitstream file"},
{"o", "output_file", "output bitstream file, "},
{"w", "width", "the width of input bitstream"},
@@ -97,16 +92,8 @@ static void show_usage()
static RK_S32 show_help()
{
RK_S32 i = 0;
RK_S32 n = sizeof(vpuApiCmd) / sizeof(VpuApiCmd_t);
mpp_log("usage: vpu_apiDemo [options] input_file, \n\n");
for (i = 0; i < n; i++) {
mpp_log("-%s %s\t\t%s\n",
vpuApiCmd[i].name, vpuApiCmd[i].argname, vpuApiCmd[i].help);
}
show_options(vpuApiCmd);
return 0;
}

View File

@@ -20,5 +20,14 @@
#include <string.h>
#include "mpp_log.h"
#include "utils.h"
void _show_options(int count, OptionInfo *options)
{
int i;
for (i = 0; i < count; i++) {
mpp_log("-%s %s\t\t%s\n",
options[i].name, options[i].argname, options[i].help);
}
}

View File

@@ -17,10 +17,22 @@
#ifndef __UTILS_H__
#define __UTILS_H__
typedef struct OptionInfo_t {
const char* name;
const char* argname;
const char* help;
} OptionInfo;
#define show_options(opt) \
do { \
_show_options(sizeof(opt)/sizeof(OptionInfo), opt); \
} while (0)
#ifdef __cplusplus
extern "C" {
#endif
void _show_options(int count, OptionInfo *options);
#ifdef __cplusplus
}