### Typical host setup for MPC-BE-style embedding Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Example of setting up the video window for embedding in a host application: set owner, message drain, and window position. ```cpp // Typical host setup for MPC-BE-style embedding: pVW->put_Owner((OAHWND)hParentWnd); pVW->put_MessageDrain((OAHWND)hAppWnd); RECT rc = {0, 0, 640, 360}; pVW->SetWindowPosition(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); ``` -------------------------------- ### Host example: read renderer version as packed int64 Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/filter-interfaces.md Shows how to query the renderer's version field using Flt_GetInt64. The version is packed into a 64-bit integer; the example extracts the major and minor components by shifting. Requires a valid IExFilterConfig pointer obtained from the filter. ```cpp // Host example: read renderer version as a packed int64 CComQIPtr pConfig = pFilter; __int64 ver = 0; if (pConfig && SUCCEEDED(pConfig->Flt_GetInt64("version", &ver))) { int major = (int)((ver >> 48) & 0xFFFF); int minor = (int)((ver >> 32) & 0xFFFF); // ... } ``` -------------------------------- ### DX11 subtitle renderer side example Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/subtitle-interfaces.md Shows how a subtitle renderer obtains the ISubRender11 interface from the video renderer and registers its callback. The video renderer exposes ISubRender11 when using DX11. ```cpp // Subtitle-renderer side (DX11 path): CComQIPtr pSR = pVideoRenderer; // video renderer exposes when DX11 pSR->SetCallback11(&myCallback); // myCallback: ISubRender11Callback ``` -------------------------------- ### Class factory and registration data for MPC Video Renderer Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/dll-entry-points.md Defines the DirectShow filter registration structures: the CreateInstance template, the pin setup array with a single input pin, the filter setup with MERIT_DO_NOT_USE, and the CFactoryTemplate array for the filter and its property pages. This data is used to register the filter in the DirectShow filter category. ```cpp template static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr); const AMOVIESETUP_PIN sudpPins[] = { {(LPWSTR)L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, (UINT)std::size(sudPinTypesIn), sudPinTypesIn}, }; const AMOVIESETUP_FILTER sudFilter[] = { {&__uuidof(CMpcVideoRenderer), L"MPC Video Renderer", MERIT_DO_NOT_USE, (UINT)std::size(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}, }; CFactoryTemplate g_Templates[] = { {sudFilter[0].strName, &__uuidof(CMpcVideoRenderer), CreateInstance, nullptr, &sudFilter[0]}, {L"MainProp", &__uuidof(CVRMainPPage), CreateInstance, nullptr, nullptr}, {L"InfoProp", &__uuidof(CVRInfoPPage), CreateInstance, nullptr, nullptr} }; int g_cTemplates = (int)std::size(g_Templates); ``` -------------------------------- ### Default stub implementations for IExFilterInfo and IExFilterConfig Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/filter-interfaces.md Provides CExFilterInfoImpl and CExFilterConfigImpl classes that inherit the interfaces and return E_NOTIMPL for every method. Use these as a starting point when implementing the interfaces in your own filter; CMpcVideoRenderer derives from CExFilterConfigImpl and overrides the methods it implements. ```cpp class CExFilterInfoImpl : public IExFilterInfo { STDMETHODIMP GetPropertyInt (LPCSTR field, int *value) { return E_NOTIMPL; }; // ... GetPropertyString, GetPropertyBin ... }; class CExFilterConfigImpl : public IExFilterConfig { STDMETHODIMP Flt_GetBool (LPCSTR field, bool *value) { return E_NOTIMPL; }; // ... all 12 Flt_* methods return E_NOTIMPL ... }; ``` -------------------------------- ### IBasicVideo::GetCurrentImage two-phase screenshot Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Example of using GetCurrentImage in two phases: first query the required buffer size, then capture the DIB. Returns E_OUTOFMEMORY if buffer too small, E_FAIL if frame size invalid. ```cpp // IBasicVideo::GetCurrentImage — two-phase screenshot long size = 0; pBV->GetCurrentImage(&size, nullptr); // phase 1: query size std::vector buf(size / sizeof(long)); long* pDIB = buf.data(); HRESULT hr = pBV->GetCurrentImage(&size, pDIB); // phase 2: capture if (SUCCEEDED(hr)) { /* write DIB to disk */ } ``` -------------------------------- ### Media subtype GUID macros (Include/MediaTypes.h) Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/types.md Defines FCC and DEFINE_MEDIATYPE_GUID macros used to create media subtype GUIDs. FCC converts a four-character code to a DWORD, and DEFINE_MEDIATYPE_GUID creates a GUID with a fixed format. ```cpp #ifndef FCC #define FCC(ch4) ((((DWORD)(ch4) & 0xFF) << 24) | (((DWORD)(ch4) & 0xFF00) << 8) | \ (((DWORD)(ch4) & 0xFF0000) >> 8) | (((DWORD)(ch4) & 0xFF000000) >> 24)) #endif #ifndef DEFINE_MEDIATYPE_GUID #define DEFINE_MEDIATYPE_GUID(name, format) DEFINE_GUID(name, format, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); #endif ``` -------------------------------- ### IExFilterConfig::Flt_GetBin Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Gets a binary field value. ```APIDOC ## [COM] IExFilterConfig::Flt_GetBin ### Description Gets a binary field value. ### Method Flt_GetBin ### Interface IExFilterConfig ### Parameters - **field** (LPCSTR) - Required - The field name. - **value** (LPVOID*) - Required - Receives a pointer to the binary data. - **size** (unsigned*) - Required - Receives the size of the data. ### Return Value - **S_OK** - Field handled. - **E_INVALIDARG** - Unknown field. - **E_POINTER** - Null out-param. ### Implemented Fields - displayedImage (currently displayed frame as DIB, allocated with LocalAlloc; caller frees with LocalFree) ``` -------------------------------- ### CExFilterConfigImpl / CExFilterInfoImpl (Default Stubs) Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/filter-interfaces.md Helper classes that inherit the interfaces with every method returning E_NOTIMPL. Use these as a starting point when implementing the interfaces in your own filter. ```APIDOC ## CExFilterConfigImpl / CExFilterInfoImpl ### Description Helper classes that inherit the interfaces with every method returning `E_NOTIMPL`. `CMpcVideoRenderer` derives from `CExFilterConfigImpl` and overrides the methods it implements. Use these as a starting point when implementing the interfaces in your own filter. ### CExFilterInfoImpl ```cpp class CExFilterInfoImpl : public IExFilterInfo { STDMETHODIMP GetPropertyInt (LPCSTR field, int *value) { return E_NOTIMPL; }; // ... GetPropertyString, GetPropertyBin ... }; ``` ### CExFilterConfigImpl ```cpp class CExFilterConfigImpl : public IExFilterConfig { STDMETHODIMP Flt_GetBool (LPCSTR field, bool *value) { return E_NOTIMPL; }; // ... all 12 Flt_* methods return E_NOTIMPL ... }; ``` ``` -------------------------------- ### Consumer side after DeliverFrame Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/subtitle-interfaces.md Shows how to retrieve and blend subtitle bitmaps after calling DeliverFrame. It gets the output and clip rects, bitmap count, and iterates over each bitmap to blend premultiplied RGBA pixels at the given position. ```cpp // Consumer side after DeliverFrame(start, stop, ctx, pFrame): RECT outRect, clipRect; int count; pFrame->GetOutputRect(&outRect); pFrame->GetClipRect(&clipRect); pFrame->GetBitmapCount(&count); for (int i = 0; i < count; i++) { ULONGLONG id; POINT pos; SIZE size; LPCVOID px; int pitch; pFrame->GetBitmap(i, &id, &pos, &size, &px, &pitch); // blend px (premultiplied RGBA, pitch bytes/row) at pos } ``` -------------------------------- ### IExFilterConfig Flt_* method declarations Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declares the runtime configuration methods for the IExFilterConfig interface. These methods get and set boolean, integer, int64, and binary fields. Return values follow the interface contract: S_OK for handled fields, E_INVALIDARG for unknown fields, and E_POINTER for null out-parameters. ```cpp STDMETHODIMP Flt_GetBool(LPCSTR field, bool* value); // 1374 STDMETHODIMP Flt_GetInt (LPCSTR field, int* value); // 1397 STDMETHODIMP Flt_GetInt64(LPCSTR field, __int64* value); // 1421 STDMETHODIMP Flt_GetBin (LPCSTR field, LPVOID* value, unsigned* size); // 1444 STDMETHODIMP Flt_SetBool(LPCSTR field, bool value); // 1461 STDMETHODIMP Flt_SetInt (LPCSTR field, int value); // 1518 STDMETHODIMP Flt_SetBin (LPCSTR field, LPVOID value, int size); // 1548 ``` -------------------------------- ### Define Dolby Vision metadata GUIDs Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines the GUIDs for Dolby Vision metadata interfaces: IID_MediaSideDataDOVIRPU, deprecated IID_MediaSideDataDOVIMetadata, and IID_MediaSideDataDOVIMetadataV2. ```cpp // {BAE40E6C-5B93-4170-90CC-5D5F02A29638} DEFINE_GUID(IID_MediaSideDataDOVIRPU, 0xbae40e6c, 0x5b93, 0x4170, 0x90, 0xcc, 0x5d, 0x5f, 0x2, 0xa2, 0x96, 0x38); // {277EE779-13F4-434E-BDEC-3D6F8C0E15D2} DEFINE_GUID([[deprecated]] IID_MediaSideDataDOVIMetadata, 0x277ee779, 0x13f4, 0x434e, 0xbd, 0xec, 0x3d, 0x6f, 0x8c, 0xe, 0x15, 0xd2); // {F1949F1C-7474-4F0F-B110-FB734C08851D} DEFINE_GUID(IID_MediaSideDataDOVIMetadataV2, 0xf1949f1c, 0x7474, 0x4f0f, 0xb1, 0x10, 0xfb, 0x73, 0x4c, 0x8, 0x85, 0x1d); ``` -------------------------------- ### Host query and tweak settings via IVideoRenderer Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Shows how a host application can query and modify renderer settings using the IVideoRenderer interface. It retrieves the current settings, enables the stats display, and applies the changes. ```cpp // Host: query and tweak settings (in-proc filter control) CComQIPtr pVR = pFilter; Settings_t st; pVR->GetSettings(st); st.bShowStats = true; pVR->SetSettings(st); pVR->SaveSettings(); ``` -------------------------------- ### Define IID_MediaSideDataEIA608CC GUID Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines the GUID for EIA-608/708 closed caption side data. The payload is a list of 3-byte CC data packets (control byte + cc_data1/2); no struct is provided. ```cpp // {40FEFD7F-85DD-4335-A804-8A33B0BF7B81} DEFINE_GUID(IID_MediaSideDataEIA608CC, 0x40fefd7f, 0x85dd, 0x4335, 0xa8, 0x4, 0x8a, 0x33, 0xb0, 0xbf, 0x7b, 0x81); ``` -------------------------------- ### IVideoRenderer::GetSettings Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Copies the current Settings_t structure. ```APIDOC ## [COM] IVideoRenderer::GetSettings ### Description Copies the current Settings_t structure. ### Method GetSettings ### Interface IVideoRenderer (IID 1AB00F10-5F55-42AC-B53F-38649F11BE3E) ### Parameters - **setings** (Settings_t&) - Required - Receives the current settings. ### Return Value - **void** - No return value. ``` -------------------------------- ### IMediaSideData::SetSideData Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Attaches a binary payload for a given GUID type to a media sample. The data is copied and stored internally. Only one side data per GUID type per sample is allowed. ```APIDOC ## IMediaSideData::SetSideData ### Description Attaches one binary payload for the specified GUID type to the media sample. The provided data is copied and stored internally. Only one side data per GUID type per sample is allowed. ### Method SetSideData ### Interface IMediaSideData (IID F940AE7F-48EB-4377-806C-8FC48CAB2292) ### Parameters - **guidType** (GUID) - Required - The GUID identifying the type of side data. - **pData** (const BYTE*) - Required - Pointer to the binary data to attach. - **size** (size_t) - Required - Size of the data in bytes. ### Return Value HRESULT - S_OK on success, or an error code on failure. ### Remarks The data is copied and stored internally. Only one side data per GUID type per sample is allowed. ### Example ```cpp CComQIPtr pMSD = pSample; if (pMSD) { MediaSideDataHDR10Plus md{}; // ... fill md ... pMSD->SetSideData(IID_MediaSideDataHDR10Plus, (const BYTE*)&md, sizeof(md)); } ``` ``` -------------------------------- ### IMediaSideData::GetSideData Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Retrieves a pointer to the internal copy of the side data for a given GUID type. The pointer remains valid for the lifetime of the sample. Returns E_FAIL if no data of that GUID type is attached, and E_POINTER for null out-parameters. ```APIDOC ## IMediaSideData::GetSideData ### Description Returns a pointer to the internal copy of the side data identified by the given GUID type. The pointer is valid for the lifetime of the sample. Returns E_FAIL when no data of that GUID type is attached, and E_POINTER for null out-parameters. ### Method GetSideData ### Interface IMediaSideData (IID F940AE7F-48EB-4377-806C-8FC48CAB2292) ### Parameters - **guidType** (GUID) - Required - The GUID identifying the type of side data. - **pData** (const BYTE**) - Required - Output pointer that receives a pointer to the internal data. - **pSize** (size_t*) - Required - Output pointer that receives the size of the data. ### Return Value HRESULT - S_OK on success, E_FAIL if no data of that GUID type is attached, E_POINTER for null out-parameters. ### Remarks The returned pointer is valid for the lifetime of the sample. Consumers must not hold the pointer after releasing the sample. ### Example ```cpp const BYTE* pData = nullptr; size_t size = 0; if (SUCCEEDED(pMSD->GetSideData(IID_MediaSideDataHDR10Plus, &pData, &size))) { const auto* md = reinterpret_cast(pData); } ``` ``` -------------------------------- ### CVideoProcessor abstract virtual interface Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-processor.md Lists the pure virtual methods that derived processors must implement, including Init, VerifyMediaType, ProcessSample, Render, and others. Note the typo 'GetCurentImage' in the source. ```cpp virtual ~CVideoProcessor() = default; virtual int Type() = 0; virtual HRESULT Init(const HWND hwnd, bool displayHdrChanged, bool* pChangeDevice = nullptr) = 0; virtual BOOL VerifyMediaType(const CMediaType* pmt) = 0; virtual BOOL InitMediaType(const CMediaType* pmt) = 0; virtual BOOL GetAlignmentSize(const CMediaType& mt, SIZE& Size) = 0; virtual HRESULT ProcessSample(IMediaSample* pSample) = 0; virtual HRESULT Render(int field, const REFERENCE_TIME frameStartTime) = 0; virtual HRESULT FillBlack() = 0; virtual void Flush() = 0; virtual HRESULT Reset(bool bDisplayModeChange) = 0; virtual bool IsInit() const { return false; } virtual void SetVideoRect(const CRect& videoRect) = 0; virtual HRESULT SetWindowRect(const CRect& windowRect) = 0; virtual void Configure(const Settings_t& config) = 0; virtual void SetRotation(int value) = 0; virtual HRESULT GetCurentImage(long *pDIBImage) = 0; // sic — "Curent" in source virtual HRESULT GetDisplayedImage(BYTE **ppDib, unsigned *pSize) = 0; virtual HRESULT GetVPInfo(std::wstring& str) = 0; virtual void CalcStatsParams() = 0; ``` -------------------------------- ### Property page usage pattern for IVideoRenderer Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/filter-interfaces.md Shows how the property page retrieves settings via GetSettings, mutates them, then applies with SetSettings and persists with SaveSettings. Requires including IVideoRenderer.h because Settings_t is a C++ struct. ```cpp // The property page uses exactly this pattern (Source/PropPage.cpp): CComQIPtr pVR = pFilter; Settings_t sets; pVR->GetSettings(sets); // ... edit controls mutate `sets` ... pVR->SetSettings(sets); pVR->SaveSettings(); ``` -------------------------------- ### IDirectXVideoMemoryConfiguration interface methods Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-renderer-input-pin.md Declares the two methods of the IDirectXVideoMemoryConfiguration interface used for DXVA2 decoder handshake. GetAvailableSurfaceTypeByIndex returns S_OK with DXVA2_SurfaceType_DecoderRenderTarget for index 0, otherwise MF_E_NO_MORE_TYPES. SetSurfaceType records m_bDXVA = (dwType == DXVA2_SurfaceType_DecoderRenderTarget) and returns S_OK. ```cpp STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType); STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType); ``` -------------------------------- ### IExFilterConfig::Flt_GetInt Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Gets an integer field value. ```APIDOC ## [COM] IExFilterConfig::Flt_GetInt ### Description Gets an integer field value. ### Method Flt_GetInt ### Interface IExFilterConfig ### Parameters - **field** (LPCSTR) - Required - The field name. - **value** (int*) - Required - Receives the integer value. ### Return Value - **S_OK** - Field handled. - **E_INVALIDARG** - Unknown field. - **E_POINTER** - Null out-param. ### Implemented Fields - renderType (0 = not initialized, 9 = DX9, 11 = DX11) - playbackState (0/1/2 = stopped/paused/running) - rotation ``` -------------------------------- ### IExFilterConfig::Flt_GetBool Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Gets a boolean field value. ```APIDOC ## [COM] IExFilterConfig::Flt_GetBool ### Description Gets a boolean field value. ### Method Flt_GetBool ### Interface IExFilterConfig ### Parameters - **field** (LPCSTR) - Required - The field name. - **value** (bool*) - Required - Receives the boolean value. ### Return Value - **S_OK** - Field handled. - **E_INVALIDARG** - Unknown field. - **E_POINTER** - Null out-param. ### Implemented Fields - statsEnable - flip - doubleRate ``` -------------------------------- ### IExFilterConfig::Flt_GetInt64 Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Gets a 64-bit integer field value. ```APIDOC ## [COM] IExFilterConfig::Flt_GetInt64 ### Description Gets a 64-bit integer field value. ### Method Flt_GetInt64 ### Interface IExFilterConfig ### Parameters - **field** (LPCSTR) - Required - The field name. - **value** (__int64*) - Required - Receives the 64-bit integer value. ### Return Value - **S_OK** - Field handled. - **E_INVALIDARG** - Unknown field. - **E_POINTER** - Null out-param. ### Implemented Fields - version (packed VER_MAJOR<<48 | VER_MINOR<<32 | VER_BUILD<<16 | REV_NUM) - originalVideoSize (a SIZE bit-cast) ``` -------------------------------- ### DisplayConfig_t structure (Source/DisplayConfig.h) Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/types.md Defines the DisplayConfig_t struct with bitfields for advanced color and HDR support, plus fields for display mode details. Includes methods HDRSupported(), HDREnabled(), and ACMEnabled() that adapt behavior for Windows 11 24H2. ```cpp struct DisplayConfig_t { union { struct { UINT32 advancedColorSupported : 1; UINT32 advancedColorEnabled : 1; UINT32 wideColorEnforced : 1; UINT32 advancedColorForceDisabled : 1; UINT32 reserved : 28; } ; UINT32 value; } advancedColor; struct { union { struct { UINT32 advancedColorSupported : 1; UINT32 advancedColorActive : 1; UINT32 reserved1 : 1; UINT32 advancedColorLimitedByPolicy : 1; UINT32 highDynamicRangeSupported : 1; UINT32 highDynamicRangeUserEnabled : 1; UINT32 wideColorSupported : 1; UINT32 wideColorUserEnabled : 1; UINT32 reserved : 24; } ; UINT32 value; }; DISPLAYCONFIG_ADVANCED_COLOR_MODE activeColorMode; } windows1124H2Colors; UINT32 width; UINT32 height; UINT32 bitsPerChannel; DISPLAYCONFIG_COLOR_ENCODING colorEncoding; DISPLAYCONFIG_RATIONAL refreshRate; DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; WCHAR displayName[CCHDEVICENAME]; WCHAR monitorName[64]; DISPLAYCONFIG_MODE_INFO modeTarget; bool HDRSupported() const; // Win11 24H2: highDynamicRangeSupported; else advancedColor.* bits bool HDREnabled() const; // Win11 24H2: supported && activeColorMode==HDR; else advancedColorEnabled && !enforced/disabled bool ACMEnabled() const; // Win11 24H2: wideColorSupported && wideColorUserEnabled }; ``` -------------------------------- ### ID3D11DecoderConfiguration interface methods Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-renderer-input-pin.md Declares the two methods of the ID3D11DecoderConfiguration interface used for D3D11 decoder handshake. ActivateD3D11Decoding hands the decoder-created D3D11 device/context to the DX11 video processor (CDX11VideoProcessor::SetDevice). Returns E_FAIL when the active processor is not DX11; S_OK when the device was accepted (also sets m_bD3D11). GetD3D11AdapterIndex returns m_pBaseRenderer->m_VideoProcessor->GetCurrentAdapter() — the adapter the renderer was created on, so the decoder can create a matching device. To change adapters, the interface contract (Include/ID3DVideoMemoryConfiguration.h) instructs the renderer to disconnect/reconnect the decoder, which re-queries the index. ```cpp STDMETHODIMP ActivateD3D11Decoding(ID3D11Device *pDevice, ID3D11DeviceContext *pContext, HANDLE hMutex, UINT nFlags); UINT STDMETHODCALLTYPE GetD3D11AdapterIndex(); ``` -------------------------------- ### Decoder-side usage of ID3D11DecoderConfiguration Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-renderer-input-pin.md Shows how a decoder uses the ID3D11DecoderConfiguration interface: query the adapter index, create an ID3D11Device on that adapter, then call ActivateD3D11Decoding with the device, context, mutex, and flags. The comment indicates this usage follows the semantics from Include/ID3DVideoMemoryConfiguration.h. ```cpp // Decoder-side usage (from Include/ID3DVideoMemoryConfiguration.h semantics): CComQIPtr pCfg = pPin; UINT adapter = pCfg->GetD3D11AdapterIndex(); // create ID3D11Device on adapter, then: hr = pCfg->ActivateD3D11Decoding(pDevice, pContext, hMutex, 0); ``` -------------------------------- ### Define IID_MediaSideDataControlFlags and enum Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines the GUID for media control flags side data and the enum with the only flag currently defined: MediaSideDataControlFlags_EndOfSequence. The payload is a single DWORD of flags. ```cpp // {B5411CE3-3B21-4FD6-80A8-CE682969F795} DEFINE_GUID(IID_MediaSideDataControlFlags, 0xb5411ce3, 0x3b21, 0x4fd6, 0x80, 0xa8, 0xce, 0x68, 0x29, 0x69, 0xf7, 0x95); enum MediaSideDataControlFlags { MediaSideDataControlFlags_EndOfSequence = (1 << 0), }; ``` -------------------------------- ### IMFGetService::GetService method Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declaration for the IMFGetService::GetService method. It returns the DXVA2 device manager for MR_VIDEO_ACCELERATION_SERVICE, or the video processor interface for MR_VIDEO_MIXER_SERVICE, otherwise E_NOINTERFACE. ```cpp STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject); ``` -------------------------------- ### HDR10+ (SMPTE 2094-40) GUID and struct Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines IID_MediaSideDataHDR10Plus and the packed MediaSideDataHDR10Plus struct with window and luminance fields. The old IID_MediaSideDataHDR10PlusOld is deprecated because it lacks itu_t_t35_country_code and application_version. ```cpp // old version without the two identification fields // {183ED511-8910-4262-88F6-4946BC799C84} DEFINE_GUID([[deprecated]] IID_MediaSideDataHDR10PlusOld, ...); // {6FF47D98-3EF9-4335-A65E-E71880C15BD9} DEFINE_GUID(IID_MediaSideDataHDR10Plus, 0x6ff47d98, 0x3ef9, 0x4335, 0xa6, 0x5e, 0xe7, 0x18, 0x80, 0xc1, 0x5b, 0xd9); #pragma pack(push, 1) struct MediaSideDataHDR10Plus { unsigned int itu_t_t35_country_code; unsigned int application_version; unsigned int num_windows; // 1-3 struct { unsigned int upper_left_corner_x; unsigned int upper_left_corner_y; unsigned int lower_right_corner_x; unsigned int lower_right_corner_y; unsigned int center_of_ellipse_x; unsigned int center_of_ellipse_y; unsigned int rotation_angle; unsigned int semimajor_axis_internal_ellipse; unsigned int semimajor_axis_external_ellipse; unsigned int semiminor_axis_external_ellipse; unsigned int overlap_process_option; double maxscl[3]; double average_maxrgb; unsigned int num_distribution_maxrgb_percentiles; struct { unsigned int percentage; double percentile; } distribution_maxrgb_percentiles[15]; double fraction_bright_pixels; unsigned int tone_mapping_flag; double knee_point_x; double knee_point_y; unsigned int num_bezier_curve_anchors; double bezier_curve_anchors[15]; unsigned int color_saturation_mapping_flag; double color_saturation_weight; } windows[3]; double targeted_system_display_maximum_luminance; unsigned int targeted_system_display_actual_peak_luminance_flag; unsigned int num_rows_targeted_system_display_actual_peak_luminance; unsigned int num_cols_targeted_system_display_actual_peak_luminance; double targeted_system_display_actual_peak_luminance[25][25]; unsigned int mastering_display_actual_peak_luminance_flag; unsigned int num_rows_mastering_display_actual_peak_luminance; unsigned int num_cols_mastering_display_actual_peak_luminance; double mastering_display_actual_peak_luminance[25][25]; }; #pragma pack(pop) ``` -------------------------------- ### HDR content light level GUID and struct Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines IID_MediaSideDataHDRContentLightLevel and the packed MediaSideDataHDRContentLightLevel struct with MaxCLL and MaxFALL. Use to attach content light level metadata. ```cpp // {ED6AE576-7CBE-41A6-9DC3-07C35DC13EF9} DEFINE_GUID(IID_MediaSideDataHDRContentLightLevel, 0xed6ae576, 0x7cbe, 0x41a6, 0x9d, 0xc3, 0x7, 0xc3, 0x5d, 0xc1, 0x3e, 0xf9); #pragma pack(push, 1) struct MediaSideDataHDRContentLightLevel { unsigned int MaxCLL; // maximum content light level (cd/m2) unsigned int MaxFALL; // maximum frame average light level (cd/m2) }; #pragma pack(pop) ``` -------------------------------- ### IVideoRenderer::SetSettings Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Stores new settings, reconfigures the video processor, and re-renders the current sample if paused. ```APIDOC ## [COM] IVideoRenderer::SetSettings ### Description Stores new settings, reconfigures the video processor, and re-renders the current sample if paused. ### Method SetSettings ### Interface IVideoRenderer (IID 1AB00F10-5F55-42AC-B53F-38649F11BE3E) ### Parameters - **setings** (const Settings_t&) - Required - The new settings to apply. ### Return Value - **void** - No return value. ### Remarks Calls m_VideoProcessor->Configure(m_Sets) and, while paused, re-renders the current sample and redraws. ``` -------------------------------- ### Catching HRESULT errors in consumer code Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/errors.md Shows how to check HRESULT values from interface methods like Flt_GetInt and how to handle construction via the class factory. Use SUCCEEDED/FAILED macros and compare against specific HRESULT values like E_POINTER and E_ABORT. ```cpp HRESULT hr = pConfig->Flt_GetInt("rotation", &rot); if (FAILED(hr)) { // E_INVALIDARG -> unknown field or wrong typed accessor } if (hr == E_POINTER) { /* null out-param bug in caller */ } // Construction via the class factory: HRESULT phr = S_OK; CUnknown* p = CreateInstance(nullptr, &phr); // phr == E_ABORT -> an instance already exists in this process ``` -------------------------------- ### HDR mastering metadata GUID and struct Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines IID_MediaSideDataHDR and the packed MediaSideDataHDR struct with display primaries, white point, and mastering luminance. Use to attach HDR mastering metadata to media samples. ```cpp // {53820DBC-A7B8-49C4-B17B-E511591A790C} DEFINE_GUID(IID_MediaSideDataHDR, 0x53820dbc, 0xa7b8, 0x49c4, 0xb1, 0x7b, 0xe5, 0x11, 0x59, 0x1a, 0x79, 0xc); #pragma pack(push, 1) struct MediaSideDataHDR { double display_primaries_x[3]; // primaries, G-B-R order double display_primaries_y[3]; double white_point_x; double white_point_y; double max_display_mastering_luminance; double min_display_mastering_luminance; }; #pragma pack(pop) ``` -------------------------------- ### CVideoRendererInputPin constructor signature Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-renderer-input-pin.md Constructor signature for CVideoRendererInputPin. Parameters include the owning base renderer, an HRESULT pointer for construction result, the pin name (the filter passes L"In"), and the concrete filter instance. ```cpp CVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name, CMpcVideoRenderer* pBaseRenderer); ``` -------------------------------- ### Host code to create and add MPC Video Renderer to a graph Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/dll-entry-points.md Shows how to explicitly create the MPC Video Renderer filter using CoCreateInstance with CLSID_CVR and add it to a filter graph with AddFilter. The filter has MERIT_DO_NOT_USE, so it must be selected explicitly rather than auto-connected. ```cpp // Host code — building the renderer into a graph explicitly: CComPtr pFilter; hr = CoCreateInstance(CLSID_CVR /* 71F080AA-8661-4093-B15E-4F6903E77D0A */, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pFilter)); hr = pGraph->AddFilter(pFilter, L"MPC Video Renderer"); // or: search the filter category enumerator by name ``` -------------------------------- ### CVideoRendererInputPin class declaration Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-renderer-input-pin.md Shows the class declaration with its base class and three COM interfaces: IMFGetService, IDirectXVideoMemoryConfiguration, and ID3D11DecoderConfiguration. ```cpp class CVideoRendererInputPin : public CRendererInputPin , public IMFGetService , public IDirectXVideoMemoryConfiguration , public ID3D11DecoderConfiguration ``` -------------------------------- ### Define IID_MediaSideData3DOffset and MediaSideData3DOffset struct Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Defines the GUID for 3D plane offset side data and the packed structure holding per-view offsets for 3D subtitle placement. The offset array can hold up to 32 entries; positive values bring subtitles closer to the viewer, negative values push them away. ```cpp // {F169B76C-75A3-49E6-A23A-14983EBF4370} DEFINE_GUID(IID_MediaSideData3DOffset, 0xf169b76c, 0x75a3, 0x49e6, 0xa2, 0x3a, 0x14, 0x98, 0x3e, 0xbf, 0x43, 0x70); #pragma pack(push, 1) struct MediaSideData3DOffset { int offset_count; // Number of valid offsets (up to 32) int offset[32]; // positive: closer to viewer; negative: further away }; #pragma pack(pop) ``` -------------------------------- ### ISubPicProvider interface definition (C++) Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/subtitle-interfaces.md Defines the ISubPicProvider COM interface with IID D62B9A1A-879A-42db-AB04-88AA8F243CFD. It enumerates subtitle events via a POSITION iterator and renders them into a SubPicDesc. CXySubPicProvider adapts ISubRenderProvider to this interface and also implements IXyCompatProvider::DeliverFrame. ```cpp interface __declspec(uuid("D62B9A1A-879A-42db-AB04-88AA8F243CFD")) ISubPicProvider : public IUnknown { static const REFERENCE_TIME UNKNOWN_TIME = _I64_MAX; STDMETHOD (Lock) () PURE; STDMETHOD (Unlock) () PURE; STDMETHOD_(POSITION, GetStartPosition) (REFERENCE_TIME rt, double fps, bool CleanOld = false) PURE; STDMETHOD_(POSITION, GetNext) (POSITION pos) PURE; STDMETHOD_(REFERENCE_TIME, GetStart) (POSITION pos, double fps) PURE; STDMETHOD_(REFERENCE_TIME, GetStop) (POSITION pos, double fps) PURE; STDMETHOD_(bool, IsAnimated) (POSITION pos) PURE; STDMETHOD (Render) (SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox) PURE; STDMETHOD (GetTextureSize) (POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft) PURE; STDMETHOD_(SUBTITLE_TYPE, GetType) () PURE; }; ``` -------------------------------- ### Attach and read HDR10+ side data Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/media-side-data.md Shows how a decoder attaches HDR10+ metadata to a sample using SetSideData and how a consumer reads it back with GetSideData. The returned pointer is valid only for the sample's lifetime. ```cpp // Decoder side — attach HDR10+ metadata to a sample: CComQIPtr pMSD = pSample; if (pMSD) { MediaSideDataHDR10Plus md{}; // ... fill md ... pMSD->SetSideData(IID_MediaSideDataHDR10Plus, (const BYTE*)&md, sizeof(md)); } // Renderer/consumer side — read it back: const BYTE* pData = nullptr; size_t size = 0; if (SUCCEEDED(pMSD->GetSideData(IID_MediaSideDataHDR10Plus, &pData, &size))) { const auto* md = reinterpret_cast(pData); } ``` -------------------------------- ### DllMain implementation Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/dll-entry-points.md Initializes and uninitializes minhook on process attach/detach, then delegates to the base-class DllEntryPoint. Used for API hooking in frame-presentation/sync helpers. ```cpp BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD dwReason, LPVOID pReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: MH_Initialize(); break; // minhook case DLL_PROCESS_DETACH: MH_Uninitialize(); break; } return DllEntryPoint(hDllHandle, dwReason, pReserved); } ``` -------------------------------- ### IVideoWindow implemented methods Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declarations for the implemented subset of IVideoWindow methods. put_Owner must be called before Run; put_MessageDrain/get_MessageDrain return VFW_E_NOT_CONNECTED when input pin not connected; SetWindowPosition toggles fullscreen modes. ```cpp STDMETHODIMP put_Owner(OAHWND Owner); // 1143 — must be called before Run STDMETHODIMP get_Owner(OAHWND *Owner); STDMETHODIMP put_MessageDrain(OAHWND Drain); // 1160 STDMETHODIMP get_MessageDrain(OAHWND* Drain); STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height); // 1179 ``` -------------------------------- ### IVideoRenderer interface methods Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declares the custom IVideoRenderer interface methods for retrieving video processor info, active state, settings, and saving settings. GetActive returns true when the input pin is connected. GetSettings copies current settings, SetSettings stores them and re-renders while paused, and SaveSettings writes to the registry. ```cpp STDMETHODIMP GetVideoProcessorInfo(std::wstring& str); // 1279 STDMETHODIMP_(bool) GetActive(); // 1284 STDMETHODIMP_(void) GetSettings(Settings_t& setings); // 1289 STDMETHODIMP_(void) SetSettings(const Settings_t& setings); // 1294 STDMETHODIMP SaveSettings(); // 1311 ``` -------------------------------- ### Toggle stats display at runtime via IExFilterConfig Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Shows how to toggle the stats display at runtime using the IExFilterConfig interface. It reads the current 'statsEnable' field and flips its value. ```cpp // Toggle stats display at runtime (host side): CComQIPtr pCfg = pFilter; bool on = false; pCfg->Flt_GetBool("statsEnable", &on); pCfg->Flt_SetBool("statsEnable", !on); ``` -------------------------------- ### Version macros in Include/Version.h Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/dll-entry-points.md Defines the version numbers and strings for the renderer. REV_NUM, REV_DATE, REV_HASH, and REV_BRANCH are generated by update_revision.cmd and come from revision.h. The packed version value reported by Flt_GetInt64("version") packs the same four components into a 64-bit value. ```cpp #define VER_RELEASE 0 #define VER_MAJOR 0 #define VER_MINOR 10 #define VER_BUILD 10 #define VERSION_NUM VER_MAJOR,VER_MINOR,VER_BUILD,REV_NUM #define VERSION_STR MAKE_STR(VER_MAJOR) "." MAKE_STR(VER_MINOR) "." MAKE_STR(VER_BUILD) "." MAKE_STR(REV_NUM) ``` -------------------------------- ### IVideoRenderer::SaveSettings Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Writes all settings as DWORD values under HKEY_CURRENT_USER\Software\MPC-BE Filters\MPC Video Renderer. ```APIDOC ## [COM] IVideoRenderer::SaveSettings ### Description Writes all settings as DWORD values under HKEY_CURRENT_USER\Software\MPC-BE Filters\MPC Video Renderer. ### Method SaveSettings ### Interface IVideoRenderer (IID 1AB00F10-5F55-42AC-B53F-38649F11BE3E) ### Parameters None. ### Return Value - **S_OK** - Success. ### Remarks Full key table is documented in configuration.md. ``` -------------------------------- ### Processor type identifiers (VP_DX9, VP_DX11, VP_DXVA2, etc.) Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/video-processor.md Defines integer constants for processor types. VP_DX9 and VP_DX11 are used by Type() and Flt_GetInt("renderType"), while the internal backend modes (VP_DXVA2, VP_D3D9_SHADER, VP_D3D11, VP_D3D11_SHADER) are defined in Helper.h. ```cpp // Source/VideoProcessor.h enum : int { VP_DX9 = 9, VP_DX11 = 11 }; ``` ```cpp // Source/Helper.h enum { VP_DXVA2 = 1, VP_D3D9_SHADER, VP_D3D11, VP_D3D11_SHADER }; // internal backend modes ``` -------------------------------- ### ID3DFullscreenControl SetD3DFullscreen and GetD3DFullscreen declarations Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declares the methods for the ID3DFullscreenControl interface, which is only exposed when d3dFullscreenControl is enabled. These methods set and read the internal fullscreen flag used to select the target window. ```cpp STDMETHODIMP SetD3DFullscreen(bool bEnabled); // 1610 STDMETHODIMP GetD3DFullscreen(bool* pbEnabled); // 1616 ``` -------------------------------- ### IKsPropertySet interface methods Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declarations for the IKsPropertySet interface methods implemented by the renderer. These methods handle property sets like AM_KSPROPSETID_CopyProt and AM_KSPROPSETID_FrameStep, returning S_OK for supported operations and E_PROP_SET_UNSUPPORTED/E_PROP_ID_UNSUPPORTED otherwise. ```cpp STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength); STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned); STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport); ``` -------------------------------- ### CMpcVideoRenderer class declaration Source: https://github.com/aleksoid1978/videorenderer/blob/master/_autodocs/api-reference/cm-pc-video-renderer.md Declares the CMpcVideoRenderer class with its COM UUID and multiple inherited interfaces, including CBaseVideoRenderer2, IKsPropertySet, IMFGetService, IBasicVideo2, IVideoWindow, ISpecifyPropertyPages, IVideoRenderer, ISubRender, ISubRender11, CExFilterConfigImpl, ID3DFullscreenControl, and ISubRenderConsumer2. ```cpp class __declspec(uuid("71F080AA-8661-4093-B15E-4F6903E77D0A")) CMpcVideoRenderer : public CBaseVideoRenderer2 , public IKsPropertySet , public IMFGetService , public IBasicVideo2 , public IVideoWindow , public ISpecifyPropertyPages , public IVideoRenderer , public ISubRender , public ISubRender11 , public CExFilterConfigImpl , public ID3DFullscreenControl , public ISubRenderConsumer2 ```