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')
536 #define MWFOURCC_IYU2 MWFOURCC('I', 'Y', 'U', '2')
550 #define MWFOURCC_V308 MWFOURCC('v', '3', '0', '8')
565 #define MWFOURCC_AYUV MWFOURCC('A', 'Y', 'U', 'V')
579 #define MWFOURCC_UYVA MWFOURCC('U', 'Y', 'V', 'A')
593 #define MWFOURCC_V408 MWFOURCC('v', '4', '0', '8')
607 #define MWFOURCC_VYUA MWFOURCC('V', 'Y', 'U', 'A')
622 #define MWFOURCC_V210 MWFOURCC('v', '2', '1', '0')
636 #define MWFOURCC_Y410 MWFOURCC('Y', '4', '1', '0')
650 #define MWFOURCC_V410 MWFOURCC('v', '4', '1', '0')
661 #define MWFOURCC_RGB10 MWFOURCC('R', 'G', '1', '0')
672 #define MWFOURCC_BGR10 MWFOURCC('B', 'G', '1', '0')
816 cx = (cx + 47) / 48 * 48;
820 cbLine = (cx * nBpp) / 8;
834 return (cbLine + dwAlign - 1) & ~(dwAlign - 1);
859 cx = (cx + 47) / 48 * 48;
863 cbLine = (cx * nBpp) / 8;
866 if (cbStride < cbLine)
869 return cbStride * cy;
872 if (cbStride < (DWORD)cx)
881 if ((cbStride & 1) || (cy & 1))
883 return cbStride * cy * 3 / 2;
890 return cbStride * cy * 2;
892 if ((cbStride & 3) || (cy & 1))
894 return cbStride * cy * 3 / 2;
898 return cbStride * cy * 2;
906 #pragma pack(push, 1)
918 DWORD biClrImportant;
922 #define KS_BI_RLE8 1L
923 #define KS_BI_RLE4 2L
924 #define KS_BI_BITFIELDS 3L
925 #define MWCAP_BITMAPINFOHEADER KS_BITMAPINFOHEADER
926 #define MWCAP_BI_RGB KS_BI_RGB
927 #define MWCAP_BI_BITFIELDS KS_BI_BITFIELDS
938 inline BOOLEAN
FOURCC_IsMask(
const DWORD * pdwMasks, DWORD dwRedMask, DWORD dwGreenMask, DWORD dwBlueMask)
940 return ((pdwMasks[0] == dwRedMask) && (pdwMasks[1] == dwGreenMask) && (pdwMasks[2] == dwBlueMask));
957 switch (biCompression) {
959 switch (biBitCount) {
971 case MWCAP_BI_BITFIELDS:
973 switch (biBitCount) {
975 if (
FOURCC_IsMask(pdwMasks, 0x0000F800, 0x000007E0, 0x0000001F))
977 else if (
FOURCC_IsMask(pdwMasks, 0x0000001F, 0x000007E0, 0x0000F800))
979 else if (
FOURCC_IsMask(pdwMasks, 0x00007C00, 0x000003E0, 0x0000001F))
981 else if (
FOURCC_IsMask(pdwMasks, 0x0000001F, 0x000003E0, 0x00007C00))
987 if (
FOURCC_IsMask(pdwMasks, 0x00FF0000, 0x0000FF00, 0x000000FF))
989 else if (
FOURCC_IsMask(pdwMasks, 0x000000FF, 0x0000FF00, 0x00FF0000))
995 if (
FOURCC_IsMask(pdwMasks, 0x00FF0000, 0x0000FF00, 0x000000FF))
997 else if (
FOURCC_IsMask(pdwMasks, 0x000000FF, 0x0000FF00, 0x00FF0000))
999 else if (
FOURCC_IsMask(pdwMasks, 0xFF000000, 0x00FF0000, 0x0000FF00))
1001 else if (
FOURCC_IsMask(pdwMasks, 0x0000FF00, 0x00FF0000, 0xFF000000))
1013 return biCompression;
1024 const MWCAP_BITMAPINFOHEADER * pbmih
1027 DWORD *pdwMasks = (DWORD *)(pbmih + 1);
#define MWFOURCC_BGR15
16bits B5G5R5A1
Definition: MWFOURCC.h:133
#define MWFOURCC_BGR10
BGR10.
Definition: MWFOURCC.h:672
#define MWFOURCC_YV12
YV12.
Definition: MWFOURCC.h:448
#define MWFOURCC_BGRA
32bits B8G8R8A8
Definition: MWFOURCC.h:166
#define MWFOURCC_ARGB
32bits A8R8G8B8
Definition: MWFOURCC.h:122
BOOLEAN FOURCC_IsPacked(DWORD dwFOURCC)
Determines whether the color format is packed.
Definition: MWFOURCC.h:709
#define MWFOURCC_P010
P010.
Definition: MWFOURCC.h:496
#define MWFOURCC_RGB10
RGB10.
Definition: MWFOURCC.h:661
#define MWFOURCC_P210
P210.
Definition: MWFOURCC.h:522
BOOLEAN FOURCC_IsRGB(DWORD dwFOURCC)
Determines whether the color format is RGB.
Definition: MWFOURCC.h:680
#define MWFOURCC_Y410
Y410.
Definition: MWFOURCC.h:636
#define MWFOURCC_UYVY
UYVY.
Definition: MWFOURCC.h:318
Definition: MWFOURCC.h:907
#define MWFOURCC_I420
I420.
Definition: MWFOURCC.h:372
#define MWFOURCC_UYVA
UYVA.
Definition: MWFOURCC.h:579
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:804
#define MWFOURCC_IYUV
IYUV.
Definition: MWFOURCC.h:398
#define MWFOURCC_IYU2
IYU2.
Definition: MWFOURCC.h:536
#define MWFOURCC_Y8
8bits Grey
Definition: MWFOURCC.h:56
#define MWFOURCC_YUYV
YUYV.
Definition: MWFOURCC.h:304
DWORD FOURCC_GetFromBitmapHeader2(const MWCAP_BITMAPINFOHEADER *pbmih)
Gets color format from the bitmap header.
Definition: MWFOURCC.h:1023
#define MWFOURCC_RGB16
16bits R5G6B5
Definition: MWFOURCC.h:89
#define MWFOURCC_GREY
8bits Grey
Definition: MWFOURCC.h:34
#define MWFOURCC_AYUV
AYUV.
Definition: MWFOURCC.h:565
DWORD FOURCC_GetFromBitmapHeader(DWORD biCompression, WORD biBitCount, DWORD *pdwMasks)
Gets color format from the bitmap header.
Definition: MWFOURCC.h:951
#define MWFOURCC_RGB24
24bits R8G8B8
Definition: MWFOURCC.h:100
#define MWFOURCC_ABGR
32bits A8B8G8R8
Definition: MWFOURCC.h:177
#define MWFOURCC_NV12
NV12.
Definition: MWFOURCC.h:422
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:938
#define MWFOURCC_V308
V308.
Definition: MWFOURCC.h:550
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:846
#define MWFOURCC_BGR16
16bits B5G6R5
Definition: MWFOURCC.h:144
#define MWFOURCC_V410
V410.
Definition: MWFOURCC.h:650
#define MWFOURCC_RGB15
16bits R5G5B5A1
Definition: MWFOURCC.h:78
#define MWFOURCC_YUY2
YUY2.
Definition: MWFOURCC.h:290
#define MWFOURCC_VYUA
VYUA.
Definition: MWFOURCC.h:607
#define MWFOURCC_UNK
Unknown color formate.
Definition: MWFOURCC.h:23
#define MWFOURCC_V408
V408.
Definition: MWFOURCC.h:593
#define MWFOURCC_V210
Definition: MWFOURCC.h:622
int FOURCC_GetBpp(DWORD dwFOURCC)
Gets the bits that pixel of color format takes.
Definition: MWFOURCC.h:737
#define MWFOURCC_NV61
NV61.
Definition: MWFOURCC.h:221
#define MWFOURCC_I422
I422.
Definition: MWFOURCC.h:248
#define MWFOURCC_RGBA
32bits R8G8B8A8
Definition: MWFOURCC.h:111
#define MWFOURCC_YV16
YV16.
Definition: MWFOURCC.h:275
#define MWFOURCC_BGR24
24bits B8G8R8
Definition: MWFOURCC.h:155
#define MWFOURCC_VYUY
VYUY.
Definition: MWFOURCC.h:346
#define MWFOURCC_NV21
NV21.
Definition: MWFOURCC.h:472
#define MWFOURCC_Y800
8bits Grey
Definition: MWFOURCC.h:45
#define MWFOURCC_Y16
16bits Grey
Definition: MWFOURCC.h:67
#define MWFOURCC_YVYU
YVYU.
Definition: MWFOURCC.h:332
#define MWFOURCC_NV16
NV16.
Definition: MWFOURCC.h:199