2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef TIIO_MOV_H
|
|
|
|
#define TIIO_MOV_H
|
|
|
|
|
2017-05-31 07:56:11 +12:00
|
|
|
#if defined(x64) || (defined(__GNUC__) && defined(_WIN32))
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "tiio_mov_proxy.h"
|
|
|
|
#else
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Windows include
|
2016-03-19 06:57:51 +13:00
|
|
|
#include <windows.h>
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// QuickTime includes
|
|
|
|
namespace QuickTime {
|
2016-07-04 20:50:30 +12:00
|
|
|
#define list QuickTime_list
|
|
|
|
#define map QuickTime_map
|
|
|
|
#define iterator QuickTime_iterator
|
|
|
|
#define float_t QuickTime_float_t
|
|
|
|
#define GetProcessInformation QuickTime_GetProcessInformation
|
|
|
|
#define int_fast8_t QuickTime_int_fast8_t
|
|
|
|
#define int_fast16_t QuickTime_int_fast16_t
|
|
|
|
#define uint_fast16_t QuickTime_uint_fast16_t
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#include "QTML.h"
|
|
|
|
#include "Movies.h"
|
|
|
|
#include "Script.h"
|
|
|
|
#include "FixMath.h"
|
|
|
|
#include "Sound.h"
|
|
|
|
#include "QuickTimeComponents.h"
|
|
|
|
|
|
|
|
#undef list
|
|
|
|
#undef map
|
|
|
|
#undef iterator
|
|
|
|
#undef float_t
|
2016-07-04 20:50:30 +12:00
|
|
|
#undef GetProcessInformation
|
|
|
|
#undef int_fast8_t
|
|
|
|
#undef int_fast16_t
|
|
|
|
#undef uint_fast16_t
|
|
|
|
|
|
|
|
#include "tquicktime.h"
|
2016-06-15 18:43:10 +12:00
|
|
|
} // namespace QuickTime
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Toonz includes
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "tlevel_io.h"
|
|
|
|
#include "tthreadmessage.h"
|
|
|
|
#include "tcommon.h"
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef IMAGE_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace QuickTime;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
|
|
|
|
class TImageWriterMov;
|
|
|
|
class TImageReaderMov;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Global functions
|
|
|
|
|
|
|
|
bool IsQuickTimeInstalled();
|
|
|
|
|
|
|
|
//***********************************************************************************
|
|
|
|
// Mov TLevelWriter class
|
|
|
|
//***********************************************************************************
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class TLevelWriterMov final : public TLevelWriter {
|
2016-06-15 18:43:10 +12:00
|
|
|
std::vector<std::pair<int, TimeValue>> m_savedFrames;
|
|
|
|
int m_IOError;
|
|
|
|
|
|
|
|
Movie m_movie;
|
|
|
|
Track m_videoTrack;
|
|
|
|
Track m_soundTrack;
|
|
|
|
Media m_videoMedia;
|
|
|
|
Media m_soundMedia;
|
|
|
|
GWorldPtr m_gworld;
|
|
|
|
PixMapHandle m_pixmap;
|
|
|
|
short m_refNum;
|
|
|
|
PixelXRGB *m_buf;
|
|
|
|
int buf_lx;
|
|
|
|
int buf_ly;
|
|
|
|
int m_firstFrame;
|
|
|
|
TThread::Mutex m_mutex;
|
|
|
|
ComponentInstance m_ci;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TLevelWriterMov(const TFilePath &path, TPropertyGroup *winfo);
|
|
|
|
~TLevelWriterMov();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
TImageWriterP getFrameWriter(TFrameId fid) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void save(const TImageP &img, int frameIndex);
|
2016-06-19 20:06:29 +12:00
|
|
|
void saveSoundTrack(TSoundTrack *st) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
static TLevelWriter *create(const TFilePath &f, TPropertyGroup *winfo) {
|
|
|
|
return new TLevelWriterMov(f, winfo);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//***********************************************************************************
|
|
|
|
// Mov TLevelReader class
|
|
|
|
//***********************************************************************************
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class DVAPI TLevelReaderMov final : public TLevelReader {
|
2016-06-15 18:43:10 +12:00
|
|
|
bool m_readAsToonzOutput; // default: false
|
|
|
|
bool m_yMirror; // default: true
|
|
|
|
bool m_loadTimecode; // default: false
|
|
|
|
int m_IOError;
|
|
|
|
|
|
|
|
short m_refNum;
|
|
|
|
Movie m_movie;
|
|
|
|
Track m_track;
|
|
|
|
MediaHandler m_timecodeHandler;
|
|
|
|
long m_depth;
|
|
|
|
std::map<int, TimeValue> currentTimes;
|
|
|
|
int m_lx, m_ly;
|
|
|
|
int m_hh, m_mm, m_ss, m_ff;
|
|
|
|
TThread::Mutex m_mutex;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TLevelReaderMov(const TFilePath &path);
|
|
|
|
~TLevelReaderMov();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
TImageReaderP getFrameReader(TFrameId fid) override;
|
|
|
|
TLevelP loadInfo() override;
|
2016-06-15 18:43:10 +12:00
|
|
|
void load(const TRasterP &rasP, int frameIndex, const TPoint &pos,
|
|
|
|
int shrinkX = 1, int shrinkY = 1);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void timecode(int frame, UCHAR &hh, UCHAR &mm, UCHAR &ss, UCHAR &ff);
|
|
|
|
void loadedTimecode(UCHAR &hh, UCHAR &mm, UCHAR &ss, UCHAR &ff);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
const TImageInfo *getImageInfo(TFrameId fid) override { return m_info; }
|
|
|
|
const TImageInfo *getImageInfo() override { return m_info; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setYMirror(bool enabled);
|
|
|
|
void setLoadTimecode(bool enabled);
|
2016-06-19 20:06:29 +12:00
|
|
|
void enableRandomAccessRead(bool enable) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TDimension getSize() const { return TDimension(m_lx, m_ly); }
|
|
|
|
TRect getBBox() const { return TRect(0, 0, m_lx - 1, m_ly - 1); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
static TLevelReader *create(const TFilePath &f);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
TLevelP loadToonzOutputFormatInfo();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
// Mov Properties
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace Tiio {
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class MovWriterProperties final : public TPropertyGroup {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
MovWriterProperties();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
} // namespace Tiio
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
#endif //! x64
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
#endif // TIIO_MOV_H
|