Nuke binary plugins 14.1.5
 
Loading...
Searching...
No Matches
DD::Image::Reader Class Reference

#include <Reader.h>

Inheritance diagram for DD::Image::Reader:
DD::Image::FileReader

Classes

class  Description
 

Public Member Functions

 Reader (Read *iop)
 
virtual ~Reader ()
 
virtual bool supports_stereo () const
 
virtual bool fileStereo () const
 
virtual bool videosequence () const
 
int rowPadMultiple () const noexcept
 Rows must be padded to be multiples of this value, in bytes. 0 means no padding.
 
void setRowPadMultiple (int rowPadMultiple) noexcept
 Rows must be padded to be multiples of this value, in bytes. 0 means no padding.
 
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
 
ReaderImpl * getImpl ()
 Get private implementation.
 
ReaderImpl * getImpl () const
 
virtual AudioReaderI * audioReader ()
 

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 flip (U64 *p, unsigned n)
 
static void fromlsb (U64 *p, unsigned n)
 
static void frommsb (U64 *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()

Reader::~Reader ( )
virtual

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

Member Function Documentation

◆ prefetchMetaData()

virtual void DD::Image::Reader::prefetchMetaData ( )
inlineprotectedvirtual

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().

◆ planarPreference()

virtual PlanarPreference DD::Image::Reader::planarPreference ( ) const
inlineprotectedvirtual

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().

◆ useStripes()

virtual bool DD::Image::Reader::useStripes ( ) const
inlineprotectedvirtual

This should be overriden by subclasses if they want striping.

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

◆ stripeHeight()

virtual size_t DD::Image::Reader::stripeHeight ( ) const
inlineprotectedvirtual

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

References DD::Image::Box::h().

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

◆ getPlaneFromChannel()

virtual PlanarI::PlaneID DD::Image::Reader::getPlaneFromChannel ( Channel  chan)
inlineprotectedvirtual

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().

◆ open()

void Reader::open ( )
protectedvirtual

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().

◆ engine()

void Reader::engine ( int  y,
int  x,
int  r,
ChannelMask  ,
Row row 
)
protectedvirtual

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));
int width() const
Definition: Reader.h:271

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().

◆ fetchPlane()

void Reader::fetchPlane ( ImagePlane imagePlane)
protectedvirtual

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().

◆ from_byte()

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().

◆ from_short()

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::Linear::from_short(), DD::Image::LUT::from_short(), lut(), and premult().

◆ from_float()

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().

◆ set_info()

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(), height(), DD::Image::Format::is_none(), DD::Image::Format::pixel_aspect(), DD::Image::Box::set(), DD::Image::Format::width(), and width().

◆ width()

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

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

Referenced by DD::Image::Read::_fetchMetaData(), and set_info().

◆ height()

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

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

Referenced by DD::Image::Read::_fetchMetaData(), and set_info().

◆ filename()

const char * Reader::filename ( ) const

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

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

◆ frame()

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().

◆ premult()

bool Reader::premult ( ) const

The premult() setting from the Read

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

◆ channel()

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().

◆ channel_name()

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().

◆ format()

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.

◆ full_size_format()

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

Change the full-size format.

References DD::Image::Info2D::full_size_format().

◆ setLUT()

virtual void DD::Image::Reader::setLUT ( LUT lut)
inlinevirtual

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

◆ lut()

virtual LUT * DD::Image::Reader::lut ( )
inlinevirtual

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

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

◆ getDefaultColorspace()

virtual std::string DD::Image::Reader::getDefaultColorspace ( ) const
inlinevirtual

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.

◆ lsb32()

static U32 DD::Image::Reader::lsb32 ( const unsigned char *  p)
inlinestatic

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

◆ msb32()

static U32 DD::Image::Reader::msb32 ( const unsigned char *  p)
inlinestatic

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

◆ lsb16()

static U16 DD::Image::Reader::lsb16 ( const unsigned char *  p)
inlinestatic

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

◆ msb16()

static U16 DD::Image::Reader::msb16 ( const unsigned char *  p)
inlinestatic

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

◆ flip() [1/2]

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.

◆ flip() [2/2]

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

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

◆ fromlsb() [1/3]

static void DD::Image::Reader::fromlsb ( U64 *  p,
unsigned  n 
)
inlinestatic

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

◆ frommsb() [1/3]

static void DD::Image::Reader::frommsb ( U64 *  p,
unsigned  n 
)
inlinestatic

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

◆ fromlsb() [2/3]

static void DD::Image::Reader::fromlsb ( U32 *  p,
unsigned  n 
)
inlinestatic

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.

◆ frommsb() [2/3]

static void DD::Image::Reader::frommsb ( U32 *  p,
unsigned  n 
)
inlinestatic

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.

◆ fromlsb() [3/3]

static void DD::Image::Reader::fromlsb ( U16 *  p,
unsigned  n 
)
inlinestatic

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.

◆ frommsb() [3/3]

static void DD::Image::Reader::frommsb ( U16 *  p,
unsigned  n 
)
inlinestatic

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.

◆ audioReader()

AudioReaderI * Reader::audioReader ( )
virtual

For internal use only. If the reader supports audio decoding, it can implement this.



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com