00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <afxtempl.h>
00025 #include "VobSubImage.h"
00026 #include "..\SubPic\ISubPic.h"
00027
00028 #define VOBSUBIDXVER 7
00029
00030 extern CString FindLangFromId(WORD id);
00031
00032 class CVobSubSettings
00033 {
00034 protected:
00035 HRESULT Render(SubPicDesc& spd, RECT& bbox);
00036
00037 public:
00038 CSize m_size;
00039 int m_x, m_y;
00040 CPoint m_org;
00041 int m_scale_x, m_scale_y;
00042 int m_alpha;
00043 int m_fSmooth;
00044 int m_fadein, m_fadeout;
00045 bool m_fAlign;
00046 int m_alignhor, m_alignver;
00047 unsigned int m_toff;
00048 bool m_fOnlyShowForcedSubs;
00049 bool m_fCustomPal;
00050 int m_tridx;
00051 RGBQUAD m_orgpal[16], m_cuspal[4];
00052
00053 CVobSubImage m_img;
00054
00055 CVobSubSettings() {InitSettings();}
00056 void InitSettings();
00057
00058 bool GetCustomPal(RGBQUAD* cuspal, int& tridx);
00059 void SetCustomPal(RGBQUAD* cuspal, int tridx);
00060
00061 void GetDestrect(CRect& r);
00062 void GetDestrect(CRect& r, int w, int h);
00063
00064 void SetAlignment(bool fAlign, int x, int y, int hor, int ver);
00065 };
00066
00067 [uuid("998D4C9A-460F-4de6-BDCD-35AB24F94ADF")]
00068 class CVobSubFile : public CVobSubSettings, public ISubStream, public ISubPicProviderImpl
00069 {
00070 protected:
00071 CString m_title;
00072
00073 void TrimExtension(CString& fn);
00074 bool ReadIdx(CString fn, int& ver), ReadSub(CString fn), ReadRar(CString fn), ReadIfo(CString fn);
00075 bool WriteIdx(CString fn), WriteSub(CString fn);
00076
00077 CMemFile m_sub;
00078
00079 BYTE* GetPacket(int idx, int& packetsize, int& datasize, int iLang = -1);
00080 bool GetFrame(int idx, int iLang = -1);
00081 bool GetFrameByTimeStamp(__int64 time);
00082 int GetFrameIdxByTimeStamp(__int64 time);
00083
00084 bool SaveVobSub(CString fn);
00085 bool SaveWinSubMux(CString fn);
00086 bool SaveScenarist(CString fn);
00087 bool SaveMaestro(CString fn);
00088
00089 public:
00090 typedef struct
00091 {
00092 __int64 filepos;
00093 __int64 start, stop;
00094 bool fForced;
00095 char vobid, cellid;
00096 __int64 celltimestamp;
00097 bool fValid;
00098 } SubPos;
00099
00100 typedef struct
00101 {
00102 int id;
00103 CString name, alt;
00104 CArray<SubPos> subpos;
00105 } SubLang;
00106
00107 int m_iLang;
00108 SubLang m_langs[32];
00109
00110 public:
00111 CVobSubFile(CCritSec* pLock);
00112 virtual ~CVobSubFile();
00113
00114 bool Copy(CVobSubFile& vsf);
00115
00116 typedef enum {None,VobSub,WinSubMux,Scenarist,Maestro} SubFormat;
00117
00118 bool Open(CString fn);
00119 bool Save(CString fn, SubFormat sf = VobSub);
00120 void Close();
00121
00122 CString GetTitle() {return(m_title);}
00123
00124 DECLARE_IUNKNOWN
00125 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00126
00127
00128 STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
00129 STDMETHODIMP_(POSITION) GetNext(POSITION pos);
00130 STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
00131 STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
00132 STDMETHODIMP_(bool) IsAnimated(POSITION pos);
00133 STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
00134
00135
00136 STDMETHODIMP GetClassID(CLSID* pClassID);
00137
00138
00139 STDMETHODIMP_(int) GetStreamCount();
00140 STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
00141 STDMETHODIMP_(int) GetStream();
00142 STDMETHODIMP SetStream(int iStream);
00143 STDMETHODIMP Reload();
00144 };
00145
00146 [uuid("D7FBFB45-2D13-494F-9B3D-FFC9557D5C45")]
00147 class CVobSubStream : public CVobSubSettings, public ISubStream, public ISubPicProviderImpl
00148 {
00149 CString m_name;
00150
00151 CCritSec m_csSubPics;
00152 struct SubPic {REFERENCE_TIME tStart, tStop; CArray<BYTE> pData;};
00153 CAutoPtrList<SubPic> m_subpics;
00154
00155 public:
00156 CVobSubStream(CCritSec* pLock);
00157 virtual ~CVobSubStream();
00158
00159 void Open(CString name, BYTE* pData, int len);
00160
00161 void Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData, int len);
00162 void RemoveAll();
00163
00164 DECLARE_IUNKNOWN
00165 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00166
00167
00168 STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
00169 STDMETHODIMP_(POSITION) GetNext(POSITION pos);
00170 STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
00171 STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
00172 STDMETHODIMP_(bool) IsAnimated(POSITION pos);
00173 STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
00174
00175
00176 STDMETHODIMP GetClassID(CLSID* pClassID);
00177
00178
00179 STDMETHODIMP_(int) GetStreamCount();
00180 STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
00181 STDMETHODIMP_(int) GetStream();
00182 STDMETHODIMP SetStream(int iStream);
00183 STDMETHODIMP Reload() {return E_NOTIMPL;}
00184 };