diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2012-05-17 23:48:10 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2012-05-17 23:48:10 +0400 |
commit | de2f31b58f7f3faed1c73651ae0ca1cee0812144 (patch) | |
tree | 92ef0d6beee8153352bff9a1c400cae0c7303b9f /src/filters/transform | |
parent | ee67e0414c5b885cd552bee412f843105addc6b6 (diff) |
move a couple of headers from the ffmpeg folder to the MPCVideoDec folder where they are used
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4775 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform')
-rw-r--r-- | src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj | 4 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters | 12 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp | 2 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/PODtypes.h | 32 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/array_allocator.h | 49 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/char_t.h | 290 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/ffImgfmt.cpp | 4 | ||||
-rw-r--r-- | src/filters/transform/MPCVideoDec/ffImgfmt.h | 489 |
8 files changed, 879 insertions, 3 deletions
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj index 181bb5c4d..3ea9d9cd0 100644 --- a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj +++ b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj @@ -261,16 +261,20 @@ <ClInclude Include="..\..\..\apps\mplayerc\WinAPIUtils.h">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
</ClInclude>
+ <ClInclude Include="array_allocator.h" />
+ <ClInclude Include="char_t.h" />
<ClInclude Include="CpuId.h" />
<ClInclude Include="DXVADecoder.h" />
<ClInclude Include="DXVADecoderH264.h" />
<ClInclude Include="DXVADecoderMpeg2.h" />
<ClInclude Include="DXVADecoderVC1.h" />
+ <ClInclude Include="ffImgfmt.h" />
<ClInclude Include="FfmpegContext.h" />
<ClInclude Include="H264RandomAccess.h" />
<ClInclude Include="IMPCVideoDecFilter.h" />
<ClInclude Include="MPCVideoDecFilter.h" />
<ClInclude Include="MPCVideoDecSettingsWnd.h" />
+ <ClInclude Include="PODtypes.h" />
<ClInclude Include="resource.h">
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
</ClInclude>
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters index 08bebf5a7..29bf877c5 100644 --- a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters +++ b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters @@ -122,6 +122,18 @@ <ClInclude Include="H264RandomAccess.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="char_t.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="ffImgfmt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="array_allocator.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="PODtypes.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MPCVideoDecFilter.rc">
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp index 9da98a347..ce81896bc 100644 --- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp +++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp @@ -34,7 +34,7 @@ #include "VideoDecOutputPin.h"
#include "CpuId.h"
-#include <ffmpeg/ffImgfmt.h>
+#include "ffImgfmt.h"
extern "C"
{
#include "FfmpegContext.h"
diff --git a/src/filters/transform/MPCVideoDec/PODtypes.h b/src/filters/transform/MPCVideoDec/PODtypes.h new file mode 100644 index 000000000..33a200159 --- /dev/null +++ b/src/filters/transform/MPCVideoDec/PODtypes.h @@ -0,0 +1,32 @@ +#ifndef _PODTYPES_H_
+#define _PODTYPES_H_
+
+template<class T> struct isPOD {enum {is = false};};
+template<> struct isPOD<bool> {enum {is = true};};
+
+template<> struct isPOD<char> {enum {is = true};};
+
+template<> struct isPOD<signed char> {enum {is = true};};
+template<> struct isPOD<short int> {enum {is = true};};
+template<> struct isPOD<int> {enum {is = true};};
+template<> struct isPOD<long int> {enum {is = true};};
+template<> struct isPOD<__int64> {enum {is = true};};
+
+template<> struct isPOD<unsigned char> {enum {is = true};};
+template<> struct isPOD<unsigned short int> {enum {is = true};};
+template<> struct isPOD<unsigned int> {enum {is = true};};
+template<> struct isPOD<unsigned long int> {enum {is = true};};
+template<> struct isPOD<unsigned __int64> {enum {is = true};};
+
+template<> struct isPOD<float> {enum {is = true};};
+template<> struct isPOD<double> {enum {is = true};};
+template<> struct isPOD<long double> {enum {is = true};};
+
+#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER >= 1300)
+template<> struct isPOD<wchar_t> {enum {is = true};};
+template<class Tp> struct isPOD<Tp*> {enum {is = true};};
+#endif
+
+template<class A> struct allocator_traits {enum {is_static = false};};
+
+#endif
diff --git a/src/filters/transform/MPCVideoDec/array_allocator.h b/src/filters/transform/MPCVideoDec/array_allocator.h new file mode 100644 index 000000000..ea4241376 --- /dev/null +++ b/src/filters/transform/MPCVideoDec/array_allocator.h @@ -0,0 +1,49 @@ +#ifndef _ARRAY_ALLOCATOR_H_
+#define _ARRAY_ALLOCATOR_H_
+
+#include "PODtypes.h"
+
+template <class T, size_t size> class array_allocator
+{
+private:
+ T* p;
+public:
+ typedef T value_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ typedef T* pointer;
+ typedef const T* const_pointer;
+
+ typedef T& reference;
+ typedef const T& const_reference;
+
+ pointer address(reference r) const {return &r;}
+ const_pointer address(const_reference r) const {return &r;}
+
+ array_allocator() throw() {}
+ template <class U, size_t sz> array_allocator(const array_allocator<U, sz>&) throw() {}
+ ~array_allocator() throw() {}
+
+ pointer allocate(size_type n, const void* = 0) {
+ p = ((T *)::operator new(size * sizeof(T)));
+ return p;
+ }
+ void deallocate(pointer p, size_type) {delete p;}
+
+ //Use placement new to engage the constructor
+ void construct(pointer p, const T& val) {new((void*)p) T(val);}
+ void destroy(pointer p) {((T*)p)->~T();}
+
+ size_type max_size() const throw() {return size;}
+ template<class U> struct rebind {typedef array_allocator<U, size> other;};
+};
+
+template<class T, size_t size> struct array_vector : std::vector<T, array_allocator<T, size> > {
+};
+
+#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER >= 1300)
+template<class T, size_t a> struct allocator_traits<array_allocator<T, a> > {enum {is_static = true};};
+#endif
+
+#endif
diff --git a/src/filters/transform/MPCVideoDec/char_t.h b/src/filters/transform/MPCVideoDec/char_t.h new file mode 100644 index 000000000..d7faec60b --- /dev/null +++ b/src/filters/transform/MPCVideoDec/char_t.h @@ -0,0 +1,290 @@ +#ifndef _CHAR_T_H_
+#define _CHAR_T_H_
+
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+
+#pragma warning(disable:4995 4996)
+
+#undef _l
+#ifdef UNICODE
+typedef wchar_t char_t;
+#define tsprintf swprintf
+#define tsnprintf_s _snwprintf_s
+#define tfprintf fwprintf
+#define tsscanf swscanf
+#define __l(x) L ## x
+#define _l(x) __l(x)
+#else
+typedef char char_t;
+#define tsprintf sprintf
+#define tsnprintf_s _snprintf_s
+#define tfprintf fprintf
+#define tsscanf sscanf
+#define _l(x) x
+#endif
+
+#ifdef __cplusplus
+
+#ifdef __GNUC__
+#ifndef __forceinline
+#define __forceinline __attribute__((__always_inline__)) inline
+#endif
+#endif
+
+static __forceinline errno_t strncat_s(wchar_t *a, size_t b, const wchar_t *c, size_t d)
+{
+ return wcsncat_s(a, b, c, d);
+}
+static __forceinline int vsnprintf_s(wchar_t *a, size_t b, size_t c, const wchar_t *d, va_list e)
+{
+ return _vsnwprintf_s(a, b, c, d, e);
+}
+static __forceinline errno_t _splitpath_s(const wchar_t * a,
+ wchar_t * b, size_t c, wchar_t * d, size_t e,
+ wchar_t * f, size_t g, wchar_t * h, size_t i)
+{
+ return _wsplitpath_s(a, b, c, d, e, f, g, h, i);
+};
+static __forceinline errno_t _makepath_s(wchar_t *a, size_t b,
+ const wchar_t *c, const wchar_t *d,
+ const wchar_t *e, const wchar_t *f)
+{
+ return _wmakepath_s(a, b, c, d, e, f);
+};
+static __forceinline wchar_t* ff_strncpy(wchar_t *dst, const wchar_t *src, size_t count)
+{
+ wcsncpy_s(dst, count, src, _TRUNCATE);
+ return dst;
+}
+static __forceinline char* ff_strncpy(char *dst, const char *src, size_t count)
+{
+ strncpy_s(dst, count, src, _TRUNCATE);
+ return dst;
+}
+
+static __forceinline wchar_t* strcat(wchar_t *a, const wchar_t *b)
+{
+ return wcscat(a, b);
+}
+static __forceinline int strcmp(const wchar_t *a, const wchar_t *b)
+{
+ return wcscmp(a, b);
+}
+static __forceinline int strncmp(const wchar_t *a, const wchar_t *b, size_t c)
+{
+ return wcsncmp(a, b, c);
+}
+static __forceinline int strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
+{
+ return _wcsnicmp(a, b, c);
+}
+
+static __forceinline long strtol(const wchar_t *a, wchar_t **b, int c)
+{
+ return wcstol(a, b, c);
+}
+static __forceinline wchar_t* strchr(const wchar_t *a, wchar_t b)
+{
+ return (wchar_t*)wcschr(a, b);
+}
+static __forceinline int _strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
+{
+ return _wcsnicmp(a, b, c);
+}
+static __forceinline wchar_t* strstr(const wchar_t *a, const wchar_t *b)
+{
+ return (wchar_t*)wcsstr(a, b);
+}
+static __forceinline size_t strlen(const wchar_t *a)
+{
+ return wcslen(a);
+}
+static __forceinline wchar_t* strcpy(wchar_t *a, const wchar_t *b)
+{
+ return wcscpy(a, b);
+}
+static __forceinline int atoi(const wchar_t *a)
+{
+ return _wtoi(a);
+}
+static __forceinline wchar_t* _itoa(int a, wchar_t *b, int c)
+{
+ return _itow(a, b, c);
+}
+static __forceinline int stricmp(const wchar_t *a, const wchar_t *b)
+{
+ return _wcsicmp(a, b);
+}
+static __forceinline unsigned long strtoul(const wchar_t *a, wchar_t **b, int c)
+{
+ return wcstoul(a, b, c);
+}
+static __forceinline double strtod(const wchar_t *a, wchar_t **b)
+{
+ return wcstod(a, b);
+}
+static __forceinline int vsprintf(wchar_t *a, const wchar_t *b, va_list c)
+{
+ return vswprintf(a, b, c);
+}
+static __forceinline int _vsnprintf(wchar_t *a, size_t b, const wchar_t *c, va_list d)
+{
+ return _vsnwprintf(a, b, c, d);
+}
+
+static __forceinline FILE* fopen(const wchar_t *a, const wchar_t *b)
+{
+ return _wfopen(a, b);
+}
+static __forceinline int fputs(const wchar_t *a, FILE *b)
+{
+ return fputws(a, b);
+}
+static __forceinline int _stricoll(const wchar_t *a, const wchar_t *b)
+{
+ return _wcsicoll(a, b);
+}
+static __forceinline wchar_t* strrchr(const wchar_t *a, wchar_t b)
+{
+ return (wchar_t*)wcsrchr(a, b);
+}
+static __forceinline wchar_t* strupr(wchar_t *a)
+{
+ return _wcsupr(a);
+}
+static __forceinline wchar_t* strlwr(wchar_t *a)
+{
+ return _wcslwr(a);
+}
+static __forceinline wchar_t* _strtime(wchar_t *a)
+{
+ return _wstrtime(a);
+}
+static __forceinline wchar_t* memchr(wchar_t *a, wchar_t b, size_t c)
+{
+ return wmemchr(a, b, c);
+}
+static __forceinline const wchar_t* memchr(const wchar_t *a, wchar_t b, size_t c)
+{
+ return wmemchr(a, b, c);
+}
+static __forceinline wchar_t* strpbrk(const wchar_t *a, const wchar_t *b)
+{
+ return (wchar_t*)wcspbrk(a, b);
+}
+static __forceinline int64_t _strtoi64(const wchar_t *nptr, wchar_t **endptr, int base)
+{
+ return _wcstoi64(nptr, endptr, base);
+};
+
+template<class Tout> struct text
+ // ANSI <--> UNICODE conversion.
+ // in : input string in char* or wchar_t*.
+ // inlen : count of characters, not byte size!! -1 for null terminated string.
+ // out : output string in char* or wchar_t*.
+ // outlen : count of characters, not byte size!!
+{
+private:
+ Tout *buf;
+ bool own;
+public:
+ template<class Tin> inline text(const Tin *in, int code_page = CP_ACP);
+ template<class Tin> inline text(const Tin *in, Tout *Ibuf, int code_page = CP_ACP);
+ template<class Tin> inline text(const Tin *in, int inlen, Tout *Ibuf, size_t outlen, int code_page = CP_ACP);
+ ~text() {
+ if (own) {
+ delete []buf;
+ }
+ }
+ operator const Tout*() const {
+ return buf;
+ }
+};
+
+
+template<> template<> inline text<char>::text(const char *in, int code_page): buf(const_cast<char*>(in)), own(false) {}
+template<> template<> inline text<char>::text(const char *in, char *Ibuf, int code_page): buf(strcpy(Ibuf, in)), own(false) {}
+template<> template<> inline text<char>::text(const char *in, int inlen, char *Ibuf, size_t outlen, int code_page): own(false)
+{
+ if (inlen != -1) {
+ buf = Ibuf;
+ if ((size_t)inlen < outlen) {
+ ff_strncpy(Ibuf, in, inlen + 1);
+ } else {
+ ff_strncpy(Ibuf, in, outlen);
+ }
+ } else {
+ buf = Ibuf;
+ ff_strncpy(Ibuf, in, outlen);
+ }
+}
+
+
+template<> template<> inline text<wchar_t>::text(const wchar_t *in, int code_page): buf(const_cast<wchar_t*>(in)), own(false) {}
+template<> template<> inline text<wchar_t>::text(const wchar_t *in, wchar_t *Ibuf, int code_page): buf(strcpy(Ibuf, in)), own(false) {}
+template<> template<> inline text<wchar_t>::text(const wchar_t *in, int inlen, wchar_t *Ibuf, size_t outlen, int code_page): own(false)
+{
+ if (inlen != -1) {
+ buf = Ibuf;
+ if ((size_t)inlen < outlen) {
+ ff_strncpy(Ibuf, in, inlen + 1);
+ } else {
+ ff_strncpy(Ibuf, in, outlen);
+ }
+ } else {
+ buf = Ibuf;
+ ff_strncpy(Ibuf, in, outlen);
+ }
+}
+
+
+template<> template<> inline text<wchar_t>::text(const char *in, int code_page): own(in ? true : false)
+{
+ if (in) {
+ size_t l = strlen(in);
+ buf = new wchar_t[l + 1];
+ MultiByteToWideChar(code_page, 0, in, int(l + 1), buf, int(l + 1));
+ } else {
+ buf = NULL;
+ }
+}
+template<> template<> inline text<wchar_t>::text(const char *in, wchar_t *Ibuf, int code_page): own(false), buf(Ibuf)
+{
+ size_t l = strlen(in);
+ MultiByteToWideChar(code_page, 0, in, int(l + 1), buf, int(l + 1));
+}
+template<> template<> inline text<wchar_t>::text(const char *in, int inlen, wchar_t *Ibuf, size_t outlen, int code_page): own(false), buf(Ibuf)
+{
+ MultiByteToWideChar(code_page, 0, in, int(inlen), buf, int(outlen));
+}
+
+
+template<> template<> inline text<char>::text(const wchar_t *in, int code_page): own(in ? true : false)
+{
+ if (in) {
+ size_t l = strlen(in);
+ int length = WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, 0, NULL, NULL);
+ buf = new char[length + 1];
+ WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, int(length + 1), NULL, NULL);
+ } else {
+ buf = NULL;
+ }
+}
+template<> template<> inline text<char>::text(const wchar_t *in, char *Ibuf, int code_page): own(false), buf(Ibuf)
+{
+ size_t l = strlen(in);
+ int length = WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, 0, NULL, NULL);
+ WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, length, NULL, NULL);
+}
+template<> template<> inline text<char>::text(const wchar_t *in, int inlen, char *Ibuf, size_t outlen, int code_page): own(false), buf(Ibuf)
+{
+ WideCharToMultiByte(code_page, 0, in, int(inlen), buf, int(outlen), NULL, NULL);
+}
+
+#endif
+
+#pragma warning(default:4995 4996)
+
+#endif
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp b/src/filters/transform/MPCVideoDec/ffImgfmt.cpp index c948006a1..631c05bcb 100644 --- a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp +++ b/src/filters/transform/MPCVideoDec/ffImgfmt.cpp @@ -21,8 +21,8 @@ #include <ffmpeg/libavcodec/avcodec.h>
#include <uuids.h>
#include <moreuuids.h>
-#include <ffmpeg/char_t.h>
-#include <ffmpeg/ffImgfmt.h>
+#include "char_t.h"
+#include "ffImgfmt.h"
const TcspInfo cspInfos[]= {
{
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.h b/src/filters/transform/MPCVideoDec/ffImgfmt.h new file mode 100644 index 000000000..23173b754 --- /dev/null +++ b/src/filters/transform/MPCVideoDec/ffImgfmt.h @@ -0,0 +1,489 @@ +#ifndef _FFIMGFMT_H_
+#define _FFIMGFMT_H_
+
+#include <ffmpeg/libavutil/pixfmt.h>
+
+//================================ ffdshow ==================================
+// the RGB related values in this enum refers to the "memory byte order" (byte order as stored in memory).
+// under x86 architecture (little endians), the byte order is stored reversed (comparing to the write order),
+// this means RGB will be stored in the memory as BGR.
+// When working with DirectShow in the Red-Green-Blue colorspace, DirectShow always
+// expects RGB at the "memory byte order", so RGB should be selected.
+// When working with files, we are interested in the "write order", which is the opposite
+// of the "memory byte order" (under x86), so you should select the opposite from the
+// destination byte order for the file.
+// (e.g. PNG images uses RGB order, so select BGR order
+// BMP image uses BGR order, so select RGB order)
+
+/* ffdshow colorspace ids, values should be unique including flag values, and must fit inside a uint64_t
+ * (an enum should be used instead of defines, but GCC does not support an enum with type uint64_t ?)
+ */
+
+// Do not reorder or renumber! Values are stored in user's registry.
+#define FF_CSP_NULL (0ULL)
+
+#define FF_CSP_420P (1ULL << 0) // 0x0000001
+#define FF_CSP_422P (1ULL << 1) // 0x0000002
+#define FF_CSP_444P (1ULL << 2) // 0x0000004
+#define FF_CSP_411P (1ULL << 3) // 0x0000008
+#define FF_CSP_410P (1ULL << 4) // 0x0000010
+
+#define FF_CSP_YUY2 (1ULL << 5) // 0x0000020
+#define FF_CSP_UYVY (1ULL << 6) // 0x0000040
+#define FF_CSP_YVYU (1ULL << 7) // 0x0000080
+#define FF_CSP_VYUY (1ULL << 8) // 0x0000100
+
+#define FF_CSP_ABGR (1ULL << 9) // 0x0000200 [a|b|g|r]
+#define FF_CSP_RGBA (1ULL << 10) // 0x0000400 [r|g|b|a]
+#define FF_CSP_BGR32 (1ULL << 11) // 0x0000800
+#define FF_CSP_BGR24 (1ULL << 12) // 0x0001000
+#define FF_CSP_BGR15 (1ULL << 13) // 0x0002000
+#define FF_CSP_BGR16 (1ULL << 14) // 0x0004000
+#define FF_CSP_RGB32 (1ULL << 15) // 0x0008000
+#define FF_CSP_RGB24 (1ULL << 16) // 0x0010000
+#define FF_CSP_RGB15 (1ULL << 17) // 0x0020000
+#define FF_CSP_RGB16 (1ULL << 18) // 0x0040000
+
+#define FF_CSP_CLJR (1ULL << 19) // 0x0080000
+#define FF_CSP_Y800 (1ULL << 20) // 0x0100000
+#define FF_CSP_NV12 (1ULL << 21) // 0x0200000
+
+#define FF_CSP_420P10 (1ULL << 22) // 0x0400000
+#define FF_CSP_444P10 (1ULL << 23) // 0x0800000
+#define FF_CSP_P016 (1ULL << 24) // 0x1000000 P016 in Media Fundation (MFVideoFormat_P016). 16bit version of NV12.
+#define FF_CSP_P010 (1ULL << 25) // 0x2000000 P010 in Media Fundation (MFVideoFormat_P010). same as FF_CSP_P016
+#define FF_CSP_422P10 (1ULL << 26) // 0x4000000
+#define FF_CSP_P210 (1ULL << 27) // 0x8000000
+#define FF_CSP_P216 (1ULL << 28) // 0x10000000
+
+#define FF_CSP_AYUV (1ULL << 29) // 0x20000000
+#define FF_CSP_Y416 (1ULL << 30) // 0x40000000
+
+#define FF_CSP_PAL8 (1ULL << 31) // 0x80000000
+
+#define FF_CSP_GBRP (1ULL << 32) // 0x100000000
+#define FF_CSP_GBRP9 (1ULL << 33) // 0x200000000
+#define FF_CSP_GBRP10 (1ULL << 34) // 0x400000000
+
+#define FF_CSP_420P9 (1ULL << 35) // 0x800000000
+#define FF_CSP_422P9 (1ULL << 36) // 0x1000000000
+#define FF_CSP_444P9 (1ULL << 37) // 0x2000000000
+
+// Flags
+#define FF_CSP_FLAGS_YUV_JPEG (1ULL << 59)
+#define FF_CSP_FLAGS_YUV_ORDER (1ULL << 60) // UV ordered chroma planes (not VU as default)
+#define FF_CSP_FLAGS_YUV_ADJ (1ULL << 61) // YUV planes are stored consecutively in one memory block
+#define FF_CSP_FLAGS_INTERLACED (1ULL << 62)
+#define FF_CSP_FLAGS_VFLIP (1ULL << 63) // flip mask
+
+#define FF_CSPS_NUM 38
+
+#define FF_CSP_UNSUPPORTED (1ULL<<FF_CSPS_NUM)
+
+#define FF_CSPS_MASK (FF_CSP_UNSUPPORTED-1)
+#define FF_CSPS_MASK_HIGH_BIT (FF_CSP_420P10|FF_CSP_422P10|FF_CSP_444P10)
+#define FF_CSPS_MASK_YUV_PLANAR (FF_CSP_420P|FF_CSP_422P|FF_CSP_444P|FF_CSP_411P|FF_CSP_410P)
+#define FF_CSPS_MASK_RGB_PLANAR (FF_CSP_GBRP|FF_CSP_GBRP9|FF_CSP_GBRP10)
+#define FF_CSPS_MASK_YUV_PACKED (FF_CSP_YUY2|FF_CSP_UYVY|FF_CSP_YVYU|FF_CSP_VYUY)
+#define FF_CSPS_MASK_RGB (FF_CSP_RGBA|FF_CSP_RGB32|FF_CSP_RGB24|FF_CSP_RGB15|FF_CSP_RGB16)
+#define FF_CSPS_MASK_BGR (FF_CSP_ABGR|FF_CSP_BGR32|FF_CSP_BGR24|FF_CSP_BGR15|FF_CSP_BGR16)
+#define FF_CSPS_MASK_FFRGB (FF_CSP_RGB32|FF_CSP_RGB24|FF_CSP_BGR32|FF_CSP_BGR24) // ffdshow converters output color spaces. Require dst stride to be multiple of 4.
+
+#include <stddef.h>
+typedef int stride_t;
+
+//==================================== xvid4 =====================================
+
+#define XVID4_CSP_PLANAR (1<< 0) /* 4:2:0 planar */
+#define XVID4_CSP_I420 (1<< 1) /* 4:2:0 packed(planar win32) */
+#define XVID4_CSP_YV12 (1<< 2) /* 4:2:0 packed(planar win32) */
+#define XVID4_CSP_YUY2 (1<< 3) /* 4:2:2 packed */
+#define XVID4_CSP_UYVY (1<< 4) /* 4:2:2 packed */
+#define XVID4_CSP_YVYU (1<< 5) /* 4:2:2 packed */
+#define XVID4_CSP_BGRA (1<< 6) /* 32-bit bgra packed */
+#define XVID4_CSP_ABGR (1<< 7) /* 32-bit abgr packed */
+#define XVID4_CSP_RGBA (1<< 8) /* 32-bit rgba packed */
+#define XVID4_CSP_BGR (1<< 9) /* 24-bit bgr packed */
+#define XVID4_CSP_RGB555 (1<<10) /* 16-bit rgb555 packed */
+#define XVID4_CSP_RGB565 (1<<11) /* 16-bit rgb565 packed */
+#define XVID4_CSP_SLICE (1<<12) /* decoder only: 4:2:0 planar, per slice rendering */
+#define XVID4_CSP_INTERNAL (1<<13) /* decoder only: 4:2:0 planar, returns ptrs to internal buffers */
+#define XVID4_CSP_NULL (1<<14) /* decoder only: dont output anything */
+#define XVID4_CSP_VFLIP (1<<31) /* vertical flip mask */
+
+static __inline uint64_t csp_xvid4_2ffdshow(int csp)
+{
+ switch (csp) {
+ case XVID4_CSP_BGR :
+ return FF_CSP_RGB24;
+ case XVID4_CSP_YV12 :
+ return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ;
+ case XVID4_CSP_YUY2 :
+ return FF_CSP_YUY2;
+ case XVID4_CSP_UYVY :
+ return FF_CSP_UYVY;
+ case XVID4_CSP_I420 :
+ return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ|FF_CSP_FLAGS_YUV_ORDER;
+ case XVID4_CSP_RGB555:
+ return FF_CSP_RGB15;
+ case XVID4_CSP_RGB565:
+ return FF_CSP_RGB16;
+ case XVID4_CSP_PLANAR:
+ return FF_CSP_420P;
+ case XVID4_CSP_YVYU :
+ return FF_CSP_YVYU;
+ case XVID4_CSP_BGRA :
+ return FF_CSP_RGB32;
+ case XVID4_CSP_ABGR :
+ return FF_CSP_ABGR;
+ case XVID4_CSP_RGBA :
+ return FF_CSP_RGBA;
+ default :
+ return FF_CSP_NULL;
+ }
+}
+
+//================================= ffmpeg ===================================
+static __inline uint64_t csp_lavc2ffdshow(enum PixelFormat pix_fmt)
+{
+ switch (pix_fmt) {
+ case PIX_FMT_YUV420P :
+ case PIX_FMT_YUVJ420P:
+ return FF_CSP_420P;
+ case PIX_FMT_YUV422P :
+ case PIX_FMT_YUVJ422P:
+ return FF_CSP_422P;
+ case PIX_FMT_YUV444P :
+ case PIX_FMT_YUVJ444P:
+ return FF_CSP_444P;
+ case PIX_FMT_YUV411P :
+ return FF_CSP_411P;
+ case PIX_FMT_YUV410P :
+ return FF_CSP_410P;
+ case PIX_FMT_YUYV422 :
+ return FF_CSP_YUY2;
+ case PIX_FMT_UYVY422 :
+ return FF_CSP_UYVY;
+ case PIX_FMT_YUV420P10:
+ return FF_CSP_420P10;
+ case PIX_FMT_YUV422P10:
+ return FF_CSP_422P10;
+ case PIX_FMT_YUV444P10:
+ return FF_CSP_444P10;
+ case PIX_FMT_BGR24 :
+ return FF_CSP_RGB24;
+ case PIX_FMT_RGB24 :
+ return FF_CSP_BGR24;
+ case PIX_FMT_RGB32 :
+ case PIX_FMT_ARGB:
+ return FF_CSP_RGB32;
+ case PIX_FMT_RGB555 :
+ return FF_CSP_RGB15;
+ case PIX_FMT_RGB565 :
+ return FF_CSP_RGB16;
+ case PIX_FMT_GRAY8 :
+ return FF_CSP_Y800;
+ case PIX_FMT_PAL8 :
+ return FF_CSP_PAL8;
+ case PIX_FMT_NV12 :
+ return FF_CSP_NV12;
+ case PIX_FMT_GBRP :
+ return FF_CSP_GBRP;
+ case PIX_FMT_GBRP9 :
+ return FF_CSP_GBRP9;
+ case PIX_FMT_GBRP10 :
+ return FF_CSP_GBRP10;
+ case PIX_FMT_YUV420P9:
+ return FF_CSP_420P9;
+ case PIX_FMT_YUV422P9:
+ return FF_CSP_422P9;
+ case PIX_FMT_YUV444P9:
+ return FF_CSP_444P9;
+ default :
+ return FF_CSP_NULL;
+ }
+}
+static __inline enum PixelFormat csp_ffdshow2lavc(uint64_t pix_fmt)
+{
+ switch (pix_fmt&FF_CSPS_MASK) {
+ case FF_CSP_420P:
+ return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ420P:PIX_FMT_YUV420P;
+ case FF_CSP_422P:
+ return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ422P:PIX_FMT_YUV422P;
+ case FF_CSP_444P:
+ return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ444P:PIX_FMT_YUV444P;
+ case FF_CSP_411P:
+ return PIX_FMT_YUV411P;
+ case FF_CSP_410P:
+ return PIX_FMT_YUV410P;
+ case FF_CSP_YUY2:
+ return PIX_FMT_YUYV422;
+ case FF_CSP_UYVY:
+ return PIX_FMT_UYVY422;
+ case FF_CSP_420P10:
+ return PIX_FMT_YUV420P10;
+ case FF_CSP_422P10:
+ return PIX_FMT_YUV422P10;
+ case FF_CSP_444P10:
+ return PIX_FMT_YUV444P10;
+ case FF_CSP_RGB24:
+ return PIX_FMT_BGR24;
+ case FF_CSP_BGR24:
+ return PIX_FMT_RGB24;
+ case FF_CSP_RGB32:
+ return PIX_FMT_RGB32;
+ case FF_CSP_BGR32:
+ return PIX_FMT_BGR32;
+ case FF_CSP_RGB15:
+ return PIX_FMT_RGB555;
+ case FF_CSP_RGB16:
+ return PIX_FMT_RGB565;
+ case FF_CSP_Y800:
+ return PIX_FMT_GRAY8;
+ case FF_CSP_PAL8:
+ return PIX_FMT_PAL8;
+ case FF_CSP_NV12:
+ return PIX_FMT_NV12;
+ case FF_CSP_ABGR:
+ return PIX_FMT_ABGR;
+ case FF_CSP_RGBA:
+ return PIX_FMT_RGBA;
+ case FF_CSP_GBRP:
+ return PIX_FMT_GBRP;
+ case FF_CSP_GBRP9:
+ return PIX_FMT_GBRP9;
+ case FF_CSP_GBRP10:
+ return PIX_FMT_GBRP10;
+ case FF_CSP_420P9:
+ return PIX_FMT_YUV420P9;
+ case FF_CSP_422P9:
+ return PIX_FMT_YUV422P9;
+ case FF_CSP_444P9:
+ return PIX_FMT_YUV444P9;
+ default :
+ return PIX_FMT_NB;
+ }
+}
+
+#define SWS_IN_CSPS \
+ ( \
+ FF_CSP_420P| \
+ FF_CSP_444P| \
+ FF_CSP_422P| \
+ FF_CSP_411P| \
+ FF_CSP_410P| \
+ FF_CSP_YUY2| \
+ FF_CSP_UYVY| \
+ FF_CSP_YVYU| \
+ FF_CSP_VYUY| \
+ FF_CSP_BGR32| \
+ FF_CSP_BGR24| \
+ FF_CSP_BGR16| \
+ FF_CSP_BGR15| \
+ FF_CSP_RGB32| \
+ FF_CSP_RGB24| \
+ FF_CSP_RGB16| \
+ FF_CSP_RGB15| \
+ FF_CSP_NV12| \
+ FF_CSP_420P10| \
+ FF_CSP_422P10| \
+ FF_CSP_444P10| \
+ FF_CSP_420P9| \
+ FF_CSP_422P9| \
+ FF_CSP_444P9| \
+ FF_CSP_Y800 \
+ )
+#define SWS_OUT_CSPS \
+ ( \
+ FF_CSP_420P| \
+ FF_CSP_444P| \
+ FF_CSP_422P| \
+ FF_CSP_411P| \
+ FF_CSP_410P| \
+ FF_CSP_YUY2| \
+ FF_CSP_UYVY| \
+ FF_CSP_YVYU| \
+ FF_CSP_VYUY| \
+ FF_CSP_RGB32| \
+ FF_CSP_RGB24| \
+ FF_CSP_RGB16| \
+ FF_CSP_RGB15| \
+ FF_CSP_BGR32| \
+ FF_CSP_BGR24| \
+ FF_CSP_BGR16| \
+ FF_CSP_BGR15| \
+ FF_CSP_NV12| \
+ FF_CSP_420P10| \
+ FF_CSP_422P10| \
+ FF_CSP_444P10| \
+ FF_CSP_420P9| \
+ FF_CSP_422P9| \
+ FF_CSP_444P9| \
+ FF_CSP_Y800 \
+ )
+
+static __inline uint64_t csp_supSWSin(uint64_t x)
+{
+ return (x&FF_CSPS_MASK)&(SWS_IN_CSPS|FF_CSPS_MASK_HIGH_BIT);
+}
+static __inline uint64_t csp_supSWSout(uint64_t x)
+{
+ return (x&FF_CSPS_MASK)&(SWS_OUT_CSPS|FF_CSPS_MASK_HIGH_BIT);
+}
+
+#endif
+
+#if defined(__cplusplus) && !defined(FF_CSP_ONLY)
+
+#ifndef _FFIMGFMTCPP_H_
+#define _FFIMGFMTCPP_H_
+
+#include "array_allocator.h"
+#include "char_t.h"
+
+struct TcspInfo {
+ uint64_t id;
+ const char_t *name;
+ int Bpp; // Bytes per pixel for each plane.
+ int bpp; // bits per pixel for all plane. (Memory usage, not the effective bit depth)
+ unsigned int numPlanes;
+ unsigned int shiftX[4], shiftY[4];
+ unsigned int black[4];
+ FOURCC fcc, fcccsp;
+ const GUID *subtype;
+ int packedLumaOffset, packedChromaOffset;
+};
+extern const TcspInfo cspInfos[];
+struct TcspInfos :std::vector<const TcspInfo*,array_allocator<const TcspInfo*,FF_CSPS_NUM*2> > {
+private:
+ struct TsortFc {
+ private:
+ uint64_t csp,outPrimaryCSP;
+ public:
+ TsortFc(uint64_t Icsp,uint64_t IoutPrimaryCSP):csp(Icsp),outPrimaryCSP(IoutPrimaryCSP) {}
+ bool operator ()(const TcspInfo* &csp1,const TcspInfo* &csp2);
+ };
+public:
+ void sort(uint64_t csp, uint64_t outPrimaryCSP);
+};
+
+static __inline const TcspInfo* csp_getInfo(uint64_t csp)
+{
+ switch (csp&(FF_CSPS_MASK|FF_CSP_FLAGS_YUV_ORDER)) {
+ case FF_CSP_420P|FF_CSP_FLAGS_YUV_ORDER: {
+ extern TcspInfo cspInfoIYUV;
+ return &cspInfoIYUV;
+ }
+ default:
+ csp&=FF_CSPS_MASK;
+ if (csp==0) {
+ return NULL;
+ }
+ int i=0;
+ while (csp>>=1) {
+ i++;
+ }
+ if (i<=FF_CSPS_NUM) {
+ return &cspInfos[i];
+ } else {
+ return NULL;
+ }
+ }
+}
+const TcspInfo* csp_getInfoFcc(FOURCC fcc);
+
+static __inline uint64_t csp_isYUVplanar(uint64_t x)
+{
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_YUV_PLANAR;
+}
+static __inline uint64_t csp_isRGBplanar(uint64_t x)
+{
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_RGB_PLANAR;
+}
+static __inline uint64_t csp_isYUVplanarHighBit(uint64_t x)
+{
+ return x & FF_CSPS_MASK & FF_CSPS_MASK_HIGH_BIT;
+}
+static __inline uint64_t csp_isYUVpacked(uint64_t x)
+{
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_YUV_PACKED;
+}
+static __inline uint64_t csp_isYUV(uint64_t x)
+{
+ return csp_isYUVpacked(x)|csp_isYUVplanar(x);
+}
+static __inline uint64_t csp_isYUV_NV(uint64_t x)
+{
+ return csp_isYUVpacked(x)|csp_isYUVplanar(x)|(x & (FF_CSP_NV12|FF_CSP_P016|FF_CSP_P010|FF_CSP_P210|FF_CSP_P216));
+}
+static __inline uint64_t csp_isRGB_RGB(uint64_t x)
+{
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_RGB;
+}
+static __inline uint64_t csp_isRGB_BGR(uint64_t x)
+{
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_BGR;
+}
+static __inline uint64_t csp_isRGB(uint64_t x)
+{
+ return csp_isRGB_RGB(x)|csp_isRGB_BGR(x);
+}
+static __inline uint64_t csp_supXvid(uint64_t x)
+{
+ return (x&FF_CSPS_MASK)&(FF_CSP_RGB24|FF_CSP_420P|FF_CSP_YUY2|FF_CSP_UYVY|FF_CSP_YVYU|FF_CSP_VYUY|FF_CSP_RGB15|FF_CSP_RGB16|FF_CSP_RGB32|FF_CSP_ABGR|FF_CSP_RGBA|FF_CSP_BGR24);
+}
+
+bool csp_inFOURCCmask(uint64_t x,FOURCC fcc);
+
+extern char_t* csp_getName2(const TcspInfo *cspInfo,uint64_t csp,char_t *buf,size_t len);
+extern char_t* csp_getName(uint64_t csp,char_t *buf,size_t len);
+extern uint64_t csp_bestMatch(uint64_t inCSP,uint64_t wantedCSPS,int *rank=NULL, uint64_t outPrimaryCSP=0);
+
+static __inline void csp_yuv_adj_to_plane(uint64_t &csp,const TcspInfo *cspInfo,unsigned int dy,unsigned char *data[4],stride_t stride[4])
+{
+ if (csp_isYUVplanar(csp) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
+ csp&=~FF_CSP_FLAGS_YUV_ADJ;
+ data[2]=data[0]+stride[0]*(dy>>cspInfo->shiftY[0]);
+ stride[1]=stride[0]>>cspInfo->shiftX[1];
+ data[1]=data[2]+stride[1]*(dy>>cspInfo->shiftY[1]);
+ stride[2]=stride[0]>>cspInfo->shiftX[2];
+ } else if ((csp & (FF_CSP_NV12|FF_CSP_P016|FF_CSP_P010|FF_CSP_P210|FF_CSP_P216)) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
+ csp&=~FF_CSP_FLAGS_YUV_ADJ;
+ data[1] = data[0] + stride[0] *dy;
+ stride[1] = stride[0];
+ }
+
+}
+static __inline void csp_yuv_order(uint64_t &csp,unsigned char *data[4],stride_t stride[4])
+{
+ if (csp_isYUVplanar(csp) && (csp&FF_CSP_FLAGS_YUV_ORDER)) {
+ csp&=~FF_CSP_FLAGS_YUV_ORDER;
+ std::swap(data[1],data[2]);
+ std::swap(stride[1],stride[2]);
+ }
+}
+static __inline void csp_vflip(uint64_t &csp,const TcspInfo *cspInfo,unsigned char *data[],stride_t stride[],unsigned int dy)
+{
+ if (csp&FF_CSP_FLAGS_VFLIP) {
+ csp&=~FF_CSP_FLAGS_VFLIP;
+ for (unsigned int i=0; i<cspInfo->numPlanes; i++) {
+ data[i]+=stride[i]*((dy>>cspInfo->shiftY[i])-1);
+ stride[i]*=-1;
+ }
+ }
+}
+
+uint64_t getBMPcolorspace(const BITMAPINFOHEADER *hdr,const TcspInfos &forcedCsps);
+
+struct TcspFcc {
+ const char_t *name;
+ FOURCC fcc;
+ uint64_t csp;
+ bool flip;
+ bool supEnc;
+};
+extern const TcspFcc cspFccs[];
+
+#endif
+
+#endif
|