mirror of https://github.com/odrling/Aegisub
Applied Pomyk's patch and fixed YV12 DirectShow
Originally committed to SVN as r905.
This commit is contained in:
parent
420ac447ee
commit
370512917c
|
@ -884,7 +884,7 @@ int SubsEditBox::BlockAtPos(int pos) {
|
||||||
int max = text.Length()-1;
|
int max = text.Length()-1;
|
||||||
|
|
||||||
// Find block number at pos
|
// Find block number at pos
|
||||||
for (int i=0;i<=pos;i++) {
|
for (int i=0;i<=pos && i<=max;i++) {
|
||||||
if (i > 0 && text[i] == _T('{')) n++;
|
if (i > 0 && text[i] == _T('{')) n++;
|
||||||
if (text[i] == _T('}') && i != max && i != pos && i != pos -1 && (i+1 == max || text[i+1] != _T('{'))) n++;
|
if (text[i] == _T('}') && i != max && i != pos && i != pos -1 && (i+1 == max || text[i+1] != _T('{'))) n++;
|
||||||
}
|
}
|
||||||
|
@ -1267,3 +1267,4 @@ void SubsEditBox::OnButtonStrikeout(wxCommandEvent &event) {
|
||||||
SetOverride(_T("\\s"));
|
SetOverride(_T("\\s"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -479,9 +479,15 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
|
||||||
|
|
||||||
// UV planes for YV12
|
// UV planes for YV12
|
||||||
if (frame.format == FORMAT_YV12) {
|
if (frame.format == FORMAT_YV12) {
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[1]);
|
int u = 1;
|
||||||
|
int v = 2;
|
||||||
|
if (frame.invertChannels) {
|
||||||
|
u = 2;
|
||||||
|
v = 1;
|
||||||
|
}
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D,0,0,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[u]);
|
||||||
if (glGetError() != 0) throw _T("Error uploading U plane.");
|
if (glGetError() != 0) throw _T("Error uploading U plane.");
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,frame.w/2,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[2]);
|
glTexSubImage2D(GL_TEXTURE_2D,0,frame.w/2,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[v]);
|
||||||
if (glGetError() != 0) throw _T("Error uploadinv V plane.");
|
if (glGetError() != 0) throw _T("Error uploadinv V plane.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
unsigned int pitch[4]; // Pitch, that is, the number of bytes used by each row.
|
unsigned int pitch[4]; // Pitch, that is, the number of bytes used by each row.
|
||||||
|
|
||||||
bool flipped; // First row is actually the bottom one
|
bool flipped; // First row is actually the bottom one
|
||||||
bool invertChannels; // Invert Red and Blue channels
|
bool invertChannels; // Invert Red and Blue channels or U and V planes
|
||||||
bool cppAlloc; // Allocated with C++'s "new" operator, instead of "malloc"
|
bool cppAlloc; // Allocated with C++'s "new" operator, instead of "malloc"
|
||||||
|
|
||||||
AegiVideoFrame();
|
AegiVideoFrame();
|
||||||
|
|
|
@ -331,15 +331,18 @@ const AegiVideoFrame AvisynthVideoProvider::DoGetFrame(int _n) {
|
||||||
AegiVideoFrame &final = iframe;
|
AegiVideoFrame &final = iframe;
|
||||||
final.flipped = false;
|
final.flipped = false;
|
||||||
final.cppAlloc = true;
|
final.cppAlloc = true;
|
||||||
|
final.invertChannels = false;
|
||||||
|
|
||||||
// Format
|
// Format
|
||||||
if (vi.IsRGB32()) {
|
if (vi.IsRGB32()) {
|
||||||
final.format = FORMAT_RGB32;
|
final.format = FORMAT_RGB32;
|
||||||
final.flipped = true;
|
final.flipped = true;
|
||||||
|
final.invertChannels = true;
|
||||||
}
|
}
|
||||||
else if (vi.IsRGB24()) {
|
else if (vi.IsRGB24()) {
|
||||||
final.format = FORMAT_RGB24;
|
final.format = FORMAT_RGB24;
|
||||||
final.flipped = true;
|
final.flipped = true;
|
||||||
|
final.invertChannels = true;
|
||||||
}
|
}
|
||||||
else if (vi.IsYV12()) final.format = FORMAT_YV12;
|
else if (vi.IsYV12()) final.format = FORMAT_YV12;
|
||||||
else if (vi.IsYUY2()) final.format = FORMAT_YUY2;
|
else if (vi.IsYUY2()) final.format = FORMAT_YUY2;
|
||||||
|
|
|
@ -358,8 +358,8 @@ HRESULT DirectShowVideoProvider::OpenVideo(wxString _filename) {
|
||||||
|
|
||||||
// Set FPS and frame duration
|
// Set FPS and frame duration
|
||||||
if (defd == 0) defd = 417083;
|
if (defd == 0) defd = 417083;
|
||||||
if (fps != 0.0) defd = long long (10000000.0 / fps);
|
if (fps != 0.0) defd = long long (10000000.0 / fps) + 1;
|
||||||
else fps = 10000000.0 / double(defd);
|
else fps = 10000000.0 / double(++defd);
|
||||||
|
|
||||||
// Set number of frames
|
// Set number of frames
|
||||||
last_fnum = 0;
|
last_fnum = 0;
|
||||||
|
@ -434,8 +434,17 @@ void DirectShowVideoProvider::ReadFrame(long long timestamp, unsigned format, un
|
||||||
else if (format == IVS_RGB32) df->frame.format = FORMAT_RGB32;
|
else if (format == IVS_RGB32) df->frame.format = FORMAT_RGB32;
|
||||||
else if (format == IVS_YV12) df->frame.format = FORMAT_YV12;
|
else if (format == IVS_YV12) df->frame.format = FORMAT_YV12;
|
||||||
|
|
||||||
|
// Allocate
|
||||||
unsigned int datalen = stride*height;
|
unsigned int datalen = stride*height;
|
||||||
df->frame.Allocate();
|
df->frame.Allocate();
|
||||||
|
|
||||||
|
// Prepare data for YV12
|
||||||
|
if (format == IVS_YV12) {
|
||||||
|
datalen = datalen * 3 / 2;
|
||||||
|
df->frame.invertChannels = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy
|
||||||
memcpy(df->frame.data[0],src,datalen);
|
memcpy(df->frame.data[0],src,datalen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue