(2.4) Fix mulSpectrums inplace#7819
Merged
opencv-pushbot merged 6 commits intoopencv:2.4from Dec 14, 2016
Merged
Conversation
Member
Author
|
👍 |
Contributor
zchrissirhcz
left a comment
There was a problem hiding this comment.
So, the key for inplace checking and avoid compiler optimization, is to check two Mat's data, instead of two InputArray/OutputArray's obj?
i.e. the follwing approaches, which is correct?
void som_function(InputArray _src, OutputArray _dst)
{
Mat src = _src.getMat( );
Mat dst = _dst.getMat( );
// check approach 1
if ( _src.getObj( ) == _dst.getObj( ) ) {
_src.copyTo(src);
}
// check approach 2
if ( src.data == dst.data ) {
_src.copyTo(src);
}
}| // correct inplace support | ||
| // Case 'dst.data == srcA.data' is handled by implementation, | ||
| // because it is used frequently (filter2D, matchTemplate) | ||
| if (dst.data == srcB.data) |
Contributor
There was a problem hiding this comment.
dst is a new created Mat, would dst.data equal to srcB.data? Since srcB = _srcB.getMat, and _srcB is passing from external calling, I don't think if (dst.data == srcB.data) is necessary.
@alalek
Member
Author
There was a problem hiding this comment.
dst is a new created Mat
.create() do not reallocate buffer if requested size is the same. Some problems come from this behavior.
Contributor
|
(Review this pull from cvtColor performance issue in #6760 ) |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiler optimizer might reorder instructions for statements like these:
In case of mixed read/write instructions result becomes wrong.