Added dummy video provider.

Originally committed to SVN as r972.
This commit is contained in:
Rodrigo Braz Monteiro 2007-04-01 22:06:00 +00:00
parent 0fa69e80e0
commit 14edd1fe3b
3 changed files with 132 additions and 54 deletions

View file

@ -128,6 +128,7 @@ aegisub_SOURCES = \
video_display_visual.cpp \ video_display_visual.cpp \
video_frame.cpp \ video_frame.cpp \
video_provider.cpp \ video_provider.cpp \
video_provider_dummy.cpp \
video_provider_lavc.cpp \ video_provider_lavc.cpp \
video_slider.cpp \ video_slider.cpp \
video_zoom.cpp \ video_zoom.cpp \

View file

@ -1,4 +1,4 @@
// Copyright (c) 2006, Rodrigo Braz Monteiro // Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@ -33,65 +33,24 @@
// Contact: mailto:zeratul@cellosoft.com // Contact: mailto:zeratul@cellosoft.com
// //
#pragma once
/////////// ///////////
// Headers // Headers
#include "setup.h"
#define EMULATE_INTTYPES
extern "C" {
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
}
#include "video_provider.h" #include "video_provider.h"
#include "mkv_wrap.h"
#include "lavc_file.h"
/////////////////////// ////////////////////////
// LibAVCodec provider // Dummy video provider
class LAVCVideoProvider : public VideoProvider { class DummyVideoProvider : public VideoProvider {
friend class LAVCAudioProvider;
private: private:
MatroskaWrapper mkv; int lastFrame;
LAVCFile *lavcfile;
AVCodecContext *codecContext;
AVStream *stream;
AVCodec *codec;
AVFrame *frame;
int vidStream;
int display_w;
int display_h;
wxArrayInt bytePos;
bool isMkv;
__int64 lastDecodeTime;
int frameNumber;
int length;
AegiVideoFrame curFrame;
bool validFrame;
uint8_t *buffer1;
uint8_t *buffer2;
int buffer1Size;
int buffer2Size;
bool GetNextFrame();
void LoadVideo(wxString filename, double fps);
void Close();
protected: protected:
const AegiVideoFrame DoGetFrame(int n); const AegiVideoFrame DoGetFrame(int n);
public: public:
LAVCVideoProvider(wxString filename, double fps); DummyVideoProvider(wxString filename, double fps);
~LAVCVideoProvider(); ~DummyVideoProvider();
wxBitmap GetFrame(int n);
int GetPosition(); int GetPosition();
int GetFrameCount(); int GetFrameCount();
@ -100,3 +59,68 @@ public:
int GetHeight(); int GetHeight();
double GetFPS(); double GetFPS();
}; };
///////////
// Factory
class DummyVideoProviderFactory : public VideoProviderFactory {
public:
VideoProvider *CreateProvider(wxString video,double fps=0.0) { return new DummyVideoProvider(video,fps); }
DummyVideoProviderFactory() : VideoProviderFactory(_T("dummy")) {}
} registerDummyVideo;
///////////////
// Constructor
DummyVideoProvider::DummyVideoProvider(wxString filename, double fps) {
lastFrame = -1;
}
//////////////
// Destructor
DummyVideoProvider::~DummyVideoProvider() {
}
/////////////
// Get frame
const AegiVideoFrame DummyVideoProvider::DoGetFrame(int n) {
lastFrame = n;
return AegiVideoFrame(640,480);
}
////////////////
// Get position
int DummyVideoProvider::GetPosition() {
return lastFrame;
}
///////////////////
// Get frame count
int DummyVideoProvider::GetFrameCount() {
return 40000;
}
/////////////
// Get width
int DummyVideoProvider::GetWidth() {
return 640;
}
//////////////
// Get height
int DummyVideoProvider::GetHeight() {
return 480;
}
///////////
// Get FPS
double DummyVideoProvider::GetFPS() {
return 24.0/1.001;
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2006, Rodrigo Braz Monteiro // Copyright (c) 2006-2007, Rodrigo Braz Monteiro
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
@ -36,17 +36,18 @@
/////////// ///////////
// Headers // Headers
#include "setup.h" #define EMULATE_INTTYPES
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
#include <wx/wxprec.h> #include <wx/wxprec.h>
#include <wx/image.h> #include <wx/image.h>
#include <algorithm> #include <algorithm>
#include "video_provider_lavc.h" #include "video_provider.h"
#include "mkv_wrap.h"
#include "lavc_file.h"
#include "utils.h" #include "utils.h"
#include "vfr.h" #include "vfr.h"
#include "ass_file.h" #include "ass_file.h"
#if 0
#include "mkv_wrap.h"
#endif
///////////////////// /////////////////////
@ -59,6 +60,58 @@
#endif #endif
///////////////////////
// LibAVCodec provider
class LAVCVideoProvider : public VideoProvider {
friend class LAVCAudioProvider;
private:
MatroskaWrapper mkv;
LAVCFile *lavcfile;
AVCodecContext *codecContext;
AVStream *stream;
AVCodec *codec;
AVFrame *frame;
int vidStream;
int display_w;
int display_h;
wxArrayInt bytePos;
bool isMkv;
__int64 lastDecodeTime;
int frameNumber;
int length;
AegiVideoFrame curFrame;
bool validFrame;
uint8_t *buffer1;
uint8_t *buffer2;
int buffer1Size;
int buffer2Size;
bool GetNextFrame();
void LoadVideo(wxString filename, double fps);
void Close();
protected:
const AegiVideoFrame DoGetFrame(int n);
public:
LAVCVideoProvider(wxString filename, double fps);
~LAVCVideoProvider();
int GetPosition();
int GetFrameCount();
int GetWidth();
int GetHeight();
double GetFPS();
};
/////////// ///////////
// Factory // Factory