<div dir="ltr"><div><div><div><div>Hello Matthieu,<br><br></div>A test case is attached. It allocates an uncompressed 1165 by 1434 pixel 16-bit image, and writes a relatively small set of pixels while still reproducing the issue.<br><br></div>It then fills a DcmFileFormat wih the values required to store it as a valid Dicom JPEG-LS image. During the dcmff.saveFile() call, the assertion failure happens:<br><br>test_dcmtk: /home/sjors/src/charls-1.0/encoderstrategy.h:81: void EncoderStrategy::AppendToBitStream(LONG, LONG): Assertion `bitpos >=0' failed.<br><br></div><div>Hopefully this will allow you to reproduce as well. I know about three fixes/workarounds (I don't know which one applies):<br></div><div>1. The patch dcmtk applied, which returns before the assertion is ever checked,<br></div><div>2. Calling Flush() again if bitpos is still lower than 0, or<br></div><div>3. Increasing the amount of iterations in Flush() so that bitpos cannot be lower than 0 after returning from that function.<br><br></div><div>Maybe some input from the CharLS developers would be useful here.<br></div><br></div>Sjors<br><div><div><div><div><div><div><div><div><div><br><div class="gmail_quote"><div dir="ltr">Op do 3 mrt. 2016 om 22:37 schreef Sjors Gielen <<a href="mailto:sjors@sjorsgielen.nl">sjors@sjorsgielen.nl</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Mathieu,<div><br></div><div>I have a working test-case, but as it contains an uncompressed image, it is currently 7 MB. I'm trying to make it smaller before I'll upload it, and hope to have that done by tomorrow. It uses CharLS through DCMTK – which, on Debian, uses system CharLS, not the DCMTK-shipped one.</div><div><br></div><div>I have been using the patch you linked as a workaround in the past, but upstream CharLS has expressed doubts over the patch as committed to DCMTK's shipped CharLS. I haven't verified these doubts myself, but the patch is not applied to CharLS upstream either. See: <a href="http://charls.codeplex.com/workitem/10742" target="_blank">http://charls.codeplex.com/workitem/10742</a> and <a href="https://github.com/team-charls/charls/blob/master/src/encoderstrategy.h#L83" target="_blank">https://github.com/team-charls/charls/blob/master/src/encoderstrategy.h#L83</a>.</div><div><br></div><div>Interestingly, in the first link above, upstream says the problem is linked in this changeset: <a href="https://github.com/team-charls/charls/commit/c7cf959f348f8e0c47f1197c89ef959372c572e9" target="_blank">https://github.com/team-charls/charls/commit/c7cf959f348f8e0c47f1197c89ef959372c572e9</a> – I can see that that changeset adds a test, but not that it fixes the actual issue upstream...</div><div><br></div><div>Sjors</div></div><br><div class="gmail_quote"><div dir="ltr">Op do 3 mrt. 2016 om 21:15 schreef Mathieu Malaterre <<a href="mailto:malat@debian.org" target="_blank">malat@debian.org</a>>:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Control: tags -1 moreinfo<br>
<br>
Dear OP,<br>
<br>
Since you did not provide material to reproduce the issue, did you try<br>
the proposed patch ?<br>
<br>
<a href="http://git.dcmtk.org/?p=dcmtk.git;a=commitdiff;h=d885abd90ef90f6566555298064190561ff0412a" rel="noreferrer" target="_blank">http://git.dcmtk.org/?p=dcmtk.git;a=commitdiff;h=d885abd90ef90f6566555298064190561ff0412a</a><br>
<br>
Unless some kind of sample file is provided I cannot possibly include<br>
a fix for the next upload.<br>
</blockquote></div></blockquote></div></div></div></div></div></div></div></div></div></div></div>