aboutsummaryrefslogtreecommitdiff
path: root/Src/libvp6/include/Vid.hpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/libvp6/include/Vid.hpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/libvp6/include/Vid.hpp')
-rw-r--r--Src/libvp6/include/Vid.hpp167
1 files changed, 167 insertions, 0 deletions
diff --git a/Src/libvp6/include/Vid.hpp b/Src/libvp6/include/Vid.hpp
new file mode 100644
index 00000000..beb336b8
--- /dev/null
+++ b/Src/libvp6/include/Vid.hpp
@@ -0,0 +1,167 @@
+#ifndef VID_HPP
+#define VID_HPP
+
+#pragma warning (disable:4786)
+
+#include <windows.h>
+#include <cstdlib>
+#include <string>
+#include <map>
+#include <exception>
+
+namespace Vid
+{
+
+ const enum Format { uyvy }; // format = uyvy;
+
+ enum { rate = 2997, scale = 100 };
+
+ class FileError : public exception
+ {
+ public:
+ explicit FileError(const char* message);
+ explicit FileError(DWORD id);
+ const char* what() const;
+ private:
+ std::string message;
+ };
+
+
+ bool nameIsOK(const char* name);
+
+ typedef __int64 offset_type;
+ typedef unsigned __int64 size_type;
+
+ class File
+ {
+ public:
+
+ static const Format format;
+
+ enum mode_t {in, out};
+
+ File();
+ File(const char* name, mode_t mode, int iWidth = 0, int iHeight = 0);
+ ~File();
+
+ void open(
+ const char* name,
+ mode_t mode,
+ DWORD flags = FILE_ATTRIBUTE_NORMAL);
+
+ void close();
+
+ void reset(int frameNum) const;
+ void advance(int count) const;
+
+ void read(void* frame) const;
+ void write(const void* frame);
+
+ bool isOpen() const;
+
+ bool eof() const;
+
+ mode_t mode() const;
+
+ const char* name() const;
+
+ int frameNum() const;
+
+ int frameCount() const;
+
+ size_type size() const;
+
+ void dimensions(int iWidth, int iHeight);
+ int width() const;
+ int height() const;
+ int frameSize() const;
+
+ private:
+
+ File& operator=(const File&);
+ File(const File&);
+
+ HANDLE m_handle;
+
+ // When opening for write with FILE_FLAG_OVERLAPPED
+ HANDLE m_hEvent;
+ OVERLAPPED m_overlapped;
+
+ mutable int frameNum_;
+
+ int frameCount_;
+
+ char name_[_MAX_PATH];
+
+ mode_t mode_;
+
+ int m_iWidth;
+ int m_iHeight;
+ int m_iFrameSize;
+ };
+
+
+ class MappedFile
+ {
+ public:
+
+ //For now, just implement read-only.
+
+ MappedFile();
+ MappedFile(const char* name, int iWidth = 0, int iHeight = 0);
+
+ ~MappedFile();
+
+ void open(const char* name);
+ void close();
+
+ const char* name() const;
+
+ int frameCount() const;
+
+ void* map(int frameNum) const;
+
+ void unmap(int frameNum) const;
+ void unmap() const;
+
+ bool isMapped(int frameNum) const;
+ int mapCount() const;
+
+ void dimensions(int iWidth, int iHeight);
+ int width() const;
+ int height() const;
+ int frameSize() const;
+
+ private:
+
+ MappedFile(const MappedFile&);
+ MappedFile& operator=(const MappedFile&);
+
+ void init(int iWidth = 0, int iHeight = 0);
+
+ HANDLE file;
+ HANDLE mapping;
+
+ DWORD allocationGranularity;
+
+ int m_frameCount;
+
+ struct ViewInfo
+ {
+ void* view;
+ void* frame;
+ };
+
+ typedef std::map<int, ViewInfo> Views;
+ mutable Views views;
+
+ std::string m_name;
+
+ int m_iWidth;
+ int m_iHeight;
+ int m_iFrameSize;
+ };
+
+}
+
+#endif