Merge pull request #160 from kleinerm/master

Pull from kleinerm for PTB BETA RELEASE "Blue skies and empty brains" - SP3
* GUI window mode fixes for OSX and MS-Windows.
Screen/Windows: Switch 32-Bit build from OSSBuilds Gstreamer to Gstreamer SDK.

Update build file to compile and link against 32-Bit GStreamer SDK
instead of 32-Bit OSSBuilds runtime. Enable GstEncodingProfiles for
video recording on 32-Bit Windows in source code. Update PsychStartup.m
to setup path to 32-Bit SDK.

-> Screen for 32-Bit Matlab on Windows rebuilt.
Fix a few glitches in printout, mostly fixing case statement options.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Comment clean up.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Comment clean up.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Renamed to match the transition of vset -> isetbio.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Added comment about where isetbio lives on gitHub.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Core: Do not use stdint.h on MS-Windows, but #define needed types ourselves.

If we want to build mex files for Windows-PTB against the Microsoft
common C runtime library (msvcrt.dll) instead of the Microsoft Visual
Studio 2010 C libraries, we can't #include <stdint.h> as this will
cause various compile errors.

Therefore don't include stdint.h but #define the two needed constants
INT64_MAX and INT32_MAX ourselves.

Tested and shown to compile correctly with all mex files on 64-Bit
Matlab on Windows.
Screen('DrawText')/Windows: Only use process-global text encoding locales.

Turns out the Microsoft common C runtime doesn't support
_create_locale() and _free_locale() for creation of locale setting
objects. To remove the need for these functions and unify more code
paths, get rid of these local locale settings.

We now only use setlocale() + caching of locale settings to change the
process-global locale setting during text conversion as part of
Screen('DrawText'), ie., store backup copy of global setting, change
global setting to our wanted setting, perform decoding with that
setting, restore original process locale. This temporary change of
locale should hopefully not have side effects.

-> Allow buildings with MSCRT.dll
windowsmakeit64: Switch build of Screen.mexw64 to use mscrt.dll.

Add the hodgepdoge of compiler and linker options to build against the
mscrt.lib/dll provided by the "Windows Driver Development Kit"
(WinDDK). With the WinDDK from Microsoft installed, this allows
building of Screen.mexw64 against mscrt.dll instead of the Microsoft
Visual Studio 2010 C runtime.

Small Plus: Consistent with GStreamer dll's.
Big Minus: Code review shows that the "plus" shouldn't matter given how
we use the GStreamer dll's. We already avoid all potential interactions
with GStreamer which could cause hazards. Building against mscrt.dll
makes it impossible for us to pass environment variables from Matlab to
Screen() or GStreamer, effectively disabling almost all PsychTweak()
functionality and reducing the effectiveness of workarounds for broken
computer clocks.

-> Hopefully this change won't be needed, it is a big net minus!

Here are the things that could cause trouble according to MSDN
documentation if we don't build against mscrt.dll: 1. Passing
environment variables (won't work - they don't show up across dll
boundaries), 2. Passing file handles (which we don't do), 3. Passing
locale settings (which we don't do), 4. malloc()'ing memory on our side
and provide it to GStreamer to own it (which we don't do), 5. free()ing
memory pointers provided by GStreamer (which we don't do). Point 1
explains why the GStreamer debug environment variable settings via
PsychTweak() never had an effect on Windows, but only on OSX and Linux.
Point 2 and 3 we don't do. Point 4 or 5 would cause heap corruption,
but we don't do this. So for all practical means and purposes we should
be just fine using the standard msvc2010 runtime libs as in the past.
Screen for 32/64-Bit Matlab on Windows rebuilt and tested.

32-Bit Screen() just incorporates the locale setting changes from
previous commit.
64-Bit Screen() is linked against mscrt.dll instead of the MS-VisualC
2010 dll's.
-> The latter one is important for testing.
Added many more checks for consistency in the routines that compute photoreceptor parameters.

It is now harder to do something stupid, such as specify a nomogram for absorbance and then pass absorbance directly, thus ignoring the nomogram that you specified.

And, the returned structure is more informative about what was computed and what was supplied.

I checked that none of these changes break test routines within the PTB.   But if you were cleverly overriding values set by DefaultPhotoreceptors, you may now need to explictly set some sources to 'None' or some values to the empty matrix.  The error messages should be moderately informative about how to go about this, and there are some examples of this being done in CIEConeFundamentalsTest (where such changes were made.)

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Tightening up cone fundamental generation code

Added options to DefaultPhotoreceptors that will produce the CIE (aka Stockman-Sharpe) 2 and 10 degree fundamentals.

Added a lot of comments about relation between various routines that do similar things.

Added check that FillInPhotoreceptors and ComputeRawConeFundamentals are consistent with one another, and added extra return args to ComputeCIEConeFundamentals and ComputeRawConeFundamentals to allow access to unnormalized quantal sensitivity functions.

Added other miscellaneous comments.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Screen: Make g_thread_init() call conditional on GLib version.

g_thread_init() is only needed up to GLib version < 2.31.0, but
deprecated above. Add a version check macro to avoid compiling it on
GLib >=2.31.0.
Screen/Windows: Add special GStreamer debug code for msvcrt builds.

On Windows + msvcrt builds, no env variables can be passed from Matlab
to Screen+Gstreamer, therefore use a trick to define GST_DEBUG env
variable at Screen verbosity > 20 inside Screen to pass it to
GStreamer. Didn't work either on R2012a, probably because stderr gets
redirected to nirvana. Whatever...
Screen.mexw64 for 64-Bit Matlab on Windows rebuilt and tested.

Another minor candidate for crash testing. Previous builds didn't
improve situation on affected machine out there.
Continuing to clean up and extend isomerization calcs.

Most of this effort is just checks and commenting.  It is possible that some of the checks will break calling code that was a little sloppy.  I believe I've fixed up all such cases within the PTB.

Added AbsorbtanceToAbsorbance, from the Stanford group.

The isomerization calcs now more cleanly incorporate the CIE standard cone fundamentals (that is, you can get them from DefaultPhotoreceptors).

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Added little utility to find color matching function peak wavelengths and values.

Used in PrintPhotoreceptors.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Cleaned up PrintPhotoreceptors some, and little bit of small bug swatting in FillInPhotoreceptors and DefaultPhotoreceptors.

Verified that the main unit tests that use this stuff still run OK.
  IsomerizationsInEyeDemo
  IsomerizationsInDishDemo
  CIEConeFundamentalsTest
  FitConeFundamentalsTest

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Tuning this up.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>