mirror of https://github.com/odrling/Aegisub
Originally committed to SVN as r665.
This commit is contained in:
parent
0fc5a75ac8
commit
79ec29c204
|
@ -256,7 +256,6 @@ HRESULT DirectShowVideoProvider::OpenVideo(wxString _filename) {
|
||||||
if (FAILED(hr = sink2->GetFrameFormat(&type, &width, &height, &arx, &ary, &defd))) return hr;
|
if (FAILED(hr = sink2->GetFrameFormat(&type, &width, &height, &arx, &ary, &defd))) return hr;
|
||||||
|
|
||||||
// Get video duration
|
// Get video duration
|
||||||
REFERENCE_TIME duration;
|
|
||||||
if (FAILED(hr = ms->GetDuration(&duration))) return hr;
|
if (FAILED(hr = ms->GetDuration(&duration))) return hr;
|
||||||
|
|
||||||
// Length of each frame? (??)
|
// Length of each frame? (??)
|
||||||
|
@ -410,7 +409,7 @@ bool DirectShowVideoProvider::NextFrame(DF &_df,int &_fn) {
|
||||||
int frameno = (int)((double)df.timestamp / defd + 0.5);
|
int frameno = (int)((double)df.timestamp / defd + 0.5);
|
||||||
|
|
||||||
// Got a good one
|
// Got a good one
|
||||||
if (frameno >= 0 && frameno < (signed) num_frames) {
|
if (frameno >= 0 && frameno <= (signed) num_frames) {
|
||||||
_fn = frameno;
|
_fn = frameno;
|
||||||
_df = df;
|
_df = df;
|
||||||
return true;
|
return true;
|
||||||
|
@ -423,35 +422,36 @@ bool DirectShowVideoProvider::NextFrame(DF &_df,int &_fn) {
|
||||||
/////////////
|
/////////////
|
||||||
// Get frame
|
// Get frame
|
||||||
wxBitmap DirectShowVideoProvider::GetFrame(int n) {
|
wxBitmap DirectShowVideoProvider::GetFrame(int n) {
|
||||||
|
// Normalize frame number
|
||||||
|
if (n >= (signed) num_frames) n = num_frames-1;
|
||||||
|
|
||||||
// Current
|
// Current
|
||||||
if (n == last_fnum) return rdf.frame;
|
if (n == last_fnum) return rdf.frame;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
DF df;
|
DF df;
|
||||||
int fn;
|
int fn;
|
||||||
|
REFERENCE_TIME cur = defd * n + 10001;
|
||||||
// Not the next, seek first
|
if (cur < 0) cur = 0;
|
||||||
if (n != last_fnum + 1) {
|
|
||||||
// Reset and seek
|
|
||||||
ResetEvent(m_hFrameReady);
|
|
||||||
REFERENCE_TIME cur = defd * (n-1) - 10001; // -1ms, account for typical timestamps rounding
|
|
||||||
if (cur < 0) cur = 0;
|
|
||||||
|
|
||||||
// Failed
|
|
||||||
if (FAILED(m_pGS->SetPositions(&cur, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning))) return wxBitmap(width,height);
|
|
||||||
|
|
||||||
// Set time
|
|
||||||
rdf.timestamp = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is next
|
// Is next
|
||||||
else {
|
if (n == last_fnum + 1) {
|
||||||
NextFrame(df,fn);
|
NextFrame(df,fn);
|
||||||
last_fnum = n;
|
last_fnum = n;
|
||||||
rdf.frame = df.frame;
|
rdf.frame = df.frame;
|
||||||
return rdf.frame;
|
return rdf.frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not the next, reset and seek first
|
||||||
|
seek:
|
||||||
|
ResetEvent(m_hFrameReady);
|
||||||
|
|
||||||
|
// Seek
|
||||||
|
if (FAILED(m_pGS->SetPositions(&cur, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning))) return wxBitmap(width,height);
|
||||||
|
|
||||||
|
// Set time
|
||||||
|
rdf.timestamp = -1;
|
||||||
|
|
||||||
// Actually get data
|
// Actually get data
|
||||||
while (true) {
|
while (true) {
|
||||||
// Get frame
|
// Get frame
|
||||||
|
@ -476,8 +476,11 @@ wxBitmap DirectShowVideoProvider::GetFrame(int n) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Passed, seek back and try again
|
||||||
else {
|
else {
|
||||||
return wxBitmap(width,height);
|
cur -= defd;
|
||||||
|
goto seek;
|
||||||
|
//return wxBitmap(width,height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ private:
|
||||||
void RegROT();
|
void RegROT();
|
||||||
void UnregROT();
|
void UnregROT();
|
||||||
|
|
||||||
|
REFERENCE_TIME duration;
|
||||||
DF rdf;
|
DF rdf;
|
||||||
CComPtr<IVideoSink> m_pR;
|
CComPtr<IVideoSink> m_pR;
|
||||||
CComPtr<IMediaControl> m_pGC;
|
CComPtr<IMediaControl> m_pGC;
|
||||||
|
|
Loading…
Reference in New Issue