DD::Image::Writer Class Reference

Inherits DD::Image::FileHandler.

Inherited by DD::Image::FileWriter.


class  Description
 Specialised Writer Description. More...

Public Types

typedef U64 FlagMask

Public Member Functions

void setFlags (FlagMask flags, bool newValue=true)
void clearFlags (FlagMask flags)
bool anyFlags (FlagMask newFlags) const
 test whether the Writer has any of the given flags
bool allFlags (FlagMask newFlags) const
 test whether the Writer has all of the given flags
 Writer (Write *i)
virtual ~Writer ()
virtual bool movie () const
virtual void execute ()
virtual void finish ()
virtual void knobs (Knob_Callback cb)
bool aborted () const
 Allows a writer to check directly if its op has been aborted.
virtual void setLUT (LUT *lut)
WriterImplgetImpl ()
WriterImplgetImpl () const

Static Public Member Functions

static void flip (U16 *p, int n)
static void flip (U32 *p, int n)
static void tolsb (U32 *p, int n)
static void tomsb (U32 *p, int n)
static void tolsb (U16 *p, int n)
static void tomsb (U16 *p, int n)

Static Public Attributes

static const FlagMask DONT_CHECK_INPUT0_CHANNELS

Protected Member Functions

LUTlut ()
virtual LUTdefaultLUT () const
virtual bool isDefaultLUTKnob (DD::Image::Knob *knob) const
const Iop::Infoinfo () const
int width () const
int height () const
double getPixelAspect () const
std::pair< int, int > getPixelAspectAsResolution () const
virtual bool clipToFormat () const
virtual int split_input (int i) const
virtual const OutputContextinputContext (int n, OutputContext &c) const
int depth () const
int num_channels () const
ChannelSet channel_mask (int num_channels) const
Channel channel (int index) const
bool premult () const
Iopinput0 ()
const Iopinput0 () const
void get (int y, int x, int r, ChannelMask channels, Row &row)
const char * filename () const
std::string createFileHash ()
std::string getHash () const
void renameFromHash ()
void to_byte (int z, uchar *, const float *, const float *, int W, int delta=1)
void to_short (int z, U16 *, const float *, const float *, int W, int bits=16, int delta=1)
void to_float (int z, float *, const float *, const float *, int W, int delta=1)
void progressFraction (double f)
void progressFraction (int a, int b)
std::set< int > executingViews () const

Protected Attributes

 Points at the Write that created this.
std::string _hash


class Write
class WriterImpl

Detailed Description

Writes data to an image file (or other image destination).

The Write creates one of these for every different filename it writes. Each different file type is a different subclass. Each subclass defines a Writer_Description object, all of these are searched to figure out what subclass to use.

For most image file formats you will want to use a subclass of the FileWriter subclass.

The implementation of the base class is in Write.C

Constructor & Destructor Documentation

Writer::~Writer ( )

The destructor should close any open files (this may be used for movie formats that keep the file open between calls to execute().

Member Function Documentation

void DD::Image::Writer::setFlags ( FlagMask  flags,
bool  newValue = true 

Turn the flags in /newFlags/ on or off, depending upon newValue. Leaves flags not in /newFlags/ unaltered. It is expected that the Writer's constructor should call this.

LUT * Writer::defaultLUT ( ) const

Return the value that should be used in lut_ if the user picks default. The default version returns the LUT::INT8. This function is needed if the default changes in response to controls defined in knobs().

virtual bool DD::Image::Writer::isDefaultLUTKnob ( DD::Image::Knob knob) const

if the value of the knob passed in contributes to the value returned from defaultLUT you should return true from this function to ensure that the default LUT is correctly updated in the panel when you change that knob

const Iop::Info& DD::Image::Writer::info ( ) const

The info() going into the Write

References DD::Image::IopInfoOwner::info().

int DD::Image::Writer::width ( ) const

The width of image to write.

int DD::Image::Writer::height ( ) const

The height of image to write.

double DD::Image::Writer::getPixelAspect ( ) const

The pixel aspect ratio of image to write.

Referenced by getPixelAspectAsResolution().

std::pair< int, int > Writer::getPixelAspectAsResolution ( ) const

The pixel aspect ratio of image to write represented as X/Y resolution values

Guess the pixel width and height from the Pixel Aspect Ratio (PAR) using a known list

References getPixelAspect().

virtual bool DD::Image::Writer::clipToFormat ( ) const

Does the format force a clip to the format, or can it write out the area outside the format (the overscan), too?

Also used to indicate whether the channels are represented incompletely in the file, so that if RB is written out then it will read back in as RG.

Referenced by DD::Image::Write::_request(), DD::Image::Write::_validate(), and DD::Image::Write::engine().

int Writer::split_input ( int  i) const

Lets a writer override the Op::split_input() method of the including Write op. This is used by Writers that can write more than one view.

Referenced by DD::Image::Write::execViewMode(), and DD::Image::Write::split_input().

const OutputContext & Writer::inputContext ( int  n,
OutputContext c 
) const

Lets a writer override the Op::inputContext() method of the including Write op. This is used by Writers that can write more than one view. Note that c is scratch space, it is not a usable return value!

References iop, and DD::Image::Op::outputContext().

Referenced by DD::Image::Write::inputContext().

int Writer::depth ( ) const

Many file formats can write a certain number of channels, but cannot identify them in any useful way other than by index. This call will return a recommended number of channels to write, based on the set the user selected for the Write operator. You may want to clamp this to the legal range (such as 1-4) for your file format.

References iop.

ChannelSet Writer::channel_mask ( int  num_channels) const

For simple file writers that use channel(int) to get their inputs, this returns a channel mask to use to call open() on the input.

References DD::Image::IopInfoOwner::channels(), DD::Image::Iop::input0(), and iop.

Channel Writer::channel ( int  index) const

For file formats that just write a number of channels (rather than any identifying information) you should use this to turn an index (starting at zero) into the channel to write. You can call this with any number, including numbers larger than depth() returns. This may return Chan_Black to indicate that no channel should be written.

References DD::Image::Write::channel_written_to(), and iop.

bool DD::Image::Writer::premult ( ) const

The premult() setting from the Write

Referenced by to_byte(), to_float(), and to_short().

Iop& DD::Image::Writer::input0 ( )

The Iop whose output should be written.

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

const Iop& DD::Image::Writer::input0 ( ) const

The Iop whose output should be written.

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

void DD::Image::Writer::get ( int  y,
int  x,
int  r,
ChannelMask  channels,
Row row 

Get a line from the input, and start parallel threads.

const char* DD::Image::Writer::filename ( ) const
void Writer::to_byte ( int  z,
uchar *  to,
const float *  from,
const float *  alpha,
int  W,
int  delta = 1 

Convert to bytes from floating point.

from should point at an array of W floats, spaced 1 apart.

These are converted and placed into to[0], to[delta], to[2*delta],...

z is the channel index (warning this is one less than the channel number). If z >= 2 then linear (multiply 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 premult(), and DD::Image::LUT::to_byte().

void Writer::to_short ( int  z,
U16 *  to,
const float *  from,
const float *  alpha,
int  W,
int  bits = 16,
int  delta = 1 

Same as to_byte() except the destination is shorts in the range 0 through (2<<bits)-1.

References premult(), DD::Image::LUT::to_short(), and DD::Image::Linear::to_short().

void Writer::to_float ( int  z,
float *  to,
const float *  from,
const float *  alpha,
int  W,
int  delta = 1 

Same as to_byte() except the destination is an array of floats. Linear conversion will leave the numbers unchanged.

References premult(), and DD::Image::LUT::to_float().

void DD::Image::Writer::progressFraction ( double  f)

Call to display percentage of the current frame done.

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

bool Writer::movie ( ) const

Return true if the destination is a "movie". If this is true then the writer is capable of writing multiple frames, and frame() and execute() may be called multiple times to write different images. The default version returns false.

Referenced by DD::Image::Write::endExecuting(), DD::Image::Write::execFrameMode(), and DD::Image::Write::execute().

void Writer::execute ( )

Write the data in iop->input0(). The frame number may be retrieved with frame() and the filename from filename(). This may call iop->error() with any error messages.

References DD::Image::Op::debug(), and iop.

Referenced by DD::Image::Write::execute().

void Writer::finish ( )

Override if the writer needs to do something to finish a sequence. This is mostly of use to movie writers that don't close out the destination on a frame-by-frame basis.

Reimplemented in DD::Image::FileWriter.

Referenced by DD::Image::Write::endExecuting(), DD::Image::Write::execute(), and DD::Image::FileWriter::finish().

void Writer::knobs ( Knob_Callback  cb)

Like the Op::knobs() method, this allows the Writers to create format-specific knobs for format-specific parameters. At present, the Writers are tasked with adding the knobs themselves after the 'file_type' knob of the parent Write.

virtual void DD::Image::Writer::setLUT ( LUT lut)

Set LUT. This is virtual to allow overrides in movWriter which performs additional processing

Referenced by DD::Image::Write::_validate(), and DD::Image::Write::execute().

WriterImpl* DD::Image::Writer::getImpl ( )
static void DD::Image::Writer::tolsb ( U32 *  p,
int  n 

Flips the array or does nothing, depending on your machine.

References DD::Image::Reader::fromlsb().

Member Data Documentation

const FlagMask DD::Image::Writer::DONT_CHECK_INPUT0_CHANNELS

tell the Write to suppress the validation of input0() and checking that it has channels. Used for the exrWriter and other stereo-aware writers, which might not be using input0. If this is set then the writer needs to perform its own checking that channels exist.

Referenced by DD::Image::Write::execute().

©2022 The Foundry Visionmongers, Ltd. All Rights Reserved.