2007-04-02 00:06:00 +02:00
|
|
|
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
2006-02-24 03:54:30 +01:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-02-24 03:54:30 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file video_provider_dummy.cpp
|
|
|
|
/// @brief Video provider returning a constant frame
|
|
|
|
/// @ingroup video_input
|
|
|
|
///
|
2006-02-24 03:54:30 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2007-04-02 20:28:09 +02:00
|
|
|
#include <wx/tokenzr.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "colorspace.h"
|
|
|
|
#include "video_provider_dummy.h"
|
2007-04-02 00:06:00 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Constructor
|
|
|
|
/// @param _fps
|
|
|
|
/// @param frames
|
|
|
|
/// @param _width
|
|
|
|
/// @param _height
|
|
|
|
/// @param colour
|
|
|
|
/// @param pattern
|
|
|
|
///
|
2007-04-04 03:54:37 +02:00
|
|
|
void DummyVideoProvider::Create(double _fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
|
2007-04-02 00:06:00 +02:00
|
|
|
lastFrame = -1;
|
2007-04-02 20:28:09 +02:00
|
|
|
framecount = frames;
|
|
|
|
fps = _fps;
|
|
|
|
width = _width;
|
|
|
|
height = _height;
|
2007-04-02 01:13:29 +02:00
|
|
|
|
2010-12-31 22:03:11 +01:00
|
|
|
frame = AegiVideoFrame(width,height);
|
|
|
|
unsigned char *dst = frame.data;
|
2007-04-02 20:28:09 +02:00
|
|
|
unsigned char r = colour.Red(), g = colour.Green(), b = colour.Blue();
|
2007-04-04 03:54:37 +02:00
|
|
|
|
|
|
|
unsigned char h, s, l, lr, lg, lb; // light variants
|
|
|
|
rgb_to_hsl(r, g, b, &h, &s, &l);
|
2009-06-04 04:28:46 +02:00
|
|
|
l += 24;
|
|
|
|
if (l < 24) l -= 48;
|
2007-04-04 03:54:37 +02:00
|
|
|
hsl_to_rgb(h, s, l, &lr, &lg, &lb);
|
|
|
|
|
|
|
|
if (pattern) {
|
2010-12-31 22:03:11 +01:00
|
|
|
int ppitch = frame.pitch / frame.GetBpp();
|
2007-04-04 22:42:44 +02:00
|
|
|
for (unsigned int y = 0; y < frame.h; ++y) {
|
2007-04-04 03:54:37 +02:00
|
|
|
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 {
|
2010-12-31 22:03:11 +01:00
|
|
|
for (int i=frame.pitch*frame.h/frame.GetBpp();--i>=0;) {
|
2007-04-04 03:54:37 +02:00
|
|
|
*dst++ = b;
|
|
|
|
*dst++ = g;
|
|
|
|
*dst++ = r;
|
|
|
|
*dst++ = 0;
|
|
|
|
}
|
2007-04-02 01:13:29 +02:00
|
|
|
}
|
2007-04-02 00:06:00 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Parsing constructor
|
|
|
|
/// @param filename
|
|
|
|
///
|
2009-07-23 21:57:57 +02:00
|
|
|
DummyVideoProvider::DummyVideoProvider(wxString filename)
|
2007-04-02 20:28:09 +02:00
|
|
|
{
|
|
|
|
wxString params;
|
2011-09-28 21:43:11 +02:00
|
|
|
if (!filename.StartsWith("?dummy:", ¶ms)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw agi::FileNotFoundError("Attempted creating dummy video provider with non-dummy filename");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2011-09-28 21:43:11 +02:00
|
|
|
wxStringTokenizer t(params, ":");
|
2007-04-02 20:28:09 +02:00
|
|
|
if (t.CountTokens() < 7) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Too few fields in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2009-07-20 02:39:38 +02:00
|
|
|
double fps;
|
2007-04-02 20:28:09 +02:00
|
|
|
long _frames, _width, _height, red, green, blue;
|
2007-04-04 03:54:37 +02:00
|
|
|
bool pattern = false;
|
2007-04-02 20:28:09 +02:00
|
|
|
|
|
|
|
wxString field = t.GetNextToken();
|
2009-07-20 02:39:38 +02:00
|
|
|
if (!field.ToDouble(&fps)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse fps field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
field = t.GetNextToken();
|
|
|
|
if (!field.ToLong(&_frames)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse framecount field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
field = t.GetNextToken();
|
|
|
|
if (!field.ToLong(&_width)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse width field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
field = t.GetNextToken();
|
|
|
|
if (!field.ToLong(&_height)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse height field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
field = t.GetNextToken();
|
|
|
|
if (!field.ToLong(&red)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse red colour field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
field = t.GetNextToken();
|
|
|
|
if (!field.ToLong(&green)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse green colour field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
field = t.GetNextToken();
|
|
|
|
if (!field.ToLong(&blue)) {
|
2010-08-02 08:32:01 +02:00
|
|
|
throw VideoOpenError("Unable to parse blue colour field in dummy video parameter list");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
2007-04-04 03:54:37 +02:00
|
|
|
field = t.GetNextToken();
|
2011-09-28 21:43:11 +02:00
|
|
|
if (field == "c") {
|
2007-04-04 03:54:37 +02:00
|
|
|
pattern = true;
|
|
|
|
}
|
|
|
|
|
2009-07-20 02:39:38 +02:00
|
|
|
Create(fps, _frames, _width, _height, wxColour(red, green, blue), pattern);
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Direct constructor
|
|
|
|
/// @param _fps
|
|
|
|
/// @param frames
|
|
|
|
/// @param _width
|
|
|
|
/// @param _height
|
|
|
|
/// @param colour
|
|
|
|
/// @param pattern
|
|
|
|
///
|
2007-04-04 03:54:37 +02:00
|
|
|
DummyVideoProvider::DummyVideoProvider(double _fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
|
|
|
|
Create(_fps, frames, _width, _height, colour, pattern);
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Destructor
|
|
|
|
///
|
2007-04-02 00:06:00 +02:00
|
|
|
DummyVideoProvider::~DummyVideoProvider() {
|
2009-05-21 21:49:23 +02:00
|
|
|
frame.Clear();
|
2007-04-02 00:06:00 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Construct a fake filename describing the video
|
|
|
|
/// @param fps
|
|
|
|
/// @param frames
|
|
|
|
/// @param _width
|
|
|
|
/// @param _height
|
|
|
|
/// @param colour
|
|
|
|
/// @param pattern
|
|
|
|
/// @return
|
|
|
|
///
|
2007-04-04 03:54:37 +02:00
|
|
|
wxString DummyVideoProvider::MakeFilename(double fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
|
2011-09-28 21:43:11 +02:00
|
|
|
return wxString::Format("?dummy:%f:%d:%d:%d:%d:%d:%d:%s", fps, frames, _width, _height, colour.Red(), colour.Green(), colour.Blue(), pattern?"c":"");
|
2007-04-02 20:28:09 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Get frame
|
|
|
|
/// @param n
|
|
|
|
/// @return
|
|
|
|
///
|
2009-07-20 05:50:25 +02:00
|
|
|
const AegiVideoFrame DummyVideoProvider::GetFrame(int n) {
|
2007-04-02 00:06:00 +02:00
|
|
|
lastFrame = n;
|
2007-04-02 01:07:29 +02:00
|
|
|
return frame;
|
2007-04-02 00:06:00 +02:00
|
|
|
}
|