Skip to content

tiff need check TIFFTAG_SAMPLEFORMAT, should not always use unsigned.#21400

Merged
alalek merged 3 commits intoopencv:4.xfrom
Harvey-Huang:master
Jan 11, 2022
Merged

tiff need check TIFFTAG_SAMPLEFORMAT, should not always use unsigned.#21400
alalek merged 3 commits intoopencv:4.xfrom
Harvey-Huang:master

Conversation

@Harvey-Huang
Copy link
Copy Markdown
Contributor

@Harvey-Huang Harvey-Huang commented Jan 6, 2022

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
force_builders=linux,win64,mac,docs

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!

(ncn != 1 && ncn != 3 && ncn != 4)))
bpp = 8;

char depth;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int depth;

It is better to move it below into "case" code blocks:

case XXX:
{
    int depth = ...
    .. use depth ...
    break;
}

bpp = 8;

char depth;
uint16 fmt = SAMPLEFORMAT_UINT;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt -> sample_format

{
case 1:
m_type = CV_MAKETYPE(CV_8U, !isGrayScale ? wanted_channels : 1);
depth = fmt == SAMPLEFORMAT_INT ? CV_8S : CV_8U;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to validate its value first:

CV_Check((int)sample_format, sample_format == SAMPLEFORMAT_UINT || sample_format == SAMPLEFORMAT_INT, "");

m_type = CV_MAKETYPE(depth, !isGrayScale ? wanted_channels : 1);
result = true;
break;
case 32:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 and 64 cases:
CV_CheckEQ((int)sample_format, SAMPLEFORMAT_IEEEFP, "");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, for 32 case, since OpenCV has CV_32S, so 32 case should allow SAMPLEFORMAT_INT?

@Harvey-Huang
Copy link
Copy Markdown
Contributor Author

thanks for reviewing, I updated the code.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you 👍

@alalek alalek merged commit c3e27bc into opencv:4.x Jan 11, 2022
@alalek alalek mentioned this pull request Feb 22, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
tiff need check TIFFTAG_SAMPLEFORMAT, should not always use unsigned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants