mirror of https://github.com/odrling/Aegisub
Option for checkerboard pattern in dummy video
Originally committed to SVN as r995.
This commit is contained in:
parent
f292339808
commit
e74727f634
|
@ -66,6 +66,7 @@ bool DialogDummyVideo::CreateDummyVideo(wxWindow *parent, wxString &out_filename
|
|||
double fps;
|
||||
long width, height, length;
|
||||
wxColour colour;
|
||||
bool pattern;
|
||||
|
||||
// Read back values and check sensibility
|
||||
if (!dlg.fps->GetValue().ToDouble(&fps) || fps <= 0) {
|
||||
|
@ -95,6 +96,7 @@ bool DialogDummyVideo::CreateDummyVideo(wxWindow *parent, wxString &out_filename
|
|||
length = 2;
|
||||
}
|
||||
colour = dlg.colour->GetColour();
|
||||
pattern = dlg.pattern->GetValue();
|
||||
|
||||
// Write to options
|
||||
Options.SetFloat(_T("Video Dummy Last FPS"), fps);
|
||||
|
@ -102,8 +104,9 @@ bool DialogDummyVideo::CreateDummyVideo(wxWindow *parent, wxString &out_filename
|
|||
Options.SetInt(_T("Video Dummy Last Height"), height);
|
||||
Options.SetInt(_T("Video Dummy Last Length"), length);
|
||||
Options.SetColour(_T("Video Dummy Last Colour"), colour);
|
||||
Options.SetBool(_T("Video Dummy Pattern"), pattern);
|
||||
|
||||
out_filename = DummyVideoProvider::MakeFilename(fps, length, width, height, colour);
|
||||
out_filename = DummyVideoProvider::MakeFilename(fps, length, width, height, colour, pattern);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -120,6 +123,7 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
|
|||
width = new wxTextCtrl(this, -1);
|
||||
height = new wxTextCtrl(this, -1);
|
||||
colour = new ColourButton(this, -1, wxSize(30, 17), Options.AsColour(_T("Video Dummy Last Colour")));
|
||||
pattern = new wxCheckBox(this, -1, _("Checkerboard pattern"));
|
||||
//fps = new wxComboBox(this, Dummy_Video_FPS, Options.AsText(_T("Video Dummy Last FPS")), wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_DROPDOWN);
|
||||
fps = new wxTextCtrl(this, Dummy_Video_FPS, Options.AsText(_T("Video Dummy Last FPS")));
|
||||
length = new wxSpinCtrl(this, Dummy_Video_Length);
|
||||
|
@ -137,6 +141,8 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
|
|||
fg->Add(res_sizer, 1, wxEXPAND);
|
||||
fg->Add(new wxStaticText(this, -1, _("Colour:")), 0, wxALIGN_CENTRE_VERTICAL);
|
||||
fg->Add(colour, 1, wxFIXED_MINSIZE|wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL);
|
||||
fg->AddStretchSpacer();
|
||||
fg->Add(pattern, 1, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL);
|
||||
fg->Add(new wxStaticText(this, -1, _("Frame rate (fps):")), 0, wxALIGN_CENTRE_VERTICAL);
|
||||
fg->Add(fps, 1, wxEXPAND);
|
||||
fg->Add(new wxStaticText(this, -1, _("Duration (frames):")), 0, wxALIGN_CENTRE_VERTICAL);
|
||||
|
@ -166,6 +172,7 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
|
|||
resolution_shortcuts->SetSelection(lastres);
|
||||
lastres++;
|
||||
}
|
||||
pattern->SetValue(Options.AsBool(_T("Video Dummy Pattern")));
|
||||
/*fps->Append(_T("23.976"));
|
||||
fps->Append(_T("29.97"));
|
||||
fps->Append(_T("24"));
|
||||
|
|
|
@ -53,6 +53,7 @@ private:
|
|||
wxTextCtrl *width;
|
||||
wxTextCtrl *height;
|
||||
ColourButton *colour;
|
||||
wxCheckBox *pattern;
|
||||
//wxComboBox *fps;
|
||||
wxTextCtrl *fps;
|
||||
wxSpinCtrl *length;
|
||||
|
|
|
@ -145,6 +145,7 @@ void OptionsManager::LoadDefaults() {
|
|||
SetColour(_T("Video Dummy Last Colour"), wxColour(47, 163, 254));
|
||||
SetFloat(_T("Video Dummy Last FPS"), 23.976);
|
||||
SetInt(_T("Video Dummy Last Length"), 40000);
|
||||
SetBool(_T("Video Dummy Pattern"), false);
|
||||
|
||||
// Video Provider (Advanced)
|
||||
SetModificationType(MOD_RESTART);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
///////////
|
||||
// Headers
|
||||
#include "video_provider_dummy.h"
|
||||
#include "colorspace.h"
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
|
||||
|
@ -52,7 +53,7 @@ public:
|
|||
|
||||
///////////////
|
||||
// Constructor
|
||||
void DummyVideoProvider::Create(double _fps, int frames, int _width, int _height, const wxColour &colour) {
|
||||
void DummyVideoProvider::Create(double _fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
|
||||
lastFrame = -1;
|
||||
framecount = frames;
|
||||
fps = _fps;
|
||||
|
@ -62,11 +63,56 @@ void DummyVideoProvider::Create(double _fps, int frames, int _width, int _height
|
|||
frame = AegiVideoFrame(width,height,FORMAT_RGB32);
|
||||
unsigned char *dst = frame.data[0];
|
||||
unsigned char r = colour.Red(), g = colour.Green(), b = colour.Blue();
|
||||
for (int i=frame.pitch[0]*frame.h/frame.GetBpp();--i>=0;) {
|
||||
*dst++ = b;
|
||||
*dst++ = g;
|
||||
*dst++ = r;
|
||||
*dst++ = 0;
|
||||
|
||||
unsigned char h, s, l, lr, lg, lb; // light variants
|
||||
rgb_to_hsl(r, g, b, &h, &s, &l);
|
||||
l = 255 - (255 - l) / 2;
|
||||
hsl_to_rgb(h, s, l, &lr, &lg, &lb);
|
||||
|
||||
if (pattern) {
|
||||
int ppitch = frame.pitch[0] / frame.GetBpp();
|
||||
for (int y = 0; y < frame.h; ++y) {
|
||||
if ((y / 8) & 1) {
|
||||
for (int x = 0; x < ppitch; ++x) {
|
||||
if ((x / 8) & 1) {
|
||||
*dst++ = b;
|
||||
*dst++ = g;
|
||||
*dst++ = r;
|
||||
*dst++ = 0;
|
||||
}
|
||||
else {
|
||||
*dst++ = lb;
|
||||
*dst++ = lg;
|
||||
*dst++ = lr;
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int x = 0; x < ppitch; ++x) {
|
||||
if ((x / 8) & 1) {
|
||||
*dst++ = lb;
|
||||
*dst++ = lg;
|
||||
*dst++ = lr;
|
||||
*dst++ = 0;
|
||||
}
|
||||
else {
|
||||
*dst++ = b;
|
||||
*dst++ = g;
|
||||
*dst++ = r;
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i=frame.pitch[0]*frame.h/frame.GetBpp();--i>=0;) {
|
||||
*dst++ = b;
|
||||
*dst++ = g;
|
||||
*dst++ = r;
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +133,7 @@ DummyVideoProvider::DummyVideoProvider(wxString filename, double _fps)
|
|||
|
||||
double parsedfps;
|
||||
long _frames, _width, _height, red, green, blue;
|
||||
bool pattern = false;
|
||||
|
||||
wxString field = t.GetNextToken();
|
||||
if (!field.ToDouble(&parsedfps)) {
|
||||
|
@ -125,14 +172,19 @@ DummyVideoProvider::DummyVideoProvider(wxString filename, double _fps)
|
|||
throw _T("Unable to parse bluecolour field in dummy video parameter list");
|
||||
}
|
||||
|
||||
Create(_fps, _frames, _width, _height, wxColour(red, green, blue));
|
||||
field = t.GetNextToken();
|
||||
if (field == _T("c")) {
|
||||
pattern = true;
|
||||
}
|
||||
|
||||
Create(_fps, _frames, _width, _height, wxColour(red, green, blue), pattern);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Direct constructor
|
||||
DummyVideoProvider::DummyVideoProvider(double _fps, int frames, int _width, int _height, const wxColour &colour) {
|
||||
Create(_fps, frames, _width, _height, colour);
|
||||
DummyVideoProvider::DummyVideoProvider(double _fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
|
||||
Create(_fps, frames, _width, _height, colour, pattern);
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,8 +196,8 @@ DummyVideoProvider::~DummyVideoProvider() {
|
|||
|
||||
//////////////////////////////////////////////////
|
||||
// Construct a fake filename describing the video
|
||||
wxString DummyVideoProvider::MakeFilename(double fps, int frames, int _width, int _height, const wxColour &colour) {
|
||||
return wxString::Format(_T("?dummy:%f:%d:%d:%d:%d:%d:%d"), fps, frames, _width, _height, colour.Red(), colour.Green(), colour.Blue());
|
||||
wxString DummyVideoProvider::MakeFilename(double fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
|
||||
return wxString::Format(_T("?dummy:%f:%d:%d:%d:%d:%d:%d:%s"), fps, frames, _width, _height, colour.Red(), colour.Green(), colour.Blue(), pattern?_T("c"):_T(""));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,17 +56,17 @@ private:
|
|||
int height;
|
||||
AegiVideoFrame frame;
|
||||
|
||||
void Create(double fps, int frames, int _width, int _height, const wxColour &colour);
|
||||
void Create(double fps, int frames, int _width, int _height, const wxColour &colour, bool pattern);
|
||||
|
||||
protected:
|
||||
const AegiVideoFrame DoGetFrame(int n);
|
||||
|
||||
public:
|
||||
DummyVideoProvider(wxString filename, double fps);
|
||||
DummyVideoProvider(double fps, int frames, int _width, int _height, const wxColour &colour);
|
||||
DummyVideoProvider(double fps, int frames, int _width, int _height, const wxColour &colour, bool pattern);
|
||||
~DummyVideoProvider();
|
||||
|
||||
static wxString MakeFilename(double fps, int frames, int _width, int _height, const wxColour &colour);
|
||||
static wxString MakeFilename(double fps, int frames, int _width, int _height, const wxColour &colour, bool pattern);
|
||||
|
||||
int GetPosition();
|
||||
int GetFrameCount();
|
||||
|
|
Loading…
Reference in New Issue