summaryrefslogtreecommitdiff
path: root/rotord/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/rotor.h')
-rwxr-xr-xrotord/rotor.h97
1 files changed, 89 insertions, 8 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 9728909..4a6c8d3 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -153,6 +153,16 @@ namespace Rotor {
return Time_spec(seconds-(1.0f/framerate),framerate);
}
};
+ class Frame_spec{
+ public:
+ Frame_spec(float _time,float _framerate,int _w,int _h){ time=_time; framerate=_framerate; w=_w; h=_h;};
+ float time;
+ float framerate;
+ int h,w;
+ Frame_spec lastframe(){
+ return Frame_spec(time-(1.0f/framerate),framerate,w,h);
+ }
+ };
class Render_status{
public:
int id;
@@ -177,7 +187,8 @@ namespace Rotor {
};
class Image_input: public Input{
public:
-
+ bool connect(Image_node* source);
+ Image_input(const string &_desc): Input(_desc){};
};
class Signal_input: public Input{
public:
@@ -205,7 +216,46 @@ namespace Rotor {
}
};
class Image{
- char* data;
+ public:
+ Image(){
+ zero();
+ };
+ Image(int _w,int _h){
+ setup(_w,_h);
+ };
+ ~Image() {
+ free();
+ };
+ void free(){
+ if (RGBdata) delete[] RGBdata;
+ if (Adata) delete[] Adata;
+ if (Zdata) delete[] Zdata;
+ zero();
+ }
+ void zero(){
+ RGBdata=nullptr;
+ Adata=nullptr;
+ Zdata=nullptr;
+ w=0;
+ h=0;
+ }
+ bool setup(int _w,int _h){
+ if (w!=_w||h!=_h){
+ free();
+ w=_w;
+ h=_h;
+ RGBdata=new uint8_t[w*h*3];
+ Adata=new uint8_t[w*h];
+ Zdata=new uint16_t[w*h];
+ return true;
+ }
+ else return false;
+ }
+ uint8_t *RGBdata;
+ uint8_t *Adata;
+ uint16_t *Zdata;
+ private:
+ int h,w;
};
class Signal_node: public Node{
public:
@@ -214,13 +264,13 @@ namespace Rotor {
class Image_node: public Node{
public:
vector<Image_input> image_inputs; //image node also has image inputs and outputs
- Image* get_output(const Time_spec &time){ //sample implementation
+ Image *get_output(const Frame_spec &frame){ //sample implementation
//do something with the inputs
//and then
- return ((Image_node*)image_inputs[0].connection)->get_output(time);
+ return ((Image_node*)image_inputs[0].connection)->get_output(frame);
}
- void get_preview(const Time_spec &time);
- Image* image; //this can be privately allocated or just passed on as the node see fit
+ Image *get_preview(const Frame_spec &frame);
+ Image *image; //this can be privately allocated or just passed on as the node see fit
private:
float image_time;
};
@@ -315,14 +365,45 @@ namespace Rotor {
else return 0.0f;
}
};
+ class Testcard: public Image_node {
+ public:
+ Testcard(){};
+ Testcard(map<string,string> &settings) {
+ base_settings(settings);
+ };
+ Testcard* clone(map<string,string> &_settings) { return new Testcard(_settings);};
+ Image *get_output(const Frame_spec &frame){
+ if (image->setup(frame.w,frame.h)) {
+ //create testcard
+ float ws=(255.0f/frame.w);
+ float hs=(255.0f/frame.h);
+ for (int i=0;i<frame.h;i++){
+ for (int j=0;j<frame.w;j++){
+ image->RGBdata[i*frame.w+j]=(uint8_t)(i*hs);
+ image->RGBdata[i*frame.w+j+1]=(uint8_t)(j*ws);
+ image->RGBdata[i*frame.w+j+2]=(uint8_t)(0);
+ image->Adata[i*frame.w+j]=(uint8_t)255;
+ image->Zdata[i*frame.w+j]=(uint16_t)512; //1.0 in fixed point 8.8 bits
+ }
+ }
+ }
+ return image;
+ }
+ private:
+ Image *image;
+ };
class Video_output: public Image_node {
public:
Video_output(){};
Video_output(map<string,string> &settings) {
base_settings(settings);
+ exporter=new ofxMovieExporter();
};
Video_output* clone(map<string,string> &_settings) { return new Video_output(_settings);};
- bool render(const float duration, const float framerate,const string &output_filename,const string &audio_filename);
+ bool render(const float duration, const float framerate,const string &output_filename,const string &audio_filename);
+
+ private:
+ ofxMovieExporter *exporter;
};
//-------------------------------------------------------------------
class Node_factory{
@@ -448,6 +529,6 @@ namespace Rotor {
/*
coding style
-Types begin with capitals 'CamelCase'
+Types begin with capitals 'New_type'
variables/ instances use lower case with underscore as a seperator
*/