ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Dcraw 1.461 plugin hangs in FindStreamFormat

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
goobit Posted - May 18 2014 : 05:08:16
Hi.

I have a "colorpicker.cur" file that ImageEn can't load as ioCUR file format. But this is not a problem for me. Problem that when dcraw plugin loaded application hangs on this file when trying to recognize it's format (hang in FindStreamFormat function when dcraw's TryFunction was called).

Test project with cur-file attached. "Try load" button hangs application (Needs dcrawlib.dll file in project folder to run).

Download Attachment: 201452031512_TestDCRAWSimple.zip
20   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 10 2015 : 13:23:58
FYI, it is available now from the Registered Users page.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
xequte Posted - Feb 02 2015 : 16:48:10
OK, thanks, we will update before too long.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
goobit Posted - Feb 02 2015 : 04:35:13
I would like to inform that new version of dcraw was released:
Revision: 1.468
Date: 2015/01/30

Thanks!
xequte Posted - Aug 18 2014 : 02:38:53
Thanks for the update,

We'll have this in the next DCRAW release.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
goobit Posted - Aug 18 2014 : 01:43:52
I wrote to the author of DCRaw tool David Coffin and he has fixed this bug:

The bug is in the RIFF file:

000000  52 49 46 46 4A 03 00 00 41 43 4F 4E 61 6E 69 68   RIFFJ...ACONanih
                    ^^ ^^ ^^ ^^
000010  24 00 00 00 24 00 00 00 01 00 00 00 01 00 00 00   $...$...........
        ^^ ^^ ^^ ^^
000020  00 00 00 00 00 00 00 00 04 00 00 00 01 00 00 00   ................

000030  0A 00 00 00 01 00 00 00 4C 49 53 54 0A 03 00 00   ........LIST....
                                            ^^ ^^ ^^ ^^
000040  66 72 61 6D 69 63 6F 6E FE 02 00 00 00 00 02 00   framicon........
...                             ^^ ^^ ^^ ^^
000340  FF FF FF FF FF FF FF FF FF FF                     ..........


The first eight bytes mean "a RIFF of size 0x34A".
The size field is the number of bytes *after* the first
eight, but in this case 0x34A (842 decimal) is the size
of the whole file. It should be "42 03 00 00".

The size fields of the "anih", "LIST", and "icon"
tags are correct, leading dcraw to believe that the RIFF
contains eight bytes of something extra. Trying to read
this nonexistent tag causes a hang.

--- dcraw.c     2014/07/03 21:19:24     1.467
+++ dcraw.c     2014/08/17 17:33:04
@@ -6558,7 +6558,7 @@
   end = ftell(ifp) + size;
   if (!memcmp(tag,"RIFF",4) || !memcmp(tag,"LIST",4)) {
     get4();
-    while (ftell(ifp)+7 < end)
+    while (ftell(ifp)+7 < end && !feof(ifp))
       parse_riff();
   } else if (!memcmp(tag,"nctg",4)) {
     while (ftell(ifp)+7 < end) {

Uwe Posted - May 25 2014 : 11:07:55
FWIW:
Just tested with IrfanView and got a warning that "colorpicker.cur" is actually an ANI file with an incorrect extension. Since this file can practically kill any application that uses ImageEn (I checked Faststone Image Viewer for example, and it crashed), I think some error handling in imageenio.pas for this type of scenario would be helpful.

-Uwe

goobit Posted - May 24 2014 : 23:22:25
Guys, this is correct cursor file that I found in Steam application folder while test batch loading process. At least old Imagine plugin for Total Commander open and display it normally.

I think the problem is in some binary data sequence stored in this particular file that cause infinite loop in dcraw plugin and this sequence can be found in other (non cursor) files.
xequte Posted - May 24 2014 : 22:57:47
Thanks Uwe,

It might be a corrupt file, we have not had time to investigate yet.




Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Uwe Posted - May 24 2014 : 15:11:00
Nigel,

Something's wrong with the file that the OP provided. Try any other regular CUR file and you will see that ImageEn loads it without any problem. I just checked a whole bunch of them.

-Uwe
xequte Posted - May 22 2014 : 18:52:34
We are investigating...

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Uwe Posted - May 21 2014 : 15:48:55
Sorry, I'm out of ideas. Looking at imageenio.pas, it seems that the FindStreamFormat call fails when checking for a format like CUR. Why that behavior is triggered by dcrawlib.dll, is beyond me.

-Uwe
goobit Posted - May 20 2014 : 03:18:19
I remake the test project. Now it uses ImageEn code only. Needs to copy the dcrawlib.dll in project folder to work. Same result.

Test project (simple): 201452031512_TestDCRAWSimple.zip
Uwe Posted - May 19 2014 : 09:36:09
D2010 Pro:
I get a "Return value of function 'TryFunctions' might be undefined" warning when compiling.

Wouldn't TryFunctions() fail if you try to reset the stream position to 0 for a file that can't be loaded in the first place? Just a thought.

-Uwe
goobit Posted - May 19 2014 : 08:57:42
Actually our ieFindStreamFormat() is a combination of FindStreamFormat and FindFileFormat plus some useful for us features (working with stream, "Aborted" parameter, using optionally file extension as first try suggestion that can greatly speeds up format detection).

Is PhotoEN uses dcraw? And even if it is the "colorpicker.cur" will be loaded "normally" since TImageEnIO.LoadFromFile() uses only file extension to determine image format and never tries to call FindStreamFormat(). And it wrongly determine it as ioCUR (actually it is normal windows cursor file but ImageEn can't load it in such format). You can rename this file to "colorpicker.dat" and load it with PhotoEN: empty MDI window will be created with TMDIChild.ImageEnView1.IO.Aborting = True).

PS. I use old 4.1.0 ImageEn version. But posted issue doesn't relate to ImageEn, it is dcraw plugin problem only.
Uwe Posted - May 19 2014 : 08:11:41
The FindFileFormat function uses FindStreamFormat to recognize the file type from the file header. Isn't that what you want? It even has a VerifyExtension property to determine the file type from the file extension as well.

By the way: if I try to load your CUR file with one of the demo programs (see Demos -> FullApps -> PhotoEN), the ImageEnView stays empty. But that has nothing to do with DCRAW.


-Uwe
goobit Posted - May 19 2014 : 04:11:02
1. This is done in dcraw loading function:

function ieLoadDcrawPlugin: Boolean;
var
  DllPath: string;
begin
  DllPath := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + DcrawDllName;
  Result := IEIsExtIOPluginLoaded(DllPath);
  if not Result and FileExists(DllPath) then begin
    IEFileFormatRemove(ioRAW);
    Result := (IEAddExtIOPlugIn(DllPath) <> 0);
  end;
end;

2. As I noted earlier our application doesn't simply convert file extension (when exists) to TIOFileType. It use file extension for first try only as a hint but when this first try not successful it tries to find corresponding file format by stream binary content (iterates "try functions" for all known formats). Such algorithm will load files with invalid file extension in correct TIOFileType format.
Uwe Posted - May 18 2014 : 13:08:38
Just a quick question: why don't you use

{...}
IEFileFormatRemove(ioRAW); // disable internal RAW support
IEAddExtIOPlugIn('dcrawlib.dll');
IEAddExtIOPlugIn('imagemagick.dll');
{...}

in the main form's OnCreate event and/ or check the file with GetAllSupportedFileExtensions or FindFileFormat (see help for details)?

-Uwe
goobit Posted - May 18 2014 : 12:24:55
I attach test project in first post. Now I know how to add urls for zip-files thus I reattach it in this post.

Yes, it is exactly what I do: "feed non camera RAW data to DCRAW". But in this case I expect exception or ioUnknown result.

About code: this is a part of ImageEnIO.FindStreamFormat() function for user registered file formats:

for q := 0 to iegFileFormats.Count - 1 do
  with TIEFileFormatInfo(iegFileFormats[q]) do
    if assigned(TryFunction) then
    begin
      Stream.Position := lp;
      if TryFunction(Stream,FileType) then
      begin
        result := FileType;
        break;
      end;
    end;

Code hangs in dcraw plugin TryFunction() which begins to change stream position and reread it in endless loop.

I attach "colorpicker.cur" that cause such problem. You can try to call FindStreamFormat() for it with dcraw loaded to reproduce this problem.

Test project: 20145185648_TestDCRAW.zip

colorpicker.cur: 2014518121914_colorpicker.zip
Uwe Posted - May 18 2014 : 10:58:18
Can you show us some code? Somewhere in your TryFunction you seem to feed non camera RAW data to DCRAW, and that's not possible.

-Uwe
goobit Posted - May 18 2014 : 10:11:58
I didn't try to load .cur file with dcraw. It can be any similar binary data that hangs TryFunction() in dcrawlib.dll.