DD::Image::Reader Class Reference

Inherited by DD::Image::FileReader.

List of all members.

Classes

class  Description

Public Member Functions

 Reader (Read *iop)
virtual ~Reader ()
virtual bool supports_stereo () const
virtual bool fileStereo () const
virtual bool videosequence () const
bool aborted () const
 Allows a reader to check directly if its op has been aborted.
const Iop::Infoinfo () const
int x () const
int y () const
int r () const
int t () const
int w () const
int h () const
bool is_constant () const
int clampx (int x) const
int clampy (int y) const
const Formatformat () const
const Formatfull_size_format () const
int ydirection () const
ChannelMask channels () const
int first_frame () const
int last_frame () const
int width () const
int height () const
const char * filename () const
int frame () const
bool premult () const
Channel channel (const char *name)
const char * channel_name (Channel c)
void format (const Format &f)
void full_size_format (const Format &f)
virtual void setLUT (LUT *lut)
virtual LUTlut ()
virtual std::string getDefaultColorspace () const
ReaderImplgetImpl ()
 Get private implementation.
ReaderImplgetImpl () const

Static Public Member Functions

static U32 lsb32 (const unsigned char *p)
static U32 msb32 (const unsigned char *p)
static U16 lsb16 (const unsigned char *p)
static U16 msb16 (const unsigned char *p)
static void flip (U16 *p, unsigned n)
static void flip (U32 *p, unsigned n)
static void fromlsb (U32 *p, unsigned n)
static void frommsb (U32 *p, unsigned n)
static void fromlsb (U16 *p, unsigned n)
static void frommsb (U16 *p, unsigned n)
static void setInPreviewMode (bool preview)
static bool inPreviewMode ()

Protected Types

enum  PlanarPreference { ePlanarNever, ePlanarAllow, ePlanarAlways }

Protected Member Functions

virtual void prefetchMetaData ()
virtual const MetaData::BundlefetchMetaData (const char *key)
virtual PlanarPreference planarPreference () const
virtual bool useStripes () const
virtual size_t stripeHeight () const
virtual PlanarI::PlaneID getPlaneFromChannel (Channel chan)
virtual void open ()
virtual void engine (int y, int x, int r, ChannelMask, Row &)
virtual void fetchPlane (ImagePlane &imagePlane)
void from_byte (Channel z, float *, const uchar *, const uchar *, int W, int delta=1)
void from_short (Channel z, float *, const U16 *, const U16 *, int W, int bits, int delta=1)
void from_float (Channel z, float *, const float *, const float *, int W, int delta=1)
void set_info (int width, int height, int depth, double aspect=0)

Protected Attributes

Readiop
LUTlut_
Iop::Info info_

Friends

class Read

Detailed Description

Reads data from a single image file (or other image source).

The Read creates one of these for each file it reads. Each different file type is a different subclass. Each subclass defines a Reader_Description object, all of these are searched to figure out what subclass to use.

For most image file types you will want to use the FileReader subclass, which provides multi-threaded access to a Unix file.

The base class for Reader both provides default implementations and serves as the "NullReader" that is used when the type cannot be figured out.


Constructor & Destructor Documentation

Reader::~Reader ( ) [virtual]

The destructor must close any files (even though the Read may have opened them).


Member Function Documentation

virtual void DD::Image::Reader::prefetchMetaData ( ) [inline, protected, virtual]

This should be overriden by videosequence file formats who wish to set frame-varying metadata. Set the metadata from this, rather than in the constructor, which would be used for other metadata.

Referenced by DD::Image::Read::_fetchMetaData().

virtual PlanarPreference DD::Image::Reader::planarPreference ( ) const [inline, protected, virtual]

Return a value to indicate the Reader's preference as to planar access.

It can return ePlanarNever if it never wants fetchPlane() to be called; ePlanarAlways if it wants engine() to be called.

Otherwise, it should return ePlanarAllow to allow both planar access or row-based access depending upon what the using code thinks appropriate (for example single Row fetching will use engine() but GeneralTile would use fetchPlane)

Referenced by DD::Image::Read::engine(), and DD::Image::Read::getPlanarI().

virtual bool DD::Image::Reader::useStripes ( ) const [inline, protected, virtual]

This should be overriden by subclasses if they want striping.

Referenced by DD::Image::Read::useStripes().

virtual size_t DD::Image::Reader::stripeHeight ( ) const [inline, protected, virtual]

This should be overriden by subclasses to return the desired stripe height.

Referenced by DD::Image::Read::stripeHeight().

virtual PlanarI::PlaneID DD::Image::Reader::getPlaneFromChannel ( Channel  chan) [inline, protected, virtual]

Override this if you want your planes to be different to the default.

By default Nuke will try and decode all the channels at once

Referenced by DD::Image::Read::getPlaneFromChannel().

void Reader::open ( ) [protected, virtual]

This is called before the first call to engine(). It should do any expensive setup that is not needed for setting the info(), such as reading in pointer tables. If this is a movie file format you should check frame() and prepare to read in that frame number.

Referenced by DD::Image::Read::_open().

void Reader::engine ( int  y,
int  x,
int  r,
ChannelMask  ,
Row row 
) [protected, virtual]

Read a line from the file and convert it to floats.

Warning: row.x may be greater than zero, row.r may be less than the image width, and channels may be less than the number of channels. Usually uncompression code is difficult to write with such clipping. To expand the size of the buffers in the row to the full width, and to read all the channel, do this:

         row.range(0, width());
         for (int z = 0; z < 4; z++)
          read_channel(y, z, row.writable(z));

The floating point buffer returned by row.writable() may be used with a cast as a temporary buffer to store 8 or 16 bit data.

References DD::Image::Op::debug().

Referenced by DD::Image::Read::engine().

void Reader::fetchPlane ( ImagePlane imagePlane) [protected, virtual]

If you override planarPreference to return anything other than ePlanarNever, you should implement this

References DD::Image::Op::debug().

Referenced by DD::Image::Read::renderStripe().

void Reader::from_byte ( Channel  z,
float *  to,
const uchar *  from,
const uchar *  alpha,
int  W,
int  delta = 1 
) [protected]

Convert bytes to floating point.

from should point at a set of W bytes, spaced delta apart. These are converted and placed into to (1 apart).

z is the channel number. If z >= 3 then linear (divide by 255) conversion is done.

Otherwise the lut() is called to do a normal conversion.

If premult() is on and alpha is not null, it should point at an array of W bytes for an alpha channel, spaced delta apart. The lut() is then called to do an unpremult-convert of the values.

References DD::Image::IopInfoOwner::channels(), DD::Image::LUT::from_byte(), lut(), and premult().

void Reader::from_short ( Channel  z,
float *  to,
const U16 *  from,
const U16 *  alpha,
int  W,
int  bits,
int  delta = 1 
) [protected]

Same as from_byte() but the source data is an array of shorts in the range 0 to (2<<bits)-1.

References DD::Image::IopInfoOwner::channels(), DD::Image::LUT::from_short(), lut(), and premult().

void Reader::from_float ( Channel  z,
float *  to,
const float *  from,
const float *  alpha,
int  W,
int  delta = 1 
) [protected]

Same as from_byte() but the source is floating point data. Linear conversion will leave the numbers unchanged.

References DD::Image::IopInfoOwner::channels(), DD::Image::LUT::from_float(), lut(), and premult().

void Reader::set_info ( int  width,
int  height,
int  depth,
double  aspect = 0 
) [protected]

Set all the fields in the info_ correctly for an image file that is the given width and height in pixels and has depth channels of color data. This sets the bounding box to 0,0,width,height and sets the channels so the first depth bits are turned on. This will try to use the Read::expected_format() if it is the right size (so user choices for pixel aspect ratio and image area are preserved), otherwise it will find or generate a new format that matches.

The option pixel_aspect value forces the pixel aspect to be the given value. Zero means that any format that matches the width & height is used, and the pixel aspect defined for that is used.

If your image file has more information such as an actual bounding box or real channel assignments, you should modify the fields of info_ directly after (or instead of) calling this.

References DD::Image::Format::add(), DD::Image::IopInfo::black_outside(), DD::Image::Read::expected_read_format(), DD::Image::Format::findExisting(), DD::Image::Format::height(), DD::Image::Format::is_none(), DD::Image::Format::pixel_aspect(), DD::Image::Box::set(), and DD::Image::Format::width().

int DD::Image::Reader::width ( ) const [inline]

Returns the width value passed to iop->set_info()

Referenced by DD::Image::Read::_fetchMetaData().

int DD::Image::Reader::height ( ) const [inline]

Returns the height value passed to iop->set_info()

Referenced by DD::Image::Read::_fetchMetaData().

const char * Reader::filename ( ) const

The filename (this is set before frame() is called)

Referenced by DD::Image::FileReader::lock().

int Reader::frame ( ) const

The frame number from the Read, rounded to an integer. If you want the floating point value or the shutter value you should use iop->frame() and iop->shutter().

Referenced by DD::Image::Read::_fetchMetaData().

bool Reader::premult ( ) const

The premult() setting from the Read

Referenced by from_byte(), from_float(), and from_short().

Channel DD::Image::Reader::channel ( const char *  name) [inline]

Calls Iop::channel(), turn a name into a channel number assignment.

References DD::Image::Iop::channel().

const char* DD::Image::Reader::channel_name ( Channel  c) [inline]

Calls Iop::channel_name(), turn channel number into name

References DD::Image::Iop::channel_name().

void DD::Image::Reader::format ( const Format f) [inline]

Change the format. Use one with the same width and height or it will screw up the width() and height() methods which most file readers rely on.

void DD::Image::Reader::full_size_format ( const Format f) [inline]

Change the full-size format.

virtual void DD::Image::Reader::setLUT ( LUT lut) [inline, virtual]

Set LUT. This is virtual to allow override in movReader which performs additional processing

virtual LUT* DD::Image::Reader::lut ( ) [inline, virtual]

Get LUT. This is virtual to allow override in movReader which performs additional processing

Referenced by DD::Image::Read::_validate(), from_byte(), from_float(), from_short(), and DD::Image::ReaderImpl::setOriginalDefaultLut().

virtual std::string DD::Image::Reader::getDefaultColorspace ( ) const [inline, virtual]

Overrides lut() with a specific colorspace name (if non-empty). If the colorspace name isn't found the Node will error and the user will have to choose an acceptable alternative.

static U32 DD::Image::Reader::lsb32 ( const unsigned char *  p) [inline, static]

Get a 32-bit value stored low byte first in a buffer

static U32 DD::Image::Reader::msb32 ( const unsigned char *  p) [inline, static]

Get a 32-bit value stored high byte first in a buffer

static U16 DD::Image::Reader::lsb16 ( const unsigned char *  p) [inline, static]

Get a 16-bit value stored low byte first in a buffer

static U16 DD::Image::Reader::msb16 ( const unsigned char *  p) [inline, static]

Get a 16-bit value stored high byte first in a buffer

void Reader::flip ( U16 *  p,
unsigned  n 
) [static]

For convenience and speed when reading file formats defined by C data structures, you can use this to flip adjacent locations of the same type into machine alignment. This should only be done to lock() data if you are sure you will only do this once and that no other thread will attempt to do it at the same time.

void Reader::flip ( U32 *  p,
unsigned  n 
) [static]

Same as previous flip but for an array of 32-bit objects.

static void DD::Image::Reader::fromlsb ( U32 *  p,
unsigned  n 
) [inline, static]

Calls flip() if necessary to convert an array of 32 bit values stored low-byte first so that they can be read by your machine.

Referenced by DD::Image::Writer::tolsb().

static void DD::Image::Reader::frommsb ( U32 *  p,
unsigned  n 
) [inline, static]

Calls flip() if necessary to convert an array of 32 bit values stored high-byte first so that they can be read by your machine.

static void DD::Image::Reader::fromlsb ( U16 *  p,
unsigned  n 
) [inline, static]

Calls flip() if necessary to convert an array of 16 bit values stored low-byte first so that they can be read by your machine.

static void DD::Image::Reader::frommsb ( U16 *  p,
unsigned  n 
) [inline, static]

Calls flip() if necessary to convert an array of 16 bit values stored high-byte first so that they can be read by your machine.