29 m_ShowStageMessage(0),
38 m_bDoPostToDestroy(bDoPostToDestroy)
53 if (
m_hwnd)
return NOERROR;
84 MsgDestroy = RegisterWindowMessage(TEXT(
"AM_DESTROY"));
98 CBaseWindow::~CBaseWindow()
115 if (!IsWindow(
m_hwnd) || (GetWindowThreadProcessId(
m_hwnd,
NULL) != GetCurrentThreadId())) {
181 if (!DestroyWindow(hwnd)) {
183 hwnd, GetLastError()));
214 ShowWindow(
m_hwnd,SW_HIDE);
251 GetWindowRect(
m_hwnd,&WindowRect);
252 AdjustWindowRectEx(&ClientRect,GetWindowLong(
m_hwnd,GWL_STYLE),
253 FALSE,GetWindowLong(
m_hwnd,GWL_EXSTYLE));
257 UINT WindowFlags = (SWP_NOACTIVATE | SWP_FRAMECHANGED);
258 WindowRect.left -= (WindowRect.left & 3);
259 WindowRect.top -= (WindowRect.top & 3);
278 RECT ClientRect,WindowRect;
279 GetWindowRect(
m_hwnd,&WindowRect);
290 GetClientRect(
m_hwnd, &ClientRect);
291 MapWindowPoints(
m_hwnd, HWND_DESKTOP, (LPPOINT) &ClientRect, 2);
292 WindowRect.left -= (ClientRect.left & 3);
293 WindowRect.top -= (ClientRect.top & 3);
294 UINT WindowFlags = (SWP_NOACTIVATE | SWP_NOSIZE);
352 HPALETTE hPalette = (HPALETTE) GetStockObject(DEFAULT_PALETTE);
410 return (GdiFlush() == FALSE ? S_FALSE : S_OK);
428 CBaseWindow *pBaseWindow = _GetWindowLongPtr<CBaseWindow*>(hwnd,0);
430 if (pBaseWindow ==
NULL) {
441 if (uMsg == WM_NCCREATE) {
442 SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~0x400000);
445 if ((uMsg != WM_NCCREATE)
446 || (
NULL == (pBaseWindow = *(
CBaseWindow**) ((LPCREATESTRUCT)lParam)->lpCreateParams)))
448 return(DefWindowProc(hwnd, uMsg, wParam, lParam));
463 LONG lasterror = GetLastError();
499 ShowWindow(
m_hwnd,SW_HIDE);
588 if (bRegistered == FALSE) {
594 wndclass.lpfnWndProc =
WndProc;
595 wndclass.cbClsExtra = 0;
598 wndclass.hIcon =
NULL;
599 wndclass.hCursor = LoadCursor (
NULL, IDC_ARROW);
600 wndclass.hbrBackground = (HBRUSH)
NULL;
601 wndclass.lpszMenuName =
NULL;
603 RegisterClass(&wndclass);
613 TEXT(
"ActiveMovie Window"),
629 DWORD Error = GetLastError();
671 BOOL bVisible = IsWindowVisible(hwnd);
672 SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
673 SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW |
674 (bVisible ? SWP_NOACTIVATE : 0));
677 if (wParam == TRUE) {
678 SetForegroundWindow(hwnd);
690 HWND HwndTop = (wParam == TRUE ? HWND_TOPMOST : HWND_NOTOPMOST);
691 BOOL bVisible = IsWindowVisible(hwnd);
692 SetWindowPos(hwnd, HwndTop, 0, 0, 0, 0,
693 SWP_NOMOVE | SWP_NOSIZE |
694 (wParam == TRUE ? SWP_SHOWWINDOW : 0) |
695 (bVisible ? SWP_NOACTIVATE : 0));
709 case WM_SYSCOLORCHANGE:
711 InvalidateRect(hwnd,
NULL,FALSE);
715 case WM_PALETTECHANGED:
724 case WM_QUERYNEWPALETTE:
733 if (IsWindowVisible(
m_hwnd)) {
734 PostMessage(
m_hwnd,WM_PAINT,0,0);
742 OnSize(LOWORD(lParam), HIWORD(lParam));
752 return DefWindowProc(hwnd,uMsg,wParam,lParam);
774 if ((Message == WM_QUERYNEWPALETTE || hwnd !=
m_hwnd)) {
779 if (!IsWindowVisible(
m_hwnd)) {
794 if (Message == WM_PALETTECHANGED) {
807 return !!IsWindow(
m_hwnd);
873 HPALETTE CBaseWindow::GetPalette()
889 ShowWindow(
m_hwnd,ShowCmd);
920 m_pBaseWindow(pBaseWindow),
925 m_bUsingImageAllocator(FALSE)
949 if (bAccept == FALSE) {
967 (
void)StringCchPrintf(szTimes,
NUMELMS(szTimes),TEXT(
"%08d : %08d"),
975 GetTextExtentPoint32(
m_hdc,szTimes,lstrlen(szTimes),&Size);
976 INT XPos = ((ClientRect.right - ClientRect.left) - Size.cx) / 2;
977 INT YPos = ((ClientRect.bottom - ClientRect.top) - Size.cy) * 4 / 5;
981 if ((XPos > 0) && (YPos > 0)) {
982 TextOut(
m_hdc,XPos,YPos,szTimes,lstrlen(szTimes));
994 RGBQUAD *pColourTable = (RGBQUAD *)(pbmi+1);
998 UINT uiReturn = SetDIBColorTable(hdc,(UINT) 0,
1003 ASSERT(uiReturn == pbmi->biClrUsed);
1025 BITMAPINFOHEADER *pbmi;
1044 HRESULT
hr = pMediaSample->GetPointer(&pImage);
1056 ASSERT(pbmi->biBitCount <= iPALETTE);
1100 SourceRect.right - SourceRect.left,
1101 SourceRect.bottom - SourceRect.top,
1136 HRESULT
hr = pMediaSample->GetPointer(&pImage);
1150 LONG lAdjustedSourceTop = SourceRect.top;
1153 if (pbmi->biHeight > 0) {
1154 lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
1173 (BITMAPINFO *) pbmi,
1188 SourceRect.right - SourceRect.left,
1189 SourceRect.bottom - SourceRect.top,
1191 (BITMAPINFO *) pbmi,
1246 IMediaSample *pMediaSample,
1247 __in LPRECT lprcSrc,
1257 HRESULT
hr = pMediaSample->GetPointer(&pImage);
1266 SourceRect = *lprcSrc;
1271 TargetRect = *lprcDst;
1275 LONG lAdjustedSourceTop = SourceRect.top;
1278 if (pbmi->biHeight > 0) {
1279 lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
1285 BOOL bRet = (0 != StretchDIBits(hdc,
1288 TargetRect.right - TargetRect.left,
1289 TargetRect.bottom - TargetRect.top,
1292 SourceRect.right - SourceRect.left,
1293 SourceRect.bottom - SourceRect.top,
1372 if (SourceWidth == SinkWidth) {
1373 if (SourceHeight == SinkHeight) {
1451 __in_opt LPCTSTR
pName,
1452 __inout HRESULT *phr) :
1464 CImageAllocator::~CImageAllocator()
1483 while (
m_lFree.GetCount() != 0) {
1502 return VFW_E_NOT_CONNECTED;
1517 if ((DWORD) pRequest->cbBuffer < pVideoInfo->bmiHeader.biSizeImage) {
1518 return E_INVALIDARG;
1523 if (pRequest->cbPrefix > 0) {
1524 return E_INVALIDARG;
1527 pRequest->cbBuffer = pVideoInfo->bmiHeader.biSizeImage;
1537 __in ALLOCATOR_PROPERTIES * pRequest,
1538 __out ALLOCATOR_PROPERTIES * pActual)
1540 ALLOCATOR_PROPERTIES Adjusted = *pRequest;
1591 if (pSample ==
NULL) {
1594 return E_OUTOFMEMORY;
1613 HRESULT
hr = NOERROR;
1619 NAME(
"Video sample"),
1624 if (pSample ==
NULL || FAILED(
hr)) {
1645 hMapping = CreateFileMapping(
hMEMORY,
1651 if (hMapping ==
NULL) {
1652 DWORD Error = GetLastError();
1653 return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, Error);
1666 hBitmap = CreateDIBSection((HDC)
NULL,
1673 if (hBitmap ==
NULL || pBase ==
NULL) {
1675 DWORD Error = GetLastError();
1676 return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, Error);
1683 DibData.
pBase = pBase;
1685 GetObject(hBitmap,
sizeof(DIBSECTION),(VOID *)&DibData.
DibSection);
1732 __in_opt LPCTSTR
pName,
1733 __inout HRESULT *phr,
1734 __in_bcount(length) LPBYTE pBuffer,
1775 m_pBaseWindow(pBaseWindow),
1776 m_pFilter(pBaseFilter),
1777 m_pDrawImage(pDrawImage),
1787 CImagePalette::~CImagePalette()
1803 const VIDEOINFOHEADER *pOldInfo)
1807 if (pOldInfo ==
NULL) {
1813 if (ContainsPalette(pNewInfo) == FALSE) {
1814 if (ContainsPalette(pOldInfo) == FALSE) {
1821 DWORD VideoEntries = pNewInfo->bmiHeader.biClrUsed;
1822 if (ContainsPalette(pNewInfo) == TRUE)
1823 if (ContainsPalette(pOldInfo) == TRUE)
1824 if (pOldInfo->bmiHeader.biClrUsed == VideoEntries)
1825 if (pOldInfo->bmiHeader.biClrUsed > 0)
1826 if (memcmp((
PVOID) GetBitmapPalette(pNewInfo),
1827 (
PVOID) GetBitmapPalette(pOldInfo),
1828 VideoEntries *
sizeof(RGBQUAD)) == 0) {
1847 __in LPSTR szDevice)
1849 const VIDEOINFOHEADER *pNewInfo = (VIDEOINFOHEADER *) pmtNew->
Format();
1850 const VIDEOINFOHEADER *pOldInfo = (VIDEOINFOHEADER *) pmtOld->
Format();
1859 NOTE(
"No update needed");
1873 if (ContainsPalette(pNewInfo) == FALSE) {
1874 NOTE(
"New has no palette");
1887 NOTE(
"Making new colour palette");
1920 VIDEOINFOHEADER *pDestInfo = (VIDEOINFOHEADER *) pDest->Format();
1921 pDestInfo->bmiHeader.biClrUsed = 0;
1922 pDestInfo->bmiHeader.biClrImportant = 0;
1926 if (PALETTISED(pDestInfo) == FALSE) {
1927 NOTE(
"No destination palette");
1933 const VIDEOINFOHEADER *pSrcInfo = (VIDEOINFOHEADER *) pSrc->
Format();
1934 if (ContainsPalette(pSrcInfo) == FALSE) {
1935 NOTE(
"No source palette");
1941 DWORD PaletteEntries = pSrcInfo->bmiHeader.biClrUsed;
1942 if (PaletteEntries == 0) {
1943 DWORD Maximum = (1 << pSrcInfo->bmiHeader.biBitCount);
1944 NOTE1(
"Setting maximum colours (%d)",Maximum);
1945 PaletteEntries = Maximum;
1950 ASSERT(pSrcInfo->bmiHeader.biClrUsed <= iPALETTE_COLORS);
1951 ASSERT(pSrcInfo->bmiHeader.biClrImportant <= PaletteEntries);
1952 ASSERT(COLORS(pDestInfo) == GetBitmapPalette(pDestInfo));
1953 pDestInfo->bmiHeader.biClrUsed = PaletteEntries;
1954 pDestInfo->bmiHeader.biClrImportant = pSrcInfo->bmiHeader.biClrImportant;
1955 ULONG BitmapSize = GetBitmapFormatSize(HEADER(pSrcInfo));
1957 if (pDest->FormatLength() < BitmapSize) {
1958 NOTE(
"Reallocating destination");
1959 pDest->ReallocFormatBuffer(BitmapSize);
1965 (
PVOID) GetBitmapPalette(pSrcInfo),
1966 PaletteEntries *
sizeof(RGBQUAD));
2018 ASSERT(ContainsPalette(pVideoInfo) == TRUE);
2019 ASSERT(pVideoInfo->bmiHeader.biClrUsed <= iPALETTE_COLORS);
2020 BITMAPINFOHEADER *pHeader = HEADER(pVideoInfo);
2022 const RGBQUAD *pColours;
2026 lp = (LOGPALETTE *)
new BYTE[
sizeof(LOGPALETTE) + SIZE_PALETTE];
2038 lp->palNumEntries = (USHORT) pHeader->biClrUsed;
2039 if (lp->palNumEntries == 0) lp->palNumEntries = (1 << pHeader->biBitCount);
2040 pColours = GetBitmapPalette(pVideoInfo);
2042 for (DWORD dwCount = 0;dwCount < lp->palNumEntries;dwCount++) {
2043 lp->palPalEntry[dwCount].peRed = pColours[dwCount].rgbRed;
2044 lp->palPalEntry[dwCount].peGreen = pColours[dwCount].rgbGreen;
2045 lp->palPalEntry[dwCount].peBlue = pColours[dwCount].rgbBlue;
2046 lp->palPalEntry[dwCount].peFlags = 0;
2053 hPalette = CreatePalette(lp);
2072 PALETTEENTRY SystemEntries[10];
2073 BOOL bIdentityPalette = TRUE;
2074 ASSERT(iColours <= iPALETTE_COLORS);
2075 const int PalLoCount = 10;
2076 const int PalHiStart = 246;
2080 if (iColours < 10) {
2094 return E_OUTOFMEMORY;
2096 INT Reserved = GetDeviceCaps(hdc,NUMRESERVED);
2097 if (Reserved != 20) {
2106 UINT Result = GetSystemPaletteEntries(hdc,0,PalLoCount,SystemEntries);
2107 for (UINT Count = 0;Count < Result;Count++) {
2108 if (SystemEntries[Count].peRed != pEntry[Count].peRed ||
2109 SystemEntries[Count].peGreen != pEntry[Count].peGreen ||
2110 SystemEntries[Count].peBlue != pEntry[Count].peBlue) {
2111 bIdentityPalette = FALSE;
2117 Result = GetSystemPaletteEntries(hdc,PalHiStart,PalLoCount,SystemEntries);
2118 for (UINT Count = 0;Count < Result;Count++) {
2119 if (INT(Count) + PalHiStart < iColours) {
2120 if (SystemEntries[Count].peRed != pEntry[PalHiStart + Count].peRed ||
2121 SystemEntries[Count].peGreen != pEntry[PalHiStart + Count].peGreen ||
2122 SystemEntries[Count].peBlue != pEntry[PalHiStart + Count].peBlue) {
2123 bIdentityPalette = FALSE;
2131 if (bIdentityPalette == FALSE) {
2137 for (UINT Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) {
2138 pEntry[Count].peFlags = PC_NOCOLLAPSE;
2172 ZeroMemory((
PVOID)&
m_Display,
sizeof(VIDEOINFOHEADER)+
sizeof(TRUECOLORINFO));
2173 m_Display.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
2184 hdcDisplay = CreateDCA(
NULL, szDeviceName,
NULL,
NULL);
2185 if (hdcDisplay ==
NULL) {
2188 szDeviceName ? szDeviceName :
"<NULL>"));
2192 szDeviceName ? szDeviceName :
"<NULL>"));
2194 HBITMAP hbm = CreateCompatibleBitmap(hdcDisplay,1,1);
2197 GetDIBits(hdcDisplay,hbm,0,1,
NULL,(BITMAPINFO *)&
m_Display.bmiHeader,DIB_RGB_COLORS);
2200 GetDIBits(hdcDisplay,hbm,0,1,
NULL,(BITMAPINFO *)&
m_Display.bmiHeader,DIB_RGB_COLORS);
2203 DeleteDC(hdcDisplay);
2222 DWORD *pBitFields = (DWORD *) BITMASKS(pInput);
2224 for (INT iColour = iRED;iColour <= iBLUE;iColour++) {
2229 if (SetBits > iMAXBITS || SetBits == 0) {
2230 NOTE1(
"Bit fields for component %d invalid",iColour);
2244 DWORD TestField = pBitFields[iColour] >> PrefixBits;
2245 DWORD Mask = ULONG_MAX << SetBits;
2246 if (TestField & Mask) {
2247 NOTE1(
"Bit fields for component %d not contiguous",iColour);
2267 init = init & (init - 1);
2289 ASSERT(Mask != 0x80000000);
2290 if (Mask == 0x80000000) {
2309 if (pInput->bmiHeader.biWidth <= 0 ||
2310 pInput->bmiHeader.biHeight <= 0) {
2311 NOTE(
"Invalid bitmap dimensions");
2317 if (pInput->bmiHeader.biCompression != BI_RGB) {
2318 if (pInput->bmiHeader.biCompression != BI_BITFIELDS) {
2319 NOTE(
"Invalid compression format");
2326 if (pInput->bmiHeader.biCompression == BI_BITFIELDS) {
2327 if (pInput->bmiHeader.biBitCount != 16) {
2328 if (pInput->bmiHeader.biBitCount != 32) {
2329 NOTE(
"BI_BITFIELDS not 16/32 bit depth");
2337 if (pInput->bmiHeader.biCompression == BI_BITFIELDS) {
2339 NOTE(
"Bit fields are not valid");
2346 if (pInput->bmiHeader.biPlanes != 1) {
2347 NOTE(
"Number of planes not one");
2353 if (pInput->bmiHeader.biSizeImage != GetBitmapSize(&pInput->bmiHeader)) {
2354 if (pInput->bmiHeader.biSizeImage) {
2355 NOTE(
"Image size incorrectly set");
2362 if (pInput->bmiHeader.biSize !=
sizeof(BITMAPINFOHEADER)) {
2363 NOTE(
"Size of BITMAPINFOHEADER wrong");
2379 if (PALETTISED(pInput) == FALSE) {
2380 if (pInput->bmiHeader.biClrUsed) {
2381 NOTE(
"Invalid palette entries");
2389 if (pInput->bmiHeader.biCompression != BI_RGB) {
2390 NOTE(
"Palettised video must be BI_RGB");
2396 if (pInput->bmiHeader.biClrUsed > PALETTE_ENTRIES(pInput)) {
2397 NOTE(
"Too many colours in palette");
2403 if (pInput->bmiHeader.biClrImportant > pInput->bmiHeader.biClrUsed) {
2404 NOTE(
"Too many important colours");
2447 BITMAPINFOHEADER *pbmi = HEADER(pVideoInfo);
2448 SetRectEmpty(&pVideoInfo->rcSource);
2449 SetRectEmpty(&pVideoInfo->rcTarget);
2453 if (PALETTISED(pVideoInfo)) {
2454 if (pVideoInfo->bmiHeader.biClrUsed == 0) {
2455 pVideoInfo->bmiHeader.biClrUsed = PALETTE_ENTRIES(pVideoInfo);
2463 if (pVideoInfo->bmiHeader.biClrImportant > pVideoInfo->bmiHeader.biClrUsed) {
2464 pVideoInfo->bmiHeader.biClrImportant = PALETTE_ENTRIES(pVideoInfo);
2469 if (pVideoInfo->bmiHeader.biSizeImage == 0) {
2470 pVideoInfo->bmiHeader.biSizeImage = GetBitmapSize(&pVideoInfo->bmiHeader);
2489 return E_INVALIDARG;
2494 if (
m_Display.bmiHeader.biBitCount == pInput->bmiHeader.biBitCount) {
2495 if (PALETTISED(pInput) == TRUE) {
2497 NOTE(
"(Video) Type connection ACCEPTED");
2505 if (
m_Display.bmiHeader.biBitCount > pInput->bmiHeader.biBitCount) {
2506 NOTE(
"(Video) Mismatch agreed");
2512 if (
m_Display.bmiHeader.biBitCount < pInput->bmiHeader.biBitCount) {
2513 NOTE(
"(Video) Format mismatch");
2514 return E_INVALIDARG;
2520 ASSERT(
m_Display.bmiHeader.biBitCount == pInput->bmiHeader.biBitCount);
2521 ASSERT(PALETTISED(pInput) == FALSE);
2532 if (pInputMask[iRED] != pDisplayMask[iRED] ||
2533 pInputMask[iGREEN] != pDisplayMask[iGREEN] ||
2534 pInputMask[iBLUE] != pDisplayMask[iBLUE]) {
2536 NOTE(
"(Video) Bit field mismatch");
2537 return E_INVALIDARG;
2540 NOTE(
"(Video) Type connection ACCEPTED");
2549 static const DWORD FailMasks[] = {0,0,0};
2551 if (pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS) {
2552 return BITMASKS(pVideoInfo);
2555 ASSERT(pVideoInfo->bmiHeader.biCompression == BI_RGB);
2557 switch (pVideoInfo->bmiHeader.biBitCount) {
2561 default:
return FailMasks;
2576 const GUID *pFormatType = pmtIn->
FormatType();
2577 if (*pFormatType != FORMAT_VideoInfo) {
2578 NOTE(
"Format GUID not a VIDEOINFOHEADER");
2579 return E_INVALIDARG;
2586 if (Length < SIZE_VIDEOHEADER) {
2587 NOTE(
"Format smaller than a VIDEOHEADER");
2591 VIDEOINFO *pInput = (VIDEOINFO *) pmtIn->
Format();
2595 const GUID *pMajorType = pmtIn->
Type();
2596 if (*pMajorType != MEDIATYPE_Video) {
2597 NOTE(
"Major type not MEDIATYPE_Video");
2598 return E_INVALIDARG;
2603 const GUID *pSubType = pmtIn->
Subtype();
2604 if (GetBitCount(pSubType) == USHRT_MAX) {
2605 NOTE(
"Invalid video media subtype");
2606 return E_INVALIDARG;
2619 __out DWORD *pMaskGreen,
2620 __out DWORD *pMaskBlue)
2629 if (
m_Display.bmiHeader.biBitCount < 16) {
2637 if (
m_Display.bmiHeader.biBitCount == 24) {
2645 DWORD *pOutputMask[] = { pMaskRed, pMaskGreen, pMaskBlue };
2651 for (INT iColour = iRED;iColour <= iBLUE;iColour++) {
2662 *(pOutputMask[iColour]) = pBitFields[iColour] >> PrefixBits;
2663 *(pOutputMask[iColour]) <<= (iMAXBITS - SetBits);
2673 if (pmt->formattype != FORMAT_VideoInfo) {
2674 return E_INVALIDARG;
2676 if (
NULL == pmt->pbFormat || pmt->cbFormat <
sizeof(VIDEOINFOHEADER)) {
2677 return E_INVALIDARG;
2679 VIDEOINFO *pVideoInfo = (VIDEOINFO *)pmt->pbFormat;
2681 HRESULT
hr = DWordAdd(pmt->cbFormat,
sizeof(VIDEOINFOHEADER2) -
sizeof(VIDEOINFOHEADER), &dwNewSize);
2685 PVOID pvNew = CoTaskMemAlloc(dwNewSize);
2686 if (pvNew ==
NULL) {
2687 return E_OUTOFMEMORY;
2689 CopyMemory(pvNew, pmt->pbFormat, FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));
2690 ZeroMemory((PBYTE)pvNew + FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader),
2691 sizeof(VIDEOINFOHEADER2) -
sizeof(VIDEOINFOHEADER));
2692 CopyMemory((PBYTE)pvNew + FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader),
2693 pmt->pbFormat + FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader),
2694 pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));
2695 VIDEOINFOHEADER2 *pVideoInfo2 = (VIDEOINFOHEADER2 *)pvNew;
2696 pVideoInfo2->dwPictAspectRatioX = (DWORD)pVideoInfo2->bmiHeader.biWidth;
2697 pVideoInfo2->dwPictAspectRatioY = (DWORD)abs(pVideoInfo2->bmiHeader.biHeight);
2698 pmt->formattype = FORMAT_VideoInfo2;
2699 CoTaskMemFree(pmt->pbFormat);
2700 pmt->pbFormat = (PBYTE)pvNew;
2701 pmt->cbFormat +=
sizeof(VIDEOINFOHEADER2) -
sizeof(VIDEOINFOHEADER);
2709 if (
NULL == pmt ||
NULL == pmt->pbFormat) {
2712 if (pmt->majortype != MEDIATYPE_Video ||
2713 pmt->formattype != FORMAT_VideoInfo ||
2714 pmt->cbFormat <
sizeof(VIDEOINFOHEADER)) {
2715 return VFW_E_TYPE_NOT_ACCEPTED;
2717 const VIDEOINFOHEADER *pHeader = (
const VIDEOINFOHEADER *)pmt->pbFormat;
2718 if (!ValidateBitmapInfoHeader(
2719 &pHeader->bmiHeader,
2720 pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader))) {
2721 return VFW_E_TYPE_NOT_ACCEPTED;
2730 if (
NULL == pmt ||
NULL == pmt->pbFormat) {
2733 if (pmt->majortype != MEDIATYPE_Video ||
2734 pmt->formattype != FORMAT_VideoInfo2 ||
2735 pmt->cbFormat <
sizeof(VIDEOINFOHEADER2)) {
2736 return VFW_E_TYPE_NOT_ACCEPTED;
2738 const VIDEOINFOHEADER2 *pHeader = (
const VIDEOINFOHEADER2 *)pmt->pbFormat;
2739 if (!ValidateBitmapInfoHeader(
2740 &pHeader->bmiHeader,
2741 pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader))) {
2742 return VFW_E_TYPE_NOT_ACCEPTED;