common_utils_linux.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. #include "common_utils.h"
  2. #include <time.h>
  3. #include <cpuid.h>
  4. #include <va/va_drm.h>
  5. #include <va/va_drmcommon.h>
  6. #include <va/va_str.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <unistd.h>
  10. #include <fcntl.h>
  11. #include <string.h>
  12. #include <dirent.h>
  13. #include <obs.h>
  14. #include <obs-encoder.h>
  15. #include <obs-nix-platform.h>
  16. #include <graphics/graphics.h>
  17. #include <util/c99defs.h>
  18. #include <util/dstr.h>
  19. #include <util/bmem.h>
  20. // Set during check_adapters to work-around VPL dispatcher not setting a VADisplay
  21. // for the MSDK runtime.
  22. static const char *default_h264_device = nullptr;
  23. static const char *default_hevc_device = nullptr;
  24. static const char *default_av1_device = nullptr;
  25. struct linux_data {
  26. int fd;
  27. VADisplay vaDisplay;
  28. };
  29. #define DEVICE_MGR_TYPE MFX_HANDLE_VA_DISPLAY
  30. // This ends up at like 72 for 1440p@120 AV1.
  31. // We may end up hitting this in practice?
  32. constexpr int32_t MAX_ALLOCABLE_SURFACES = 128;
  33. struct surface_info {
  34. VASurfaceID id;
  35. int32_t width, height;
  36. gs_texture_t *tex_y;
  37. gs_texture_t *tex_uv;
  38. };
  39. mfxStatus simple_alloc(mfxHDL pthis, mfxFrameAllocRequest *request,
  40. mfxFrameAllocResponse *response)
  41. {
  42. if (request->Type & (MFX_MEMTYPE_SYSTEM_MEMORY |
  43. MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
  44. return MFX_ERR_UNSUPPORTED;
  45. response->mids = (mfxMemId *)nullptr;
  46. response->NumFrameActual = 0;
  47. mfxSession *session = (mfxSession *)pthis;
  48. VADisplay display;
  49. mfxStatus sts =
  50. MFXVideoCORE_GetHandle(*session, DEVICE_MGR_TYPE, &display);
  51. MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
  52. // https://ffmpeg.org/doxygen/5.1/hwcontext__vaapi_8c_source.html#l00109
  53. // though earlier comments suggest the driver ignores rt_format so we could choose whatever.
  54. unsigned int rt_format;
  55. int32_t pix_format;
  56. switch (request->Info.FourCC) {
  57. case MFX_FOURCC_P010:
  58. rt_format = VA_RT_FORMAT_YUV420_10;
  59. pix_format = VA_FOURCC_P010;
  60. break;
  61. case MFX_FOURCC_NV12:
  62. default:
  63. rt_format = VA_RT_FORMAT_YUV420;
  64. pix_format = VA_FOURCC_NV12;
  65. break;
  66. }
  67. int num_attrs = 2;
  68. VASurfaceAttrib attrs[2] = {
  69. {
  70. .type = VASurfaceAttribMemoryType,
  71. .flags = VA_SURFACE_ATTRIB_SETTABLE,
  72. .value =
  73. {
  74. .type = VAGenericValueTypeInteger,
  75. .value =
  76. {.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2},
  77. },
  78. },
  79. {
  80. .type = VASurfaceAttribPixelFormat,
  81. .flags = VA_SURFACE_ATTRIB_SETTABLE,
  82. .value =
  83. {
  84. .type = VAGenericValueTypeInteger,
  85. .value = {.i = (int)pix_format},
  86. },
  87. }};
  88. unsigned int num_surfaces = request->NumFrameSuggested;
  89. VASurfaceID temp_surfaces[MAX_ALLOCABLE_SURFACES] = {0};
  90. assert(num_surfaces < MAX_ALLOCABLE_SURFACES);
  91. VAStatus vasts;
  92. if ((vasts = vaCreateSurfaces(display, rt_format, request->Info.Width,
  93. request->Info.Height, temp_surfaces,
  94. num_surfaces, attrs, num_attrs)) !=
  95. VA_STATUS_SUCCESS) {
  96. blog(LOG_ERROR, "failed to create surfaces: %d", vasts);
  97. return MFX_ERR_MEMORY_ALLOC;
  98. }
  99. // Follow the FFmpeg trick and stuff our pointer at the end.
  100. mfxMemId *mids =
  101. (mfxMemId *)bmalloc(sizeof(mfxMemId) * num_surfaces + 1);
  102. struct surface_info *surfaces = (struct surface_info *)bmalloc(
  103. sizeof(struct surface_info) * num_surfaces);
  104. mids[num_surfaces] = surfaces; // stuff it
  105. for (uint64_t i = 0; i < num_surfaces; i++) {
  106. surfaces[i].id = temp_surfaces[i];
  107. surfaces[i].width = request->Info.Width;
  108. surfaces[i].height = request->Info.Height;
  109. mids[i] = &surfaces[i];
  110. VADRMPRIMESurfaceDescriptor surfDesc = {0};
  111. if (vaExportSurfaceHandle(display, surfaces[i].id,
  112. VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
  113. VA_EXPORT_SURFACE_READ_WRITE,
  114. &surfDesc) != VA_STATUS_SUCCESS)
  115. return MFX_ERR_MEMORY_ALLOC;
  116. obs_enter_graphics();
  117. // TODO: P010 format support
  118. assert(surfDesc.num_objects == 1);
  119. int fds[4] = {0};
  120. uint32_t strides[4] = {0};
  121. uint32_t offsets[4] = {0};
  122. uint64_t modifiers[4] = {0};
  123. fds[0] =
  124. surfDesc.objects[surfDesc.layers[0].object_index[0]].fd;
  125. fds[1] =
  126. surfDesc.objects[surfDesc.layers[1].object_index[0]].fd;
  127. strides[0] = surfDesc.layers[0].pitch[0];
  128. strides[1] = surfDesc.layers[1].pitch[0];
  129. offsets[0] = surfDesc.layers[0].offset[0];
  130. offsets[1] = surfDesc.layers[1].offset[0];
  131. modifiers[0] =
  132. surfDesc.objects[surfDesc.layers[0].object_index[0]]
  133. .drm_format_modifier;
  134. modifiers[1] =
  135. surfDesc.objects[surfDesc.layers[1].object_index[0]]
  136. .drm_format_modifier;
  137. surfaces[i].tex_y = gs_texture_create_from_dmabuf(
  138. surfDesc.width, surfDesc.height,
  139. surfDesc.layers[0].drm_format, GS_R8, 1, fds, strides,
  140. offsets, modifiers);
  141. surfaces[i].tex_uv = gs_texture_create_from_dmabuf(
  142. surfDesc.width / 2, surfDesc.height,
  143. surfDesc.layers[1].drm_format, GS_R8G8, 1, fds + 1,
  144. strides + 1, offsets + 1, modifiers + 1);
  145. obs_leave_graphics();
  146. close(surfDesc.objects[surfDesc.layers[0].object_index[0]].fd);
  147. if (!surfaces[i].tex_y || !surfaces[i].tex_uv) {
  148. return MFX_ERR_MEMORY_ALLOC;
  149. }
  150. }
  151. response->mids = (mfxMemId *)mids;
  152. response->NumFrameActual = num_surfaces;
  153. return MFX_ERR_NONE;
  154. }
  155. mfxStatus simple_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
  156. {
  157. UNUSED_PARAMETER(pthis);
  158. UNUSED_PARAMETER(mid);
  159. UNUSED_PARAMETER(ptr);
  160. return MFX_ERR_UNSUPPORTED;
  161. }
  162. mfxStatus simple_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
  163. {
  164. UNUSED_PARAMETER(pthis);
  165. UNUSED_PARAMETER(mid);
  166. UNUSED_PARAMETER(ptr);
  167. return MFX_ERR_UNSUPPORTED;
  168. }
  169. mfxStatus simple_gethdl(mfxHDL pthis, mfxMemId mid, mfxHDL *handle)
  170. {
  171. UNUSED_PARAMETER(pthis);
  172. if (NULL == handle)
  173. return MFX_ERR_INVALID_HANDLE;
  174. // Seemingly undocumented, but Pair format defined by
  175. // oneVPL-intel-gpu-intel-onevpl-23.1.0/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp
  176. // https://github.com/intel/vpl-gpu-rt/blob/4170dd9fa1ea319dda81b6189616ecc9b178a321/_studio/shared/src/libmfx_core_vaapi.cpp#L1464
  177. mfxHDLPair *pPair = (mfxHDLPair *)handle;
  178. // first must be a pointer to a VASurfaceID and will be dereferenced by
  179. // the driver.
  180. pPair->first = &((struct surface_info *)mid)->id;
  181. pPair->second = 0;
  182. return MFX_ERR_NONE;
  183. }
  184. mfxStatus simple_free(mfxHDL pthis, mfxFrameAllocResponse *response)
  185. {
  186. if (response == nullptr)
  187. return MFX_ERR_NULL_PTR;
  188. if (response->mids == nullptr || response->NumFrameActual == 0)
  189. return MFX_ERR_NONE;
  190. mfxSession *session = (mfxSession *)pthis;
  191. VADisplay display;
  192. mfxStatus sts =
  193. MFXVideoCORE_GetHandle(*session, DEVICE_MGR_TYPE, &display);
  194. MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
  195. struct surface_info *surfs =
  196. (struct surface_info *)response->mids[response->NumFrameActual];
  197. VASurfaceID temp_surfaces[MAX_ALLOCABLE_SURFACES] = {0};
  198. obs_enter_graphics();
  199. for (int i = 0; i < response->NumFrameActual; i++) {
  200. temp_surfaces[i] = *(VASurfaceID *)response->mids[i];
  201. gs_texture_destroy(surfs[i].tex_y);
  202. gs_texture_destroy(surfs[i].tex_uv);
  203. }
  204. obs_leave_graphics();
  205. bfree(surfs);
  206. bfree(response->mids);
  207. if (vaDestroySurfaces(display, temp_surfaces,
  208. response->NumFrameActual) != VA_STATUS_SUCCESS)
  209. return MFX_ERR_MEMORY_ALLOC;
  210. return MFX_ERR_NONE;
  211. }
  212. mfxStatus simple_copytex(mfxHDL pthis, mfxMemId mid, void *tex, mfxU64 lock_key,
  213. mfxU64 *next_key)
  214. {
  215. UNUSED_PARAMETER(lock_key);
  216. UNUSED_PARAMETER(next_key);
  217. profile_start("copy_tex");
  218. mfxSession *session = (mfxSession *)pthis;
  219. VADisplay display;
  220. mfxStatus sts =
  221. MFXVideoCORE_GetHandle(*session, DEVICE_MGR_TYPE, &display);
  222. MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
  223. struct encoder_texture *ptex = (struct encoder_texture *)tex;
  224. struct surface_info *surf = (struct surface_info *)mid;
  225. obs_enter_graphics();
  226. gs_copy_texture(surf->tex_y, ptex->tex[0]);
  227. gs_copy_texture(surf->tex_uv, ptex->tex[1]);
  228. obs_leave_graphics();
  229. profile_end("copy_tex");
  230. return MFX_ERR_NONE;
  231. }
  232. struct get_drm_device_params {
  233. const char **out_path;
  234. uint32_t idx;
  235. };
  236. bool get_drm_device(void *param, const char *node, uint32_t idx)
  237. {
  238. struct get_drm_device_params *p = (struct get_drm_device_params *)param;
  239. if (idx == p->idx) {
  240. *p->out_path = node;
  241. return false;
  242. }
  243. return true;
  244. }
  245. // Initialize Intel VPL Session, device/display and memory manager
  246. mfxStatus Initialize(mfxVersion ver, mfxSession *pSession,
  247. mfxFrameAllocator *pmfxAllocator, mfxHDL *deviceHandle,
  248. bool bCreateSharedHandles, enum qsv_codec codec,
  249. void **data)
  250. {
  251. UNUSED_PARAMETER(ver);
  252. UNUSED_PARAMETER(deviceHandle);
  253. UNUSED_PARAMETER(bCreateSharedHandles);
  254. mfxStatus sts = MFX_ERR_NONE;
  255. mfxVariant impl;
  256. // Initialize Intel VPL Session
  257. mfxLoader loader = MFXLoad();
  258. mfxConfig cfg = MFXCreateConfig(loader);
  259. impl.Type = MFX_VARIANT_TYPE_U32;
  260. impl.Data.U32 = MFX_IMPL_TYPE_HARDWARE;
  261. MFXSetConfigFilterProperty(
  262. cfg, (const mfxU8 *)"mfxImplDescription.Impl", impl);
  263. impl.Type = MFX_VARIANT_TYPE_U32;
  264. impl.Data.U32 = INTEL_VENDOR_ID;
  265. MFXSetConfigFilterProperty(
  266. cfg, (const mfxU8 *)"mfxImplDescription.VendorID", impl);
  267. impl.Type = MFX_VARIANT_TYPE_U32;
  268. impl.Data.U32 = MFX_ACCEL_MODE_VIA_VAAPI_DRM_RENDER_NODE;
  269. MFXSetConfigFilterProperty(
  270. cfg, (const mfxU8 *)"mfxImplDescription.AccelerationMode",
  271. impl);
  272. const char *device_path = NULL;
  273. int fd = -1;
  274. if (pmfxAllocator) {
  275. obs_video_info ovi;
  276. obs_get_video_info(&ovi);
  277. struct get_drm_device_params params = {&device_path,
  278. (uint32_t)ovi.adapter};
  279. obs_enter_graphics();
  280. gs_enum_adapters(get_drm_device, &params);
  281. obs_leave_graphics();
  282. } else {
  283. if (codec == QSV_CODEC_AVC && default_h264_device)
  284. device_path = default_h264_device;
  285. else if (codec == QSV_CODEC_HEVC && default_hevc_device)
  286. device_path = default_hevc_device;
  287. else if (codec == QSV_CODEC_AV1 && default_av1_device)
  288. device_path = default_av1_device;
  289. }
  290. fd = open(device_path, O_RDWR);
  291. if (fd < 0) {
  292. blog(LOG_ERROR, "Failed to open device '%s'", device_path);
  293. return MFX_ERR_DEVICE_FAILED;
  294. }
  295. mfxHDL vaDisplay = vaGetDisplayDRM(fd);
  296. if (!vaDisplay) {
  297. return MFX_ERR_DEVICE_FAILED;
  298. }
  299. sts = MFXCreateSession(loader, 0, pSession);
  300. if (MFX_ERR_NONE > sts) {
  301. blog(LOG_ERROR, "Failed to initialize MFX");
  302. MSDK_PRINT_RET_MSG(sts);
  303. close(fd);
  304. return sts;
  305. }
  306. // VPL expects the VADisplay to be initialized.
  307. int major;
  308. int minor;
  309. if (vaInitialize(vaDisplay, &major, &minor) != VA_STATUS_SUCCESS) {
  310. blog(LOG_ERROR, "Failed to initialize VA-API");
  311. vaTerminate(vaDisplay);
  312. close(fd);
  313. return MFX_ERR_DEVICE_FAILED;
  314. }
  315. sts = MFXVideoCORE_SetHandle(*pSession, DEVICE_MGR_TYPE, vaDisplay);
  316. MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
  317. if (pmfxAllocator) {
  318. // Allow us to access the session during allocation.
  319. pmfxAllocator->pthis = pSession;
  320. pmfxAllocator->Alloc = simple_alloc;
  321. pmfxAllocator->Free = simple_free;
  322. pmfxAllocator->Lock = simple_lock;
  323. pmfxAllocator->Unlock = simple_unlock;
  324. pmfxAllocator->GetHDL = simple_gethdl;
  325. sts = MFXVideoCORE_SetFrameAllocator(*pSession, pmfxAllocator);
  326. MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
  327. }
  328. struct linux_data *d =
  329. (struct linux_data *)bmalloc(sizeof(struct linux_data));
  330. d->fd = fd;
  331. d->vaDisplay = (VADisplay)vaDisplay;
  332. *data = d;
  333. return sts;
  334. }
  335. void Release() {}
  336. // Release per session resources.
  337. void ReleaseSessionData(void *data)
  338. {
  339. struct linux_data *d = (struct linux_data *)data;
  340. if (d) {
  341. vaTerminate(d->vaDisplay);
  342. close(d->fd);
  343. bfree(d);
  344. }
  345. }
  346. void mfxGetTime(mfxTime *timestamp)
  347. {
  348. clock_gettime(CLOCK_MONOTONIC, timestamp);
  349. }
  350. double TimeDiffMsec(mfxTime tfinish, mfxTime tstart)
  351. {
  352. UNUSED_PARAMETER(tfinish);
  353. UNUSED_PARAMETER(tstart);
  354. //unused so far
  355. return 0.0;
  356. }
  357. extern "C" void util_cpuid(int cpuinfo[4], int level)
  358. {
  359. __get_cpuid(level, (unsigned int *)&cpuinfo[0],
  360. (unsigned int *)&cpuinfo[1], (unsigned int *)&cpuinfo[2],
  361. (unsigned int *)&cpuinfo[3]);
  362. }
  363. struct vaapi_device {
  364. int fd;
  365. VADisplay display;
  366. const char *driver;
  367. };
  368. static void vaapi_open(const char *device_path, struct vaapi_device *device)
  369. {
  370. int fd = open(device_path, O_RDWR);
  371. if (fd < 0) {
  372. return;
  373. }
  374. VADisplay display = vaGetDisplayDRM(fd);
  375. if (!display) {
  376. close(fd);
  377. return;
  378. }
  379. // VA-API is noisy by default.
  380. vaSetInfoCallback(display, nullptr, nullptr);
  381. vaSetErrorCallback(display, nullptr, nullptr);
  382. int major;
  383. int minor;
  384. if (vaInitialize(display, &major, &minor) != VA_STATUS_SUCCESS) {
  385. vaTerminate(display);
  386. close(fd);
  387. return;
  388. }
  389. const char *driver = vaQueryVendorString(display);
  390. if (strstr(driver, "Intel i965 driver") != nullptr) {
  391. blog(LOG_WARNING,
  392. "Legacy intel-vaapi-driver detected, incompatible with QSV");
  393. vaTerminate(display);
  394. close(fd);
  395. return;
  396. }
  397. device->fd = fd;
  398. device->display = display;
  399. device->driver = driver;
  400. }
  401. static void vaapi_close(struct vaapi_device *device)
  402. {
  403. vaTerminate(device->display);
  404. close(device->fd);
  405. }
  406. static uint32_t vaapi_check_support(VADisplay display, VAProfile profile,
  407. VAEntrypoint entrypoint)
  408. {
  409. VAConfigAttrib attrib[1];
  410. attrib->type = VAConfigAttribRateControl;
  411. VAStatus va_status =
  412. vaGetConfigAttributes(display, profile, entrypoint, attrib, 1);
  413. uint32_t rc = 0;
  414. switch (va_status) {
  415. case VA_STATUS_SUCCESS:
  416. rc = attrib->value;
  417. break;
  418. case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
  419. case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
  420. default:
  421. break;
  422. }
  423. return (rc & VA_RC_CBR || rc & VA_RC_CQP || rc & VA_RC_VBR);
  424. }
  425. static bool vaapi_supports_h264(VADisplay display)
  426. {
  427. bool ret = false;
  428. ret |= vaapi_check_support(display, VAProfileH264ConstrainedBaseline,
  429. VAEntrypointEncSlice);
  430. ret |= vaapi_check_support(display, VAProfileH264Main,
  431. VAEntrypointEncSlice);
  432. ret |= vaapi_check_support(display, VAProfileH264High,
  433. VAEntrypointEncSlice);
  434. if (!ret) {
  435. ret |= vaapi_check_support(display,
  436. VAProfileH264ConstrainedBaseline,
  437. VAEntrypointEncSliceLP);
  438. ret |= vaapi_check_support(display, VAProfileH264Main,
  439. VAEntrypointEncSliceLP);
  440. ret |= vaapi_check_support(display, VAProfileH264High,
  441. VAEntrypointEncSliceLP);
  442. }
  443. return ret;
  444. }
  445. static bool vaapi_supports_av1(VADisplay display)
  446. {
  447. bool ret = false;
  448. // Are there any devices with non-LowPower entrypoints?
  449. ret |= vaapi_check_support(display, VAProfileAV1Profile0,
  450. VAEntrypointEncSlice);
  451. ret |= vaapi_check_support(display, VAProfileAV1Profile0,
  452. VAEntrypointEncSliceLP);
  453. return ret;
  454. }
  455. static bool vaapi_supports_hevc(VADisplay display)
  456. {
  457. bool ret = false;
  458. ret |= vaapi_check_support(display, VAProfileHEVCMain,
  459. VAEntrypointEncSlice);
  460. ret |= vaapi_check_support(display, VAProfileHEVCMain,
  461. VAEntrypointEncSliceLP);
  462. return ret;
  463. }
  464. bool check_adapter(void *param, const char *node, uint32_t idx)
  465. {
  466. struct vaapi_device device = {0};
  467. struct adapter_info *adapters = (struct adapter_info *)param;
  468. vaapi_open(node, &device);
  469. if (!device.display)
  470. return true;
  471. struct adapter_info *adapter = &adapters[idx];
  472. adapter->is_intel = strstr(device.driver, "Intel") != nullptr;
  473. // This is currently only used for LowPower coding which is busted on VA-API anyway.
  474. adapter->is_dgpu = false;
  475. adapter->supports_av1 = vaapi_supports_av1(device.display);
  476. adapter->supports_hevc = vaapi_supports_hevc(device.display);
  477. if (adapter->is_intel && default_h264_device == nullptr)
  478. default_h264_device = strdup(node);
  479. if (adapter->is_intel && adapter->supports_av1 &&
  480. default_av1_device == nullptr)
  481. default_av1_device = strdup(node);
  482. if (adapter->is_intel && adapter->supports_hevc &&
  483. default_hevc_device == nullptr)
  484. default_hevc_device = strdup(node);
  485. vaapi_close(&device);
  486. return true;
  487. }
  488. void check_adapters(struct adapter_info *adapters, size_t *adapter_count)
  489. {
  490. obs_enter_graphics();
  491. uint32_t gs_count = gs_get_adapter_count();
  492. if (*adapter_count < gs_count) {
  493. blog(LOG_WARNING, "Too many video adapters: %ld < %d",
  494. *adapter_count, gs_count);
  495. obs_leave_graphics();
  496. return;
  497. }
  498. gs_enum_adapters(check_adapter, adapters);
  499. obs_leave_graphics();
  500. }