mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 17:16:50 +08:00
[format]: use astyle to format all source file
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@96 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
|
||||
#define VPU_API_NOPTS_VALUE (0x8000000000000000LL)
|
||||
|
||||
typedef enum VPU_API_CMD
|
||||
{
|
||||
typedef enum VPU_API_CMD {
|
||||
VPU_API_ENC_SETCFG,
|
||||
VPU_API_ENC_GETCFG,
|
||||
VPU_API_ENC_SETFORMAT,
|
||||
@@ -35,8 +34,7 @@ typedef enum VPU_API_CMD
|
||||
VPU_API_SET_INFO_CHANGE,
|
||||
} VPU_API_CMD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
RK_U32 TimeLow;
|
||||
RK_U32 TimeHigh;
|
||||
} TIME_STAMP;
|
||||
@@ -48,8 +46,7 @@ typedef struct VPUMem {
|
||||
RK_U32 *offset;
|
||||
} VPUMemLinear_t;
|
||||
|
||||
typedef struct tVPU_FRAME
|
||||
{
|
||||
typedef struct tVPU_FRAME {
|
||||
RK_U32 FrameBusAddr[2]; // 0: Y address; 1: UV address;
|
||||
RK_U32 FrameWidth; // buffer horizontal stride
|
||||
RK_U32 FrameHeight; // buffer vertical stride
|
||||
@@ -110,8 +107,7 @@ typedef struct EncoderOut {
|
||||
|
||||
} EncoderOut_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
VPU_H264ENC_YUV420_PLANAR = 0, /* YYYY... UUUU... VVVV */
|
||||
VPU_H264ENC_YUV420_SEMIPLANAR = 1, /* YYYY... UVUVUV... */
|
||||
VPU_H264ENC_YUV422_INTERLEAVED_YUYV = 2, /* YUYVYUYV... */
|
||||
@@ -167,22 +163,21 @@ typedef enum CODEC_TYPE {
|
||||
CODEC_BUTT,
|
||||
} CODEC_TYPE;
|
||||
|
||||
typedef enum VPU_API_ERR{
|
||||
typedef enum VPU_API_ERR {
|
||||
VPU_API_OK = 0,
|
||||
VPU_API_ERR_UNKNOW = -1,
|
||||
VPU_API_ERR_BASE = -1000,
|
||||
VPU_API_ERR_LIST_STREAM = VPU_API_ERR_BASE -1,
|
||||
VPU_API_ERR_INIT = VPU_API_ERR_BASE -2,
|
||||
VPU_API_ERR_VPU_CODEC_INIT = VPU_API_ERR_BASE -3,
|
||||
VPU_API_ERR_STREAM = VPU_API_ERR_BASE -4,
|
||||
VPU_API_ERR_FATAL_THREAD = VPU_API_ERR_BASE -5,
|
||||
VPU_API_EOS_STREAM_REACHED = VPU_API_ERR_BASE -11,
|
||||
VPU_API_ERR_LIST_STREAM = VPU_API_ERR_BASE - 1,
|
||||
VPU_API_ERR_INIT = VPU_API_ERR_BASE - 2,
|
||||
VPU_API_ERR_VPU_CODEC_INIT = VPU_API_ERR_BASE - 3,
|
||||
VPU_API_ERR_STREAM = VPU_API_ERR_BASE - 4,
|
||||
VPU_API_ERR_FATAL_THREAD = VPU_API_ERR_BASE - 5,
|
||||
VPU_API_EOS_STREAM_REACHED = VPU_API_ERR_BASE - 11,
|
||||
|
||||
VPU_API_ERR_BUTT,
|
||||
} VPU_API_ERR;
|
||||
|
||||
typedef struct EncParameter
|
||||
{
|
||||
typedef struct EncParameter {
|
||||
RK_S32 width;
|
||||
RK_S32 height;
|
||||
RK_S32 rc_mode;
|
||||
@@ -276,7 +271,7 @@ typedef struct VpuCodecContext {
|
||||
|
||||
RK_S32 (*encoder_sendframe)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm);
|
||||
RK_S32 (*encoder_getstream)(struct VpuCodecContext *ctx, EncoderOut_t *aEncOut);
|
||||
}VpuCodecContext_t;
|
||||
} VpuCodecContext_t;
|
||||
|
||||
/* allocated vpu codec context */
|
||||
#ifdef __cplusplus
|
||||
|
@@ -86,7 +86,7 @@ static RK_S32 vpu_api_getframe(VpuCodecContext *ctx, DecoderOut_t *aDecOut)
|
||||
return VPU_API_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
return api->decode_getoutframe(ctx,aDecOut);
|
||||
return api->decode_getoutframe(ctx, aDecOut);
|
||||
}
|
||||
|
||||
static RK_S32 vpu_api_sendframe(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm)
|
||||
@@ -118,7 +118,7 @@ static RK_S32 vpu_api_getstream(VpuCodecContext *ctx, EncoderOut_t *aEncOut)
|
||||
return VPU_API_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
return api->encoder_getstream(ctx,aEncOut);
|
||||
return api->encoder_getstream(ctx, aEncOut);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ static RK_S32 vpu_api_flush(VpuCodecContext *ctx)
|
||||
return api->flush(ctx);
|
||||
}
|
||||
|
||||
static RK_S32 vpu_api_control(VpuCodecContext *ctx, VPU_API_CMD cmdType,void *param)
|
||||
static RK_S32 vpu_api_control(VpuCodecContext *ctx, VPU_API_CMD cmdType, void *param)
|
||||
{
|
||||
if (ctx == NULL) {
|
||||
mpp_log("vpu_api_decode fail, input invalid");
|
||||
@@ -206,7 +206,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!s->vpuApiObj){
|
||||
if (!s->vpuApiObj) {
|
||||
mpp_err("Input context has not been properly allocated and is not NULL either");
|
||||
return -1;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ RK_S32 vpu_close_context(VpuCodecContext **ctx)
|
||||
mpp_free(s->extradata);
|
||||
s->extradata = NULL;
|
||||
}
|
||||
if(s->private_data){
|
||||
if (s->private_data) {
|
||||
mpp_free(s->private_data);
|
||||
s->private_data = NULL;
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ RK_S32 VpuApi::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *aEncInS
|
||||
return 0;
|
||||
}
|
||||
|
||||
RK_S32 VpuApi::encoder_getstream(VpuCodecContext *ctx,EncoderOut_t *aEncOut)
|
||||
RK_S32 VpuApi::encoder_getstream(VpuCodecContext *ctx, EncoderOut_t *aEncOut)
|
||||
{
|
||||
mpp_log("%s in\n", __FUNCTION__);
|
||||
(void)ctx;
|
||||
|
@@ -19,7 +19,8 @@
|
||||
|
||||
#include "vpu_api.h"
|
||||
|
||||
class VpuApi {
|
||||
class VpuApi
|
||||
{
|
||||
public:
|
||||
VpuApi();
|
||||
~VpuApi();
|
||||
@@ -29,7 +30,7 @@ public:
|
||||
|
||||
RK_S32 decode(VpuCodecContext *ctx, VideoPacket_t *pkt, DecoderOut_t *aDecOut);
|
||||
RK_S32 decode_sendstream(VpuCodecContext *ctx, VideoPacket_t *pkt);
|
||||
RK_S32 decode_getoutframe(VpuCodecContext *ctx,DecoderOut_t *aDecOut);
|
||||
RK_S32 decode_getoutframe(VpuCodecContext *ctx, DecoderOut_t *aDecOut);
|
||||
RK_S32 preProcessPacket(VpuCodecContext *ctx, VideoPacket_t *pkt);
|
||||
|
||||
RK_S32 encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut);
|
||||
|
@@ -27,11 +27,11 @@
|
||||
|
||||
RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
|
||||
{
|
||||
char prop[PROP_VALUE_MAX+1];
|
||||
char prop[PROP_VALUE_MAX + 1];
|
||||
int len = __system_property_get(name, prop);
|
||||
if (len > 0) {
|
||||
char *endptr;
|
||||
int base = (prop[0] == '0' && prop[1] == 'x')?(16):(10);
|
||||
int base = (prop[0] == '0' && prop[1] == 'x') ? (16) : (10);
|
||||
errno = 0;
|
||||
*value = strtoul(prop, &endptr, base);
|
||||
if (errno || (prop == endptr)) {
|
||||
@@ -47,7 +47,7 @@ RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
|
||||
RK_S32 os_get_env_str(const char *name, char **value, char *default_value)
|
||||
{
|
||||
// use unsigned char to avoid warnning
|
||||
static unsigned char env_str[2][PROP_VALUE_MAX+1];
|
||||
static unsigned char env_str[2][PROP_VALUE_MAX + 1];
|
||||
static RK_U32 env_idx = 0;
|
||||
char *prop = (char *)env_str[env_idx];
|
||||
int len = __system_property_get(name, prop);
|
||||
@@ -62,16 +62,16 @@ RK_S32 os_get_env_str(const char *name, char **value, char *default_value)
|
||||
|
||||
RK_S32 os_set_env_u32(const char *name, RK_U32 value)
|
||||
{
|
||||
char buf[PROP_VALUE_MAX+1+2];
|
||||
char buf[PROP_VALUE_MAX + 1 + 2];
|
||||
snprintf(buf, sizeof(buf), "0x%x", value);
|
||||
int len = __system_property_set(name, buf);
|
||||
return (len)?(0):(-1);
|
||||
return (len) ? (0) : (-1);
|
||||
}
|
||||
|
||||
RK_S32 os_set_env_str(const char *name, char *value)
|
||||
{
|
||||
int len = __system_property_set(name, value);
|
||||
return (len)?(0):(-1);
|
||||
return (len) ? (0) : (-1);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -31,7 +31,8 @@
|
||||
typedef void *(*node_destructor)(void *);
|
||||
|
||||
struct mpp_list_node;
|
||||
class mpp_list {
|
||||
class mpp_list
|
||||
{
|
||||
public:
|
||||
mpp_list(node_destructor func);
|
||||
~mpp_list();
|
||||
@@ -77,8 +78,7 @@ private:
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct list_head
|
||||
{
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
|
@@ -28,7 +28,7 @@ RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
|
||||
*value = default_value;
|
||||
} else {
|
||||
char *endptr;
|
||||
int base = (ptr[0] == '0' && ptr[1] == 'x')?(16):(10);
|
||||
int base = (ptr[0] == '0' && ptr[1] == 'x') ? (16) : (10);
|
||||
errno = 0;
|
||||
*value = strtoul(ptr, &endptr, base);
|
||||
if (errno || (ptr == endptr)) {
|
||||
|
@@ -51,7 +51,7 @@ static inline void list_node_init_with_key_and_size(mpp_list_node *node, RK_U32
|
||||
|
||||
static mpp_list_node* create_list(void *data, RK_S32 size, RK_U32 key)
|
||||
{
|
||||
mpp_list_node *node = (mpp_list_node*)malloc(sizeof(mpp_list_node)+size);
|
||||
mpp_list_node *node = (mpp_list_node*)malloc(sizeof(mpp_list_node) + size);
|
||||
if (node) {
|
||||
void *dst = (void*)(node + 1);
|
||||
list_node_init_with_key_and_size(node, key, size);
|
||||
|
@@ -52,11 +52,11 @@ void _mpp_log(const char *tag, const char *fmt, ...)
|
||||
buf = msg_log_nothing;
|
||||
} else if (len == MPP_LOG_MAX_LEN) {
|
||||
buf = msg_log_warning;
|
||||
} else if (fmt[len-1] != '\n') {
|
||||
} else if (fmt[len - 1] != '\n') {
|
||||
char msg[MPP_LOG_MAX_LEN];
|
||||
snprintf(msg, sizeof(msg), "%s", fmt);
|
||||
msg[len] = '\n';
|
||||
msg[len+1] = '\0';
|
||||
msg[len + 1] = '\0';
|
||||
buf = msg;
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ void _mpp_err(const char *tag, const char *fmt, ...)
|
||||
buf = msg_log_nothing;
|
||||
} else if (len == MPP_LOG_MAX_LEN) {
|
||||
buf = msg_log_warning;
|
||||
} else if (fmt[len-1] != '\n') {
|
||||
} else if (fmt[len - 1] != '\n') {
|
||||
char msg[MPP_LOG_MAX_LEN];
|
||||
snprintf(msg, sizeof(msg), "%s", fmt);
|
||||
msg[len] = '\n';
|
||||
msg[len+1] = '\0';
|
||||
msg[len + 1] = '\0';
|
||||
buf = msg;
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
|
||||
*value = default_value;
|
||||
} else {
|
||||
char *endptr;
|
||||
int base = (ptr[0] == '0' && ptr[1] == 'x')?(16):(10);
|
||||
int base = (ptr[0] == '0' && ptr[1] == 'x') ? (16) : (10);
|
||||
errno = 0;
|
||||
*value = strtoul(ptr, &endptr, base);
|
||||
if (errno || (ptr == endptr)) {
|
||||
|
@@ -20,7 +20,7 @@
|
||||
int os_malloc(void **memptr, size_t alignment, size_t size)
|
||||
{
|
||||
*memptr = _aligned_malloc(size, alignment);
|
||||
return (*memptr)?(0):(-1);
|
||||
return (*memptr) ? (0) : (-1);
|
||||
}
|
||||
|
||||
void os_free(void *ptr)
|
||||
|
@@ -99,8 +99,8 @@ static RK_S32 show_help()
|
||||
{
|
||||
mpp_log("usage: vpu_apiDemo [options] input_file, \n\n");
|
||||
|
||||
RK_S32 i =0;
|
||||
RK_S32 n = sizeof(vpuApiCmd)/sizeof(VpuApiCmd_t);
|
||||
RK_S32 i = 0;
|
||||
RK_S32 n = sizeof(vpuApiCmd) / sizeof(VpuApiCmd_t);
|
||||
for (i = 0; i < n; i++) {
|
||||
mpp_log("-%s %s\t\t%s\n",
|
||||
vpuApiCmd[i].name, vpuApiCmd[i].argname, vpuApiCmd[i].help);
|
||||
@@ -112,9 +112,9 @@ static RK_S32 show_help()
|
||||
static RK_S32 parse_options(int argc, char **argv, VpuApiDemoCmdContext_t* cmdCxt)
|
||||
{
|
||||
char *opt;
|
||||
RK_S32 optindex, handleoptions = 1, ret =0;
|
||||
RK_S32 optindex, handleoptions = 1, ret = 0;
|
||||
|
||||
if ((argc <2) || (cmdCxt == NULL)) {
|
||||
if ((argc < 2) || (cmdCxt == NULL)) {
|
||||
mpp_log("vpu api demo, input parameter invalid\n");
|
||||
show_usage();
|
||||
return ERROR_INVALID_PARAM;
|
||||
@@ -173,7 +173,7 @@ static RK_S32 parse_options(int argc, char **argv, VpuApiDemoCmdContext_t* cmdCx
|
||||
goto PARSE_OPINIONS_OUT;
|
||||
}
|
||||
case 'h':
|
||||
if ((*(opt+1) != '\0') && !strncmp(opt, "help", 4)) {
|
||||
if ((*(opt + 1) != '\0') && !strncmp(opt, "help", 4)) {
|
||||
show_help();
|
||||
ret = VPU_DEMO_PARSE_HELP_OK;
|
||||
goto PARSE_OPINIONS_OUT;
|
||||
@@ -196,7 +196,7 @@ static RK_S32 parse_options(int argc, char **argv, VpuApiDemoCmdContext_t* cmdCx
|
||||
}
|
||||
|
||||
default:
|
||||
if ((*(opt+1) != '\0') && argv[optindex]) {
|
||||
if ((*(opt + 1) != '\0') && argv[optindex]) {
|
||||
if (!strncmp(opt, "coding", 6)) {
|
||||
mpp_log("coding, argv[optindex]: %s",
|
||||
argv[optindex]);
|
||||
@@ -221,7 +221,7 @@ static RK_S32 parse_options(int argc, char **argv, VpuApiDemoCmdContext_t* cmdCx
|
||||
}
|
||||
|
||||
PARSE_OPINIONS_OUT:
|
||||
if (ret <0) {
|
||||
if (ret < 0) {
|
||||
mpp_log("vpu api demo, input parameter invalid\n");
|
||||
show_usage();
|
||||
return ERROR_INVALID_PARAM;
|
||||
@@ -236,8 +236,7 @@ static RK_S32 readBytesFromFile(RK_U8* buf, RK_S32 aBytes, FILE* file)
|
||||
}
|
||||
|
||||
RK_S32 ret = (RK_S32)fread(buf, 1, aBytes, file);
|
||||
if(ret != aBytes)
|
||||
{
|
||||
if (ret != aBytes) {
|
||||
mpp_log("read %d bytes from file fail\n", aBytes);
|
||||
return -1;
|
||||
}
|
||||
@@ -260,12 +259,12 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
EncoderOut_t *enc_out = NULL;
|
||||
VpuApiEncInput enc_in_strm;
|
||||
VpuApiEncInput *api_enc_in = &enc_in_strm;
|
||||
EncInputStream_t *enc_in =NULL;
|
||||
EncInputStream_t *enc_in = NULL;
|
||||
EncParameter_t *enc_param = NULL;
|
||||
RK_S64 fakeTimeUs =0;
|
||||
RK_S64 fakeTimeUs = 0;
|
||||
int Format = VPU_H264ENC_YUV420_SEMIPLANAR;
|
||||
|
||||
if ((cmd->have_input == 0) || (cmd->width <=0) || (cmd->height <=0)
|
||||
if ((cmd->have_input == 0) || (cmd->width <= 0) || (cmd->height <= 0)
|
||||
|| (cmd->coding <= OMX_RK_VIDEO_CodingAutoDetect)) {
|
||||
mpp_log("Warning: missing needed parameters for vpu api demo\n");
|
||||
}
|
||||
@@ -312,7 +311,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
}
|
||||
|
||||
ret = vpu_open_context(&ctx);
|
||||
if (ret || (ctx ==NULL)) {
|
||||
if (ret || (ctx == NULL)) {
|
||||
ENCODE_ERR_RET(ERROR_MEMORY);
|
||||
}
|
||||
|
||||
@@ -327,7 +326,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
ctx->no_thread = 1;
|
||||
|
||||
ctx->private_data = malloc(sizeof(EncParameter_t));
|
||||
memset(ctx->private_data,0,sizeof(EncParameter_t));
|
||||
memset(ctx->private_data, 0, sizeof(EncParameter_t));
|
||||
|
||||
enc_param = (EncParameter_t*)ctx->private_data;
|
||||
enc_param->width = cmd->width;
|
||||
@@ -338,7 +337,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
enc_param->cabacInitIdc = 0;
|
||||
enc_param->intraPicRate = 30;
|
||||
|
||||
if ((ret = ctx->init(ctx, NULL, 0)) !=0) {
|
||||
if ((ret = ctx->init(ctx, NULL, 0)) != 0) {
|
||||
mpp_log("init vpu api context fail, ret: 0x%X\n", ret);
|
||||
ENCODE_ERR_RET(ERROR_INIT_VPU);
|
||||
}
|
||||
@@ -349,7 +348,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
** after init.
|
||||
*/
|
||||
mpp_log("encode init ok, sps len: %d\n", ctx->extradata_size);
|
||||
if(pOutFile && (ctx->extradata_size >0)) {
|
||||
if (pOutFile && (ctx->extradata_size > 0)) {
|
||||
mpp_log("dump %d bytes enc output stream to file\n",
|
||||
ctx->extradata_size);
|
||||
|
||||
@@ -358,27 +357,27 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
fflush(pOutFile);
|
||||
}
|
||||
|
||||
ctx->control(ctx,VPU_API_ENC_SETFORMAT,&Format);
|
||||
ctx->control(ctx, VPU_API_ENC_SETFORMAT, &Format);
|
||||
|
||||
ctx->control(ctx,VPU_API_ENC_GETCFG,enc_param);
|
||||
ctx->control(ctx, VPU_API_ENC_GETCFG, enc_param);
|
||||
enc_param->rc_mode = 1;
|
||||
ctx->control(ctx,VPU_API_ENC_SETCFG,enc_param);
|
||||
ctx->control(ctx, VPU_API_ENC_SETCFG, enc_param);
|
||||
/*
|
||||
** vpu api encode process.
|
||||
*/
|
||||
mpp_log("init vpu api context ok, input yuv stream file size: %d\n", fileSize);
|
||||
RK_U32 w_align = ((ctx->width + 15) & (~15));
|
||||
RK_U32 h_align = ((ctx->height + 15) & (~15));
|
||||
size = w_align * h_align * 3/2;
|
||||
size = w_align * h_align * 3 / 2;
|
||||
nal = BSWAP32(nal);
|
||||
|
||||
do {
|
||||
if (ftell(pInFile) >=fileSize) {
|
||||
if (ftell(pInFile) >= fileSize) {
|
||||
mpp_log("read end of file, complete\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (enc_in && (enc_in->size ==0)) {
|
||||
if (enc_in && (enc_in->size == 0)) {
|
||||
if (enc_in->buf == NULL) {
|
||||
enc_in->buf = (RK_U8*)(malloc)(size);
|
||||
if (enc_in->buf == NULL) {
|
||||
@@ -387,7 +386,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
api_enc_in->capability = size;
|
||||
}
|
||||
|
||||
if (api_enc_in->capability <((RK_U32)size)) {
|
||||
if (api_enc_in->capability < ((RK_U32)size)) {
|
||||
enc_in->buf = (RK_U8*)(realloc)((void*)(enc_in->buf), size);
|
||||
if (enc_in->buf == NULL) {
|
||||
ENCODE_ERR_RET(ERROR_MEMORY);
|
||||
@@ -400,7 +399,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
} else {
|
||||
enc_in->size = size;
|
||||
enc_in->timeUs = fakeTimeUs;
|
||||
fakeTimeUs +=40000;
|
||||
fakeTimeUs += 40000;
|
||||
}
|
||||
|
||||
mpp_log("read one frame, size: %d, timeUs: %lld, filePos: %ld\n",
|
||||
@@ -418,7 +417,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
** head by yourself.
|
||||
*/
|
||||
if ((enc_out->size) && (enc_out->data)) {
|
||||
if(pOutFile) {
|
||||
if (pOutFile) {
|
||||
mpp_log("dump %d bytes enc output stream to file\n",
|
||||
enc_out->size);
|
||||
fwrite((RK_U8*)&nal, 1, 4, pOutFile);
|
||||
@@ -431,7 +430,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
}
|
||||
|
||||
msleep(3);
|
||||
}while(1);
|
||||
} while (1);
|
||||
|
||||
ENCODE_OUT:
|
||||
if (enc_in && enc_in->buf) {
|
||||
@@ -477,19 +476,19 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
FILE* pInFile = NULL;
|
||||
FILE* pOutFile = NULL;
|
||||
struct VpuCodecContext* ctx = NULL;
|
||||
RK_S32 fileSize =0, pkt_size =0;
|
||||
RK_S32 fileSize = 0, pkt_size = 0;
|
||||
RK_S32 ret = 0;
|
||||
RK_U32 frame_count = 0;
|
||||
DecoderOut_t decOut;
|
||||
VideoPacket_t demoPkt;
|
||||
VideoPacket_t* pkt =NULL;
|
||||
VideoPacket_t* pkt = NULL;
|
||||
DecoderOut_t *pOut = NULL;
|
||||
VPU_FRAME *frame = NULL;
|
||||
RK_S64 fakeTimeUs =0;
|
||||
RK_S64 fakeTimeUs = 0;
|
||||
RK_U8* pExtra = NULL;
|
||||
RK_U32 extraSize = 0;
|
||||
|
||||
if ((cmd->have_input == 0) || (cmd->width <=0) || (cmd->height <=0)
|
||||
if ((cmd->have_input == 0) || (cmd->width <= 0) || (cmd->height <= 0)
|
||||
|| (cmd->coding <= OMX_RK_VIDEO_CodingAutoDetect)) {
|
||||
mpp_log("Warning: missing needed parameters for vpu api demo\n");
|
||||
}
|
||||
@@ -518,7 +517,7 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
mpp_log("can not write output file\n");
|
||||
DECODE_ERR_RET(ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (cmd->record_frames ==0)
|
||||
if (cmd->record_frames == 0)
|
||||
cmd->record_frames = 5;
|
||||
}
|
||||
|
||||
@@ -536,13 +535,13 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
pOut = &decOut;
|
||||
|
||||
pOut->data = (RK_U8*)(malloc)(sizeof(VPU_FRAME));
|
||||
if (pOut->data ==NULL) {
|
||||
if (pOut->data == NULL) {
|
||||
DECODE_ERR_RET(ERROR_MEMORY);
|
||||
}
|
||||
memset(pOut->data, 0, sizeof(VPU_FRAME));
|
||||
|
||||
ret = vpu_open_context(&ctx);
|
||||
if (ret || (ctx ==NULL)) {
|
||||
if (ret || (ctx == NULL)) {
|
||||
DECODE_ERR_RET(ERROR_MEMORY);
|
||||
}
|
||||
|
||||
@@ -556,7 +555,7 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
mpp_log("codec extra data size: %d\n", extraSize);
|
||||
|
||||
pExtra = (RK_U8*)(malloc)(extraSize);
|
||||
if (pExtra ==NULL) {
|
||||
if (pExtra == NULL) {
|
||||
DECODE_ERR_RET(ERROR_MEMORY);
|
||||
}
|
||||
memset(pExtra, 0, extraSize);
|
||||
@@ -575,7 +574,7 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
ctx->height = cmd->height;
|
||||
ctx->no_thread = 1;
|
||||
|
||||
if ((ret = ctx->init(ctx, pExtra, extraSize)) !=0) {
|
||||
if ((ret = ctx->init(ctx, pExtra, extraSize)) != 0) {
|
||||
mpp_log("init vpu api context fail, ret: 0x%X\n", ret);
|
||||
DECODE_ERR_RET(ERROR_INIT_VPU);
|
||||
}
|
||||
@@ -586,27 +585,27 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
mpp_log("init vpu api context ok, fileSize: %d\n", fileSize);
|
||||
|
||||
do {
|
||||
if (ftell(pInFile) >=fileSize) {
|
||||
if (ftell(pInFile) >= fileSize) {
|
||||
mpp_log("read end of file, complete\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (pkt && (pkt->size ==0)) {
|
||||
if (pkt && (pkt->size == 0)) {
|
||||
if (readBytesFromFile((RK_U8*)(&pkt_size), 4, pInFile)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pkt->data ==NULL) {
|
||||
if (pkt->data == NULL) {
|
||||
pkt->data = (RK_U8*)(malloc)(pkt_size);
|
||||
if (pkt->data ==NULL) {
|
||||
if (pkt->data == NULL) {
|
||||
DECODE_ERR_RET(ERROR_MEMORY);
|
||||
}
|
||||
pkt->capability = pkt_size;
|
||||
}
|
||||
|
||||
if (pkt->capability <((RK_U32)pkt_size)) {
|
||||
if (pkt->capability < ((RK_U32)pkt_size)) {
|
||||
pkt->data = (RK_U8*)(realloc)((void*)(pkt->data), pkt_size);
|
||||
if (pkt->data ==NULL) {
|
||||
if (pkt->data == NULL) {
|
||||
DECODE_ERR_RET(ERROR_MEMORY);
|
||||
}
|
||||
pkt->capability = pkt_size;
|
||||
@@ -617,7 +616,7 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
} else {
|
||||
pkt->size = pkt_size;
|
||||
pkt->pts = fakeTimeUs;
|
||||
fakeTimeUs +=40000;
|
||||
fakeTimeUs += 40000;
|
||||
}
|
||||
|
||||
mpp_log("read one packet, size: %d, pts: %lld, filePos: %ld\n",
|
||||
@@ -627,7 +626,7 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
/* note: must set out put size to 0 before do decoder. */
|
||||
pOut->size = 0;
|
||||
|
||||
if ((ret = ctx->decode(ctx, pkt, pOut)) !=0) {
|
||||
if ((ret = ctx->decode(ctx, pkt, pOut)) != 0) {
|
||||
DECODE_ERR_RET(ERROR_VPU_DECODE);
|
||||
} else {
|
||||
mpp_log("vpu decode one frame, out len: %d, left size: %d\n",
|
||||
@@ -641,11 +640,11 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
if ((pOut->size) && (pOut->data)) {
|
||||
frame = (VPU_FRAME *)(pOut->data);
|
||||
VPUMemLink(&frame->vpumem);
|
||||
RK_U32 wAlign16 = ((frame->DisplayWidth+ 15) & (~15));
|
||||
RK_U32 wAlign16 = ((frame->DisplayWidth + 15) & (~15));
|
||||
RK_U32 hAlign16 = ((frame->DisplayHeight + 15) & (~15));
|
||||
RK_U32 frameSize = wAlign16*hAlign16*3/2;
|
||||
RK_U32 frameSize = wAlign16 * hAlign16 * 3 / 2;
|
||||
|
||||
if(pOutFile && (frame_count++ <cmd->record_frames)) {
|
||||
if (pOutFile && (frame_count++ < cmd->record_frames)) {
|
||||
mpp_log("write %d frame(yuv420sp) data, %d bytes to file\n",
|
||||
frame_count, frameSize);
|
||||
|
||||
@@ -663,7 +662,7 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd)
|
||||
}
|
||||
|
||||
msleep(3);
|
||||
}while(!(ctx->decoder_err));
|
||||
} while (!(ctx->decoder_err));
|
||||
|
||||
DECODE_OUT:
|
||||
if (pkt && pkt->data) {
|
||||
@@ -705,7 +704,7 @@ int main(int argc, char **argv)
|
||||
mpp_log("/******* vpu api demo in *******/\n");
|
||||
|
||||
VpuApiDemoCmdContext_t demoCmdCtx;
|
||||
RK_S32 ret =0;
|
||||
RK_S32 ret = 0;
|
||||
VPU_API_DEMO_DEBUG_DISABLE = 0;
|
||||
|
||||
if (argc == 1) {
|
||||
@@ -717,7 +716,7 @@ int main(int argc, char **argv)
|
||||
VpuApiDemoCmdContext_t* cmd = &demoCmdCtx;
|
||||
memset (cmd, 0, sizeof(VpuApiDemoCmdContext_t));
|
||||
cmd->codec_type = CODEC_DECODER;
|
||||
if ((ret = parse_options(argc, argv, cmd)) !=0) {
|
||||
if ((ret = parse_options(argc, argv, cmd)) != 0) {
|
||||
if (ret == VPU_DEMO_PARSE_HELP_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user