| 540 | } |
| 541 | |
| 542 | IPluginV2Ext* CropAndResizePluginCreator::createPlugin(char const* /* name */, PluginFieldCollection const* fc) noexcept |
| 543 | { |
| 544 | try |
| 545 | { |
| 546 | PLUGIN_VALIDATE(fc != nullptr); |
| 547 | PluginField const* fields = fc->fields; |
| 548 | int32_t nbFields = fc->nbFields; |
| 549 | int32_t cropWidth = 0; |
| 550 | int32_t cropHeight = 0; |
| 551 | |
| 552 | validateRequiredAttributesExist({"crop_width", "crop_height"}, fc); |
| 553 | |
| 554 | for (int32_t i = 0; i < nbFields; ++i) |
| 555 | { |
| 556 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 557 | |
| 558 | if (!strcmp(fields[i].name, "crop_width")) |
| 559 | { |
| 560 | cropWidth = *(reinterpret_cast<int32_t const*>(fields[i].data)); |
| 561 | } |
| 562 | |
| 563 | if (!strcmp(fields[i].name, "crop_height")) |
| 564 | { |
| 565 | cropHeight = *(reinterpret_cast<int32_t const*>(fields[i].data)); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | PLUGIN_VALIDATE(cropWidth > 0 && cropHeight > 0); |
| 570 | IPluginV2Ext* plugin = new CropAndResizePlugin(cropWidth, cropHeight); |
| 571 | plugin->setPluginNamespace(mNamespace.c_str()); |
| 572 | return plugin; |
| 573 | } |
| 574 | catch (std::exception const& e) |
| 575 | { |
| 576 | caughtError(e); |
| 577 | } |
| 578 | return nullptr; |
| 579 | } |
| 580 | |
| 581 | IPluginV2DynamicExt* CropAndResizeDynamicPluginCreator::createPlugin( |
| 582 | char const* /*name */, PluginFieldCollection const* fc) noexcept |
nothing calls this directly
no test coverage detected