2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 #include "VobSubImage.h"
26 #include "..\SubPic\ISubPic.h"
28 #define VOBSUBIDXVER 7
30 extern CString
FindLangFromId(WORD id
);
35 HRESULT
Render(SubPicDesc
& spd
, RECT
& bbox
);
41 int m_scale_x
, m_scale_y
; // % (don't set it to unsigned because as a side effect it will mess up negative coordinates in GetDestrect())
43 int m_fSmooth
; // 0: OFF, 1: ON, 2: OLD (means no filtering at all)
44 int m_fadein
, m_fadeout
; // ms
46 int m_alignhor
, m_alignver
; // 0: left/top, 1: center, 2: right/bottom
47 unsigned int m_toff
; // ms
48 bool m_fOnlyShowForcedSubs
;
51 RGBQUAD m_orgpal
[16], m_cuspal
[4];
55 CVobSubSettings() {InitSettings();}
58 bool GetCustomPal(RGBQUAD
* cuspal
, int& tridx
);
59 void SetCustomPal(RGBQUAD
* cuspal
, int tridx
);
61 void GetDestrect(CRect
& r
); // destrect of m_img, considering the current alignment mode
62 void GetDestrect(CRect
& r
, int w
, int h
); // this will scale it to the frame size of (w, h)
64 void SetAlignment(bool fAlign
, int x
, int y
, int hor
, int ver
);
67 [uuid("998D4C9A-460F-4de6-BDCD-35AB24F94ADF")]
68 class CVobSubFile
: public CVobSubSettings
, public ISubStream
, public CSubPicProviderImpl
73 void TrimExtension(CString
& fn
);
74 bool ReadIdx(CString fn
, int& ver
), ReadSub(CString fn
), ReadRar(CString fn
), ReadIfo(CString fn
);
75 bool WriteIdx(CString fn
), WriteSub(CString fn
);
79 BYTE
* GetPacket(int idx
, int& packetsize
, int& datasize
, int iLang
= -1);
80 bool GetFrame(int idx
, int iLang
= -1);
81 bool GetFrameByTimeStamp(__int64 time
);
82 int GetFrameIdxByTimeStamp(__int64 time
);
84 bool SaveVobSub(CString fn
);
85 bool SaveWinSubMux(CString fn
);
86 bool SaveScenarist(CString fn
);
87 bool SaveMaestro(CString fn
);
96 __int64 celltimestamp
;
104 CAtlArray
<SubPos
> subpos
;
111 CVobSubFile(CCritSec
* pLock
);
112 virtual ~CVobSubFile();
114 bool Copy(CVobSubFile
& vsf
);
116 typedef enum {None
,VobSub
,WinSubMux
,Scenarist
,Maestro
} SubFormat
;
118 bool Open(CString fn
);
119 bool Save(CString fn
, SubFormat sf
= VobSub
);
122 CString
GetTitle() {return(m_title
);}
125 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
, void** ppv
);
128 STDMETHODIMP_(POSITION
) GetStartPosition(REFERENCE_TIME rt
, double fps
);
129 STDMETHODIMP_(POSITION
) GetNext(POSITION pos
);
130 STDMETHODIMP_(REFERENCE_TIME
) GetStart(POSITION pos
, double fps
);
131 STDMETHODIMP_(REFERENCE_TIME
) GetStop(POSITION pos
, double fps
);
132 STDMETHODIMP_(bool) IsAnimated(POSITION pos
);
133 STDMETHODIMP
Render(SubPicDesc
& spd
, REFERENCE_TIME rt
, double fps
, RECT
& bbox
);
136 STDMETHODIMP
GetClassID(CLSID
* pClassID
);
139 STDMETHODIMP_(int) GetStreamCount();
140 STDMETHODIMP
GetStreamInfo(int i
, WCHAR
** ppName
, LCID
* pLCID
);
141 STDMETHODIMP_(int) GetStream();
142 STDMETHODIMP
SetStream(int iStream
);
143 STDMETHODIMP
Reload();
146 [uuid("D7FBFB45-2D13-494F-9B3D-FFC9557D5C45")]
147 class CVobSubStream
: public CVobSubSettings
, public ISubStream
, public CSubPicProviderImpl
151 CCritSec m_csSubPics
;
152 struct SubPic
{REFERENCE_TIME tStart
, tStop
; CAtlArray
<BYTE
> pData
;};
153 CAutoPtrList
<SubPic
> m_subpics
;
156 CVobSubStream(CCritSec
* pLock
);
157 virtual ~CVobSubStream();
159 void Open(CString name
, BYTE
* pData
, int len
);
161 void Add(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, BYTE
* pData
, int len
);
165 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
, void** ppv
);
168 STDMETHODIMP_(POSITION
) GetStartPosition(REFERENCE_TIME rt
, double fps
);
169 STDMETHODIMP_(POSITION
) GetNext(POSITION pos
);
170 STDMETHODIMP_(REFERENCE_TIME
) GetStart(POSITION pos
, double fps
);
171 STDMETHODIMP_(REFERENCE_TIME
) GetStop(POSITION pos
, double fps
);
172 STDMETHODIMP_(bool) IsAnimated(POSITION pos
);
173 STDMETHODIMP
Render(SubPicDesc
& spd
, REFERENCE_TIME rt
, double fps
, RECT
& bbox
);
176 STDMETHODIMP
GetClassID(CLSID
* pClassID
);
179 STDMETHODIMP_(int) GetStreamCount();
180 STDMETHODIMP
GetStreamInfo(int i
, WCHAR
** ppName
, LCID
* pLCID
);
181 STDMETHODIMP_(int) GetStream();
182 STDMETHODIMP
SetStream(int iStream
);
183 STDMETHODIMP
Reload() {return E_NOTIMPL
;}