Skip to content

Commit

Permalink
perf: Improve perf of IBA::channels in-place operation (AcademySoftwa…
Browse files Browse the repository at this point in the history
…reFoundation#4088)

For the in-place case (where src and dst refer to the same IB), we were
doing an unnecessary full-image copy.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
  • Loading branch information
lgritz authored and 1div0 committed Feb 24, 2024
1 parent f6f9e26 commit 3037b71
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libOpenImageIO/imagebufalgo_channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ ImageBufAlgo::channels(ImageBuf& dst, const ImageBuf& src, int nchannels,
{
// Handle in-place case
if (&dst == &src) {
ImageBuf tmp = src;
return channels(dst, tmp, nchannels, channelorder, channelvalues,
newchannelnames, shuffle_channel_names, nthreads);
ImageBuf tmp;
bool ok = channels(tmp, src, nchannels, channelorder, channelvalues,
newchannelnames, shuffle_channel_names, nthreads);
dst = std::move(tmp);
return ok;
}

pvt::LoggedTimer logtime("IBA::channels");
Expand Down

0 comments on commit 3037b71

Please sign in to comment.