mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
[test]: update sample for fbc support
The FBC data should be in this form: +---------------------+ | header (4K aligned) | +---------------------+ | | | payload data | | | +---------------------+ The payload data size is equal to the orignal format size. Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I2855c89db43c3e2cc302ac40e96e36ef6147f041
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user