|
15 | 15 | #include "st_video_transmitter.h" |
16 | 16 |
|
17 | 17 | #define MTL_LATENCY_COMPENSATION_PACKET_SHIFT 5 |
| 18 | +#define MTL_LATENCY_COMPENSATION_PACKET_SHIFT_MIN_TICK \ |
| 19 | + 1 /* at least shift 1 tick for RL pacing */ |
18 | 20 |
|
19 | 21 | #ifdef MTL_SIMULATE_PACKET_DROPS |
20 | 22 | static inline void tv_simulate_packet_loss(struct st_tx_video_session_impl* s, |
@@ -523,7 +525,7 @@ static int tv_init_pacing(struct mtl_main_impl* impl, |
523 | 525 | dbg("%s[%02d], max_onward_epochs %u\n", __func__, idx, pacing->max_onward_epochs); |
524 | 526 | /* default VRX compensate as rl accuracy, update later in tv_train_pacing */ |
525 | 527 | pacing->pad_interval = s->st20_total_pkts; |
526 | | - pacing->rl_rtp_offset_ns = 0; /* set later for RL pacing */ |
| 528 | + pacing->rl_rtp_offset_ticks = 0; /* set later for RL pacing */ |
527 | 529 |
|
528 | 530 | int num_port = s->ops.num_port; |
529 | 531 | int ret; |
@@ -560,8 +562,10 @@ static int tv_init_pacing(struct mtl_main_impl* impl, |
560 | 562 |
|
561 | 563 | /* RL pacing: shift RTP timestamp back by few packets to compensate warm-up pad */ |
562 | 564 | if (s->pacing_way[MTL_SESSION_PORT_P] == ST21_TX_PACING_WAY_RL) { |
563 | | - pacing->rl_rtp_offset_ns = |
564 | | - (uint64_t)(MTL_LATENCY_COMPENSATION_PACKET_SHIFT * pacing->trs); |
| 565 | + pacing->rl_rtp_offset_ticks = |
| 566 | + RTE_MAX(MTL_LATENCY_COMPENSATION_PACKET_SHIFT_MIN_TICK, |
| 567 | + st10_tai_to_media_clk(MTL_LATENCY_COMPENSATION_PACKET_SHIFT * pacing->trs, |
| 568 | + s->fps_tm.sampling_clock_rate)); |
565 | 569 | } |
566 | 570 |
|
567 | 571 | /* calculate vrx pkts */ |
@@ -602,10 +606,10 @@ static int tv_init_pacing(struct mtl_main_impl* impl, |
602 | 606 | } |
603 | 607 | info( |
604 | 608 | "%s[%02d], trs %f trOffset %f vrx %u warm_pkts %u frame time %fms fps %f " |
605 | | - "rl_rtp_adj %" PRIu64 "ns\n", |
| 609 | + "rl_rtp_adj %u ticks\n", |
606 | 610 | __func__, idx, pacing->trs, pacing->tr_offset, pacing->vrx, pacing->warm_pkts, |
607 | 611 | pacing->frame_time / NS_PER_MS, st_frame_rate(s->ops.fps), |
608 | | - pacing->rl_rtp_offset_ns); |
| 612 | + pacing->rl_rtp_offset_ticks); |
609 | 613 | /* resolve pacing tasklet */ |
610 | 614 | for (int i = 0; i < num_port; i++) { |
611 | 615 | ret = st_video_resolve_pacing_tasklet(s, i); |
@@ -746,9 +750,10 @@ static void tv_update_rtp_time_stamp(struct st_tx_video_session_impl* s, |
746 | 750 | } else { |
747 | 751 | tai_for_rtp_ts = pacing->ptp_time_cursor; |
748 | 752 | } |
749 | | - tai_for_rtp_ts += delta_ns - pacing->rl_rtp_offset_ns; |
| 753 | + tai_for_rtp_ts += delta_ns; |
750 | 754 | pacing->rtp_time_stamp = |
751 | | - st10_tai_to_media_clk(tai_for_rtp_ts, s->fps_tm.sampling_clock_rate); |
| 755 | + st10_tai_to_media_clk(tai_for_rtp_ts, s->fps_tm.sampling_clock_rate) - |
| 756 | + pacing->rl_rtp_offset_ticks; |
752 | 757 | } |
753 | 758 | dbg("%s(%d), rtp time stamp %u\n", __func__, s->idx, pacing->rtp_time_stamp); |
754 | 759 | } |
@@ -1366,10 +1371,10 @@ static int tv_build_rtp(struct mtl_main_impl* impl, struct st_tx_video_session_i |
1366 | 1371 | } else { |
1367 | 1372 | tai_for_rtp_ts = s->pacing.ptp_time_cursor; |
1368 | 1373 | } |
1369 | | - tai_for_rtp_ts += (uint64_t)s->ops.rtp_timestamp_delta_us * NS_PER_US - |
1370 | | - s->pacing.rl_rtp_offset_ns; |
| 1374 | + tai_for_rtp_ts += (uint64_t)s->ops.rtp_timestamp_delta_us * NS_PER_US; |
1371 | 1375 | s->pacing.rtp_time_stamp = |
1372 | | - st10_tai_to_media_clk(tai_for_rtp_ts, s->fps_tm.sampling_clock_rate); |
| 1376 | + st10_tai_to_media_clk(tai_for_rtp_ts, s->fps_tm.sampling_clock_rate) - |
| 1377 | + s->pacing.rl_rtp_offset_ticks; |
1373 | 1378 | } |
1374 | 1379 | dbg("%s(%d), rtp time stamp %u\n", __func__, s->idx, s->pacing.rtp_time_stamp); |
1375 | 1380 | } |
@@ -1439,10 +1444,10 @@ static int tv_build_rtp_chain(struct mtl_main_impl* impl, |
1439 | 1444 | } else { |
1440 | 1445 | tai_for_rtp_ts = s->pacing.ptp_time_cursor; |
1441 | 1446 | } |
1442 | | - tai_for_rtp_ts += (uint64_t)s->ops.rtp_timestamp_delta_us * NS_PER_US - |
1443 | | - s->pacing.rl_rtp_offset_ns; |
| 1447 | + tai_for_rtp_ts += (uint64_t)s->ops.rtp_timestamp_delta_us * NS_PER_US; |
1444 | 1448 | s->pacing.rtp_time_stamp = |
1445 | | - st10_tai_to_media_clk(tai_for_rtp_ts, s->fps_tm.sampling_clock_rate); |
| 1449 | + st10_tai_to_media_clk(tai_for_rtp_ts, s->fps_tm.sampling_clock_rate) - |
| 1450 | + s->pacing.rl_rtp_offset_ticks; |
1446 | 1451 | } |
1447 | 1452 | dbg("%s(%d), rtp time stamp %u\n", __func__, s->idx, s->pacing.rtp_time_stamp); |
1448 | 1453 | } |
|
0 commit comments