quartz: Retrieve the video format directly from the pin.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-05-06 19:28:49 -05:00 committed by Alexandre Julliard
parent 855f17f349
commit 1ba3f252b5
4 changed files with 25 additions and 67 deletions

View File

@ -31,6 +31,7 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "dshow.h" #include "dshow.h"
#include "dvdmedia.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h" #include "wine/heap.h"
#include "wine/strmbase.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_GetSourceRect)(BaseControlVideo* This, RECT *pSourceRect);
typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage); typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage);
typedef HRESULT (WINAPI *BaseControlVideo_GetTargetRect)(BaseControlVideo* This, RECT *pTargetRect); 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_IsDefaultSourceRect)(BaseControlVideo* This);
typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultTargetRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultTargetRect)(BaseControlVideo* This);
typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This);
@ -187,7 +187,6 @@ typedef struct BaseControlVideoFuncTable
BaseControlVideo_GetSourceRect pfnGetSourceRect; BaseControlVideo_GetSourceRect pfnGetSourceRect;
BaseControlVideo_GetStaticImage pfnGetStaticImage; BaseControlVideo_GetStaticImage pfnGetStaticImage;
BaseControlVideo_GetTargetRect pfnGetTargetRect; BaseControlVideo_GetTargetRect pfnGetTargetRect;
BaseControlVideo_GetVideoFormat pfnGetVideoFormat;
BaseControlVideo_IsDefaultSourceRect pfnIsDefaultSourceRect; BaseControlVideo_IsDefaultSourceRect pfnIsDefaultSourceRect;
BaseControlVideo_IsDefaultTargetRect pfnIsDefaultTargetRect; BaseControlVideo_IsDefaultTargetRect pfnIsDefaultTargetRect;
BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect; BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect;

View File

@ -120,9 +120,24 @@ static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID i
return hr; 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) static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame)
{ {
VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface); BaseControlVideo *This = impl_from_IBasicVideo(iface);
if (!pAvgTimePerFrame) if (!pAvgTimePerFrame)
@ -132,14 +147,12 @@ static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIM
TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame); TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
vih = This->pFuncsTable->pfnGetVideoFormat(This); *pAvgTimePerFrame = get_video_format(This)->AvgTimePerFrame;
*pAvgTimePerFrame = vih->AvgTimePerFrame;
return S_OK; return S_OK;
} }
static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate) static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate)
{ {
VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface); BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate); 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) if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED; return VFW_E_NOT_CONNECTED;
vih = This->pFuncsTable->pfnGetVideoFormat(This); *pBitRate = get_video_format(This)->dwBitRate;
*pBitRate = vih->dwBitRate;
return S_OK; return S_OK;
} }
static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate) static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate)
{ {
VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface); BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate); 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) if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED; return VFW_E_NOT_CONNECTED;
vih = This->pFuncsTable->pfnGetVideoFormat(This); *pBitErrorRate = get_video_format(This)->dwBitErrorRate;
*pBitErrorRate = vih->dwBitErrorRate;
return S_OK; return S_OK;
} }
static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth) static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth)
{ {
VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface); BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth); TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
if (!pVideoWidth) if (!pVideoWidth)
return E_POINTER; return E_POINTER;
vih = This->pFuncsTable->pfnGetVideoFormat(This); *pVideoWidth = get_bitmap_header(This)->biWidth;
*pVideoWidth = vih->bmiHeader.biWidth;
return S_OK; return S_OK;
} }
static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight) static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight)
{ {
VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface); BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight); TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
if (!pVideoHeight) if (!pVideoHeight)
return E_POINTER; return E_POINTER;
vih = This->pFuncsTable->pfnGetVideoFormat(This); *pVideoHeight = abs(get_bitmap_header(This)->biHeight);
*pVideoHeight = abs(vih->bmiHeader.biHeight);
return S_OK; 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) static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight)
{ {
VIDEOINFOHEADER *vih;
BaseControlVideo *This = impl_from_IBasicVideo(iface); BaseControlVideo *This = impl_from_IBasicVideo(iface);
const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(This);
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight); TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
if (!pWidth || !pHeight) if (!pWidth || !pHeight)
return E_POINTER; return E_POINTER;
vih = This->pFuncsTable->pfnGetVideoFormat(This); *pHeight = bitmap_header->biHeight;
*pHeight = vih->bmiHeader.biHeight; *pWidth = bitmap_header->biWidth;
*pWidth = vih->bmiHeader.biWidth;
return S_OK; return S_OK;
} }

View File

@ -352,28 +352,6 @@ static HRESULT WINAPI VideoRenderer_GetTargetRect(BaseControlVideo* iface, RECT
return S_OK; 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) static HRESULT WINAPI VideoRenderer_IsDefaultSourceRect(BaseControlVideo* iface)
{ {
struct video_renderer *This = impl_from_BaseControlVideo(iface); struct video_renderer *This = impl_from_BaseControlVideo(iface);
@ -430,7 +408,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
VideoRenderer_GetSourceRect, VideoRenderer_GetSourceRect,
VideoRenderer_GetStaticImage, VideoRenderer_GetStaticImage,
VideoRenderer_GetTargetRect, VideoRenderer_GetTargetRect,
VideoRenderer_GetVideoFormat,
VideoRenderer_IsDefaultSourceRect, VideoRenderer_IsDefaultSourceRect,
VideoRenderer_IsDefaultTargetRect, VideoRenderer_IsDefaultTargetRect,
VideoRenderer_SetDefaultSourceRect, VideoRenderer_SetDefaultSourceRect,

View File

@ -772,28 +772,6 @@ static HRESULT WINAPI VMR9_GetTargetRect(BaseControlVideo* This, RECT *pTargetRe
return S_OK; 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) static HRESULT WINAPI VMR9_IsDefaultSourceRect(BaseControlVideo* This)
{ {
struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
@ -850,7 +828,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
VMR9_GetSourceRect, VMR9_GetSourceRect,
VMR9_GetStaticImage, VMR9_GetStaticImage,
VMR9_GetTargetRect, VMR9_GetTargetRect,
VMR9_GetVideoFormat,
VMR9_IsDefaultSourceRect, VMR9_IsDefaultSourceRect,
VMR9_IsDefaultTargetRect, VMR9_IsDefaultTargetRect,
VMR9_SetDefaultSourceRect, VMR9_SetDefaultSourceRect,