summaryrefslogtreecommitdiff
path: root/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h')
-rw-r--r--working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h b/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h
new file mode 100644
index 0000000..4c8f96e
--- /dev/null
+++ b/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h
@@ -0,0 +1,55 @@
+#ifndef ffmpeg_fas_wrapper_H
+#define ffmpeg_fas_wrapper_H
+
+#include <string>
+#include <iostream>
+#include "ffmpeg_fas.c"
+
+
+namespace ffmpeg_fas {
+ class decoder
+ {
+ public:
+ decoder(){
+ fas_initialize(FAS_TRUE,FAS_RGB24);
+ loaded=false;
+ framerate=0.0f;
+ numFrames=0;
+ }
+ bool open(std::string& filename){
+ fas_error_type e=fas_open_video(&context,filename.c_str());
+ if (e==FAS_SUCCESS){
+ loaded=true;
+ framerate=(((float)context->format_context->streams[context->stream_idx]->r_frame_rate.num)/((float)context->format_context->streams[context->stream_idx]->r_frame_rate.den));
+ numFrames=context->format_context->streams[context->stream_idx]->nb_frames;
+ if (numFrames<1){
+ //some codecs don't keep this info in the header
+ numFrames = (int)(( context->format_context->duration / (double)AV_TIME_BASE ) * framerate );
+ //this approach still doesn't seem to give quite the right answer- comes out a little too big
+ //could alternatively just redefine the length if the reader fails
+ }
+ }
+ else {
+ std::cerr<<"ffmpeg_fas ERROR: "<<fas_error_message(e)<<std::endl;
+ loaded=true;
+ }
+ return loaded;
+ }
+ float getFrameRate(){
+ return framerate;
+ }
+ int getNumberOfFrames();
+ int getNumberOfChannels();
+ int getWidth();
+ int getHeight();
+ bool fetchFrame(int width,int height,int wanted);
+ void cleanup(); //necessary?
+
+ fas_raw_image_type frame;
+ fas_context_ref_type context;
+ bool loaded;
+ float framerate;
+ int numFrames;
+ };
+}
+#endif