diff --git a/test/mpi_enc_test.c b/test/mpi_enc_test.c index b183a82b..de7a388c 100644 --- a/test/mpi_enc_test.c +++ b/test/mpi_enc_test.c @@ -70,6 +70,7 @@ typedef struct { RK_U32 num_frames; // resources + size_t header_size; size_t frame_size; /* NOTE: packet buffer may overflow */ size_t packet_size; @@ -142,7 +143,7 @@ MPP_RET test_ctx_init(MpiEncTestData **data, MpiEncTestArgs *cmd) } // update resource parameter - switch (p->fmt) { + switch (p->fmt & MPP_FRAME_FMT_MASK) { case MPP_FMT_YUV420SP: case MPP_FMT_YUV420P: { p->frame_size = MPP_ALIGN(p->hor_stride, 64) * MPP_ALIGN(p->ver_stride, 64) * 3 / 2; @@ -164,6 +165,11 @@ MPP_RET test_ctx_init(MpiEncTestData **data, MpiEncTestArgs *cmd) } break; } + if (MPP_FRAME_FMT_IS_FBC(p->fmt)) + p->header_size = MPP_ALIGN(MPP_ALIGN(p->width, 16) * MPP_ALIGN(p->height, 16) / 16, SZ_4K); + else + p->header_size = 0; + /* * osd idx size range from 16x16 bytes(pixels) to hor_stride*ver_stride(bytes). * for general use, 1/8 Y buffer is enough. @@ -489,7 +495,6 @@ MPP_RET test_mpp_run(MpiEncTestData *p) mpp_frame_set_ver_stride(frame, p->ver_stride); mpp_frame_set_fmt(frame, p->fmt); mpp_frame_set_eos(frame, p->frm_eos); - if (p->ref.max_lt_ref_cnt) { // force idr as reference every 15 frames //RK_S32 quotient = p->frame_count / 15; @@ -608,7 +613,7 @@ int mpi_enc_test(MpiEncTestArgs *cmd) goto MPP_TEST_OUT; } - ret = mpp_buffer_get(NULL, &p->frm_buf, p->frame_size); + ret = mpp_buffer_get(NULL, &p->frm_buf, p->frame_size + p->header_size); if (ret) { mpp_err_f("failed to get buffer for input frame ret %d\n", ret); goto MPP_TEST_OUT; diff --git a/utils/utils.c b/utils/utils.c index 9a88b173..7a80f636 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -20,6 +20,7 @@ #include "mpp_mem.h" #include "mpp_log.h" +#include "mpp_common.h" #include "utils.h" void _show_options(int count, OptionInfo *options) @@ -271,6 +272,48 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height, RK_U8 *buf_u = buf_y + hor_stride * ver_stride; // NOTE: diff from gen_yuv_image RK_U8 *buf_v = buf_u + hor_stride * ver_stride / 4; // NOTE: diff from gen_yuv_image + if (MPP_FRAME_FMT_IS_FBC(fmt)) { + RK_U32 align_w = MPP_ALIGN(width, 16); + RK_U32 align_h = MPP_ALIGN(height, 16); + RK_U32 header_size = MPP_ALIGN(align_w * align_h / 16, SZ_4K); + + /* read fbc header first */ + read_size = fread(buf, 1, header_size, fp); + if (read_size != header_size) { + mpp_err_f("read fbc file header failed %d vs %d\n", + read_size, header_size); + ret = MPP_NOK; + goto err; + } + buf += header_size; + + switch (fmt & MPP_FRAME_FMT_MASK) { + case MPP_FMT_YUV420SP : { + read_size = fread(buf, 1, align_w * align_h * 3 / 2, fp); + if (read_size != align_w * align_h * 3 / 2) { + mpp_err_f("read 420sp fbc file payload failed %d vs %d\n", + read_size, align_w * align_h * 3 / 2); + ret = MPP_NOK; + goto err; + } + } break; + case MPP_FMT_YUV422SP : { + read_size = fread(buf, 1, align_w * align_h * 2, fp); + if (read_size != align_w * align_h * 2) { + mpp_err_f("read 422sp fbc file payload failed %d vs %d\n", + read_size, align_w * align_h * 2); + ret = MPP_NOK; + goto err; + } + } break; + default : { + mpp_err_f("not supported fbc format %x\n", fmt); + } break; + } + + return MPP_OK; + } + switch (fmt) { case MPP_FMT_YUV420SP : { for (row = 0; row < height; row++) { @@ -521,6 +564,9 @@ MPP_RET name_to_frame_format(const char *name, MppFrameFormat *fmt) } else if (!strcmp(ext, "RGBA8888")) { mpp_log("found RGBA8888"); *fmt = MPP_FMT_RGBA8888; + } else if (!strcmp(ext, "fbc")) { + mpp_log("found fbc"); + *fmt = MPP_FMT_YUV420SP | MPP_FRAME_FBC_AFBC_V1; } else { ret = MPP_NOK; }