<html>
    <head>
      <base href="https://bugs.webkit.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK][WPE] Support JPEG 2000 images"
   href="https://bugs.webkit.org/show_bug.cgi?id=186272#c20">Comment # 20</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK][WPE] Support JPEG 2000 images"
   href="https://bugs.webkit.org/show_bug.cgi?id=186272">bug 186272</a>
              from <span class="vcard"><a class="email" href="mailto:cgarcia@igalia.com" title="Carlos Garcia Campos <cgarcia@igalia.com>"> <span class="fn">Carlos Garcia Campos</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=359745&action=diff" name="attach_359745" title="Patch">attachment 359745</a> <a href="attachment.cgi?id=359745&action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=359745&action=review">https://bugs.webkit.org/attachment.cgi?id=359745&action=review</a>

<span class="quote">>> Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:57
>> +    *b = std::max(0, std::min(upb, y + static_cast<int>(1.772 * static_cast<float>(cb))));

> Why not use matrix coefficients wholly, like it's done in the color_esycc_to_rgb() function in openjpeg?

> Instead of std::min/std::max, you could consider using clampTo<>(), but keeping all of calculation in float.
> So for r value, you'd have:

>     r = static_cast<int>(clampTo<float>(y - 0.0000368 + 1.40199 * cr, 0, upb));</span >

I have no idea, this code is copied from OpenJPEG. I just used min/max instead of the ifs in the original code. I'll use clamp as you suggest.

<span class="quote">>> Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:68
>> +    size_t max = maxw * maxh;

> Any way to impose sane limits on these sizes, and/or to protect from overflow?</span >

Ditto. I guess we could use CheckedArithmetic.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>