Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp  view on Meta::CPAN

    int                         version;               // file format version
    bool                        multipart;             // from a multipart file
    Int64                       previewPosition;       // file position for preview
    DeepFrameBuffer             frameBuffer;           // framebuffer to write into
    int                         currentScanLine;       // next scanline to be written
    int                         missingScanLines;      // number of lines to write
    LineOrder                   lineOrder;             // the file's lineorder
    int                         minX;                  // data window's min x coord
    int                         maxX;                  // data window's max x coord
    int                         minY;                  // data window's min y coord
    int                         maxY;                  // data window's max x coord
    vector<Int64>               lineOffsets;           // stores offsets in file for
                                                       // each scanline
    vector<size_t>              bytesPerLine;          // combined size of a line over
                                                       // all channels
    Compressor::Format          format;                // compressor's data format
    vector<OutSliceInfo*>       slices;                // info about channels in file
    Int64                       lineOffsetsPosition;   // file position for line
                                                       // offset table

    vector<LineBuffer*>         lineBuffers;           // each holds one line buffer
    int                         linesInBuffer;         // number of scanlines each
                                                       // buffer holds
    int                         partNumber;            // the output part number

    char*                       sampleCountSliceBase;  // the pointer to the number
                                                       // of samples in each pixel
    int                         sampleCountXStride;    // the x stride for sampleCountSliceBase
    int                         sampleCountYStride;    // the y stride for sampleCountSliceBase

    Array<unsigned int>         lineSampleCount;       // the number of samples
                                                       // in each line

    Int64                       maxSampleCountTableSize;
                                                       // the max size in bytes for a pixel
                                                       // sample count table
    OutputStreamMutex*  _streamData;
    bool                _deleteStream;

    Data (int numThreads);
    ~Data ();


    inline LineBuffer *         getLineBuffer (int number);// hash function from line
                                                           // buffer indices into our
                                                           // vector of line buffers

    inline int&                 getSampleCount(int x, int y); // get the number of samples
                                                              // in each pixel
};


DeepScanLineOutputFile::Data::Data (int numThreads):
    lineOffsetsPosition (0),
    partNumber (-1) ,
    _streamData(NULL),
    _deleteStream(false)
{
    //
    // We need at least one lineBuffer, but if threading is used,
    // to keep n threads busy we need 2*n lineBuffers.
    //

    lineBuffers.resize (max (1, 2 * numThreads));
    for (size_t i = 0; i < lineBuffers.size(); i++)
        lineBuffers[i] = 0;
}


DeepScanLineOutputFile::Data::~Data ()
{
    for (size_t i = 0; i < lineBuffers.size(); i++)
        if (lineBuffers[i] != 0)
            delete lineBuffers[i];

    for (size_t i = 0; i < slices.size(); i++)
        delete slices[i];
}


int&
DeepScanLineOutputFile::Data::getSampleCount(int x, int y)
{
    return sampleCount(sampleCountSliceBase,
                       sampleCountXStride,
                       sampleCountYStride,
                       x, y);
}


LineBuffer*
DeepScanLineOutputFile::Data::getLineBuffer (int number)
{
    return lineBuffers[number % lineBuffers.size()];
}


namespace {

Int64
writeLineOffsets (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const vector<Int64> &lineOffsets)
{
    Int64 pos = os.tellp();

    if (pos == -1)
        IEX_NAMESPACE::throwErrnoExc ("Cannot determine current file position (%T).");

    for (unsigned int i = 0; i < lineOffsets.size(); i++)
        OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, lineOffsets[i]);

    return pos;
}


void
writePixelData (OutputStreamMutex *filedata,
                DeepScanLineOutputFile::Data *partdata,
                int lineBufferMinY,
                const char pixelData[],
                Int64 packedDataSize,
                Int64 unpackedDataSize,



( run in 0.480 second using v1.01-cache-2.11-cpan-99c4e6809bf )