Applied Pomyk's patch and fixed YV12 DirectShow

Originally committed to SVN as r905.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-29 05:47:29 +00:00
parent 420ac447ee
commit 370512917c
5 changed files with 25 additions and 6 deletions

View file

@ -884,7 +884,7 @@ int SubsEditBox::BlockAtPos(int pos) {
int max = text.Length()-1;
// 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 (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"));
}

View file

@ -479,9 +479,15 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
// UV planes for 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.");
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.");
}

View file

@ -61,7 +61,7 @@ public:
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 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"
AegiVideoFrame();

View file

@ -331,15 +331,18 @@ const AegiVideoFrame AvisynthVideoProvider::DoGetFrame(int _n) {
AegiVideoFrame &final = iframe;
final.flipped = false;
final.cppAlloc = true;
final.invertChannels = false;
// Format
if (vi.IsRGB32()) {
final.format = FORMAT_RGB32;
final.flipped = true;
final.invertChannels = true;
}
else if (vi.IsRGB24()) {
final.format = FORMAT_RGB24;
final.flipped = true;
final.invertChannels = true;
}
else if (vi.IsYV12()) final.format = FORMAT_YV12;
else if (vi.IsYUY2()) final.format = FORMAT_YUY2;

View file

@ -358,8 +358,8 @@ HRESULT DirectShowVideoProvider::OpenVideo(wxString _filename) {
// Set FPS and frame duration
if (defd == 0) defd = 417083;
if (fps != 0.0) defd = long long (10000000.0 / fps);
else fps = 10000000.0 / double(defd);
if (fps != 0.0) defd = long long (10000000.0 / fps) + 1;
else fps = 10000000.0 / double(++defd);
// Set number of frames
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_YV12) df->frame.format = FORMAT_YV12;
// Allocate
unsigned int datalen = stride*height;
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);
}
}