Blame lib/ifdfile.hpp

rpm-build d2b433
/* -*- Mode: C++ -*- */
rpm-build d2b433
/*
rpm-build d2b433
 * libopenraw - ifdfile.h
rpm-build d2b433
 *
rpm-build d2b433
 * Copyright (C) 2006-2015 Hubert Figuiere
rpm-build d2b433
 *
rpm-build d2b433
 * This library is free software: you can redistribute it and/or
rpm-build d2b433
 * modify it under the terms of the GNU Lesser General Public License
rpm-build d2b433
 * as published by the Free Software Foundation, either version 3 of
rpm-build d2b433
 * the License, or (at your option) any later version.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is distributed in the hope that it will be useful,
rpm-build d2b433
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build d2b433
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build d2b433
 * Lesser General Public License for more details.
rpm-build d2b433
 *
rpm-build d2b433
 * You should have received a copy of the GNU Lesser General Public
rpm-build d2b433
 * License along with this library.  If not, see
rpm-build d2b433
 * <http://www.gnu.org/licenses/>.
rpm-build d2b433
 */
rpm-build d2b433
rpm-build d2b433
#ifndef OR_INTERNALS_IFD_FILE_H_
rpm-build d2b433
#define OR_INTERNALS_IFD_FILE_H_
rpm-build d2b433
rpm-build d2b433
#include <stdint.h>
rpm-build d2b433
#include <sys/types.h>
rpm-build d2b433
rpm-build d2b433
#include <vector>
rpm-build d2b433
rpm-build d2b433
#include <libopenraw/consts.h>
rpm-build d2b433
rpm-build d2b433
#include "rawfile.hpp"
rpm-build d2b433
#include "io/stream.hpp"
rpm-build d2b433
#include "ifd.hpp"
rpm-build d2b433
#include "rawcontainer.hpp"
rpm-build d2b433
#include "ifddir.hpp"
rpm-build d2b433
#include "makernotedir.hpp"
rpm-build d2b433
rpm-build d2b433
namespace OpenRaw {
rpm-build d2b433
rpm-build d2b433
class MetaValue;
rpm-build d2b433
class RawData;
rpm-build d2b433
rpm-build d2b433
namespace Internals {
rpm-build d2b433
class IfdFileContainer;
rpm-build d2b433
rpm-build d2b433
/** @brief generic IFD based raw file. */
rpm-build d2b433
class IfdFile : public OpenRaw::RawFile {
rpm-build d2b433
#if defined(IN_TESTSUITE)
rpm-build d2b433
public:
rpm-build d2b433
    friend class ::Test; // for testing
rpm-build d2b433
#endif
rpm-build d2b433
rpm-build d2b433
protected:
rpm-build d2b433
    IfdFile(const IO::Stream::Ptr &s, Type _type,
rpm-build d2b433
            bool instantiateContainer = true);
rpm-build d2b433
    virtual ~IfdFile();
rpm-build d2b433
rpm-build d2b433
    /** list the thumbnails in the IFD
rpm-build d2b433
     * @retval list the list of thumbnails
rpm-build d2b433
     * @return the error code. OR_ERROR_NOT_FOUND if no
rpm-build d2b433
     * thumbnail are found.
rpm-build d2b433
     */
rpm-build d2b433
    virtual ::or_error _enumThumbnailSizes(
rpm-build d2b433
        std::vector<uint32_t> &list) override;
rpm-build d2b433
rpm-build d2b433
    /** locate the thumnail in the IFD
rpm-build d2b433
     * @param dir the IfdDir where to locate the thumbnail
rpm-build d2b433
     * @return the error code. OR_ERROR_NOT_FOUND if the
rpm-build d2b433
     * thumbnail are not found.
rpm-build d2b433
     */
rpm-build d2b433
    virtual ::or_error _locateThumbnail(const IfdDir::Ref &dir,
rpm-build d2b433
                                        std::vector<uint32_t> &list);
rpm-build d2b433
    /** load the compressed rawdata from a standard location in an IFD
rpm-build d2b433
     * @param data the data storage
rpm-build d2b433
     * @param dir the IFD
rpm-build d2b433
     * @return the error code.
rpm-build d2b433
     */
rpm-build d2b433
    ::or_error _getRawDataFromDir(RawData &data, const IfdDir::Ref &dir;;
rpm-build d2b433
rpm-build d2b433
    /** Get the JPEG thumbnail offset from dir.
rpm-build d2b433
     * @param dir the IFD to get the thumbnail from
rpm-build d2b433
     * @param len the length of the JPEG stream. 0 is not valid.
rpm-build d2b433
     * @return the offset. 0 is not valid.
rpm-build d2b433
     */
rpm-build d2b433
    virtual uint32_t _getJpegThumbnailOffset(const IfdDir::Ref &dir,
rpm-build d2b433
                                             uint32_t &len;;
rpm-build d2b433
rpm-build d2b433
    IO::Stream::Ptr m_io;          /**< the IO handle */
rpm-build d2b433
    IfdFileContainer *m_container; /**< the real container */
rpm-build d2b433
rpm-build d2b433
    virtual RawContainer *getContainer() const override;
rpm-build d2b433
rpm-build d2b433
    virtual IfdDir::Ref _locateCfaIfd() = 0;
rpm-build d2b433
    virtual IfdDir::Ref _locateMainIfd() = 0;
rpm-build d2b433
    virtual IfdDir::Ref _locateExifIfd();
rpm-build d2b433
    virtual MakerNoteDir::Ref _locateMakerNoteIfd();
rpm-build d2b433
rpm-build d2b433
    virtual void _identifyId() override;
rpm-build d2b433
rpm-build d2b433
    virtual MetaValue *_getMetaValue(int32_t meta_index) override;
rpm-build d2b433
rpm-build d2b433
    /** Translate the compression type from the tiff type (16MSB)
rpm-build d2b433
     * to the RAW specific type if needed (16MSB)
rpm-build d2b433
     * @param tiffCompression the 16 bits value from TIFF
rpm-build d2b433
     * @return the actually value. Anything >= 2^16 is specific the RAW type
rpm-build d2b433
     */
rpm-build d2b433
    virtual uint32_t _translateCompressionType(
rpm-build d2b433
        IFD::TiffCompress tiffCompression);
rpm-build d2b433
rpm-build d2b433
    /** Unpack the data
rpm-build d2b433
     * @param bpc bits per components
rpm-build d2b433
     * @param compression the compression type
rpm-build d2b433
     * @param x the width
rpm-build d2b433
     * @param y the height
rpm-build d2b433
     * @param offset the offset of the data
rpm-build d2b433
     * @param byte_length the amount of data
rpm-build d2b433
     * @return error code
rpm-build d2b433
     */
rpm-build d2b433
    virtual ::or_error _unpackData(uint16_t bpc, uint32_t compression,
rpm-build d2b433
                                   RawData &data, uint32_t x, uint32_t y,
rpm-build d2b433
                                   uint32_t offset, uint32_t byte_length);
rpm-build d2b433
rpm-build d2b433
    /** access the corresponding IFD. Will locate them if needed */
rpm-build d2b433
    const IfdDir::Ref &cfaIfd();
rpm-build d2b433
    const IfdDir::Ref &mainIfd();
rpm-build d2b433
    const IfdDir::Ref &exifIfd();
rpm-build d2b433
    const MakerNoteDir::Ref &makerNoteIfd();
rpm-build d2b433
rpm-build d2b433
    virtual ::or_error _getRawData(RawData &data, uint32_t options) override;
rpm-build d2b433
    // call to decrompress if needed from _getRawData()
rpm-build d2b433
    virtual ::or_error _decompressIfNeeded(RawData &, uint32_t);
rpm-build d2b433
rpm-build d2b433
private:
rpm-build d2b433
    IfdDir::Ref m_cfaIfd; /**< the IFD for the CFA */
rpm-build d2b433
    IfdDir::Ref
rpm-build d2b433
        m_mainIfd;                    /**< the IFD for the main image
rpm-build d2b433
                                                                   * does not necessarily reference
rpm-build d2b433
                                                                   * the CFA
rpm-build d2b433
                                                                   */
rpm-build d2b433
    IfdDir::Ref m_exifIfd;            /**< the Exif IFD */
rpm-build d2b433
    MakerNoteDir::Ref m_makerNoteIfd; /**< the MakerNote IFD */
rpm-build d2b433
rpm-build d2b433
    IfdFile(const IfdFile &) = delete;
rpm-build d2b433
    IfdFile &operator=(const IfdFile &) = delete;
rpm-build d2b433
};
rpm-build d2b433
}
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
/*
rpm-build d2b433
  Local Variables:
rpm-build d2b433
  mode:c++
rpm-build d2b433
  c-file-style:"stroustrup"
rpm-build d2b433
  c-file-offsets:((innamespace . 0))
rpm-build d2b433
  tab-width:2
rpm-build d2b433
  c-basic-offset:2
rpm-build d2b433
  indent-tabs-mode:nil
rpm-build d2b433
  fill-column:80
rpm-build d2b433
  End:
rpm-build d2b433
*/
rpm-build d2b433
#endif