<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
>Everything should be able to reset + re.read, i mean it's just data on disk/memory so i don't see why it wouldn't work (without bugs).<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The image is in-line, and Gfx::buildImageStream() creates an EmbedStream() with EmbedStream(parser->getStream(), std::move(dict), false, 0, true);</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
EmbedStream() doesn't implement its own reset().</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
When I tried creating an EmbedStream::reset() that called str->reset() and cleared record and replay, when DCTStream::DCTStream() eventually gets the stream after the reset before the second pass for optimizecolorspace, it starts back at the beginning of the
object instead of where the in-line DCT image starts. It eventually finds the image (which is better than before where the read position remained at the end of the image and the second pass found nothing), but it doesn't seem like a good solution.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
EmbedStream::getStart(), setPos(), and moveStart() all print messages like error(errInternal, -1, "Internal: called getStart() on EmbedStream");</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Are you sure that EmbedStream() can be reset in this context without messing up the parser?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have been using -optimizecolorspace for about 5 years, and this is the first time that it didn't work, so if in-line images can't be reset without messing up the parser, I could have PSOutputDev::doImageL1Sep() skip the scan if it can detect that the image
stream an EmbedStream.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
William</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> poppler <poppler-bounces@lists.freedesktop.org> on behalf of Albert Astals Cid <aacid@kde.org><br>
<b>Sent:</b> Friday, September 11, 2020 5:57 AM<br>
<b>To:</b> poppler@lists.freedesktop.org <poppler@lists.freedesktop.org><br>
<b>Subject:</b> Re: [poppler] pdftops -optimizecolorspace and ImageStream::reset()</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">El dijous, 10 de setembre de 2020, a les 23:00:57 CEST, William Bader va escriure:<br>
> I have a PDF where 'pdftops -level1sep -optimizecolorspace' gets 'Syntax Error: Could not find start of jpeg data' and drops part of the image.<br>
> The problem happens in PSOutputDev::doImageL1Sep() where it prescans the image by making a new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits()).<br>
> When I made the patch to add -optimizecolorspace, I had first tried scanning the original stream and then using imgStr->reset(), but it didn't work for some types of streams, so I switched creating a new stream, which is the code currently in poppler.<br>
> But even that doesn't seem to work for DCTStream.<br>
> <br>
> Is the problem that some types of streams can never be reread (which means that -optimizecolorspace can't work as written) or that rereading streams isn't well tested and I might be able to fix it by reviewing the initialization?<br>
<br>
Everyting should be able to reset + re.read, i mean it's just data on disk/memory so i don't see why it wouldn't work (without bugs).<br>
<br>
Cheers,<br>
Albert<br>
<br>
> <br>
> I can post a bug report, including the PDF, which is only 350KB, if it would help.<br>
> <br>
> Thanks, William<br>
> <br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
poppler mailing list<br>
poppler@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/poppler">https://lists.freedesktop.org/mailman/listinfo/poppler</a><br>
</div>
</span></font></div>
</div>
</body>
</html>