10#include "LibMWCapture/WinTypes.h"
13#define MWFOURCC(ch0, ch1, ch2, ch3) \
14 ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
15 ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
23#define MWFOURCC_UNK MWFOURCC('U', 'N', 'K', 'N')
34#define MWFOURCC_GREY MWFOURCC('G', 'R', 'E', 'Y')
45#define MWFOURCC_Y800 MWFOURCC('Y', '8', '0', '0')
56#define MWFOURCC_Y8 MWFOURCC('Y', '8', ' ', ' ')
67#define MWFOURCC_Y16 MWFOURCC('Y', '1', '6', ' ')
78#define MWFOURCC_RGB15 MWFOURCC('R', 'G', 'B', '5')
89#define MWFOURCC_RGB16 MWFOURCC('R', 'G', 'B', '6')
100#define MWFOURCC_RGB24 MWFOURCC('R', 'G', 'B', ' ')
111#define MWFOURCC_RGBA MWFOURCC('R', 'G', 'B', 'A')
122#define MWFOURCC_ARGB MWFOURCC('A', 'R', 'G', 'B')
133#define MWFOURCC_BGR15 MWFOURCC('B', 'G', 'R', '5')
144#define MWFOURCC_BGR16 MWFOURCC('B', 'G', 'R', '6')
155#define MWFOURCC_BGR24 MWFOURCC('B', 'G', 'R', ' ')
166#define MWFOURCC_BGRA MWFOURCC('B', 'G', 'R', 'A')
177#define MWFOURCC_ABGR MWFOURCC('A', 'B', 'G', 'R')
199#define MWFOURCC_NV16 MWFOURCC('N', 'V', '1', '6')
221#define MWFOURCC_NV61 MWFOURCC('N', 'V', '6', '1')
248#define MWFOURCC_I422 MWFOURCC('I', '4', '2', '2')
275#define MWFOURCC_YV16 MWFOURCC('Y', 'V', '1', '6')
290#define MWFOURCC_YUY2 MWFOURCC('Y', 'U', 'Y', '2')
304#define MWFOURCC_YUYV MWFOURCC('Y', 'U', 'Y', 'V')
318#define MWFOURCC_UYVY MWFOURCC('U', 'Y', 'V', 'Y')
332#define MWFOURCC_YVYU MWFOURCC('Y', 'V', 'Y', 'U')
346#define MWFOURCC_VYUY MWFOURCC('V', 'Y', 'U', 'Y')
372#define MWFOURCC_I420 MWFOURCC('I', '4', '2', '0')
398#define MWFOURCC_IYUV MWFOURCC('I', 'Y', 'U', 'V')
422#define MWFOURCC_NV12 MWFOURCC('N', 'V', '1', '2')
448#define MWFOURCC_YV12 MWFOURCC('Y', 'V', '1', '2')
472#define MWFOURCC_NV21 MWFOURCC('N', 'V', '2', '1')
496#define MWFOURCC_P010 MWFOURCC('P', '0', '1', '0')
522#define MWFOURCC_P210 MWFOURCC('P', '2', '1', '0')
537#define MWFOURCC_Y210 MWFOURCC('Y', '2', '1', '0')
551#define MWFOURCC_IYU2 MWFOURCC('I', 'Y', 'U', '2')
565#define MWFOURCC_V308 MWFOURCC('v', '3', '0', '8')
580#define MWFOURCC_AYUV MWFOURCC('A', 'Y', 'U', 'V')
594#define MWFOURCC_UYVA MWFOURCC('U', 'Y', 'V', 'A')
608#define MWFOURCC_V408 MWFOURCC('v', '4', '0', '8')
622#define MWFOURCC_VYUA MWFOURCC('V', 'Y', 'U', 'A')
637#define MWFOURCC_V210 MWFOURCC('v', '2', '1', '0')
651#define MWFOURCC_Y410 MWFOURCC('Y', '4', '1', '0')
665#define MWFOURCC_V410 MWFOURCC('v', '4', '1', '0')
676#define MWFOURCC_RGB10 MWFOURCC('R', 'G', '1', '0')
687#define MWFOURCC_BGR10 MWFOURCC('B', 'G', '1', '0')
831 cx = (cx + 47) / 48 * 48;
835 cbLine = (cx * nBpp) / 8;
849 return (cbLine + dwAlign - 1) & ~(dwAlign - 1);
874 cx = (cx + 47) / 48 * 48;
878 cbLine = (cx * nBpp) / 8;
881 if (cbStride < cbLine)
884 return cbStride * cy;
887 if (cbStride < (DWORD)cx)
896 if ((cbStride & 1) || (cy & 1))
898 return cbStride * cy * 3 / 2;
905 return cbStride * cy * 2;
907 if ((cbStride & 3) || (cy & 1))
909 return cbStride * cy * 3 / 2;
913 return cbStride * cy * 2;
933 DWORD biClrImportant;
939#define KS_BI_BITFIELDS 3L
940#define MWCAP_BITMAPINFOHEADER KS_BITMAPINFOHEADER
941#define MWCAP_BI_RGB KS_BI_RGB
942#define MWCAP_BI_BITFIELDS KS_BI_BITFIELDS
953inline BOOLEAN
FOURCC_IsMask(
const DWORD * pdwMasks, DWORD dwRedMask, DWORD dwGreenMask, DWORD dwBlueMask)
955 return ((pdwMasks[0] == dwRedMask) && (pdwMasks[1] == dwGreenMask) && (pdwMasks[2] == dwBlueMask));
972 switch (biCompression) {
974 switch (biBitCount) {
986 case MWCAP_BI_BITFIELDS:
988 switch (biBitCount) {
990 if (
FOURCC_IsMask(pdwMasks, 0x0000F800, 0x000007E0, 0x0000001F))
992 else if (
FOURCC_IsMask(pdwMasks, 0x0000001F, 0x000007E0, 0x0000F800))
994 else if (
FOURCC_IsMask(pdwMasks, 0x00007C00, 0x000003E0, 0x0000001F))
996 else if (
FOURCC_IsMask(pdwMasks, 0x0000001F, 0x000003E0, 0x00007C00))
1002 if (
FOURCC_IsMask(pdwMasks, 0x00FF0000, 0x0000FF00, 0x000000FF))
1004 else if (
FOURCC_IsMask(pdwMasks, 0x000000FF, 0x0000FF00, 0x00FF0000))
1010 if (
FOURCC_IsMask(pdwMasks, 0x00FF0000, 0x0000FF00, 0x000000FF))
1012 else if (
FOURCC_IsMask(pdwMasks, 0x000000FF, 0x0000FF00, 0x00FF0000))
1014 else if (
FOURCC_IsMask(pdwMasks, 0xFF000000, 0x00FF0000, 0x0000FF00))
1016 else if (
FOURCC_IsMask(pdwMasks, 0x0000FF00, 0x00FF0000, 0xFF000000))
1028 return biCompression;
1039 const MWCAP_BITMAPINFOHEADER * pbmih
1042 DWORD *pdwMasks = (DWORD *)(pbmih + 1);
DWORD FOURCC_GetFromBitmapHeader2(const MWCAP_BITMAPINFOHEADER *pbmih)
Gets color format from the bitmap header.
Definition: MWFOURCC.h:1038
#define MWFOURCC_Y16
16bits Grey
Definition: MWFOURCC.h:67
#define MWFOURCC_Y410
Y410.
Definition: MWFOURCC.h:651
BOOLEAN FOURCC_IsPacked(DWORD dwFOURCC)
Determines whether the color format is packed.
Definition: MWFOURCC.h:724
#define MWFOURCC_RGB15
16bits R5G5B5A1
Definition: MWFOURCC.h:78
#define MWFOURCC_ARGB
32bits A8R8G8B8
Definition: MWFOURCC.h:122
#define MWFOURCC_NV21
NV21.
Definition: MWFOURCC.h:472
#define MWFOURCC_V210
Definition: MWFOURCC.h:637
#define MWFOURCC_VYUA
VYUA.
Definition: MWFOURCC.h:622
#define MWFOURCC_ABGR
32bits A8B8G8R8
Definition: MWFOURCC.h:177
BOOLEAN FOURCC_IsMask(const DWORD *pdwMasks, DWORD dwRedMask, DWORD dwGreenMask, DWORD dwBlueMask)
Determins whether the mask is the same as specified color format.
Definition: MWFOURCC.h:953
#define MWFOURCC_I420
I420.
Definition: MWFOURCC.h:372
BOOLEAN FOURCC_IsRGB(DWORD dwFOURCC)
Determines whether the color format is RGB.
Definition: MWFOURCC.h:695
#define MWFOURCC_BGR15
16bits B5G5R5A1
Definition: MWFOURCC.h:133
#define MWFOURCC_BGR24
24bits B8G8R8
Definition: MWFOURCC.h:155
#define MWFOURCC_V408
V408.
Definition: MWFOURCC.h:608
DWORD FOURCC_CalcImageSize(DWORD dwFOURCC, int cx, int cy, DWORD cbStride)
Counts the number of bytes that a frame takes, depending on the color format, resolution and the line...
Definition: MWFOURCC.h:861
#define MWFOURCC_YVYU
YVYU.
Definition: MWFOURCC.h:332
#define MWFOURCC_RGB24
24bits R8G8B8
Definition: MWFOURCC.h:100
#define MWFOURCC_YUY2
YUY2.
Definition: MWFOURCC.h:290
#define MWFOURCC_V308
V308.
Definition: MWFOURCC.h:565
#define MWFOURCC_RGBA
32bits R8G8B8A8
Definition: MWFOURCC.h:111
#define MWFOURCC_NV61
NV61.
Definition: MWFOURCC.h:221
#define MWFOURCC_IYUV
IYUV.
Definition: MWFOURCC.h:398
#define MWFOURCC_Y8
8bits Grey
Definition: MWFOURCC.h:56
#define MWFOURCC_GREY
8bits Grey
Definition: MWFOURCC.h:34
#define MWFOURCC_AYUV
AYUV.
Definition: MWFOURCC.h:580
#define MWFOURCC_YUYV
YUYV.
Definition: MWFOURCC.h:304
#define MWFOURCC_YV16
YV16.
Definition: MWFOURCC.h:275
#define MWFOURCC_NV16
NV16.
Definition: MWFOURCC.h:199
#define MWFOURCC_BGR16
16bits B5G6R5
Definition: MWFOURCC.h:144
#define MWFOURCC_UNK
Unknown color formate.
Definition: MWFOURCC.h:23
#define MWFOURCC_YV12
YV12.
Definition: MWFOURCC.h:448
int FOURCC_GetBpp(DWORD dwFOURCC)
Gets the bits that pixel of color format takes.
Definition: MWFOURCC.h:752
#define MWFOURCC_UYVA
UYVA.
Definition: MWFOURCC.h:594
#define MWFOURCC_Y800
8bits Grey
Definition: MWFOURCC.h:45
#define MWFOURCC_NV12
NV12.
Definition: MWFOURCC.h:422
#define MWFOURCC_VYUY
VYUY.
Definition: MWFOURCC.h:346
#define MWFOURCC_IYU2
IYU2.
Definition: MWFOURCC.h:551
#define MWFOURCC_BGR10
BGR10.
Definition: MWFOURCC.h:687
#define MWFOURCC_RGB16
16bits R5G6B5
Definition: MWFOURCC.h:89
DWORD FOURCC_GetFromBitmapHeader(DWORD biCompression, WORD biBitCount, DWORD *pdwMasks)
Gets color format from the bitmap header.
Definition: MWFOURCC.h:966
#define MWFOURCC_V410
V410.
Definition: MWFOURCC.h:665
#define MWFOURCC_BGRA
32bits B8G8R8A8
Definition: MWFOURCC.h:166
#define MWFOURCC_RGB10
RGB10.
Definition: MWFOURCC.h:676
#define MWFOURCC_P210
P210.
Definition: MWFOURCC.h:522
#define MWFOURCC_UYVY
UYVY.
Definition: MWFOURCC.h:318
DWORD FOURCC_CalcMinStride(DWORD dwFOURCC, int cx, DWORD dwAlign)
Counts the number of bytes that a line data of image takes, depending on the width of image and the c...
Definition: MWFOURCC.h:819
#define MWFOURCC_I422
I422.
Definition: MWFOURCC.h:248
#define MWFOURCC_P010
P010.
Definition: MWFOURCC.h:496
Definition: MWFOURCC.h:922