|
| 1 | +# SPDX-License-Identifier: BSD-3-Clause |
| 2 | +# Copyright(c) 2024-2025 Intel Corporation |
| 3 | + |
| 4 | +import pytest |
| 5 | +from mtl_engine.media_files import yuv_files_422p10le, yuv_files_422rfc10 |
| 6 | +from mtl_engine.rxtxapp import RxTxApp |
| 7 | + |
| 8 | + |
| 9 | +@pytest.mark.smoke |
| 10 | +@pytest.mark.nightly |
| 11 | +@pytest.mark.parametrize( |
| 12 | + "media_file", |
| 13 | + list(yuv_files_422p10le.values()), |
| 14 | + indirect=["media_file"], |
| 15 | + ids=list(yuv_files_422p10le.keys()), |
| 16 | +) |
| 17 | +def test_422p10le_refactored( |
| 18 | + hosts, |
| 19 | + build, |
| 20 | + media, |
| 21 | + nic_port_list, |
| 22 | + test_time, |
| 23 | + test_config, |
| 24 | + prepare_ramdisk, |
| 25 | + media_file, |
| 26 | +): |
| 27 | + """Send files in YUV422PLANAR10LE format converting to transport format YUV_422_10bit""" |
| 28 | + media_file_info, media_file_path = media_file |
| 29 | + host = list(hosts.values())[0] |
| 30 | + |
| 31 | + capture_cfg = dict(test_config.get("capture_cfg", {})) |
| 32 | + capture_cfg["test_name"] = f"test_format_refactored_{media_file_info['filename']}" |
| 33 | + |
| 34 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 35 | + |
| 36 | + app.create_command( |
| 37 | + session_type="st20p", |
| 38 | + nic_port_list=host.vfs, |
| 39 | + test_mode="multicast", |
| 40 | + width=media_file_info["width"], |
| 41 | + height=media_file_info["height"], |
| 42 | + framerate=f"p{media_file_info['fps']}", |
| 43 | + pixel_format=media_file_info["file_format"], |
| 44 | + transport_format=media_file_info["format"], |
| 45 | + input_file=media_file_path, |
| 46 | + test_time=test_time, |
| 47 | + ) |
| 48 | + |
| 49 | + app.execute_test( |
| 50 | + build=build, |
| 51 | + test_time=test_time, |
| 52 | + host=host, |
| 53 | + capture_cfg=capture_cfg, |
| 54 | + ) |
| 55 | + |
| 56 | + |
| 57 | +# List of supported formats based on st_frame_fmt_from_transport() |
| 58 | +pixel_formats = dict( |
| 59 | + YUV_422_10bit=("ST20_FMT_YUV_422_10BIT", "YUV422RFC4175PG2BE10"), |
| 60 | + YUV_422_8bit=("ST20_FMT_YUV_422_8BIT", "UYVY"), |
| 61 | + YUV_422_12bit=("ST20_FMT_YUV_422_12BIT", "YUV422RFC4175PG2BE12"), |
| 62 | + YUV_444_10bit=("ST20_FMT_YUV_444_10BIT", "YUV444RFC4175PG4BE10"), |
| 63 | + YUV_444_12bit=("ST20_FMT_YUV_444_12BIT", "YUV444RFC4175PG2BE12"), |
| 64 | + YUV_420_8bit=("ST20_FMT_YUV_420_8BIT", "YUV420CUSTOM8"), |
| 65 | + RGB_8bit=("ST20_FMT_RGB_8BIT", "RGB8"), |
| 66 | + RGB_10bit=("ST20_FMT_RGB_10BIT", "RGBRFC4175PG4BE10"), |
| 67 | + RGB_12bit=("ST20_FMT_RGB_12BIT", "RGBRFC4175PG2BE12"), |
| 68 | + YUV_422_PLANAR10LE=("ST20_FMT_YUV_422_PLANAR10LE", "YUV422PLANAR10LE"), |
| 69 | + V210=("ST20_FMT_V210", "V210"), |
| 70 | +) |
| 71 | + |
| 72 | + |
| 73 | +# List of supported one-way convertions based on st_frame_get_converter() |
| 74 | +convert1_formats = dict( |
| 75 | + UYVY="UYVY", |
| 76 | + YUV422PLANAR8="YUV422PLANAR8", |
| 77 | + YUV420PLANAR8="YUV420PLANAR8", |
| 78 | +) |
| 79 | + |
| 80 | + |
| 81 | +@pytest.mark.nightly |
| 82 | +@pytest.mark.parametrize( |
| 83 | + "media_file", |
| 84 | + [yuv_files_422rfc10["Penguin_1080p"]], |
| 85 | + indirect=["media_file"], |
| 86 | + ids=["Penguin_1080p"], |
| 87 | +) |
| 88 | +@pytest.mark.parametrize("format", convert1_formats.keys()) |
| 89 | +def test_convert_on_rx_refactored( |
| 90 | + hosts, build, media, nic_port_list, test_time, format, media_file |
| 91 | +): |
| 92 | + """Send file in YUV_422_10bit pixel formats with supported conversion on RX side""" |
| 93 | + media_file_info, media_file_path = media_file |
| 94 | + host = list(hosts.values())[0] |
| 95 | + |
| 96 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 97 | + |
| 98 | + app.create_command( |
| 99 | + session_type="st20p", |
| 100 | + nic_port_list=host.vfs, |
| 101 | + test_mode="multicast", |
| 102 | + packing="GPM", |
| 103 | + width=media_file_info["width"], |
| 104 | + height=media_file_info["height"], |
| 105 | + framerate="p30", |
| 106 | + pixel_format="YUV422RFC4175PG2BE10", |
| 107 | + transport_format="YUV_422_10bit", |
| 108 | + input_file=media_file_path, |
| 109 | + test_time=test_time, |
| 110 | + ) |
| 111 | + |
| 112 | + app.execute_test( |
| 113 | + build=build, |
| 114 | + test_time=test_time, |
| 115 | + host=host, |
| 116 | + ) |
| 117 | + |
| 118 | + |
| 119 | +# List of supported two-way convertions based on st_frame_get_converter() |
| 120 | +convert2_formats = dict( |
| 121 | + V210=("ST20_FMT_YUV_422_10BIT", "YUV_422_10bit", "YUV422RFC4175PG2BE10"), |
| 122 | + Y210=("ST20_FMT_YUV_422_10BIT", "YUV_422_10bit", "YUV422RFC4175PG2BE10"), |
| 123 | + YUV422PLANAR12LE=( |
| 124 | + "ST20_FMT_YUV_422_12BIT", |
| 125 | + "YUV_422_12bit", |
| 126 | + "YUV422RFC4175PG2BE12", |
| 127 | + ), |
| 128 | + YUV444PLANAR10LE=( |
| 129 | + "ST20_FMT_YUV_444_10BIT", |
| 130 | + "YUV_444_10bit", |
| 131 | + "YUV444RFC4175PG4BE10", |
| 132 | + ), |
| 133 | + YUV444PLANAR12LE=( |
| 134 | + "ST20_FMT_YUV_444_12BIT", |
| 135 | + "YUV_444_12bit", |
| 136 | + "YUV444RFC4175PG2BE12", |
| 137 | + ), |
| 138 | + GBRPLANAR10LE=("ST20_FMT_RGB_10BIT", "RGB_10bit", "RGBRFC4175PG4BE10"), |
| 139 | + GBRPLANAR12LE=("ST20_FMT_RGB_12BIT", "RGB_12bit", "RGBRFC4175PG2BE12"), |
| 140 | +) |
| 141 | + |
| 142 | + |
| 143 | +@pytest.mark.parametrize( |
| 144 | + "media_file", |
| 145 | + [yuv_files_422rfc10["test_8K"]], |
| 146 | + indirect=["media_file"], |
| 147 | + ids=["test_8K"], |
| 148 | +) |
| 149 | +@pytest.mark.parametrize("format", convert2_formats.keys()) |
| 150 | +def test_tx_rx_conversion_refactored( |
| 151 | + hosts, |
| 152 | + build, |
| 153 | + media, |
| 154 | + nic_port_list, |
| 155 | + test_time, |
| 156 | + format, |
| 157 | + media_file, |
| 158 | +): |
| 159 | + """Send file in different pixel formats with supported two-way conversion on TX and RX""" |
| 160 | + media_file_info, media_file_path = media_file |
| 161 | + text_format, transport_format, _ = convert2_formats[format] |
| 162 | + host = list(hosts.values())[0] |
| 163 | + |
| 164 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 165 | + |
| 166 | + app.create_command( |
| 167 | + session_type="st20p", |
| 168 | + nic_port_list=host.vfs, |
| 169 | + test_mode="multicast", |
| 170 | + packing="GPM", |
| 171 | + width=media_file_info["width"], |
| 172 | + height=media_file_info["height"], |
| 173 | + framerate="p30", |
| 174 | + pixel_format=format, |
| 175 | + transport_format=transport_format, |
| 176 | + input_file=media_file_path, |
| 177 | + test_time=test_time, |
| 178 | + ) |
| 179 | + |
| 180 | + app.execute_test( |
| 181 | + build=build, |
| 182 | + test_time=test_time, |
| 183 | + host=host, |
| 184 | + ) |
| 185 | + |
| 186 | + |
| 187 | +@pytest.mark.parametrize( |
| 188 | + "media_file", |
| 189 | + [yuv_files_422rfc10["test_8K"]], |
| 190 | + indirect=["media_file"], |
| 191 | + ids=["test_8K"], |
| 192 | +) |
| 193 | +@pytest.mark.parametrize("format", pixel_formats.keys()) |
| 194 | +def test_formats_refactored( |
| 195 | + hosts, |
| 196 | + build, |
| 197 | + media, |
| 198 | + nic_port_list, |
| 199 | + test_time, |
| 200 | + format, |
| 201 | + test_config, |
| 202 | + prepare_ramdisk, |
| 203 | + media_file, |
| 204 | +): |
| 205 | + """Send file in different supported pixel formats without conversion during transport""" |
| 206 | + media_file_info, media_file_path = media_file |
| 207 | + text_format, file_format = pixel_formats[format] |
| 208 | + host = list(hosts.values())[0] |
| 209 | + |
| 210 | + capture_cfg = dict(test_config.get("capture_cfg", {})) |
| 211 | + capture_cfg["test_name"] = f"test_format_refactored_formats_{format}" |
| 212 | + |
| 213 | + app = RxTxApp(f"{build}/tests/tools/RxTxApp/build") |
| 214 | + |
| 215 | + app.create_command( |
| 216 | + session_type="st20p", |
| 217 | + nic_port_list=host.vfs, |
| 218 | + test_mode="multicast", |
| 219 | + packing="GPM", |
| 220 | + width=media_file_info["width"], |
| 221 | + height=media_file_info["height"], |
| 222 | + framerate="p30", |
| 223 | + pixel_format=file_format, |
| 224 | + transport_format=format, |
| 225 | + input_file=media_file_path, |
| 226 | + test_time=test_time, |
| 227 | + ) |
| 228 | + |
| 229 | + app.execute_test( |
| 230 | + build=build, |
| 231 | + test_time=test_time, |
| 232 | + host=host, |
| 233 | + capture_cfg=capture_cfg, |
| 234 | + ) |
0 commit comments