From 6c7ffdfb26c51a3a3cbf18549f6f5c5bd79af949 Mon Sep 17 00:00:00 2001 From: DawidWesierski4 <92673141+DawidWesierski4@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:58:11 +0200 Subject: [PATCH 01/12] Add Exemptions for .patch Files in .gitignore (#971) Exclude .patch files from being ignored in the patch and ecosystem directories --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 7cad32293..bb1bc4f93 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,8 @@ dkms.conf .* *.log *.patch +!patches/*.patch +!ecosystem/*.patch *.diff *.yuv *.pcapng From ef90ace25b26f079b7c1c7e30db85e870219cf55 Mon Sep 17 00:00:00 2001 From: PanKaker <92713340+PanKaker@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:17:33 +0200 Subject: [PATCH 02/12] =?UTF-8?q?Fix:=20Checking=20ret=20code=20of=20the?= =?UTF-8?q?=20created=20buffer=20when=20MTL=5FGPU=5FDIRECT=5FENABLED=20i?= =?UTF-8?q?=E2=80=A6=20(#974)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes MTL_GPU_DIRECT_ENABLED feature. The ret code of created buffers are checked before working with the frame. Co-authored-by: DawidWesierski4 --- lib/src/st2110/st_rx_video_session.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/st2110/st_rx_video_session.c b/lib/src/st2110/st_rx_video_session.c index 147216b4c..5e9954d1b 100644 --- a/lib/src/st2110/st_rx_video_session.c +++ b/lib/src/st2110/st_rx_video_session.c @@ -457,9 +457,13 @@ static int rv_alloc_frames(struct mtl_main_impl* impl, } else { #ifdef MTL_GPU_DIRECT_ENABLED if (rv_framebuffer_in_gpu_direct_vram(s)) { - info("%s rv_framebuffer_in_gpu_direct_vram \n", __func__); + info("%s: using gpu direct feature.\n", __func__); GpuContext* gpu = s->ops.gpu_context; ret = gpu_allocate_shared_buffer(gpu, &frame, size); + if (ret < 0) { + err("%s: failed to allocate gpu memory on vram. ret: %d\n", __func__, ret); + return -ENOMEM; + } } else #endif /* MTL_GPU_DIRECT_ENABLED */ frame = mt_rte_zmalloc_socket(size, soc_id); From 664344a8aa14e6c8d706b76b538265a93afc51f1 Mon Sep 17 00:00:00 2001 From: DawidWesierski4 <92673141+DawidWesierski4@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:18:37 +0200 Subject: [PATCH 03/12] Fix: fix and refactor st41 possible errors (#972) * Fix possible null pointer reference in app_tx_fmd_init * Fix: coveriy out of band issue * Increate quality of tx_fastmetadata_session_build_packet code * coverity fix: fixing less-than-zero comparison * add st41 context app multithread access error * Add error message when the st41 functionality of RxTx app detects multithread access to the contex app resource, which should not be shared. Fixes: c43152d9 Co-developed-by: Aleksandr Ivanov Co-developed-by: Kolelis, Szymon --- app/src/parse_json.c | 6 ++++-- app/src/tx_fastmetadata_app.c | 22 ++++++++++++++------- lib/src/st2110/st_tx_fastmetadata_session.c | 18 +++++++++++++---- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/src/parse_json.c b/app/src/parse_json.c index e9f3708bc..92c8634a3 100644 --- a/app/src/parse_json.c +++ b/app/src/parse_json.c @@ -1255,7 +1255,7 @@ static int st_json_parse_tx_fmd(int idx, json_object* fmd_obj, st_json_object_object_get(fmd_obj, "fastmetadata_data_item_type"); if (fmd_dit_obj) { uint32_t fmd_dit = json_object_get_int(fmd_dit_obj); - if (fmd_dit < 0 || fmd_dit > 0x3fffff) { + if (fmd_dit > 0x3fffff) { err("%s, invalid fastmetadata_data_item_type 0x%x\n", __func__, fmd_dit); return -ST_JSON_NOT_VALID; } @@ -1269,8 +1269,10 @@ static int st_json_parse_tx_fmd(int idx, json_object* fmd_obj, /* parse fmd data item K-bit */ json_object* fmd_k_bit_obj = st_json_object_object_get(fmd_obj, "fastmetadata_k_bit"); if (fmd_k_bit_obj) { + /* assign to uint and check if the value more then 1 + * (the value should be in range of [0,1]) */ uint8_t fmd_k_bit = json_object_get_int(fmd_k_bit_obj); - if (fmd_k_bit < 0 || fmd_k_bit > 1) { + if (fmd_k_bit > 1) { err("%s, invalid fastmetadata_k_bit 0x%x\n", __func__, fmd_k_bit); return -ST_JSON_NOT_VALID; } diff --git a/app/src/tx_fastmetadata_app.c b/app/src/tx_fastmetadata_app.c index b3c422ecf..2b9dab931 100644 --- a/app/src/tx_fastmetadata_app.c +++ b/app/src/tx_fastmetadata_app.c @@ -94,21 +94,29 @@ static void* app_tx_fmd_frame_thread(void* arg) { info("%s(%d), start\n", __func__, idx); while (!s->st41_app_thread_stop) { st_pthread_mutex_lock(&s->st41_wake_mutex); - producer_idx = s->framebuff_producer_idx; - framebuff = &s->framebuffs[producer_idx]; - if (ST_TX_FRAME_FREE != framebuff->stat) { - /* not in free */ - if (!s->st41_app_thread_stop) + framebuff = &s->framebuffs[s->framebuff_producer_idx]; + + if (framebuff->stat != ST_TX_FRAME_FREE) { + if (!s->st41_app_thread_stop) { st_pthread_cond_wait(&s->st41_wake_cond, &s->st41_wake_mutex); + } st_pthread_mutex_unlock(&s->st41_wake_mutex); continue; } + + producer_idx = s->framebuff_producer_idx; st_pthread_mutex_unlock(&s->st41_wake_mutex); struct st41_frame* frame_addr = st41_tx_get_framebuffer(s->handle, producer_idx); app_tx_fmd_build_frame(s, frame_addr); st_pthread_mutex_lock(&s->st41_wake_mutex); + if (producer_idx != s->framebuff_producer_idx) { + err("%s(%d), Apps can't share the context app structure\n", __func__, idx); + st_pthread_mutex_unlock(&s->st41_wake_mutex); + return NULL; + } + framebuff->size = sizeof(*frame_addr); framebuff->stat = ST_TX_FRAME_READY; /* point to next */ @@ -440,8 +448,8 @@ static int app_tx_fmd_init(struct st_app_context* ctx, ops.notify_rtp_done = app_tx_fmd_rtp_done; ops.framebuff_cnt = s->framebuff_cnt; ops.fps = fmd ? fmd->info.fmd_fps : ST_FPS_P59_94; - ops.fmd_dit = fmd->info.fmd_dit; - ops.fmd_k_bit = fmd->info.fmd_k_bit; + ops.fmd_dit = fmd ? fmd->info.fmd_dit : 0; + ops.fmd_k_bit = fmd ? fmd->info.fmd_k_bit : 0; s->st41_pcap_input = false; ops.type = fmd ? fmd->info.type : ST41_TYPE_FRAME_LEVEL; ops.interlaced = fmd ? fmd->info.interlaced : false; diff --git a/lib/src/st2110/st_tx_fastmetadata_session.c b/lib/src/st2110/st_tx_fastmetadata_session.c index adfc49e59..83dc092ef 100644 --- a/lib/src/st2110/st_tx_fastmetadata_session.c +++ b/lib/src/st2110/st_tx_fastmetadata_session.c @@ -389,15 +389,20 @@ static int tx_fastmetadata_session_update_redundant( static void tx_fastmetadata_session_build_packet( struct st_tx_fastmetadata_session_impl* s, struct rte_mbuf* pkt) { - struct mt_udp_hdr* hdr; + struct st41_fmd_hdr* hdr; struct rte_ipv4_hdr* ipv4; struct rte_udp_hdr* udp; struct st41_rtp_hdr* rtp; - hdr = rte_pktmbuf_mtod(pkt, struct mt_udp_hdr*); + if (rte_pktmbuf_data_len(pkt) < sizeof(*hdr)) { + err("%s: packet is less than fmd hdr size", __func__); + return; + } + + hdr = rte_pktmbuf_mtod(pkt, struct st41_fmd_hdr*); ipv4 = &hdr->ipv4; udp = &hdr->udp; - rtp = (struct st41_rtp_hdr*)&udp[1]; + rtp = &hdr->rtp; /* copy the hdr: eth, ip, udp */ rte_memcpy(&hdr->eth, &s->hdr[MTL_SESSION_PORT_P].eth, sizeof(hdr->eth)); @@ -417,7 +422,6 @@ static void tx_fastmetadata_session_build_packet( rtp->base.tmstamp = htonl(s->pacing.rtp_time_stamp); /* Set place for payload just behind rtp header */ - uint8_t* payload = (uint8_t*)&rtp[1]; struct st_frame_trans* frame_info = &s->st41_frames[s->st41_frame_idx]; uint32_t offset = s->st41_pkt_idx * s->max_pkt_len; void* src_addr = frame_info->addr + offset; @@ -426,6 +430,12 @@ static void tx_fastmetadata_session_build_packet( uint16_t data_item_length = (data_item_length_bytes + 3) / 4; /* expressed in number of 4-byte words */ + if (rte_pktmbuf_data_len(pkt) < sizeof(*hdr) + data_item_length) { + err("%s: packet doesn't contain RTP payload", __func__); + return; + } + + uint8_t* payload = (uint8_t*)(rtp + 1); if (!(data_item_length_bytes > s->max_pkt_len)) { int offset = 0; for (int i = 0; i < data_item_length_bytes; i++) { From 3c74fdc808727b7780d12344a198c4d35c88221a Mon Sep 17 00:00:00 2001 From: DawidWesierski4 <92673141+DawidWesierski4@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:56:27 +0200 Subject: [PATCH 04/12] Fix: FMD Adjust the Space Memory Check (#975) In the FMD build packet, we were checking the space using a value that represented 4-byte chunks. This has been fixed by multiplying the value by 4. Fixes: 664344a8 Co-authored-by: Kolelis, Szymon --- lib/src/st2110/st_tx_fastmetadata_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/st2110/st_tx_fastmetadata_session.c b/lib/src/st2110/st_tx_fastmetadata_session.c index 83dc092ef..65aa5bae7 100644 --- a/lib/src/st2110/st_tx_fastmetadata_session.c +++ b/lib/src/st2110/st_tx_fastmetadata_session.c @@ -430,7 +430,7 @@ static void tx_fastmetadata_session_build_packet( uint16_t data_item_length = (data_item_length_bytes + 3) / 4; /* expressed in number of 4-byte words */ - if (rte_pktmbuf_data_len(pkt) < sizeof(*hdr) + data_item_length) { + if (rte_pktmbuf_data_len(pkt) < sizeof(*hdr) + data_item_length_bytes ) { err("%s: packet doesn't contain RTP payload", __func__); return; } From 30597528e9301da24d1418dd5d82ff1ed1e30c80 Mon Sep 17 00:00:00 2001 From: PanKaker <92713340+PanKaker@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:14:12 +0200 Subject: [PATCH 05/12] Fix: code formatting (#978) This PR will fix code formatting of the last fixes covered in: https://github.com/OpenVisualCloud/Media-Transport-Library/pulls?q=is%3Apr+is%3Aclosed --- lib/src/st2110/st_tx_fastmetadata_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/st2110/st_tx_fastmetadata_session.c b/lib/src/st2110/st_tx_fastmetadata_session.c index 65aa5bae7..d6d9bd0ee 100644 --- a/lib/src/st2110/st_tx_fastmetadata_session.c +++ b/lib/src/st2110/st_tx_fastmetadata_session.c @@ -430,7 +430,7 @@ static void tx_fastmetadata_session_build_packet( uint16_t data_item_length = (data_item_length_bytes + 3) / 4; /* expressed in number of 4-byte words */ - if (rte_pktmbuf_data_len(pkt) < sizeof(*hdr) + data_item_length_bytes ) { + if (rte_pktmbuf_data_len(pkt) < sizeof(*hdr) + data_item_length_bytes) { err("%s: packet doesn't contain RTP payload", __func__); return; } From d2515b90cc0ef651f6d0a6661d5a644490bfc3f3 Mon Sep 17 00:00:00 2001 From: Lukas G <20104521+zLukas@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:50:39 +0200 Subject: [PATCH 06/12] fix clang-linter action (#979) PR fill fix This PR will make both linter to use V14 version --------- Co-authored-by: GH Action - Upstream Sync --- .github/workflows/afxdp_build.yml | 3 ++- .github/workflows/centos_build.yml | 3 ++- .github/workflows/tools_build.yml | 3 ++- .github/workflows/ubuntu_build.yml | 3 ++- format-coding.sh | 11 +++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/afxdp_build.yml b/.github/workflows/afxdp_build.yml index 78d1198fe..3f978660d 100644 --- a/.github/workflows/afxdp_build.yml +++ b/.github/workflows/afxdp_build.yml @@ -52,8 +52,9 @@ jobs: egress-policy: audit - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: DoozyX/clang-format-lint-action@a83a8fb7d371f66da7dd1c4f33a193023899494b # v0.16 + - uses: DoozyX/clang-format-lint-action@v0.18.2 with: + clangFormatVersion: '14' source: '.' extensions: 'hpp,h,cpp,c,cc' diff --git a/.github/workflows/centos_build.yml b/.github/workflows/centos_build.yml index 0ee4652ff..9623053ca 100644 --- a/.github/workflows/centos_build.yml +++ b/.github/workflows/centos_build.yml @@ -48,8 +48,9 @@ jobs: egress-policy: audit - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: DoozyX/clang-format-lint-action@a83a8fb7d371f66da7dd1c4f33a193023899494b # v0.16 + - uses: DoozyX/clang-format-lint-action@v0.18.2 with: + clangFormatVersion: '14' source: '.' extensions: 'hpp,h,cpp,c,cc' diff --git a/.github/workflows/tools_build.yml b/.github/workflows/tools_build.yml index f8ccad0a8..11277f05a 100644 --- a/.github/workflows/tools_build.yml +++ b/.github/workflows/tools_build.yml @@ -47,8 +47,9 @@ jobs: egress-policy: audit - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: DoozyX/clang-format-lint-action@a83a8fb7d371f66da7dd1c4f33a193023899494b # v0.16 + - uses: DoozyX/clang-format-lint-action@v0.18.2 with: + clangFormatVersion: '14' source: '.' extensions: 'hpp,h,cpp,c,cc' diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml index 57edcfa2e..2ceb203cd 100644 --- a/.github/workflows/ubuntu_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -48,8 +48,9 @@ jobs: egress-policy: audit - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: DoozyX/clang-format-lint-action@a83a8fb7d371f66da7dd1c4f33a193023899494b # v0.16 + - uses: DoozyX/clang-format-lint-action@v0.18.2 with: + clangFormatVersion: '14' source: '.' extensions: 'hpp,h,cpp,c,cc' diff --git a/format-coding.sh b/format-coding.sh index 27d4efd5d..2ae58c80f 100755 --- a/format-coding.sh +++ b/format-coding.sh @@ -5,6 +5,17 @@ # Based on clang-format # For ubuntu, pls "apt-get install clang-format" +# When updating clang format version, remeber to update also GHA clang lister version: +# - uses: DoozyX/clang-format-lint-action@v0.18.2 +# with: +# clangFormatVersion: '14' +# source: '.' +# extensions: 'hpp,h,cpp,c,cc' +# in +# .github/workflows/afxdp_build.yml +# .github/workflows/centos_build.yml +# .github/workflows/tools_build.yml +# .github/workflows/ubuntu_build.yml set -e From 69d88fec277d9bde5f53a67b7fe817fa6dad52f7 Mon Sep 17 00:00:00 2001 From: skolelis Date: Mon, 23 Sep 2024 11:47:10 +0200 Subject: [PATCH 07/12] Add: RxTxApp updated to have ST41 testing possibilities (#981) --- app/src/app_base.h | 14 +++ app/src/parse_json.c | 47 ++++++++- app/src/rx_fastmetadata_app.c | 175 ++++++++++++++++++++++++++++++++-- include/st41_api.h | 10 +- 4 files changed, 237 insertions(+), 9 deletions(-) diff --git a/app/src/app_base.h b/app/src/app_base.h index e3973c647..cddc9b9d8 100644 --- a/app/src/app_base.h +++ b/app/src/app_base.h @@ -366,11 +366,25 @@ struct st_app_rx_anc_session { struct st_app_rx_fmd_session { int idx; st41_rx_handle handle; + + /* Reference file handling */ + char st41_ref_url[ST_APP_URL_MAX_LEN + 1]; + int st41_ref_fd; + uint8_t* st41_ref_begin; + uint8_t* st41_ref_end; + uint8_t* st41_ref_cursor; + pthread_t st41_app_thread; pthread_cond_t st41_wake_cond; pthread_mutex_t st41_wake_mutex; bool st41_app_thread_stop; + /* Expected values */ + uint32_t st41_dit; + uint32_t st41_k_bit; + + uint32_t errors_count; + /* stat */ int stat_frame_total_received; uint64_t stat_frame_first_rx_time; diff --git a/app/src/parse_json.c b/app/src/parse_json.c index 92c8634a3..c471f295a 100644 --- a/app/src/parse_json.c +++ b/app/src/parse_json.c @@ -1332,8 +1332,16 @@ static int st_json_parse_rx_fmd(int idx, json_object* fmd_obj, /* parse payload type */ ret = parse_base_payload_type(fmd_obj, &fmd->base); if (ret < 0) { - err("%s, use default pt %u\n", __func__, ST_APP_PAYLOAD_TYPE_FASTMETADATA); + err("%s, using default expected payload type %u.\n", __func__, + ST_APP_PAYLOAD_TYPE_FASTMETADATA); fmd->base.payload_type = ST_APP_PAYLOAD_TYPE_FASTMETADATA; + } else { + if (fmd->base.payload_type == 0) { + /* if value = 0, no expected payload type value */ + info("%s, No expected payload type.\n", __func__); + } else { + info("%s, using expected payload type %u.\n", __func__, fmd->base.payload_type); + } } /* parse fmd interlaced */ @@ -1346,6 +1354,43 @@ static int st_json_parse_rx_fmd(int idx, json_object* fmd_obj, fmd->enable_rtcp = json_object_get_boolean(st_json_object_object_get(fmd_obj, "enable_rtcp")); + /* parse fmd data item type */ + json_object* fmd_dit_obj = + st_json_object_object_get(fmd_obj, "fastmetadata_data_item_type"); + if (fmd_dit_obj) { + uint32_t fmd_dit = json_object_get_int(fmd_dit_obj); + if (fmd_dit > 0x3fffff) { + err("%s, invalid fastmetadata_data_item_type 0x%x.\n", __func__, fmd_dit); + return -ST_JSON_NOT_VALID; + } + fmd->info.fmd_dit = fmd_dit; + info("%s, expected fastmetadata_data_item_type = 0x%x.\n", __func__, fmd_dit); + } else { + info("%s, No expected fastmetadata_data_item_type set.\n", __func__); + fmd->info.fmd_dit = 0xffffffff; /* No expected fmd data item type */ + } + + /* parse fmd data item K-bit */ + json_object* fmd_k_bit_obj = st_json_object_object_get(fmd_obj, "fastmetadata_k_bit"); + if (fmd_k_bit_obj) { + uint8_t fmd_k_bit = json_object_get_int(fmd_k_bit_obj); + if (fmd_k_bit > 1) { + err("%s, invalid fastmetadata_k_bit 0x%x.\n", __func__, fmd_k_bit); + return -ST_JSON_NOT_VALID; + } + fmd->info.fmd_k_bit = fmd_k_bit; + info("%s, expected fastmetadata_k_bit = 0x%x.\n", __func__, fmd_k_bit); + } else { + info("%s, No expected fastmetadata_k_bit set.\n", __func__); + fmd->info.fmd_k_bit = 0xff; /* No expected fmd K-bit */ + } + + /* parse fmd url */ + ret = parse_url(fmd_obj, "fastmetadata_url", fmd->info.fmd_url); + if (ret < 0) { + info("%s, no fastmetadata reference file.\n", __func__); + } + return ST_JSON_SUCCESS; } diff --git a/app/src/rx_fastmetadata_app.c b/app/src/rx_fastmetadata_app.c index ec6e27bb0..e9787e846 100644 --- a/app/src/rx_fastmetadata_app.c +++ b/app/src/rx_fastmetadata_app.c @@ -4,12 +4,155 @@ #include "rx_fastmetadata_app.h" -static void app_rx_fmd_handle_rtp(struct st_app_rx_fmd_session* s) { - dbg("%s(%d).\n", __func__, s->idx); +static void app_rx_fmd_close_source(struct st_app_rx_fmd_session* session) { + if (session->st41_ref_fd >= 0) { + munmap(session->st41_ref_begin, session->st41_ref_end - session->st41_ref_begin); + close(session->st41_ref_fd); + session->st41_ref_fd = -1; + } +} + +static int app_rx_fmd_open_ref(struct st_app_rx_fmd_session* session) { + int fd, idx = session->idx; + struct stat i; + session->st41_ref_fd = -1; + + fd = st_open(session->st41_ref_url, O_RDONLY); + if (fd < 0) { + info("%s(%d), open file '%s' fail.\n", __func__, idx, session->st41_ref_url); + return -EIO; + } + + if (fstat(fd, &i) < 0) { + err("%s, fstat '%s' fail.\n", __func__, session->st41_ref_url); + close(fd); + return -EIO; + } + + uint8_t* m = mmap(NULL, i.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (MAP_FAILED == m) { + err("%s(%d), mmap '%s' fail.\n", __func__, idx, session->st41_ref_url); + close(fd); + return -EIO; + } + + session->st41_ref_begin = m; + session->st41_ref_cursor = m; + session->st41_ref_end = m + i.st_size; + session->st41_ref_fd = fd; + + info("%s, opening file '%s' success.\n", __func__, session->st41_ref_url); + return 0; +} + +static int app_rx_fmd_compare_with_ref(struct st_app_rx_fmd_session* session, void* frame, + int frame_size) { + int ret = -1; + uint32_t last_zeros = 0; /* 4 bytes with 0 */ + uint32_t st41_ref_remaining_length = + session ? session->st41_ref_end - session->st41_ref_cursor : 0; + + if (frame_size <= st41_ref_remaining_length) { + ret = memcmp(frame, session->st41_ref_cursor, frame_size); + if (ret) { + session->errors_count++; + err("%s() FAIL: reference file comparison with frame.\n", __func__); + } else { + dbg("%s() PASS: reference file comparison with frame.\n", __func__); + } + } else { + if (frame_size - st41_ref_remaining_length > 3) { + ret = -1; + session->errors_count++; + err("%s() FAIL: frame_size > ref_remaining_length by %d.\n", __func__, + frame_size - st41_ref_remaining_length); + } else { + ret = memcmp(frame, session->st41_ref_cursor, st41_ref_remaining_length); + if (ret) { + session->errors_count++; + err("%s() FAIL: reference file comparison with ending frame.\n", __func__); + } else { + dbg("%s() PASS: reference file comparison with ending frame.\n", __func__); + + /* Verify last 0-3 bytes of frame (filled with zero's) */ + ret = memcmp(&(((uint8_t*)frame)[st41_ref_remaining_length]), (void*)&last_zeros, + frame_size - st41_ref_remaining_length); + if (ret) { + session->errors_count++; + err("%s() FAIL: frame comparison with ending zeros.\n", __func__); + } else { + dbg("%s() PASS: frame comparison with ending zeros.\n", __func__); + } + } + } + } + +#ifdef DEBUG /* print out of frame and reference file if error */ + if (ret) { + err("%s() FRAME START>>", __func__); + for (int i = 0; i < frame_size; i++) { + err("%c", ((char*)frame)[i]); + } + err("<>", __func__); + for (int i = 0; i < frame_size; i++) { + err("%c", ((char*)(session->st41_ref_cursor))[i]); + } + err("<st41_ref_cursor += frame_size; + if (session->st41_ref_cursor >= session->st41_ref_end) + session->st41_ref_cursor = session->st41_ref_begin; + + return ret; +} + +static void app_rx_fmd_handle_rtp(struct st_app_rx_fmd_session* s, void* usrptr) { + struct st41_rtp_hdr* hdr = (struct st41_rtp_hdr*)usrptr; + void* payload = (void*)(&hdr[1]); + + hdr->swaped_st41_hdr_chunk = ntohl(hdr->swaped_st41_hdr_chunk); + + /* Testing data_item_type */ + if (s->st41_dit != 0xffffffff) { + if (hdr->st41_hdr_chunk.data_item_type != s->st41_dit) { + s->errors_count++; + err("%s(%d) FAIL: hdr->st41_hdr_chunk.data_item_type=%u, expected to be %u.\n", + __func__, s->idx, hdr->st41_hdr_chunk.data_item_type, s->st41_dit); + } else { + dbg("%s(%d) PASS: hdr->st41_hdr_chunk.data_item_type=%u, expected to be %u.\n", + __func__, s->idx, hdr->st41_hdr_chunk.data_item_type, s->st41_dit); + } + } + + /* Testing data_item K-bit */ + if (s->st41_k_bit != 0xff) { + if (hdr->st41_hdr_chunk.data_item_k_bit != s->st41_k_bit) { + s->errors_count++; + err("%s(%d) FAIL: hdr->st41_hdr_chunk.data_item_k_bit=%u, expected to be %u.\n", + __func__, s->idx, hdr->st41_hdr_chunk.data_item_k_bit, s->st41_k_bit); + } else { + dbg("%s(%d) PASS: hdr->st41_hdr_chunk.data_item_k_bit=%u, expected to be %u.\n", + __func__, s->idx, hdr->st41_hdr_chunk.data_item_k_bit, s->st41_k_bit); + } + } s->stat_frame_total_received++; if (!s->stat_frame_first_rx_time) s->stat_frame_first_rx_time = st_app_get_monotonic_time(); + + /* Compare each packet with reference (part by part) */ + if (s->st41_ref_fd > 0) { + app_rx_fmd_compare_with_ref(s, payload, hdr->st41_hdr_chunk.data_item_length * 4); + /* (field hdr->st41_hdr_chunk.data_item_length is expressed in 4-byte words, thus + * multiplying by 4) */ + } + + hdr->swaped_st41_hdr_chunk = htonl(hdr->swaped_st41_hdr_chunk); } static void* app_rx_fmd_read_thread(void* arg) { @@ -31,7 +174,7 @@ static void* app_rx_fmd_read_thread(void* arg) { continue; } /* parse the packet */ - app_rx_fmd_handle_rtp(s); + app_rx_fmd_handle_rtp(s, usrptr); st41_rx_put_mbuf(s->handle, mbuf); } info("%s(%d), stop\n", __func__, idx); @@ -67,6 +210,8 @@ static int app_rx_fmd_uinit(struct st_app_rx_fmd_session* s) { st_pthread_mutex_destroy(&s->st41_wake_mutex); st_pthread_cond_destroy(&s->st41_wake_cond); + app_rx_fmd_close_source(s); + return 0; } @@ -107,12 +252,30 @@ static int app_rx_fmd_init(struct st_app_context* ctx, } ops.rtp_ring_size = 1024; ops.payload_type = fmd ? fmd->base.payload_type : ST_APP_PAYLOAD_TYPE_FASTMETADATA; + s->st41_dit = fmd ? fmd->info.fmd_dit : 0xffffffff; + s->st41_k_bit = fmd ? fmd->info.fmd_k_bit : 0xff; ops.interlaced = fmd ? fmd->info.interlaced : false; ops.notify_rtp_ready = app_rx_fmd_rtp_ready; if (fmd && fmd->enable_rtcp) ops.flags |= ST41_RX_FLAG_ENABLE_RTCP; st_pthread_mutex_init(&s->st41_wake_mutex, NULL); st_pthread_cond_init(&s->st41_wake_cond, NULL); + s->errors_count = 0; + s->st41_ref_fd = -1; + if (fmd) { + if (strcmp(fmd->info.fmd_url, "")) { + snprintf(s->st41_ref_url, sizeof(s->st41_ref_url), "%s", + fmd ? fmd->info.fmd_url : "null"); + + ret = app_rx_fmd_open_ref(s); + if (ret < 0) { + err("%s(%d), app_rx_fmd_open_ref fail %d.\n", __func__, idx, ret); + app_rx_fmd_uinit(s); + return -EIO; + } + } + } + handle = st41_rx_create(ctx->st, &ops); if (!handle) { err("%s(%d), st41_rx_create fail\n", __func__, idx); @@ -152,9 +315,9 @@ static int app_rx_fmd_result(struct st_app_rx_fmd_session* s) { if (!s->stat_frame_total_received) return -EINVAL; - critical("%s(%d), %s, fps %f, %d frame received\n", __func__, idx, - app_rx_fmd_fps_check(framerate) ? "OK" : "FAILED", framerate, - s->stat_frame_total_received); + critical("%s(%d), %s, fps %f, %d frame received, %d counted errors.\n", __func__, idx, + (app_rx_fmd_fps_check(framerate) && (s->errors_count == 0)) ? "OK" : "FAILED", + framerate, s->stat_frame_total_received, s->errors_count); return 0; } diff --git a/include/st41_api.h b/include/st41_api.h index acd4c583a..fab759535 100644 --- a/include/st41_api.h +++ b/include/st41_api.h @@ -244,9 +244,15 @@ struct st41_rx_ops { /** Mandatory. UDP dest port number */ uint16_t udp_port[MTL_SESSION_PORT_MAX]; - /** Mandatory. 7 bits payload type define in RFC3550. Zero means disable the - * payload_type check on the RX pkt path */ + /** Mandatory. 7 bits payload type define in RFC3550. Value zero (0) means disable the + * payload_type check on the RX pkt path */ uint8_t payload_type; + /** Optional. Expected 22 bits data item type. Value 0xffffffff means disable the + * data item type check on the RX pkt path */ + uint32_t fmd_dit; + /** Optional. Expected 1 bit K-bit. Value 0xff means disable the + * K-bit check on the RX pkt path */ + uint8_t fmd_k_bit; /** Mandatory. interlaced or not */ bool interlaced; From dbb4cd6a93a83c22bce4b4c3892700c6fbad855f Mon Sep 17 00:00:00 2001 From: Konstantin Ilichev Date: Tue, 24 Sep 2024 13:32:45 +0200 Subject: [PATCH 08/12] Fix: error handling in parsing sample freq in FFmpeg audio plugins (#984) Commit 065923f3f768 ("Refactor FFmpeg audio plugin sample rate parsing") added a helper function for parsing the sample frequency. However, the error returned from the function was checked incorrectly (inverted). This led to a segmentation fault when starting FFmpeg with MTL audio plugins. This commit fixes the error handling by checking if the return value is non zero. Fixes: 065923f3f768 ("Refactor FFmpeg audio plugin sample rate parsing") Change-type: DefectResolution Signed-off-by: Konstantin Ilichev --- ecosystem/ffmpeg_plugin/mtl_st30p_rx.c | 2 +- ecosystem/ffmpeg_plugin/mtl_st30p_tx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c b/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c index 0f7922ed6..0bfcc9e55 100644 --- a/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c +++ b/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c @@ -119,7 +119,7 @@ static int mtl_st30p_read_header(AVFormatContext* ctx) { ops_rx.ptime = s->ptime; ops_rx.channel = s->channels; ret = mtl_parse_st30_sample_rate(&ops_rx.sampling, s->sample_rate); - if (!ret) { + if (ret) { err(ctx, "%s, invalid sample_rate: %d\n", __func__, s->sample_rate); return ret; } diff --git a/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c b/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c index 2912ecab9..e622b4dc5 100644 --- a/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c +++ b/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c @@ -111,7 +111,7 @@ static int mtl_st30p_write_header(AVFormatContext* ctx) { ops_tx.channel = codecpar->ch_layout.nb_channels; #endif ret = mtl_parse_st30_sample_rate(&ops_tx.sampling, codecpar->sample_rate); - if (!ret) { + if (ret) { err(ctx, "%s, unknown sample_rate %d\n", __func__, codecpar->sample_rate); return ret; } From f33cc15021198192004817845c135601cde9915e Mon Sep 17 00:00:00 2001 From: Tomasz Date: Tue, 1 Oct 2024 12:34:17 +0200 Subject: [PATCH 09/12] Fix st30p ffmpeg plugin, (#986) "ar" and "ac" are standard FFmpeg parameters and shall not be used as plugin parameters. For this reason the user could not customize commands Change "ar" to "sample_rate" audio sample rate Change "ac" to "channels" number of audio channel change "at" to "ptime" audio packet time --- ecosystem/ffmpeg_plugin/README.md | 8 ++++---- ecosystem/ffmpeg_plugin/mtl_st30p_rx.c | 10 +++++----- ecosystem/ffmpeg_plugin/mtl_st30p_tx.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ecosystem/ffmpeg_plugin/README.md b/ecosystem/ffmpeg_plugin/README.md index 69cb078ce..645093d2c 100644 --- a/ecosystem/ffmpeg_plugin/README.md +++ b/ecosystem/ffmpeg_plugin/README.md @@ -152,7 +152,7 @@ ffmpeg -stream_loop -1 -video_size 1920x1080 -f rawvideo -pix_fmt yuv422p10le -i Reading a st2110-30 stream(pcm24,1ms packet time,2 channels) on "239.168.85.20:30000" with payload_type 111 and encoded to a wav file: ```bash -ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -pcm_fmt pcm24 -at 1ms -ac 2 -f mtl_st30p -i "0" dump.wav -y +ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -pcm_fmt pcm24 -ptime 1ms -channels 2 -f mtl_st30p -i "0" dump.wav -y ``` ### 4.2 St30p output @@ -160,7 +160,7 @@ ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port Reading from a wav file and sending a st2110-30 stream(pcm24,1ms packet time,2 channels) on "239.168.85.20:30000" with payload_type 111: ```bash -ffmpeg -stream_loop -1 -i test.wav -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_tx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -at 1ms -f mtl_st30p - +ffmpeg -stream_loop -1 -i test.wav -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_tx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -ptime 1ms -f mtl_st30p - ``` ### 4.3 St30p pcm16 example @@ -168,9 +168,9 @@ ffmpeg -stream_loop -1 -i test.wav -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_t For pcm16 audio, use `mtl_st30p_pcm16` muxer, set `pcm_fmt` to `pcm16` for demuxer. ```bash -ffmpeg -stream_loop -1 -i test.wav -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_tx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -at 1ms -f mtl_st30p_pcm16 - +ffmpeg -stream_loop -1 -i test.wav -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_tx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -ptime 1ms -f mtl_st30p_pcm16 - -ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -pcm_fmt pcm16 -at 1ms -ac 2 -f mtl_st30p -i "0" dump_pcm16.wav -y +ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -pcm_fmt pcm16 -ptime 1ms -channels 2 -f mtl_st30p -i "0" dump_pcm16.wav -y ``` ### Enabling experimental MTL_GPU_DIRECT in FFmpeg with ST20p Support diff --git a/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c b/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c index 0bfcc9e55..f03991f87 100644 --- a/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c +++ b/ecosystem/ffmpeg_plugin/mtl_st30p_rx.c @@ -266,16 +266,16 @@ static const AVOption mtl_st30p_rx_options[] = { 0, 60, DEC}, - {"ar", - "audio sampling rate", + {"sample_rate", + "audio sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 1, INT_MAX, DEC}, - {"ac", - "audio channel", + {"channels", + "number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = 2}, @@ -288,7 +288,7 @@ static const AVOption mtl_st30p_rx_options[] = { AV_OPT_TYPE_STRING, {.str = NULL}, .flags = DEC}, - {"at", + {"ptime", "audio packet time", OFFSET(ptime_str), AV_OPT_TYPE_STRING, diff --git a/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c b/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c index e622b4dc5..e72c56b44 100644 --- a/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c +++ b/ecosystem/ffmpeg_plugin/mtl_st30p_tx.c @@ -230,7 +230,7 @@ static const AVOption mtl_st30p_tx_options[] = { 3, 8000, ENC}, - {"at", + {"ptime", "audio packet time", OFFSET(ptime_str), AV_OPT_TYPE_STRING, From c74fe35107699a7cd06e7045be08e155721b2791 Mon Sep 17 00:00:00 2001 From: PanKaker <92713340+PanKaker@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:42:07 +0200 Subject: [PATCH 10/12] Fix: coverity findings. Improve logging of GPU direct (#991) Improve logging of GPU direct and fix issues from coverity. --- app/src/rx_fastmetadata_app.c | 6 ++---- lib/src/st2110/st_rx_video_session.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) mode change 100644 => 100755 lib/src/st2110/st_rx_video_session.c diff --git a/app/src/rx_fastmetadata_app.c b/app/src/rx_fastmetadata_app.c index e9787e846..67d16e3eb 100644 --- a/app/src/rx_fastmetadata_app.c +++ b/app/src/rx_fastmetadata_app.c @@ -49,8 +49,7 @@ static int app_rx_fmd_compare_with_ref(struct st_app_rx_fmd_session* session, vo int frame_size) { int ret = -1; uint32_t last_zeros = 0; /* 4 bytes with 0 */ - uint32_t st41_ref_remaining_length = - session ? session->st41_ref_end - session->st41_ref_cursor : 0; + uint32_t st41_ref_remaining_length = session->st41_ref_end - session->st41_ref_cursor; if (frame_size <= st41_ref_remaining_length) { ret = memcmp(frame, session->st41_ref_cursor, frame_size); @@ -264,8 +263,7 @@ static int app_rx_fmd_init(struct st_app_context* ctx, s->st41_ref_fd = -1; if (fmd) { if (strcmp(fmd->info.fmd_url, "")) { - snprintf(s->st41_ref_url, sizeof(s->st41_ref_url), "%s", - fmd ? fmd->info.fmd_url : "null"); + snprintf(s->st41_ref_url, sizeof(s->st41_ref_url), "%s", fmd->info.fmd_url); ret = app_rx_fmd_open_ref(s); if (ret < 0) { diff --git a/lib/src/st2110/st_rx_video_session.c b/lib/src/st2110/st_rx_video_session.c old mode 100644 new mode 100755 index 5e9954d1b..aca43a4cd --- a/lib/src/st2110/st_rx_video_session.c +++ b/lib/src/st2110/st_rx_video_session.c @@ -457,11 +457,11 @@ static int rv_alloc_frames(struct mtl_main_impl* impl, } else { #ifdef MTL_GPU_DIRECT_ENABLED if (rv_framebuffer_in_gpu_direct_vram(s)) { - info("%s: using gpu direct feature.\n", __func__); + info("%s: using GPU direct feature.\n", __func__); GpuContext* gpu = s->ops.gpu_context; ret = gpu_allocate_shared_buffer(gpu, &frame, size); if (ret < 0) { - err("%s: failed to allocate gpu memory on vram. ret: %d\n", __func__, ret); + err("%s: failed to allocate GPU memory on vram. ret: %d\n", __func__, ret); return -ENOMEM; } } else From dab016da6d6f2b19adc92383ba1d1a9661c736e7 Mon Sep 17 00:00:00 2001 From: PanKaker <92713340+PanKaker@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:56:22 +0200 Subject: [PATCH 11/12] Fix: st41 RTP assigned fields during the initialization (#992) Fix ST41 Initialization params --- app/src/tx_fastmetadata_app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/tx_fastmetadata_app.c b/app/src/tx_fastmetadata_app.c index 2b9dab931..b85b200ab 100644 --- a/app/src/tx_fastmetadata_app.c +++ b/app/src/tx_fastmetadata_app.c @@ -480,8 +480,8 @@ static int app_tx_fmd_init(struct st_app_context* ctx, } /* copying frame fields for RTP mode to function*/ - s->st41_dit = fmd->info.fmd_dit; - s->st41_k_bit = fmd->info.fmd_k_bit; + s->st41_dit = ops.fmd_dit; + s->st41_k_bit = ops.fmd_k_bit; s->handle = handle; snprintf(s->st41_source_url, sizeof(s->st41_source_url), "%s", From 9ccf8caf2c1e07dd425b588f831c789b474ea259 Mon Sep 17 00:00:00 2001 From: PanKaker <92713340+PanKaker@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:30:33 +0200 Subject: [PATCH 12/12] Doc: update documentation of the project. Update changelog, configuration guide (#993) Update documentation of: - Configuration guide - Changelog Improve formating of documentation: - gpu.md - ffmpeg_plugin --- CHANGELOG.md | 23 ++++++++++++-- doc/configuration_guide.md | 50 ++++++++++++++++++++++++++++++- doc/gpu.md | 43 ++++++++------------------ ecosystem/ffmpeg_plugin/README.md | 12 ++++++-- 4 files changed, 91 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 802143df0..dd03696a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,27 @@ # Changelog -## Changelog for 24.12 +## Changelog for 24.09 * ice: update driver to 1.14.9 -* st2110/20: add force numa option support on session level, see ST20_TX_FLAG_FORCE_NUMA/ST20_RX_FLAG_FORCE_NUMA -* st2110/30: add force numa option support on session level, see ST30_TX_FLAG_FORCE_NUMA/ST30_RX_FLAG_FORCE_NUMA +* st2110/20: add force NUMA option support on session level, see ST20_TX_FLAG_FORCE_NUMA/ST20_RX_FLAG_FORCE_NUMA +* st2110/30: add force NUMA option support on session level, see ST30_TX_FLAG_FORCE_NUMA/ST30_RX_FLAG_FORCE_NUMA +* ffmpeg: fix RX side dropping frames at the beginning of the session with st20/st22/st30. +* st22: fix last frame dropping in TX. Ensure that last frame status changed to FREE. +* dpdk: optimizing memory pool size. +* manager: fix docker build. +* ffmpeg: improve unicast initialization, reduce amount of dropping frames in the beginning of the session. +* ixgbe: add driver support. Tested on 10-Gigabit X540-AT2 (1528) and Intel 10G X550T (1563). +* sch/tasklet: fix API correct NUMA assigned when `mtl_sch_create` is used. +* sch/tasklet: fix segfault when lcore out of `RTE_MAX_LCORE` assigned. +* app: add new video formats to sample app - YUV_420_16bit, YUV_422_8BIT, YUV_444_8bit, YUV_444_16bit. +* RTP: fix checking for valid payload type. +* st30: add `fifo_size` parameter parsing from user. +* st41: add `St2110-41` format for 'Fast Metadata Framework' standard. +* ffmpeg: add support of `44100` rate for `st30` format. +* ffmpeg: add support for v7.0 version +* st22: fix correct NUMA assigned `socket_id` with pipeline when creating a new session. +* GPU: add support for GPU direct buffers in ST2110/20. See `app/sample/gpu_direct` for usage. +* ffmpeg: add support for GPU buffers. ## Changelog for 24.06 diff --git a/doc/configuration_guide.md b/doc/configuration_guide.md index 64bed3605..aaebd7b72 100644 --- a/doc/configuration_guide.md +++ b/doc/configuration_guide.md @@ -58,6 +58,18 @@ Example `tx_1v_1a_1anc.json` file, find more example config file in [example con "ancillary_url": "./test.txt", "ancillary_fps": "p59" } + ], + "fastmetadata": [ + { + "replicas": 1, + "start_port": 40000, + "payload_type": 115, + "type": "frame", + "fastmetadata_data_item_type": 123456, + "fastmetadata_k_bit": 1, + "fastmetadata_url": "./test.txt", + "fastmetadata_fps": "p59" + } ] } ] @@ -155,7 +167,27 @@ Items in each element of the "ancillary" array ​ **ancillary_url (string):** ancillary source - **ancillary_fps (string):** `"p59", "p50", "p29"`ancillary fps which should be aligned to video +​ **ancillary_fps (string):** `"p59", "p50", "p29"` ancillary fps which should be aligned to video + +#### fast metadata (array of fast metadata sessions) + +Items in each element of the "fastmetadata" array + +​ **replicas (int):** `1~max_num` the number of session copies + +​ **type (string):** `"frame", "rtp"` app->lib data type + +​ **start_port (int):** `0~65535` start udp port for copies of sessions + +​ **payload_type (int):** `0~127` 7 bits payload type define in RFC3550 + +​ **fastmetadata_data_item_type (int):** `0~4194303` (0x - 0x3fffff) 22 bits data item type + +​ **fastmetadata_k_bit (int):** `0~1` 1 bit K-bit value + +​ **fastmetadata_url (string):** fast metadata source + + **fastmetadata_fps (string):** `"p59", "p50", "p29"` fast metadata fps which should be aligned to video ### RX Sessions (array of rx session groups) @@ -219,6 +251,22 @@ Items in each element of the "ancillary" array ​ **payload_type (int):** `0~127` 7 bits payload type define in RFC3550 +#### fast metadata (array of fast metadata sessions) for RX + +Items in each element of the "fastmetadata" array + +​ **replicas (int):** `1~max_num` the number of session copies + +​ **start_port (int):** `0~65535` start udp port for copies of sessions + +​ **payload_type (int):** `0~127` 7 bits payload type define in RFC3550 + +​ **fastmetadata_data_item_type (int):** `0~4194303` (0x - 0x3fffff) 22 bits data item type - reference value (for testing the flow) - Optional setting + +​ **fastmetadata_k_bit (int):** `0~1` 1 bit K-bit value - reference value (for testing the flow) - Optional setting + +​ **fastmetadata_url (string):** fast metadata reference file (for testing the flow) - Optional setting + ### Others **shared_tx_queues (bool):** If enable the shared tx queues or not, (optional). The queue number is limited for NIC, to support sessions more than queue number, enable this option to share queue resource between sessions. diff --git a/doc/gpu.md b/doc/gpu.md index ddb475e05..c56e96649 100644 --- a/doc/gpu.md +++ b/doc/gpu.md @@ -1,34 +1,21 @@ # GPU -This is an experimental feature - ## General Info -The idea to use Lever Zero API to allocation buffers directly in GPU to reduce amount of copy from kernel to user space. -GPU <-> NIC. - -This library provides a wrapper for Level Zero to init GPU and provide functions to allocate shared or device memory. - -## Build - -Use Cmake to build the project - -## How to use it +It's possible to create a memory buffer in GPU for the frames in st20 protocol. +This is done by using [gpu direct](../gpu_direct/README.md) library. -1) Use 'get_devices' to list drivers and devices index. -2) Use 'init_gpu_device' to init gpu context -3) Allocate memory with 'gpu_allocate_device_buffer' or 'gpu_allocate_shared_buffer' -4) Use 'gpu_memcpy' and 'gpu_memset' for memcpy and memset operations -5) Free space with gpu_free_buf. -6) Free gpu context with free_gpu_context. +Refer to [gpu direct s20 pipeline](../app/sample/gpu_direct) to see an example. ## Build MTL GPU-Direct Library + Use Meson to build the GPU-Direct library specifically. -``` bash +```bash cd /gpu_direct meson setup build sudo meson install -C build + # check package installed pkg-config --libs mtl_gpu_direct @@ -36,37 +23,33 @@ pkg-config --libs mtl_gpu_direct ./build.sh ``` -``` bash Run TX Sample App -Prepare a file (test.yuv) of 1920x1080 UYVY frames to send. You can refer to run.md for more details. +Prepare a file (test.yuv) of 1920x1080 UYVY frames to send. You can refer to [run guide](../doc/run.md) for more details. +```bash ./build/app/GpuDirectVideoTxMultiSample 192.168.99.110 20000 test.yuv +``` + Run RX Sample App You need the SDL library to display the received frame. -``` ``` bash ./build/app/GpuDirectVideoRxMultiSample 192.168.99.111 192.168.99.110 20000 ``` - ## How to enable it in MTL Currently, only the ST20P receive frame mode supports VRAM frame allocation. + To enable this feature, use the following flag while initializing the session: `ST20P_RX_FLAG_USE_GPU_DIRECT_FRAMEBUFFERS` This setting instructs MTL to allocate frames directly in VRAM. -Additionally, you must initialize the GPU device in your application using this library +Additionally, you must initialize the GPU device in your application using gpu direct library by `init_gpu_device` function. - Pass the address of the device with the gpu_context parameter: -`gpu_context` to the st20p rx flags during session initalization. +`gpu_context` to the st20p rx flags during session initialization. **Warning:** Direct memory access functionality is disabled when using this flag. Memory allocated in VRAM cannot be accessed directly using dpdk API. - -### Links - -- [Level Zero Intro](https://www.intel.com/content/www/us/en/developer/articles/technical/using-oneapi-level-zero-interface.html) \ No newline at end of file diff --git a/ecosystem/ffmpeg_plugin/README.md b/ecosystem/ffmpeg_plugin/README.md index 645093d2c..d3f6290ce 100644 --- a/ecosystem/ffmpeg_plugin/README.md +++ b/ecosystem/ffmpeg_plugin/README.md @@ -173,17 +173,20 @@ ffmpeg -stream_loop -1 -i test.wav -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_t ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port 30000 -payload_type 111 -pcm_fmt pcm16 -ptime 1ms -channels 2 -f mtl_st30p -i "0" dump_pcm16.wav -y ``` -### Enabling experimental MTL_GPU_DIRECT in FFmpeg with ST20p Support +## 5. St20 GPU direct guide The MTL_GPU_DIRECT experimental feature aims at enhancing FFmpeg's performance by allowing direct access to GPU memory, which can be particularly beneficial when working with high-throughput video streams such as those handled by the MTL ST20 codec plugin. -#### Building FFmpeg with MTL_GPU_DIRECT Enabled +### 5.1 Enabling experimental MTL_GPU_DIRECT in FFmpeg with ST20p Support + To take advantage of the MTL_GPU_DIRECT feature FFmpeg has to be built with this option enabled. Here’s how to do it: ```bash ./configure --enable-shared --disable-static --enable-nonfree --enable-pic --enable-gpl --enable-libopenh264 --enable-encoder=libopenh264 --enable-mtl --extra-cflags="-DMTL_GPU_DIRECT_ENABLED" ``` + or use + ```bash ./build_ffmpeg_plugin.sh -g ``` @@ -195,17 +198,20 @@ enabled gpu_direct: ./ffmpeg -p_port 0000:af:01.0 -p_sip 192.168.96.2 -p_rx_ip 239.168.85.20 -udp_port 20000 -payload_type 112 -fps 59.94 -pix_fmt yuv422p10le -video_size 1920x1080 -gpu_direct 1 -gpu_driver 0 -gpu_device 0 -f mtl_st20p -i "k" -f rawvideo /dev/null -y ``` -#### Additional Notes +### 5.2 Additional Notes + **GPU Direct Flag:** When compiling FFmpeg with the MTL_GPU_DIRECT feature enabled, ensure that your system's GPU drivers and hardware support direct GPU memory access. GPU device IDs and GPU driver IDs are printed during initialization. **Options:** + 1. `-gpu_device` 1. `-gpu_driver` Both default to 0, but if your device doesn't initialize, adjust it using the information printed during initialization. **Example:** + ```plaintext Drivers count: 1 Driver: 0: Device: 0: Name: Intel(R) Data Center GPU Flex 170, Type: 1, VendorID: 8086, DeviceID: 22208