mirror of https://github.com/odrling/Aegisub
DirectShow Video Provider now supports zoom and aspect ratio, but it's ugly and slow... still no subs.
Originally committed to SVN as r666.
This commit is contained in:
parent
79ec29c204
commit
1ea3e085d9
|
@ -341,10 +341,6 @@ void FrameMain::InitMenu() {
|
||||||
wxMenuItem *RecentKeyframesParent = new wxMenuItem(videoMenu, Menu_File_Recent_Keyframes_Parent, _("Recent"), _T(""), wxITEM_NORMAL, RecentKeyframes);
|
wxMenuItem *RecentKeyframesParent = new wxMenuItem(videoMenu, Menu_File_Recent_Keyframes_Parent, _("Recent"), _T(""), wxITEM_NORMAL, RecentKeyframes);
|
||||||
videoMenu->Append(RecentKeyframesParent);
|
videoMenu->Append(RecentKeyframesParent);
|
||||||
videoMenu->AppendSeparator();
|
videoMenu->AppendSeparator();
|
||||||
AppendBitmapMenuItem(videoMenu,Menu_Video_JumpTo, _("&Jump To...\t") + Hotkeys.GetText(_T("Video Jump")), _("Jump to frame or time"), wxBITMAP(jumpto_button));
|
|
||||||
AppendBitmapMenuItem(videoMenu,Menu_Subs_Snap_Video_To_Start, _("Jump video to start\t") + Hotkeys.GetText(_T("Jump Video To Start")), _("Jumps the video to the start frame of current subtitle"), wxBITMAP(video_to_substart));
|
|
||||||
AppendBitmapMenuItem(videoMenu,Menu_Subs_Snap_Video_To_End, _("Jump video to end\t") + Hotkeys.GetText(_T("Jump Video To End")), _("Jumps the video to the end frame of current subtitle"), wxBITMAP(video_to_subend));
|
|
||||||
videoMenu->AppendSeparator();
|
|
||||||
wxMenu *ZoomMenu = new wxMenu;
|
wxMenu *ZoomMenu = new wxMenu;
|
||||||
wxMenuItem *ZoomParent = new wxMenuItem(subtitlesMenu,Menu_View_Zoom,_("Set Zoom"),_T(""),wxITEM_NORMAL,ZoomMenu);
|
wxMenuItem *ZoomParent = new wxMenuItem(subtitlesMenu,Menu_View_Zoom,_("Set Zoom"),_T(""),wxITEM_NORMAL,ZoomMenu);
|
||||||
ZoomParent->SetBitmap(wxBITMAP(blank_button));
|
ZoomParent->SetBitmap(wxBITMAP(blank_button));
|
||||||
|
@ -361,6 +357,10 @@ void FrameMain::InitMenu() {
|
||||||
AspectMenu->AppendCheckItem(Menu_Video_AR_235, _("&Cinematic (2.35)"), _("Forces video to 2.35 aspect ratio"));
|
AspectMenu->AppendCheckItem(Menu_Video_AR_235, _("&Cinematic (2.35)"), _("Forces video to 2.35 aspect ratio"));
|
||||||
AspectMenu->AppendCheckItem(Menu_Video_AR_Custom, _("Custom..."), _("Forces video to a custom aspect ratio"));
|
AspectMenu->AppendCheckItem(Menu_Video_AR_Custom, _("Custom..."), _("Forces video to a custom aspect ratio"));
|
||||||
videoMenu->Append(AspectParent);
|
videoMenu->Append(AspectParent);
|
||||||
|
videoMenu->AppendSeparator();
|
||||||
|
AppendBitmapMenuItem(videoMenu,Menu_Video_JumpTo, _("&Jump To...\t") + Hotkeys.GetText(_T("Video Jump")), _("Jump to frame or time"), wxBITMAP(jumpto_button));
|
||||||
|
AppendBitmapMenuItem(videoMenu,Menu_Subs_Snap_Video_To_Start, _("Jump video to start\t") + Hotkeys.GetText(_T("Jump Video To Start")), _("Jumps the video to the start frame of current subtitle"), wxBITMAP(video_to_substart));
|
||||||
|
AppendBitmapMenuItem(videoMenu,Menu_Subs_Snap_Video_To_End, _("Jump video to end\t") + Hotkeys.GetText(_T("Jump Video To End")), _("Jumps the video to the end frame of current subtitle"), wxBITMAP(video_to_subend));
|
||||||
MenuBar->Append(videoMenu, _("&Video"));
|
MenuBar->Append(videoMenu, _("&Video"));
|
||||||
|
|
||||||
// Create audio menu
|
// Create audio menu
|
||||||
|
|
|
@ -56,6 +56,8 @@ DEFINE_GUID(CLSID_VideoSink, 0xf13d3732, 0x96bd, 0x4108, 0xaf, 0xeb, 0xe8, 0x5f,
|
||||||
// Constructor
|
// Constructor
|
||||||
// Based on Haali's code for DirectShowSource2
|
// Based on Haali's code for DirectShowSource2
|
||||||
DirectShowVideoProvider::DirectShowVideoProvider(wxString _filename, wxString _subfilename) {
|
DirectShowVideoProvider::DirectShowVideoProvider(wxString _filename, wxString _subfilename) {
|
||||||
|
zoom = 1.0;
|
||||||
|
dar = 4.0/3.0;
|
||||||
m_hFrameReady = CreateEvent(NULL, FALSE, FALSE, NULL);
|
m_hFrameReady = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
OpenVideo(_filename);
|
OpenVideo(_filename);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +207,7 @@ HRESULT DirectShowVideoProvider::OpenVideo(wxString _filename) {
|
||||||
|
|
||||||
// Set allowed types for sink
|
// Set allowed types for sink
|
||||||
//sink->SetAllowedTypes(IVS_RGB32|IVS_YV12|IVS_YUY2);
|
//sink->SetAllowedTypes(IVS_RGB32|IVS_YV12|IVS_YUY2);
|
||||||
sink->SetAllowedTypes(IVS_RGB32);
|
sink->SetAllowedTypes(IVS_RGB24);
|
||||||
|
|
||||||
// Pass the event to sink, so it gets set when a frame is available
|
// Pass the event to sink, so it gets set when a frame is available
|
||||||
ResetEvent(m_hFrameReady);
|
ResetEvent(m_hFrameReady);
|
||||||
|
@ -320,28 +322,39 @@ void DirectShowVideoProvider::ReadFrame(long long timestamp, unsigned format, un
|
||||||
// Set frame
|
// Set frame
|
||||||
DF *df = (DF*) arg;
|
DF *df = (DF*) arg;
|
||||||
df->timestamp = timestamp;
|
df->timestamp = timestamp;
|
||||||
int w_cp = width;
|
unsigned int w_cp = width;
|
||||||
int h_cp = height;
|
unsigned int h_cp = height;
|
||||||
|
|
||||||
// Create data
|
// Create data
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
data = new unsigned char[width*height*bpp];
|
//data = new unsigned char[width*height*bpp];
|
||||||
int dstride = width*bpp;
|
data = (unsigned char *) malloc(width*height*bpp);
|
||||||
|
unsigned int dstride = width*bpp;
|
||||||
|
|
||||||
// Read RGB32 data
|
// Read RGB24 data
|
||||||
if (format == IVS_RGB32) {
|
if (format == IVS_RGB24) {
|
||||||
unsigned char *dst = data + h_cp*dstride;
|
unsigned char *dst = data + h_cp*dstride;
|
||||||
|
const unsigned char *src = frame;
|
||||||
|
//unsigned char t1,t2;
|
||||||
w_cp *= bpp;
|
w_cp *= bpp;
|
||||||
for (int y = 0; y < h_cp; ++y) {
|
for (int y=h_cp; --y>=0;) {
|
||||||
|
dst -= dstride;
|
||||||
|
for (int x=width; --x>=0;) {
|
||||||
|
//t1 = *src++;
|
||||||
|
//t2 = *src++;
|
||||||
|
*dst++ = *(src+2);
|
||||||
|
*dst++ = *(src+1);
|
||||||
|
*dst++ = *src;
|
||||||
|
src += 3;
|
||||||
|
}
|
||||||
dst -= dstride;
|
dst -= dstride;
|
||||||
memcpy(dst, frame, w_cp);
|
|
||||||
frame += stride;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create bitmap out of data
|
// Create bitmap out of data
|
||||||
df->frame = wxBitmap((const char*) data, width, height, bpp*8);
|
//df->frame = wxBitmap((const char*) data, width, height, bpp*8);
|
||||||
delete data;
|
//delete data;
|
||||||
|
df->frame = wxImage(width,height,data,false);
|
||||||
|
|
||||||
//else if (format == IVS_YV12 && vi->pixel_type == VideoInfo::CS_YV12) {
|
//else if (format == IVS_YV12 && vi->pixel_type == VideoInfo::CS_YV12) {
|
||||||
// // plane Y
|
// // plane Y
|
||||||
|
@ -412,6 +425,9 @@ bool DirectShowVideoProvider::NextFrame(DF &_df,int &_fn) {
|
||||||
if (frameno >= 0 && frameno <= (signed) num_frames) {
|
if (frameno >= 0 && frameno <= (signed) num_frames) {
|
||||||
_fn = frameno;
|
_fn = frameno;
|
||||||
_df = df;
|
_df = df;
|
||||||
|
if (zoom != 1.0 || dar != 1.0) {
|
||||||
|
_df.frame.Rescale(height*zoom*dar,height*zoom,wxIMAGE_QUALITY_NORMAL);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,7 +442,7 @@ wxBitmap DirectShowVideoProvider::GetFrame(int n) {
|
||||||
if (n >= (signed) num_frames) n = num_frames-1;
|
if (n >= (signed) num_frames) n = num_frames-1;
|
||||||
|
|
||||||
// Current
|
// Current
|
||||||
if (n == last_fnum) return rdf.frame;
|
if (n == last_fnum) return wxBitmap(rdf.frame);
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
DF df;
|
DF df;
|
||||||
|
@ -439,7 +455,7 @@ wxBitmap DirectShowVideoProvider::GetFrame(int n) {
|
||||||
NextFrame(df,fn);
|
NextFrame(df,fn);
|
||||||
last_fnum = n;
|
last_fnum = n;
|
||||||
rdf.frame = df.frame;
|
rdf.frame = df.frame;
|
||||||
return rdf.frame;
|
return wxBitmap(rdf.frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not the next, reset and seek first
|
// Not the next, reset and seek first
|
||||||
|
@ -486,7 +502,7 @@ seek:
|
||||||
|
|
||||||
// Return frame
|
// Return frame
|
||||||
last_fnum = n;
|
last_fnum = n;
|
||||||
return rdf.frame;
|
return wxBitmap(rdf.frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -499,12 +515,16 @@ void DirectShowVideoProvider::RefreshSubtitles() {
|
||||||
///////////
|
///////////
|
||||||
// Set DAR
|
// Set DAR
|
||||||
void DirectShowVideoProvider::SetDAR(double _dar) {
|
void DirectShowVideoProvider::SetDAR(double _dar) {
|
||||||
|
dar = _dar;
|
||||||
|
last_fnum = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// Set Zoom
|
// Set Zoom
|
||||||
void DirectShowVideoProvider::SetZoom(double _zoom) {
|
void DirectShowVideoProvider::SetZoom(double _zoom) {
|
||||||
|
zoom = _zoom;
|
||||||
|
last_fnum = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,10 @@ class DirectShowVideoProvider: public VideoProvider {
|
||||||
struct DF {
|
struct DF {
|
||||||
public:
|
public:
|
||||||
REFERENCE_TIME timestamp; // DS timestamp that we used for this frame
|
REFERENCE_TIME timestamp; // DS timestamp that we used for this frame
|
||||||
wxBitmap frame;
|
wxImage frame;
|
||||||
|
|
||||||
DF() : timestamp(-1) { }
|
DF() : timestamp(-1) { }
|
||||||
DF(wxBitmap f) : timestamp(-1), frame(f) { }
|
DF(wxImage f) : timestamp(-1), frame(f) { }
|
||||||
DF(const DF& f) { operator=(f); }
|
DF(const DF& f) { operator=(f); }
|
||||||
DF& operator=(const DF& f) { timestamp = f.timestamp; frame = f.frame; return *this; }
|
DF& operator=(const DF& f) { timestamp = f.timestamp; frame = f.frame; return *this; }
|
||||||
};
|
};
|
||||||
|
@ -118,8 +118,8 @@ public:
|
||||||
int GetFrameCount() { return num_frames; };
|
int GetFrameCount() { return num_frames; };
|
||||||
double GetFPS() { return fps; };
|
double GetFPS() { return fps; };
|
||||||
|
|
||||||
int GetWidth() { return width; };
|
int GetWidth() { return height*zoom*dar; };
|
||||||
int GetHeight() { return height; };
|
int GetHeight() { return height*zoom; };
|
||||||
double GetZoom() { return zoom; };
|
double GetZoom() { return zoom; };
|
||||||
|
|
||||||
int GetSourceWidth() { return width; };
|
int GetSourceWidth() { return width; };
|
||||||
|
|
Loading…
Reference in New Issue