| 686 | } |
| 687 | |
| 688 | void Pipe::addSplitResizeTransform(size_t num_streams, size_t min_outstreams_per_resize_after_split, bool strict) |
| 689 | { |
| 690 | OutputPortRawPtrs resize_output_ports(num_streams); |
| 691 | |
| 692 | size_t groups = std::min<size_t>(numOutputPorts(), num_streams / min_outstreams_per_resize_after_split); |
| 693 | size_t instream_per_group = (numOutputPorts() + groups - 1) / groups; |
| 694 | size_t groups_with_extra_instream = numOutputPorts() % groups; |
| 695 | size_t outstreams_per_group = (num_streams + groups - 1) / groups; |
| 696 | size_t groups_with_extra_outstream = num_streams % groups; |
| 697 | |
| 698 | chassert(groups > 1); |
| 699 | |
| 700 | for (size_t i = 0, next_input = 0, next_output = 0; i < groups; ++i) |
| 701 | { |
| 702 | ProcessorPtr resize; |
| 703 | if (strict) |
| 704 | resize = std::make_shared<StrictResizeProcessor>(getSharedHeader(), instream_per_group, outstreams_per_group); |
| 705 | else |
| 706 | resize = std::make_shared<ResizeProcessor>(getSharedHeader(), instream_per_group, outstreams_per_group); |
| 707 | |
| 708 | for (auto it = resize->getInputs().begin(); it != resize->getInputs().end(); ++it) |
| 709 | { |
| 710 | if (std::next(it) != resize->getInputs().end() || groups_with_extra_instream == 0 || i < groups_with_extra_instream) |
| 711 | { |
| 712 | connect(*output_ports[next_input], *it); |
| 713 | ++next_input; |
| 714 | } |
| 715 | else |
| 716 | { |
| 717 | auto null_source = std::make_shared<NullSource>(getSharedHeader()); |
| 718 | connect(null_source->getPort(), *it); |
| 719 | processors->emplace_back(std::move(null_source)); |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | for (auto it = resize->getOutputs().begin(); it != resize->getOutputs().end(); ++it) |
| 724 | { |
| 725 | if (std::next(it) != resize->getOutputs().end() || groups_with_extra_outstream == 0 || i < groups_with_extra_outstream) |
| 726 | { |
| 727 | resize_output_ports[next_output] = &*it; |
| 728 | ++next_output; |
| 729 | } |
| 730 | else |
| 731 | { |
| 732 | auto null_sink = std::make_shared<NullSink>(getSharedHeader()); |
| 733 | connect(*it, null_sink->getPort()); |
| 734 | processors->emplace_back(std::move(null_sink)); |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | if (collected_processors) |
| 739 | collected_processors->emplace_back(resize); |
| 740 | processors->emplace_back(std::move(resize)); |
| 741 | } |
| 742 | |
| 743 | output_ports = std::move(resize_output_ports); |
| 744 | |
| 745 | header = output_ports.front()->getSharedHeader(); |
nothing calls this directly
no test coverage detected