summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-05-02 18:35:29 +0100
committerTim Redfern <tim@herge.(none)>2013-05-02 18:35:29 +0100
commit4aa8f7c20c5e8bbe1ed9b007a1193ced8b019f4d (patch)
treea15b5161b4bdff3f3115355e6e34229595876dfa
parent836848622f85231c3ff6b9af49704fec4c035df4 (diff)
include problems - added makde Clang for clarity
-rw-r--r--rotord/Makefile5
-rw-r--r--rotord/libavexporter.cpp5
-rwxr-xr-xrotord/rotor.cpp14
-rwxr-xr-xrotord/rotor.h123
-rw-r--r--rotord/rotord.cbp1
5 files changed, 72 insertions, 76 deletions
diff --git a/rotord/Makefile b/rotord/Makefile
index 2d9b597..4735e7a 100644
--- a/rotord/Makefile
+++ b/rotord/Makefile
@@ -99,6 +99,10 @@ LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
all: Release
+Clang: CXX = clang
+
+Clang: $(PROGRAM)
+
Release: CXXFLAGS += -O2
Release: $(PROGRAM)
@@ -202,6 +206,7 @@ ifneq ($(DEPS),)
endif
endif
+
clean:
$(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
diff --git a/rotord/libavexporter.cpp b/rotord/libavexporter.cpp
index d9faa5b..7b6d1cf 100644
--- a/rotord/libavexporter.cpp
+++ b/rotord/libavexporter.cpp
@@ -56,12 +56,11 @@ bool libav::Exporter::record(std::string filename){
open_video(oc, video_codec, video_st);
if (audio_st) {
audioframesize=open_audio(oc, audio_codec, audio_st);
- audiostep=((float)audio_st->r_frame_rate.den)/audio_st->r_frame_rate.num;
- audiostep=((float)audioframesize)/44100.0f; //where to get the framesize from?????
+ audiostep=((float)audioframesize)/(audio_st->codec->sample_rate);
std::cerr << "opened audio codec with "<<audioframesize<<" frame size and "<<audiostep<<" seconds per frame"<<std::endl;
}
-
+
av_dump_format(oc, 0, filename.c_str(), 1);
// open the output file, if needed //
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp
index c79a9c7..b0bf8ab 100755
--- a/rotord/rotor.cpp
+++ b/rotord/rotor.cpp
@@ -1,16 +1,6 @@
#include "rotor.h"
-//float equality
-bool fequal(const float u,const float v){
- if (abs(u-v)<.001) return true;
- else return false;
-};
-bool flessorequal(const float u,const float v){
- //v is less or equal to u
- if (u-v>-.001) return true;
- else return false;
-};
using namespace Rotor;
@@ -120,7 +110,7 @@ string Audio_thumbnailer::print(){
stringstream output;
Poco::Base64Encoder *enc=new Poco::Base64Encoder(output);
- enc->write(data,width*height);
+ enc->write((char*)data,width*height);
//tring output;
/*
for (int j=0;j<height;j++) {
@@ -254,7 +244,7 @@ Image* Video_input::get_output(const Frame_spec &frame){
//can image node point to buffer in gst rather than copying the pixels?
//to test using fp time to seek: need a short movie with synced audio
-
+
//fix actual duration and audio file
//trace frame that is being read
if (player->isLoaded()){
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 2915fb6..441be2f 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -1,48 +1,7 @@
/*
-requirement driven design
-
-do we store graphs as files or in a db with UUID as key?
-
-we traverse the graph as recursive function calls until we satisfy all dependencies
-
-NO NODE HAS MORE THAN ONE OUTPUT
-WE DON'T LINK TO AN OUTPUT OBJECT WE LINK TO THE NODE - GET_OUTPUT IS THE RENDER FUNCTION
-MORE THAN ONE NODE CAN LINK THE SAME OUTPUT
-NODES CACHE AT LEAST ONE FRAME
-
-??the only node with more than 1 output is audio?
-??lets rethink this
-??audio analysis nodes can be seperate - they can all load from the same audio file - were gonna have to process each pass
-??output splitter? channel splitter? these can be done as 1 object per channel?
-??I think so
-
-settings - how do we deal with settings being controllable
-signal inputs can have a gui representation as well
-other gui items don't have an input
-
-scaling to come
-
-time is always in floating points seconds - time has to be requested when rendering - either a preview
-what about testing a float for equality?
-maybe we should look at time in int (frames) - - what does this imply
-is it easier to have a function like:
-bool Same_frame(float time1, float time2);
-
-nb where a signal enters a channel comp input - it is duplicated - so nodes should cache a value (more for time effects)
-
-sql stuff
-
-NB best way to use is: interface uploads audio and makes thumbnail: graph determines what kind of audio analysis is used by referring to plugins
-jesus where is it hanging in the frigging debugger
-
-GOOD GOOD GOOD
-
-next - build signal_output and make a working chain with dummy data
-
-
-
-main definitions of libavcodec.h are in utils.c
+nodes can have many inputs but only 1 output
+image nodes that use an image as input can pass on the incoming image only if its unchanged.
*/
#include <unordered_map>
@@ -69,6 +28,7 @@ main definitions of libavcodec.h are in utils.c
#include "Poco/Path.h"
#include <iostream>
+
using Poco::UUID;
using Poco::UUIDGenerator;
using Poco::Net::HTTPResponse;
@@ -116,6 +76,20 @@ namespace Rotor {
#define PREVIEW 2
#define RENDER 3
+#ifndef FEQUAL
+//float equality
+bool fequal(const float u,const float v){
+ if (abs(u-v)<.001) return true;
+ else return false;
+};
+bool flessorequal(const float u,const float v){
+ //v is less or equal to u
+ if (u-v>-.001) return true;
+ else return false;
+};
+#define FEQUAL
+#endif
+
//forward declaration
class Node;
class Signal_node;
@@ -209,11 +183,11 @@ namespace Rotor {
};
class Time_spec{
public:
- Time_spec(float _seconds,float _framerate){ seconds=_seconds; framerate=_framerate; };
- float seconds;
+ Time_spec(float _time,float _framerate){ time=_time; framerate=_framerate; };
+ float time;
float framerate;
- Time_spec lastframe(){
- return Time_spec(seconds-(1.0f/framerate),framerate);
+ Time_spec lastframe() const{
+ return Time_spec(time-(1.0f/framerate),framerate);
}
};
class Frame_spec{
@@ -244,7 +218,7 @@ namespace Rotor {
};
class Input{
public:
- Input(const string &_desc): description(_desc),connection(nullptr){};
+ Input(const string &_desc): connection(nullptr),description(_desc){};
Node* connection;
string description;
};
@@ -280,7 +254,7 @@ namespace Rotor {
};
class Signal_node: public Node{
public:
- virtual float get_output(const Time_spec &time) { return 0.0f; };
+ virtual const float get_output(const Time_spec &time) { return 0.0f; };
};
class Image_node: public Node{
public:
@@ -313,15 +287,15 @@ namespace Rotor {
bool init(int _channels,int _bits,int _samples,int _rate);
void cleanup();
int process_frame(uint8_t *data,int samples_in_frame);
- float get_output(const Time_spec &time) {
+ const float get_output(const Time_spec &time) {
if (analyser.features.size()) {
- auto i=analyser.features.lower_bound(time.seconds);
+ auto i=analyser.features.lower_bound(time.time);
if (i!=analyser.features.end()){
float lk=i->first;
int ln=i->second;
if (i++!=analyser.features.end()){
float uk=i->first;
- return (((time.seconds-lk)/(uk-lk))+ln);
+ return (((time.time-lk)/(uk-lk))+ln);
}
else return (float)ln;
}
@@ -342,10 +316,12 @@ namespace Rotor {
divide_amount=ofToFloat(check(settings,"amount"));
};
Signal_divide* clone(map<string,string> &_settings) { return new Signal_divide(_settings);};
- float get_output(const Time_spec &time) {
- if (inputs[0]->connection) {
- return (((Signal_node*)inputs[0]->connection)->get_output(time))/divide_amount;
- }
+ const float get_output(const Time_spec &time) {
+ if (inputs.size()) { //there should there be a way to specify number of inputs in the code rather than in xml
+ if (inputs[0]->connection) {
+ return (((Signal_node*)inputs[0]->connection)->get_output(time))/divide_amount;
+ }
+ }
return 0.0f;
}
float divide_amount;
@@ -357,7 +333,7 @@ namespace Rotor {
base_settings(settings);
};
Is_new_integer* clone(map<string,string> &_settings) { return new Is_new_integer(_settings);};
- float get_output(const Time_spec &time) {
+ const float get_output(const Time_spec &time) {
if (inputs[0]->connection) {
float s1=(((Signal_node*)(inputs[0]->connection))->get_output(time));
float s2=(((Signal_node*)(inputs[0]->connection))->get_output(time.lastframe()));
@@ -376,7 +352,7 @@ namespace Rotor {
};
Signal_output* clone(map<string,string> &_settings) { return new Signal_output(_settings);};
bool render(const float duration, const float framerate,string &xml_out);
- float get_output(const Time_spec &time) {
+ const float get_output(const Time_spec &time) {
if (inputs[0]->connection) {
return ((Signal_node*)(inputs[0]->connection))->get_output(time);
}
@@ -394,10 +370,10 @@ namespace Rotor {
Testcard* clone(map<string,string> &_settings) { return new Testcard(_settings);};
Image *get_output(const Frame_spec &frame){
if (image->setup(frame.w,frame.h)) {
-
+
}
//always create testcard
- float ws=(255.0f/frame.w);
+ //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++){
@@ -413,6 +389,33 @@ namespace Rotor {
private:
Image *image; //is an image generator
};
+ class Invert: public Image_node {
+ public:
+ Invert(){};
+ Invert(map<string,string> &settings) {
+ base_settings(settings);
+ image=new Image();
+ };
+ ~Invert(){ delete image;};
+ Invert* clone(map<string,string> &_settings) { return new Invert(_settings);};
+ Image *get_output(const Frame_spec &frame){
+ if (inputs.size()) {
+ if (inputs[0]->connection) {
+ Time_spec requested=Time_spec(frame.time,frame.framerate);
+ if (fequal((((Signal_node*)inputs[0]->connection)->get_output(requested)),1.0f)) {
+ //invert=!invert;
+ }
+ }
+ }
+ if (image_inputs[0]->connection) {
+
+ }
+ return image;
+ }
+ private:
+ Image *image; //is an image generator
+ //bool invert;
+ };
class Video_output: public Image_node {
public:
Video_output(){};
diff --git a/rotord/rotord.cbp b/rotord/rotord.cbp
index 7a975b4..690d6b9 100644
--- a/rotord/rotord.cbp
+++ b/rotord/rotord.cbp
@@ -51,7 +51,6 @@
<Unit filename="Makefile" />
<Unit filename="Pixels.cpp" />
<Unit filename="Pixels.h" />
- <Unit filename="avCodec.h" />
<Unit filename="graph.cpp" />
<Unit filename="gstvideoloader.cpp" />
<Unit filename="gstvideoloader.h" />