summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.h
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-09-27 19:36:29 -0400
committerComment <tim@gray.(none)>2013-09-27 19:36:29 -0400
commit873f295e28a20e2e774852d8d7010ff5629549b4 (patch)
tree3237d0b7f9852d3ab0f69bdd59aac2848ed1dec1 /rotord/src/rotor.h
parentf40d511775eb8dfae9a28870c5e0125b5e55b305 (diff)
fixed crash when no node specified to load video
Diffstat (limited to 'rotord/src/rotor.h')
-rw-r--r--rotord/src/rotor.h44
1 files changed, 34 insertions, 10 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 72ef7d0..be6ecee 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -894,7 +894,7 @@ namespace Rotor {
if (attributes["filename"]->value!="") {
load(find_setting(settings,"media_path","")+attributes["filename"]->value);
}
- lastframe=0;
+ lastframe=-1;
};
~Video_loader(){};
bool load(const string &filename){
@@ -919,17 +919,40 @@ namespace Rotor {
if (isLoaded){
float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value);
float clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value;
- int wanted=(((int) ((frame.time*frame.framerate)+0.5))%max(1,player.get_number_frames()-1));
- if (wanted!=lastframe){
- if (!player.fetch_frame(frame.w,frame.h,wanted)) { //seek fail
- Poco::Logger& logger = Poco::Logger::get("Rotor");
- logger.error("Video_loader failed to seek frame "+toString(wanted)+" of "+attributes["filename"]->value);
-
- if (image.w>0) return &image; //just return the previous frame if possible
- else return nullptr;
+ if (attributes["mode"]->intVal==VIDEOFRAMES_blend){
+ float wanted=fmod(frame.time*frame.framerate,(float)player.get_number_frames());
+ if (((int)wanted)!=lastframe){
+ //get a new pair of frames possibly by switching the next one
+ if (lastframe=(int)wanted-1){
+ in1=in2;
+ }
+ else {
+ player.fetch_frame(frame.w,frame.h,(int)wanted);
+ in1.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
+ }
+ player.fetch_frame(frame.w,frame.h,((int)wanted+1)%max(1,player.get_number_frames()));
+ in2.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
}
- image.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
lastframe=wanted;
+ float amt=1.0f-(wanted-((int)wanted));
+ image=in1;
+ image*=amt;
+ Image in2t=in2;
+ in2t*=(1.0f-amt);
+ image+=in2t;
+ }
+ else {
+ int wanted=(((int) ((frame.time*frame.framerate)+0.5))%max(1,player.get_number_frames()));
+ if (wanted!=lastframe){
+ if (!player.fetch_frame(frame.w,frame.h,wanted)) { //seek fail
+ Poco::Logger& logger = Poco::Logger::get("Rotor");
+ logger.error("Video_loader failed to seek frame "+toString(wanted)+" of "+attributes["filename"]->value);
+
+ if (image.w>0) return &image; //just return the previous frame if possible
+ else return nullptr;
+ }
+ image.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
+ }
}
return &image;
}
@@ -941,6 +964,7 @@ namespace Rotor {
//ffmpegsource::decoder player;
libav::video_decoder player;
int lastframe;
+ Image in1,in2; //for blend frames;
};
class Video_output: public Image_node {
//Video_output 'presents' the output movie. Aspect ratio, bars, fadein/fadeout would happen here