From f9e004bcc06d926a90dc1b45deaaeec50e4d700e Mon Sep 17 00:00:00 2001 From: Frank Du Date: Sat, 7 Oct 2023 09:09:17 +0800 Subject: [PATCH] st20/rx: use dynamic ext frame for both converter and non-converter mode (#522) Simple the usage, for non-converter use raw st20 dynamic ext mode, for convert, call the ext frame query in the frame ready callback. Signed-off-by: Frank Du --- .../rx_st20_pipeline_dyn_ext_frame_sample.c | 8 +- doc/external_frame.md | 141 ++++++++---------- include/st_pipeline_api.h | 33 +--- lib/src/st2110/pipeline/st20_pipeline_rx.c | 124 +++++++-------- lib/src/st2110/pipeline/st20_pipeline_rx.h | 1 + tests/src/st20p_test.cpp | 97 ++++-------- tests/src/tests.h | 1 - 7 files changed, 154 insertions(+), 251 deletions(-) diff --git a/app/sample/ext_frame/rx_st20_pipeline_dyn_ext_frame_sample.c b/app/sample/ext_frame/rx_st20_pipeline_dyn_ext_frame_sample.c index 3ea8a06eb..c1a1e6d4f 100644 --- a/app/sample/ext_frame/rx_st20_pipeline_dyn_ext_frame_sample.c +++ b/app/sample/ext_frame/rx_st20_pipeline_dyn_ext_frame_sample.c @@ -37,7 +37,7 @@ static int rx_st20p_frame_available(void* priv) { return 0; } -static int rx_st20p_query_ext_frame(void* priv, struct st20_ext_frame* ext_frame, +static int rx_st20p_query_ext_frame(void* priv, struct st_ext_frame* ext_frame, struct st20_rx_frame_meta* meta) { struct rx_st20p_sample_ctx* s = priv; int i = s->ext_idx; @@ -45,9 +45,9 @@ static int rx_st20p_query_ext_frame(void* priv, struct st20_ext_frame* ext_frame /* you can check the timestamp from lib by meta->timestamp */ - ext_frame->buf_addr = s->ext_frames[i].buf_addr; - ext_frame->buf_iova = s->ext_frames[i].buf_iova; - ext_frame->buf_len = s->ext_frames[i].buf_len; + ext_frame->addr[0] = s->ext_frames[i].buf_addr; + ext_frame->iova[0] = s->ext_frames[i].buf_iova; + ext_frame->size = s->ext_frames[i].buf_len; /* save your private data here get it from st_frame.opaque */ /* ext_frame->opaque = ?; */ diff --git a/doc/external_frame.md b/doc/external_frame.md index 29d3df918..92df77c54 100644 --- a/doc/external_frame.md +++ b/doc/external_frame.md @@ -68,9 +68,40 @@ static int tx_st20p_frame_done(void* priv, struct st_frame*frame) { } ``` +Others follow the general API flow. + ### 2.3 st20p_rx usages -#### 2.3.1 dedicated frames +#### 2.3.1 dynamic frames + +in ops, set the flag and set query_ext_frame callback + +```c +ops_rx.flags |= ST20P_RX_FLAG_EXT_FRAME; +ops_rx.query_ext_frame = st20p_rx_query_ext_frame; +//... +//implement the callback +static int st20p_rx_query_ext_frame(void* priv, st_ext_frame* ext_frame, + struct st20_rx_frame_meta* meta) { + ctx* s = (ctx*)priv; + uint8_t planes = st_frame_fmt_planes(fmt[i]); + + /* fill the ext frame */ + for (uint8_t plane = 0; plane < planes; plane++) { + ext_frame.addr[i] = your_addr[i]; + ext_frame.iova[i] = your_iova[i]; // must provide IOVA for no convert mode + ext_frame.linesize[i] = your_linesize[i]; + } + ext_frame.size = your_frame_size; + ext_frame.opaque = your_frame_handle; + + return 0; +} +``` + +User should maintain the lifetime of frames after st22p_rx_get_frame. + +#### 2.3.2 dedicated frames set the ext_frames array in ops @@ -90,57 +121,7 @@ ops_rx.ext_frames = ext_frames; rx_handle = st20p_rx_create(st, &ops_rx); ``` -use as the general API - -#### 2.3.2 dynamic frames - convert mode - -in ops, set the flag - -```c -ops_rx.flags |= ST20P_RX_FLAG_EXT_FRAME; -``` - -when receiving a frame, get the frame with ext_frame info and put the frame - -```c -struct st_ext_frame ext_frame; -uint8_t planes = st_frame_fmt_planes(frame->fmt); -for(int i = 0; i < planes; i++) { - ext_frame.addr[i] = your_addr[i]; - ext_frame.linesize[i] = your_linesize[i]; -} -ext_frame.size = your_frame_size; -ext_frame.opaque = your_frame_handle; -frame = st20p_rx_get_ext_frame(rx_handle, &ext_frame); -st20p_rx_put_frame(rx_handle, frame); // you can put it right away -use_frame(your_frame_handle); -``` - -user should maintain the lifetime of frames - -#### 2.3.3 dynamic frames - no convert mode - -(the same usage as raw video API 3.3.2) -implement and set query_ext_frame callback and set incomplete frame flag - -```c -// set the callback in ops -// set the incomplete frame flag -ops_rx.query_ext_frame = st20p_rx_query_ext_frame; -ops_rx.flags |= ST20P_RX_FLAG_RECEIVE_INCOMPLETE_FRAME; -//... -//implement the callback -static int st20p_rx_query_ext_frame(void* priv, st20_ext_frame*ext_frame, struct st20_rx_frame_meta* meta) { - ctx* s = (ctx*)priv; - ext_frame->buf_addr = your_addr[0]; - ext_frame->buf_iova = your_iova[0]; - ext_frame->buf_len = your_frame_size; - ext_frame->opaque = your_frame_handle; - return 0; -} -``` - -use as the general API, user should maintain the lifetime of frames +Others follow the general API flow. ### 2.4 st22p_tx usages @@ -183,6 +164,8 @@ static int tx_st22p_frame_done(void* priv, struct st_frame*frame) { } ``` +Others follow the general API flow. + ### 2.5 st22p_rx usages #### 2.5.1 dynamic frames @@ -201,17 +184,13 @@ static int st22p_rx_query_ext_frame(void* priv, st_ext_frame* ext_frame, /* fill the ext frame */ for (uint8_t plane = 0; plane < planes; plane++) { - ext_frame->linesize[plane] = st_frame_least_linesize(fmt[i], width[i], plane); - if (plane == 0) { - ext_frame->addr[plane] = xxx; - ext_frame->iova[plane] = xxx; - } else { - ext_frame->addr[plane] = xxx; - ext_frame->iova[plane] = xxx; - } + ext_frame.addr[i] = your_addr[i]; + ext_frame.iova[i] = your_iova[i]; // must provide IOVA for no convert mode + ext_frame.linesize[i] = your_linesize[i]; } - ext_frame->size = xxx; - ext_frame->opaque = xxx; + ext_frame.size = your_frame_size; + ext_frame.opaque = your_frame_handle; + return 0; } ``` @@ -256,25 +235,7 @@ st20_tx_set_ext_frame(s->handle, idx, &ext_frame); ### 3.3 st20_rx usages -#### 3.3.1 dedicated frames - -set the ext_frames array in ops - -```c -struct st20_ext_frame ext_frames[fb_cnt]; -for (int i = 0; i < fb_cnt;++i) { - ext_frames[i].buf_addr = your_addr; - ext_frames[i].buf_iova = your_iova; - ext_frames[i].buf_len = your_frame_size; - ext_frames[i].opaque = your_frame_handle; -} -ops_rx.ext_frames = ext_frames; -rx_handle = st20_rx_create(st, &ops_rx); -``` - -use as the general API - -#### 3.3.2 dynamic frames +#### 3.3.1 dynamic frames implement and set query_ext_frame callback and set incomplete frame flag @@ -296,3 +257,21 @@ static int rx_query_ext_frame(void* priv, st20_ext_frame*ext_frame, struct st20_ ``` use as the general API, user should maintain the lifetime of frames + +#### 3.3.2 dedicated frames + +set the ext_frames array in ops + +```c +struct st20_ext_frame ext_frames[fb_cnt]; +for (int i = 0; i < fb_cnt;++i) { + ext_frames[i].buf_addr = your_addr; + ext_frames[i].buf_iova = your_iova; + ext_frames[i].buf_len = your_frame_size; + ext_frames[i].opaque = your_frame_handle; +} +ops_rx.ext_frames = ext_frames; +rx_handle = st20_rx_create(st, &ops_rx); +``` + +Others follow the general API flow. diff --git a/include/st_pipeline_api.h b/include/st_pipeline_api.h index d971dded7..4cb73b6bb 100644 --- a/include/st_pipeline_api.h +++ b/include/st_pipeline_api.h @@ -369,7 +369,7 @@ enum st22_quality_mode { #define ST22P_TX_FLAG_DISABLE_BULK (MTL_BIT32(7)) /** * Flag bit in flags of struct st22p_tx_ops. - * Lib uses user allocated memory for frames. + * Lib uses user dynamic allocated memory for frames. * The external frames are provided by calling * st22p_tx_put_ext_frame. */ @@ -387,7 +387,7 @@ enum st22_quality_mode { #define ST20P_TX_FLAG_USER_R_MAC (MTL_BIT32(1)) /** * Flag bit in flags of struct st20p_tx_ops. - * Lib uses user allocated memory for frames. + * Lib uses user dynamic allocated memory for frames. * The external frames are provided by calling * st20p_tx_put_ext_frame. */ @@ -455,8 +455,8 @@ enum st22_quality_mode { #define ST22P_RX_FLAG_SIMULATE_PKT_LOSS (MTL_BIT32(3)) /** * Flag bit in flags of struct st22p_rx_ops. - * Enable the external frame mode, and user must provide a query callback(query_ext_frame - * in st22p_rx_ops) to let MTL can get the frame when needed. + * Enable the dynamic external frame mode, and user must provide a query + * callback(query_ext_frame in st22p_rx_ops) to let MTL can get the frame when needed. */ #define ST22P_RX_FLAG_EXT_FRAME (MTL_BIT32(4)) @@ -480,9 +480,9 @@ enum st22_quality_mode { #define ST20P_RX_FLAG_ENABLE_VSYNC (MTL_BIT32(1)) /** * Flag bit in flags of struct st20p_rx_ops. - * Only used for internal convert mode. - * The external frames are provided by calling - * st20p_rx_get_ext_frame. + * Enable the dynamic external frame mode, and user must provide a query + * callback(query_ext_frame in st20p_rx_ops) to let MTL can get the frame when needed. + * Note to enable ST20P_RX_FLAG_RECEIVE_INCOMPLETE_FRAME also for non-converter mode. */ #define ST20P_RX_FLAG_EXT_FRAME (MTL_BIT32(2)) /** @@ -855,11 +855,10 @@ struct st20p_rx_ops { struct st_rx_rtcp_ops* rtcp; /** * Optional. Callback when the lib query next external frame's data address. - * Only for non-convert mode with ST20P_RX_FLAG_RECEIVE_INCOMPLETE_FRAME. * And only non-block method can be used within this callback as it run from lcore * tasklet routine. */ - int (*query_ext_frame)(void* priv, struct st20_ext_frame* ext_frame, + int (*query_ext_frame)(void* priv, struct st_ext_frame* ext_frame, struct st20_rx_frame_meta* meta); /** * Optional. event callback, lib will call this when there is some event happened. @@ -1550,22 +1549,6 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops); */ int st20p_rx_free(st20p_rx_handle handle); -/** - * Get one rx frame from the rx st2110-20 pipeline session with external framebuffer. - * This is only used for internal convert mode, the convert is done in this call. - * Call st20p_rx_put_frame to return the frame to session. - * - * @param handle - * The handle to the rx st2110-20 pipeline session. - * @param ext_frame - * The pointer to the structure describing external framebuffer. - * @return - * - NULL if no available frame in the session. - * - Otherwise, the frame pointer. - */ -struct st_frame* st20p_rx_get_ext_frame(st20p_rx_handle handle, - struct st_ext_frame* ext_frame); - /** * Get one rx frame from the rx st2110-20 pipeline session. * Call st20p_rx_put_frame to return the frame to session. diff --git a/lib/src/st2110/pipeline/st20_pipeline_rx.c b/lib/src/st2110/pipeline/st20_pipeline_rx.c index 53bd3328f..d72fc684a 100644 --- a/lib/src/st2110/pipeline/st20_pipeline_rx.c +++ b/lib/src/st2110/pipeline/st20_pipeline_rx.c @@ -140,6 +140,36 @@ static int rx_st20p_frame_ready(void* priv, void* frame, return -EBUSY; } + /* query the ext frame for no convert mode */ + if (ctx->dynamic_ext_frame && !ctx->derive) { + struct st_ext_frame ext_frame; + memset(&ext_frame, 0x0, sizeof(ext_frame)); + int ret = ctx->ops.query_ext_frame(ctx->ops.priv, &ext_frame, meta); + if (ret < 0) { + err("%s(%d), query_ext_frame for frame %u fail %d\n", __func__, ctx->idx, + framebuff->idx, ret); + mt_pthread_mutex_unlock(&ctx->lock); + return ret; + } + + uint8_t planes = st_frame_fmt_planes(framebuff->dst.fmt); + for (int plane = 0; plane < planes; plane++) { + framebuff->dst.addr[plane] = ext_frame.addr[plane]; + framebuff->dst.iova[plane] = ext_frame.iova[plane]; + framebuff->dst.linesize[plane] = ext_frame.linesize[plane]; + } + framebuff->dst.data_size = framebuff->dst.buffer_size = ext_frame.size; + framebuff->dst.opaque = ext_frame.opaque; + framebuff->dst.flags |= ST_FRAME_FLAG_EXT_BUF; + ret = st_frame_sanity_check(&framebuff->dst); + if (ret < 0) { + err("%s(%d), ext_frame check frame %u fail %d\n", __func__, ctx->idx, + framebuff->idx, ret); + mt_pthread_mutex_unlock(&ctx->lock); + return ret; + } + } + framebuff->src.addr[0] = frame; framebuff->src.data_size = meta->frame_total_size; framebuff->src.second_field = framebuff->dst.second_field = meta->second_field; @@ -209,12 +239,19 @@ static int rx_st20p_query_ext_frame(void* priv, struct st20_ext_frame* ext_frame return -EBUSY; } - ret = ctx->ops.query_ext_frame(ctx->ops.priv, ext_frame, meta); + struct st_ext_frame ext_st; + memset(&ext_st, 0, sizeof(ext_st)); + ret = ctx->ops.query_ext_frame(ctx->ops.priv, &ext_st, meta); if (ret < 0) { mt_pthread_mutex_unlock(&ctx->lock); return -EBUSY; } - framebuff->src.opaque = ext_frame->opaque; + /* only 1 plane for no converter mode */ + ext_frame->buf_addr = ext_st.addr[0]; + ext_frame->buf_iova = ext_st.iova[0]; + ext_frame->buf_len = ext_st.size; + ext_frame->opaque = ext_st.opaque; + framebuff->src.opaque = ext_st.opaque; mt_pthread_mutex_unlock(&ctx->lock); return 0; @@ -402,7 +439,7 @@ static int rx_st20p_create_transport(struct mtl_main_impl* impl, struct st20p_rx } if (ops->query_ext_frame) { if (!(ops->flags & ST20P_RX_FLAG_RECEIVE_INCOMPLETE_FRAME)) { - err("%s, pls enable incomplete frame flag for query ext mode\n", __func__); + err("%s, pls enable incomplete frame flag for derive query ext mode\n", __func__); if (trans_ext_frames) mt_rte_free(trans_ext_frames); return -EINVAL; } @@ -584,74 +621,6 @@ static int rx_st20p_get_converter(struct mtl_main_impl* impl, struct st20p_rx_ct return 0; } -struct st_frame* st20p_rx_get_ext_frame(st20p_rx_handle handle, - struct st_ext_frame* ext_frame) { - struct st20p_rx_ctx* ctx = handle; - int idx = ctx->idx; - struct st20p_rx_frame* framebuff; - struct st_frame* frame; - - if (ctx->type != MT_ST20_HANDLE_PIPELINE_RX) { - err("%s(%d), invalid type %d\n", __func__, idx, ctx->type); - return NULL; - } - - if (!(ctx->ops.flags & ST20P_RX_FLAG_EXT_FRAME)) { - err("%s(%d), EXT_FRAME flag not enabled\n", __func__, idx); - return NULL; - } - - if (!ctx->internal_converter) { - err("%s(%d), only used for internal converter\n", __func__, idx); - return NULL; - } - - if (!ctx->ready) return NULL; /* not ready */ - - mt_pthread_mutex_lock(&ctx->lock); - - framebuff = - rx_st20p_next_available(ctx, ctx->framebuff_consumer_idx, ST20P_RX_FRAME_READY); - /* not any ready frame */ - if (!framebuff) { - mt_pthread_mutex_unlock(&ctx->lock); - return NULL; - } - for (int plane = 0; plane < st_frame_fmt_planes(framebuff->dst.fmt); plane++) { - framebuff->dst.addr[plane] = ext_frame->addr[plane]; - framebuff->dst.iova[plane] = ext_frame->iova[plane]; - framebuff->dst.linesize[plane] = ext_frame->linesize[plane]; - } - framebuff->dst.data_size = framebuff->dst.buffer_size = ext_frame->size; - framebuff->dst.opaque = ext_frame->opaque; - framebuff->dst.flags |= ST_FRAME_FLAG_EXT_BUF; - int ret = st_frame_sanity_check(&framebuff->dst); - if (ret < 0) { - err("%s, ext framebuffer sanity check fail %d fb_idx %d\n", __func__, ret, - ctx->framebuff_consumer_idx); - mt_pthread_mutex_unlock(&ctx->lock); - return NULL; - } - ctx->internal_converter->convert_func(&framebuff->src, &framebuff->dst); - - framebuff->stat = ST20P_RX_FRAME_IN_USER; - /* point to next */ - ctx->framebuff_consumer_idx = rx_st20p_next_idx(ctx, framebuff->idx); - - mt_pthread_mutex_unlock(&ctx->lock); - - dbg("%s(%d), frame %u succ\n", __func__, idx, framebuff->idx); - frame = &framebuff->dst; - if (framebuff->user_meta_data_size) { - frame->user_meta = framebuff->user_meta; - frame->user_meta_size = framebuff->user_meta_data_size; - } else { - frame->user_meta = NULL; - frame->user_meta_size = 0; - } - return frame; -} - struct st_frame* st20p_rx_get_frame(st20p_rx_handle handle) { struct st20p_rx_ctx* ctx = handle; int idx = ctx->idx; @@ -749,6 +718,13 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) { return NULL; } + if (ops->flags & ST20P_RX_FLAG_EXT_FRAME) { + if (!ops->query_ext_frame) { + err("%s, no query_ext_frame query callback for dynamic ext frame mode\n", __func__); + return NULL; + } + } + dst_size = st_frame_size(ops->output_fmt, ops->width, ops->height, ops->interlaced); if (!dst_size) { err("%s(%d), get dst size fail\n", __func__, idx); @@ -764,6 +740,7 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) { ctx->idx = idx; ctx->ready = false; ctx->derive = st_frame_fmt_equal_transport(ops->output_fmt, ops->transport_fmt); + ctx->dynamic_ext_frame = (ops->flags & ST20P_RX_FLAG_EXT_FRAME) ? true : false; ctx->impl = impl; ctx->type = MT_ST20_HANDLE_PIPELINE_RX; ctx->dst_size = dst_size; @@ -807,8 +784,9 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) { /* all ready now */ ctx->ready = true; - notice("%s(%d), transport fmt %s, output fmt %s\n", __func__, idx, - st20_frame_fmt_name(ops->transport_fmt), st_frame_fmt_name(ops->output_fmt)); + notice("%s(%d), transport fmt %s, output fmt %s, dynamic_ext_frame %s\n", __func__, idx, + st20_frame_fmt_name(ops->transport_fmt), st_frame_fmt_name(ops->output_fmt), + ctx->dynamic_ext_frame ? "true" : "false"); st20p_rx_idx++; if (ctx->ops.notify_frame_available) { /* notify app */ diff --git a/lib/src/st2110/pipeline/st20_pipeline_rx.h b/lib/src/st2110/pipeline/st20_pipeline_rx.h index 4bf1d72bf..58e9c8f7f 100644 --- a/lib/src/st2110/pipeline/st20_pipeline_rx.h +++ b/lib/src/st2110/pipeline/st20_pipeline_rx.h @@ -48,6 +48,7 @@ struct st20p_rx_ctx { struct st_frame_converter* internal_converter; bool ready; bool derive; + bool dynamic_ext_frame; size_t dst_size; diff --git a/tests/src/st20p_test.cpp b/tests/src/st20p_test.cpp index 9ae41712e..8712d1461 100644 --- a/tests/src/st20p_test.cpp +++ b/tests/src/st20p_test.cpp @@ -499,25 +499,12 @@ static void test_internal_st20p_rx_frame_thread(void* args) { dbg("%s(%d), start\n", __func__, s->idx); while (!s->stop) { - if (s->rx_get_ext) { - frame = - st20p_rx_get_ext_frame((st20p_rx_handle)handle, &s->p_ext_frames[s->ext_idx]); - if (!frame) { /* no frame */ - lck.lock(); - if (!s->stop) s->cv.wait(lck); - lck.unlock(); - continue; - } - s->ext_idx++; - if (s->ext_idx >= s->fb_cnt) s->ext_idx = 0; - } else { - frame = st20p_rx_get_frame((st20p_rx_handle)handle); - if (!frame) { /* no frame */ - lck.lock(); - if (!s->stop) s->cv.wait(lck); - lck.unlock(); - continue; - } + frame = st20p_rx_get_frame((st20p_rx_handle)handle); + if (!frame) { /* no frame */ + lck.lock(); + if (!s->stop) s->cv.wait(lck); + lck.unlock(); + continue; } if (frame->opaque) { @@ -579,7 +566,7 @@ static void test_internal_st20p_rx_frame_thread(void* args) { dbg("%s(%d), stop\n", __func__, s->idx); } -static int test_st20p_rx_query_ext_frame(void* priv, st20_ext_frame* ext_frame, +static int test_st20p_rx_query_ext_frame(void* priv, st_ext_frame* ext_frame, struct st20_rx_frame_meta* meta) { tests_context* s = (tests_context*)priv; int i = s->ext_idx; @@ -590,9 +577,7 @@ static int test_st20p_rx_query_ext_frame(void* priv, st20_ext_frame* ext_frame, return -EIO; } - ext_frame->buf_addr = s->p_ext_frames[i].addr[0]; - ext_frame->buf_iova = s->p_ext_frames[i].iova[0]; - ext_frame->buf_len = s->p_ext_frames[i].size; + *ext_frame = s->p_ext_frames[i]; s->ext_fb_in_use[i] = true; ext_frame->opaque = &s->ext_fb_in_use[i]; @@ -610,9 +595,8 @@ struct st20p_rx_digest_test_para { int timeout_ms; bool tx_ext; bool rx_ext; - bool rx_get_ext; + bool rx_dedicated_ext; bool check_fps; - bool dynamic; enum st_test_level level; int fb_cnt; bool user_timestamp; @@ -635,9 +619,8 @@ static void test_st20p_init_rx_digest_para(struct st20p_rx_digest_test_para* par para->timeout_ms = 0; para->tx_ext = false; para->rx_ext = false; - para->rx_get_ext = false; + para->rx_dedicated_ext = false; para->check_fps = true; - para->dynamic = false; para->level = ST_TEST_LEVEL_MANDATORY; para->user_timestamp = false; para->vsync = true; @@ -889,7 +872,6 @@ static void st20p_rx_digest_test(enum st_fps fps[], int width[], int height[], test_ctx_rx[i]->fmt = rx_fmt[i]; test_ctx_rx[i]->user_timestamp = para->user_timestamp; test_ctx_rx[i]->user_meta = para->user_meta; - test_ctx_rx[i]->rx_get_ext = para->rx_get_ext; test_ctx_rx[i]->frame_size = st_frame_size(rx_fmt[i], width[i], height[i], para->interlace); /* copy sha */ @@ -963,14 +945,17 @@ static void st20p_rx_digest_test(enum st_fps fps[], int width[], int height[], ops_rx.framebuff_cnt = test_ctx_rx[i]->fb_cnt; ops_rx.notify_frame_available = test_st20p_rx_frame_available; ops_rx.notify_event = test_ctx_notify_event; - if (para->dynamic) { - ops_rx.query_ext_frame = test_st20p_rx_query_ext_frame; - ops_rx.flags |= ST20P_RX_FLAG_RECEIVE_INCOMPLETE_FRAME; - } else if (para->rx_ext && !para->rx_get_ext) { - ops_rx.ext_frames = test_ctx_rx[i]->p_ext_frames; + if (para->rx_ext) { + if (para->rx_dedicated_ext) { + ops_rx.ext_frames = test_ctx_rx[i]->p_ext_frames; + } else { + ops_rx.flags |= ST20P_RX_FLAG_EXT_FRAME; + ops_rx.query_ext_frame = test_st20p_rx_query_ext_frame; + if (st_frame_fmt_equal_transport(ops_rx.output_fmt, ops_rx.transport_fmt)) + ops_rx.flags |= ST20P_RX_FLAG_RECEIVE_INCOMPLETE_FRAME; + } } if (para->vsync) ops_rx.flags |= ST20P_RX_FLAG_ENABLE_VSYNC; - if (para->rx_get_ext) ops_rx.flags |= ST20P_RX_FLAG_EXT_FRAME; if (para->pkt_convert) ops_rx.flags |= ST20P_RX_FLAG_PKT_CONVERT; struct st_rx_rtcp_ops ops_rx_rtcp; @@ -1075,10 +1060,7 @@ static void st20p_rx_digest_test(enum st_fps fps[], int width[], int height[], info("%s, session %d fb_rec %d framerate %f:%f\n", __func__, i, test_ctx_rx[i]->fb_rec, framerate_rx[i], expect_framerate_rx[i]); EXPECT_GT(test_ctx_rx[i]->fb_rec, 0); - if (para->dynamic) - EXPECT_LE(test_ctx_rx[i]->incomplete_frame_cnt, 4); - else - EXPECT_LE(test_ctx_rx[i]->incomplete_frame_cnt, 2); + EXPECT_LE(test_ctx_rx[i]->incomplete_frame_cnt, 4); EXPECT_EQ(test_ctx_rx[i]->sha_fail_cnt, 0); EXPECT_LE(test_ctx_rx[i]->user_meta_fail_cnt, 2); if (para->check_fps) { @@ -1312,7 +1294,6 @@ TEST(St20p, rx_ext_digest_1080p_no_convert_s2) { para.sessions = 2; para.device = ST_PLUGIN_DEVICE_TEST_INTERNAL; para.rx_ext = true; - para.level = ST_TEST_LEVEL_ALL; st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } @@ -1350,11 +1331,12 @@ TEST(St20p, rx_ext_digest_1080p_packet_convert_s2) { para.rx_ext = true; para.check_fps = false; para.pkt_convert = true; + para.level = ST_TEST_LEVEL_ALL; st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } -TEST(St20p, tx_rx_ext_digest_1080p_no_convert_s2) { +TEST(St20p, ext_digest_1080p_no_convert_s2) { enum st_fps fps[2] = {ST_FPS_P50, ST_FPS_P59_94}; int width[2] = {1920, 1920}; int height[2] = {1080, 1080}; @@ -1375,7 +1357,7 @@ TEST(St20p, tx_rx_ext_digest_1080p_no_convert_s2) { st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } -TEST(St20p, tx_rx_ext_digest_1080p_convert_s2) { +TEST(St20p, ext_digest_1080p_convert_s2) { enum st_fps fps[2] = {ST_FPS_P50, ST_FPS_P59_94}; int width[2] = {1920, 1920}; int height[2] = {1080, 1080}; @@ -1395,27 +1377,7 @@ TEST(St20p, tx_rx_ext_digest_1080p_convert_s2) { st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } -TEST(St20p, rx_dynamic_ext_digest_1080p_no_convert_s2) { - enum st_fps fps[2] = {ST_FPS_P29_97, ST_FPS_P59_94}; - int width[2] = {1920, 1280}; - int height[2] = {1080, 720}; - enum st_frame_fmt tx_fmt[2] = {ST_FRAME_FMT_YUV422RFC4175PG2BE10, - ST_FRAME_FMT_YUV422RFC4175PG2BE10}; - enum st20_fmt t_fmt[2] = {ST20_FMT_YUV_422_10BIT, ST20_FMT_YUV_422_10BIT}; - enum st_frame_fmt rx_fmt[2] = {ST_FRAME_FMT_YUV422RFC4175PG2BE10, - ST_FRAME_FMT_YUV422RFC4175PG2BE10}; - - struct st20p_rx_digest_test_para para; - test_st20p_init_rx_digest_para(¶); - para.sessions = 2; - para.device = ST_PLUGIN_DEVICE_TEST_INTERNAL; - para.rx_ext = true; - para.dynamic = true; - - st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); -} - -TEST(St20p, rx_get_ext_digest_1080p_convert_s2) { +TEST(St20p, rx_dedicated_ext_digest_1080p_convert_s2) { enum st_fps fps[2] = {ST_FPS_P29_97, ST_FPS_P59_94}; int width[2] = {1920, 1280}; int height[2] = {1080, 720}; @@ -1428,12 +1390,12 @@ TEST(St20p, rx_get_ext_digest_1080p_convert_s2) { para.sessions = 2; para.device = ST_PLUGIN_DEVICE_TEST_INTERNAL; para.rx_ext = true; - para.rx_get_ext = true; + para.rx_dedicated_ext = true; st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } -TEST(St20p, tx_rx_ext_digest_1080p_convert_with_padding_s2) { +TEST(St20p, ext_digest_1080p_convert_with_padding_s2) { enum st_fps fps[2] = {ST_FPS_P59_94, ST_FPS_P59_94}; int width[2] = {1920, 1920}; int height[2] = {1080, 1080}; @@ -1453,7 +1415,7 @@ TEST(St20p, tx_rx_ext_digest_1080p_convert_with_padding_s2) { st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } -TEST(St20p, rx_get_ext_digest_1080p_convert_with_padding_s2) { +TEST(St20p, rx_dedicated_ext_digest_1080p_convert_with_padding_s2) { enum st_fps fps[2] = {ST_FPS_P59_94, ST_FPS_P59_94}; int width[2] = {1920, 1920}; int height[2] = {1080, 1080}; @@ -1467,14 +1429,14 @@ TEST(St20p, rx_get_ext_digest_1080p_convert_with_padding_s2) { para.device = ST_PLUGIN_DEVICE_TEST_INTERNAL; para.tx_ext = true; para.rx_ext = true; - para.rx_get_ext = true; + para.rx_dedicated_ext = true; para.check_fps = false; para.line_padding_size = 512; st20p_rx_digest_test(fps, width, height, tx_fmt, t_fmt, rx_fmt, ¶); } -TEST(St20p, tx_rx_ext_digest_1080p_packet_convert_with_padding_s2) { +TEST(St20p, ext_digest_1080p_packet_convert_with_padding_s2) { enum st_fps fps[2] = {ST_FPS_P59_94, ST_FPS_P59_94}; int width[2] = {1920, 1920}; int height[2] = {1080, 1080}; @@ -1488,6 +1450,7 @@ TEST(St20p, tx_rx_ext_digest_1080p_packet_convert_with_padding_s2) { para.device = ST_PLUGIN_DEVICE_TEST_INTERNAL; para.tx_ext = true; para.rx_ext = true; + para.rx_dedicated_ext = true; para.check_fps = false; para.line_padding_size = 1024; para.pkt_convert = true; diff --git a/tests/src/tests.h b/tests/src/tests.h index e872cd1bc..bc3bbf96c 100644 --- a/tests/src/tests.h +++ b/tests/src/tests.h @@ -215,7 +215,6 @@ class tests_context { int ext_idx = 0; bool ext_fb_in_use[3] = {false}; /* assume 3 framebuffer */ mtl_dma_mem_handle dma_mem = NULL; - bool rx_get_ext = false; bool user_pacing = false; /* user timestamp which advanced by 1 for every frame */