Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
evrhelpers.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "evrhelpers_p.h"
5
6#ifndef D3DFMT_YV12
7#define D3DFMT_YV12 (D3DFORMAT)MAKEFOURCC ('Y', 'V', '1', '2')
8#endif
9#ifndef D3DFMT_NV12
10#define D3DFMT_NV12 (D3DFORMAT)MAKEFOURCC ('N', 'V', '1', '2')
11#endif
12
14
15HRESULT qt_evr_getFourCC(IMFMediaType *type, DWORD *fourCC)
16{
17 if (!fourCC)
18 return E_POINTER;
19
20 HRESULT hr = S_OK;
21 GUID guidSubType = GUID_NULL;
22
23 if (SUCCEEDED(hr))
24 hr = type->GetGUID(MF_MT_SUBTYPE, &guidSubType);
25
26 if (SUCCEEDED(hr))
27 *fourCC = guidSubType.Data1;
28
29 return hr;
30}
31
32bool qt_evr_areMediaTypesEqual(IMFMediaType *type1, IMFMediaType *type2)
33{
34 if (!type1 && !type2)
35 return true;
36 if (!type1 || !type2)
37 return false;
38
39 DWORD dwFlags = 0;
40 HRESULT hr = type1->IsEqual(type2, &dwFlags);
41
42 return (hr == S_OK);
43}
44
45HRESULT qt_evr_validateVideoArea(const MFVideoArea& area, UINT32 width, UINT32 height)
46{
47 float fOffsetX = qt_evr_MFOffsetToFloat(area.OffsetX);
48 float fOffsetY = qt_evr_MFOffsetToFloat(area.OffsetY);
49
50 if ( ((LONG)fOffsetX + area.Area.cx > (LONG)width) ||
51 ((LONG)fOffsetY + area.Area.cy > (LONG)height) ) {
52 return MF_E_INVALIDMEDIATYPE;
53 }
54 return S_OK;
55}
56
57bool qt_evr_isSampleTimePassed(IMFClock *clock, IMFSample *sample)
58{
59 if (!sample || !clock)
60 return false;
61
62 HRESULT hr = S_OK;
63 MFTIME hnsTimeNow = 0;
64 MFTIME hnsSystemTime = 0;
65 MFTIME hnsSampleStart = 0;
66 MFTIME hnsSampleDuration = 0;
67
68 hr = clock->GetCorrelatedTime(0, &hnsTimeNow, &hnsSystemTime);
69
70 if (SUCCEEDED(hr))
71 hr = sample->GetSampleTime(&hnsSampleStart);
72
73 if (SUCCEEDED(hr))
74 hr = sample->GetSampleDuration(&hnsSampleDuration);
75
76 if (SUCCEEDED(hr)) {
77 if (hnsSampleStart + hnsSampleDuration < hnsTimeNow)
78 return true;
79 }
80
81 return false;
82}
83
85{
86 switch (format) {
87 case D3DFMT_A8R8G8B8:
89 case D3DFMT_X8R8G8B8:
91 case D3DFMT_A8:
93 case D3DFMT_A8B8G8R8:
95 case D3DFMT_X8B8G8R8:
97 case D3DFMT_UYVY:
99 case D3DFMT_YUY2:
101 case D3DFMT_NV12:
103 case D3DFMT_YV12:
105 case D3DFMT_UNKNOWN:
106 default:
108 }
109}
110
112{
113 switch (format) {
115 return D3DFMT_A8B8G8R8;
117 return D3DFMT_A8R8G8B8;
119 return D3DFMT_X8R8G8B8;
121 return D3DFMT_A8;
123 return D3DFMT_A8B8G8R8;
125 return D3DFMT_X8B8G8R8;
127 return D3DFMT_UYVY;
129 return D3DFMT_YUY2;
131 return D3DFMT_NV12;
133 return D3DFMT_YV12;
135 default:
136 return D3DFMT_UNKNOWN;
137 }
138}
139
PixelFormat
Enumerates video data types.
#define D3DFMT_YV12
Definition evrhelpers.cpp:7
D3DFORMAT qt_evr_D3DFormatFromPixelFormat(QVideoFrameFormat::PixelFormat format)
bool qt_evr_areMediaTypesEqual(IMFMediaType *type1, IMFMediaType *type2)
#define D3DFMT_NV12
QVideoFrameFormat::PixelFormat qt_evr_pixelFormatFromD3DFormat(DWORD format)
QT_BEGIN_NAMESPACE HRESULT qt_evr_getFourCC(IMFMediaType *type, DWORD *fourCC)
bool qt_evr_isSampleTimePassed(IMFClock *clock, IMFSample *sample)
HRESULT qt_evr_validateVideoArea(const MFVideoArea &area, UINT32 width, UINT32 height)
float qt_evr_MFOffsetToFloat(const MFOffset &offset)
Combined button and popup list for selecting options.
static int area(const QSize &s)
Definition qicon.cpp:153
GLint GLsizei GLsizei height
GLint GLsizei width
GLenum type
GLint GLsizei GLsizei GLenum format
long HRESULT