summaryrefslogtreecommitdiff
path: root/rotord/src/libavwrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/libavwrapper.h')
-rw-r--r--rotord/src/libavwrapper.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h
index d30ea95..870815f 100644
--- a/rotord/src/libavwrapper.h
+++ b/rotord/src/libavwrapper.h
@@ -69,6 +69,8 @@ extern "C" {
#include <math.h>
#include <vector>
+#include <ffms.h>
+
namespace libav {
@@ -154,6 +156,68 @@ namespace libav {
};
+ class ffms2_decoder
+ {
+ public:
+ ffms2_decoder(){
+ maybeInitFFMpegLib();
+ pixfmts[0] = FFMS_GetPixFmt("rgb24");
+ pixfmts[1] = -1;
+ h=0;
+ w=0;
+ videosource=NULL;
+ loaded=false;
+ errinfo.Buffer = errmsg;
+ errinfo.BufferSize = sizeof(errmsg);
+ errinfo.ErrorType = FFMS_ERROR_SUCCESS;
+ errinfo.SubType = FFMS_ERROR_SUCCESS;
+ }
+ ~ffms2_decoder(){
+ cleanup();
+ }
+ void cleanup();
+ bool open(const std::string& filename);
+ float getFrameRate(){
+ if (loaded) return (((float)videoprops->FPSNumerator)/((float)videoprops->FPSDenominator));
+ else return -1.0f;
+ }
+ int getNumberOfFrames(){
+ if (loaded) return videoprops->NumFrames;
+ else return -1;
+ }
+ int getNumberOfChannels(){
+ return 3; //this is what we convert to
+ }
+ int getWidth(){
+ return w;
+ }
+ int getHeight(){
+ return h;
+ }
+ bool fetchFrame(int width,int height,int wanted){
+ if (FFMS_SetOutputFormatV2(videosource, pixfmts, width, height, FFMS_RESIZER_BICUBIC, &errinfo)) {
+ std::cerr<<"ffmpegsource: "<<errinfo.Buffer<<std::endl;
+ return false;
+ }
+ frame = FFMS_GetFrame(videosource, wanted%videoprops->NumFrames, &errinfo);
+ if (frame == NULL) {
+ std::cerr<<"ffmpegsource: "<<errinfo.Buffer<<std::endl;
+ return false;
+ }
+ return true;
+
+ }
+
+ FFMS_VideoSource *videosource;
+ FFMS_VideoProperties *videoprops;
+ FFMS_Frame *frame;
+ FFMS_ErrorInfo errinfo;
+ char errmsg[1024];
+ int pixfmts[2];
+ bool loaded;
+ int h,w;
+ };
+
/*
// TODO - finish refactoring based on
// http://svn.gnumonks.org/trunk/21c3-video/ffmpeg/ffmpeg-0.4.9-pre1/output_example.c