[PATCH 2/5] quartz: Retrieve the video format directly from the pin.
Zebediah Figura
z.figura12 at gmail.com
Wed May 6 19:28:49 CDT 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/quartz/quartz_private.h | 3 +--
dlls/quartz/video.c | 43 ++++++++++++++++++++----------------
dlls/quartz/videorenderer.c | 23 -------------------
dlls/quartz/vmr9.c | 23 -------------------
4 files changed, 25 insertions(+), 67 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h
index 9c39b642c48..2aca6000742 100644
--- a/dlls/quartz/quartz_private.h
+++ b/dlls/quartz/quartz_private.h
@@ -31,6 +31,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "dshow.h"
+#include "dvdmedia.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/strmbase.h"
@@ -174,7 +175,6 @@ typedef struct tagBaseControlVideo
typedef HRESULT (WINAPI *BaseControlVideo_GetSourceRect)(BaseControlVideo* This, RECT *pSourceRect);
typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage);
typedef HRESULT (WINAPI *BaseControlVideo_GetTargetRect)(BaseControlVideo* This, RECT *pTargetRect);
-typedef VIDEOINFOHEADER* (WINAPI *BaseControlVideo_GetVideoFormat)(BaseControlVideo* This);
typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultSourceRect)(BaseControlVideo* This);
typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultTargetRect)(BaseControlVideo* This);
typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This);
@@ -187,7 +187,6 @@ typedef struct BaseControlVideoFuncTable
BaseControlVideo_GetSourceRect pfnGetSourceRect;
BaseControlVideo_GetStaticImage pfnGetStaticImage;
BaseControlVideo_GetTargetRect pfnGetTargetRect;
- BaseControlVideo_GetVideoFormat pfnGetVideoFormat;
BaseControlVideo_IsDefaultSourceRect pfnIsDefaultSourceRect;
BaseControlVideo_IsDefaultTargetRect pfnIsDefaultTargetRect;
BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect;
diff --git a/dlls/quartz/video.c b/dlls/quartz/video.c
index 11baee261d5..213e3ce92db 100644
--- a/dlls/quartz/video.c
+++ b/dlls/quartz/video.c
@@ -120,9 +120,24 @@ static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID i
return hr;
}
+static const VIDEOINFOHEADER *get_video_format(BaseControlVideo *video)
+{
+ /* Members of VIDEOINFOHEADER up to bmiHeader are identical to those of
+ * VIDEOINFOHEADER2. */
+ return (const VIDEOINFOHEADER *)video->pPin->mt.pbFormat;
+}
+
+static const BITMAPINFOHEADER *get_bitmap_header(BaseControlVideo *video)
+{
+ const AM_MEDIA_TYPE *mt = &video->pPin->mt;
+ if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
+ return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader;
+ else
+ return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader;
+}
+
static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame)
{
- VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
if (!pAvgTimePerFrame)
@@ -132,14 +147,12 @@ static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIM
TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
- vih = This->pFuncsTable->pfnGetVideoFormat(This);
- *pAvgTimePerFrame = vih->AvgTimePerFrame;
+ *pAvgTimePerFrame = get_video_format(This)->AvgTimePerFrame;
return S_OK;
}
static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate)
{
- VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
@@ -149,14 +162,12 @@ static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate
if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED;
- vih = This->pFuncsTable->pfnGetVideoFormat(This);
- *pBitRate = vih->dwBitRate;
+ *pBitRate = get_video_format(This)->dwBitRate;
return S_OK;
}
static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate)
{
- VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
@@ -166,37 +177,32 @@ static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBi
if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED;
- vih = This->pFuncsTable->pfnGetVideoFormat(This);
- *pBitErrorRate = vih->dwBitErrorRate;
+ *pBitErrorRate = get_video_format(This)->dwBitErrorRate;
return S_OK;
}
static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth)
{
- VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
if (!pVideoWidth)
return E_POINTER;
- vih = This->pFuncsTable->pfnGetVideoFormat(This);
- *pVideoWidth = vih->bmiHeader.biWidth;
+ *pVideoWidth = get_bitmap_header(This)->biWidth;
return S_OK;
}
static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight)
{
- VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
if (!pVideoHeight)
return E_POINTER;
- vih = This->pFuncsTable->pfnGetVideoFormat(This);
- *pVideoHeight = abs(vih->bmiHeader.biHeight);
+ *pVideoHeight = abs(get_bitmap_header(This)->biHeight);
return S_OK;
}
@@ -550,16 +556,15 @@ static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *ifa
static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight)
{
- VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
+ const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(This);
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
if (!pWidth || !pHeight)
return E_POINTER;
- vih = This->pFuncsTable->pfnGetVideoFormat(This);
- *pHeight = vih->bmiHeader.biHeight;
- *pWidth = vih->bmiHeader.biWidth;
+ *pHeight = bitmap_header->biHeight;
+ *pWidth = bitmap_header->biWidth;
return S_OK;
}
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index 6e31e196951..b7a82e4faa3 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -352,28 +352,6 @@ static HRESULT WINAPI VideoRenderer_GetTargetRect(BaseControlVideo* iface, RECT
return S_OK;
}
-static VIDEOINFOHEADER* WINAPI VideoRenderer_GetVideoFormat(BaseControlVideo* iface)
-{
- struct video_renderer *This = impl_from_BaseControlVideo(iface);
- AM_MEDIA_TYPE *pmt;
-
- TRACE("(%p/%p)\n", This, iface);
-
- pmt = &This->renderer.sink.pin.mt;
- if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) {
- return (VIDEOINFOHEADER*)pmt->pbFormat;
- } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) {
- static VIDEOINFOHEADER vih;
- VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
- memcpy(&vih,vih2,sizeof(VIDEOINFOHEADER));
- memcpy(&vih.bmiHeader, &vih2->bmiHeader, sizeof(BITMAPINFOHEADER));
- return &vih;
- } else {
- ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt->formattype));
- return NULL;
- }
-}
-
static HRESULT WINAPI VideoRenderer_IsDefaultSourceRect(BaseControlVideo* iface)
{
struct video_renderer *This = impl_from_BaseControlVideo(iface);
@@ -430,7 +408,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
VideoRenderer_GetSourceRect,
VideoRenderer_GetStaticImage,
VideoRenderer_GetTargetRect,
- VideoRenderer_GetVideoFormat,
VideoRenderer_IsDefaultSourceRect,
VideoRenderer_IsDefaultTargetRect,
VideoRenderer_SetDefaultSourceRect,
diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c
index 8fdcb3809be..abca2a03d17 100644
--- a/dlls/quartz/vmr9.c
+++ b/dlls/quartz/vmr9.c
@@ -772,28 +772,6 @@ static HRESULT WINAPI VMR9_GetTargetRect(BaseControlVideo* This, RECT *pTargetRe
return S_OK;
}
-static VIDEOINFOHEADER* WINAPI VMR9_GetVideoFormat(BaseControlVideo* This)
-{
- struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
- AM_MEDIA_TYPE *pmt;
-
- TRACE("(%p/%p)\n", pVMR9, This);
-
- pmt = &pVMR9->renderer.sink.pin.mt;
- if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) {
- return (VIDEOINFOHEADER*)pmt->pbFormat;
- } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) {
- static VIDEOINFOHEADER vih;
- VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
- memcpy(&vih,vih2,sizeof(VIDEOINFOHEADER));
- memcpy(&vih.bmiHeader, &vih2->bmiHeader, sizeof(BITMAPINFOHEADER));
- return &vih;
- } else {
- ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt->formattype));
- return NULL;
- }
-}
-
static HRESULT WINAPI VMR9_IsDefaultSourceRect(BaseControlVideo* This)
{
struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
@@ -850,7 +828,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
VMR9_GetSourceRect,
VMR9_GetStaticImage,
VMR9_GetTargetRect,
- VMR9_GetVideoFormat,
VMR9_IsDefaultSourceRect,
VMR9_IsDefaultTargetRect,
VMR9_SetDefaultSourceRect,
--
2.26.2
More information about the wine-devel
mailing list