Skip to content

imgcodec: gif: remove unnecessary warning#27169

Merged
asmorkalov merged 2 commits intoopencv:4.xfrom
Kumataro:fix27168
Mar 31, 2025
Merged

imgcodec: gif: remove unnecessary warning#27169
asmorkalov merged 2 commits intoopencv:4.xfrom
Kumataro:fix27168

Conversation

@Kumataro
Copy link
Copy Markdown
Contributor

Close #27168

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 another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the 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

@Kumataro
Copy link
Copy Markdown
Contributor Author

I suggest following fix.

            if (code < colorTableSize) {
                imgCodeStream[idx++] = (uchar)code;
            } else {
-               CV_LOG_WARNING(NULL, "Too long LZW length in GIF.");
                CV_Assert(idx + lzwExtraTable[code].length <= width * height);
                for (int i = 0; i < lzwExtraTable[code].length - 1; i++) {

See https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch#Decoding_2

If code < colorTableSize, LZWdecoder outputs single color-index using code.
If not, LZW decoder outputs multiple color-indexes with its dictionary.

We do not have to ouput warning because they are normal behaviour.

@asmorkalov asmorkalov requested a review from vrabaud March 30, 2025 10:30
@asmorkalov asmorkalov self-requested a review March 31, 2025 06:25
@asmorkalov asmorkalov added this to the 4.12.0 milestone Mar 31, 2025
@asmorkalov asmorkalov self-assigned this Mar 31, 2025
@asmorkalov asmorkalov merged commit 1f468dd into opencv:4.x Mar 31, 2025
27 of 28 checks passed
@asmorkalov asmorkalov mentioned this pull request Apr 29, 2025
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.

imgcodec: gif: there are too many runtime warnings on accuracy test

3 participants