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 "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;

View File

@ -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;
}

View File

@ -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,

View File

@ -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,