diff --git a/aegisub/Makefile.am b/aegisub/Makefile.am index da3f1385b..4ef794c2a 100644 --- a/aegisub/Makefile.am +++ b/aegisub/Makefile.am @@ -128,6 +128,7 @@ aegisub_SOURCES = \ video_display_visual.cpp \ video_frame.cpp \ video_provider.cpp \ + video_provider_dummy.cpp \ video_provider_lavc.cpp \ video_slider.cpp \ video_zoom.cpp \ diff --git a/aegisub/video_provider_lavc.h b/aegisub/video_provider_dummy.cpp similarity index 59% rename from aegisub/video_provider_lavc.h rename to aegisub/video_provider_dummy.cpp index 80f019e01..134cbfb4b 100644 --- a/aegisub/video_provider_lavc.h +++ b/aegisub/video_provider_dummy.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Rodrigo Braz Monteiro +// Copyright (c) 2007, Rodrigo Braz Monteiro // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -33,65 +33,24 @@ // Contact: mailto:zeratul@cellosoft.com // -#pragma once - /////////// // Headers -#include "setup.h" -#define EMULATE_INTTYPES -extern "C" { -#include -#include -} #include "video_provider.h" -#include "mkv_wrap.h" -#include "lavc_file.h" -/////////////////////// -// LibAVCodec provider -class LAVCVideoProvider : public VideoProvider { - friend class LAVCAudioProvider; +//////////////////////// +// Dummy video provider +class DummyVideoProvider : public VideoProvider { 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(); + int lastFrame; protected: const AegiVideoFrame DoGetFrame(int n); public: - LAVCVideoProvider(wxString filename, double fps); - ~LAVCVideoProvider(); - - wxBitmap GetFrame(int n); + DummyVideoProvider(wxString filename, double fps); + ~DummyVideoProvider(); int GetPosition(); int GetFrameCount(); @@ -100,3 +59,68 @@ public: int GetHeight(); 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; +} diff --git a/aegisub/video_provider_lavc.cpp b/aegisub/video_provider_lavc.cpp index 98d0bd5b7..84013fde2 100644 --- a/aegisub/video_provider_lavc.cpp +++ b/aegisub/video_provider_lavc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Rodrigo Braz Monteiro +// Copyright (c) 2006-2007, Rodrigo Braz Monteiro // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -36,17 +36,18 @@ /////////// // Headers -#include "setup.h" +#define EMULATE_INTTYPES +#include +#include #include #include #include -#include "video_provider_lavc.h" +#include "video_provider.h" +#include "mkv_wrap.h" +#include "lavc_file.h" #include "utils.h" #include "vfr.h" #include "ass_file.h" -#if 0 -#include "mkv_wrap.h" -#endif ///////////////////// @@ -59,6 +60,58 @@ #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