Log in

View Full Version : Reading 8bit PGM / BMP image files


mc0ne
16th July 2011, 02:49
Hello Doom9 community,

some weeks ago I started a new thread (http://doom10.org/index.php?topic=1793.0)for an open source students project in the Doom10 newbee part.

The details of the current situation can be found here (http://doom10.org/index.php?topic=1793.msg8559#msg8559).

To sum it up: We want to read 8bit grayscale PGM or 8bit grayscale BMP files, make a videostream out of them and use them for further editting and outputting via x264.

1. Question

ImageSource according to the documentation supports:

(e)bmp, dds, ebmp, jpg/jpe/jpeg, pal, pcx, png, pbm/pgm/ppm, raw, sgi/bw/rgb/rgba, tga, tif/tiff.

But our internal testings show different results. PGM, BMP does not work. If converted to PNG then all works =P

This is a little bit confusing, but it seems like ImageSource doesn't like 8bit grayscale input even though in the examples it looks like it should work:

# Read a greyscale (8-bit) BMP (using AviSynth's internal BMP reader):
ImageSource("GoldPetals-8bit.bmp")

But doesn't =P Our whole project is really dependent on this and we would be very thankful for any help.

I am also aware of other ImageReaders like FFImageReader and ImmaReader. So far I was not able to install Immavs and try out if it can handle the above mentioned formats.

Other internal tests say, that AviSynth 2.6.0 is also not able to read those PGMs natively.

I will upload 20 images of each format into Zip-archieves (Password: doom10):

PGM (http://www63.zippyshare.com/v/44015235/file.html)- Zippyshare

BMP (http://www63.zippyshare.com/v/36673817/file.html)- Zippyshare


2. Question

We are still unsure about how to interact with AviSynth via our GUI. What we want is to directly display the content of the .avs-file like in VirtualDub. A team member would like to know how this can be accomplished the optimal way. VFW as the API came up here and there. We are still in the testing and finding out how-to phase regarding this point, but are open for any input that would jump start us.

Any link to a tutorial or example that opens an avs-file on the programming language level and uses it to display it on the GUI would be perfect

If any of these two main questions are in the wrong forum-part, please let me know

Thank you all for your help.

greetings

mc0ne

Archimedes
16th July 2011, 11:48
Your BMP files works fine here (AviSynth 2.60, latest release) with ImageSource, ImmaRead and FFVideoSource. Your PGM files works only with FFVideoSource.

mc0ne
16th July 2011, 17:32
Hi Archimedes,

wow very nice that you tested this directly, many thanks :)

Someone in Doom10 said, that FFVideoSource does not support seeking for image file sequences.

I had some problems getting ImmaRead and FFmpegSource to work too =P

Do you think AviSynth 2.6.0 Alpha 3 is reliable and stable?

Thanks all again,
we are open for any input :)

Wilbert
16th July 2011, 18:52
@Archimedes,


ImmaRead("F:\TestPics\18_droptop101079.pgm")


Loads fine for me (with v2.60a3, although that's shouldn't matter). Do you get an error-message?

ImageSource throws the message "Exception while processing ScriptEnvironment::ThrowError().", although pgm is listed as a supported format of DevIL (http://openil.sourceforge.net/features.php). I guess there is something wrong with the error-handling in AviSynth???

IanB
17th July 2011, 12:30
Getting "Exception while processing ScriptEnvironment::ThrowError()." means _vsnprintf() chucked some sort of wobbly processing the fmt string and the related arguments. Probably an Access violation.

env->ThrowError() results in this codevoid ScriptEnvironment::ThrowError(const char* fmt, ...) {
char buf[8192];
va_list val;
va_start(val, fmt);
try {
_vsnprintf(buf,sizeof(buf)-1, fmt, val);
if (!this) throw this; // Force inclusion of try catch code!
} catch (...) {
strcpy(buf,"Exception while processing ScriptEnvironment::ThrowError().");
}
va_end(val);
buf[sizeof(buf)-1] = '\0';
throw AvisynthError(ScriptEnvironment::SaveString(buf));
}I had a quick check of the ImageSource() code and I see nothing obvious. Any more hints? :confused:

Gavino
17th July 2011, 13:19
I had a quick check of the ImageSource() code and I see nothing obvious.
if (err != IL_NO_ERROR) {
env->ThrowError("ImageReader: error '%s' in DevIL library.\nreading file %s", getErrStr(err), filename);
}
Since getErrStr() returns a (C++) string, this should be getErrStr(err).c_str()

Another possible bug I notice is missing LeaveCriticalSection() in the error case in animation (line 497 in current CVS).

Archimedes
17th July 2011, 18:06
Loads fine for me (with v2.60a3, although that's shouldn't matter). Do you get an error-message?
No error message. Program freezes.

IanB
18th July 2011, 22:20
@Gavino,

Yes, that would certainly cause things to go belly up. Well spotted. ;)

And the LeaveCriticalSection(), oops! :o

mc0ne
18th July 2011, 23:58
Dear friends,

we had a team meeting today and discussed different topics of our project and situation.

One of the hot topics is AviSynth as we initially intented to use it for our software solution that our customer liked that way (AviSynth + x264).

One of our team mates said, that even with 2.6.0 Alpha 3 + DevIL 1.7.8 he was not able to read those bmp files.

I checked it out right now and I too can't open them. What I did:

1. Deinstalled AviSynth 2.58, install 2.6.0a3.
2. Pasted DevIL.dll (1.7.8) into --> \System32\DevIL.dll
3. Pasted ILU.dll and ILUT.dll also into System32\..
4. Downloaded msvcp80.dll and msvcr80.dll somewhere from the net (very strange dll-site=P) and pasted into System32\..
5. Made an .avs-file in the same directory of the bmp-frames and put in the following line:

Imagesource("19_drop_top2000%d.bmp", 00, 79, 20, use_DevIL=true)

6. put that file to Mediaplayer Classic HC x86

--> Exception while processing ScriptEnvironment::ThrowError().(C:\...\BMP\test1.avs, line 1)

Ok, when use_DevIL=false:

--> the same exception massage comes.

When the line looks like:

Imagesource("19_drop_top200079.bmp")

--> a warning window opens with the following content:

"Media Player Classic - Home Cinema could not render some of the pins in the graph, you may not have the needed codecs or filters on the system. Then comes a long description of sizes compressions, headers, formats etc. =P"

The same player has no problems to read png files with the same script commands.

I feel like I did not "install" the DevIL library correct. I would be very thankful for a noob like description of how you set up your AviSynth and DLL's so that you get it to work :)

I would be very much open for a description for the other readers too.

Our operation system is Windows 7 x64.

Greetings,

mc0ne

IanB
19th July 2011, 05:31
Any version of Avisynth after 2009/08/14 will not correctly report the DevIL error message text (bug found by Gavino in post #6). Version 2.5.8 predates this bug.

DevIL.dll 1.7.8 requires the 2005 VC runtime libraries to be correctly installed. See post 1514129 for more details.

Avisynth 2.5.8 does not expect DevIL version 1.7.8 but should mostly work with it (flip vertical requirements issues, newer error return codes not known about).