quartz/avidec: Reimplement the AVI decoder directly on top of strmbase_filter.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1ac3fe36c2
commit
ad13ce161a
|
@ -38,51 +38,51 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
||||||
|
|
||||||
typedef struct AVIDecImpl
|
typedef struct AVIDecImpl
|
||||||
{
|
{
|
||||||
TransformFilter tf;
|
struct strmbase_filter filter;
|
||||||
|
CRITICAL_SECTION stream_cs;
|
||||||
|
|
||||||
|
struct strmbase_source source;
|
||||||
|
IQualityControl source_IQualityControl_iface;
|
||||||
|
IUnknown *seeking;
|
||||||
|
|
||||||
|
struct strmbase_sink sink;
|
||||||
|
|
||||||
|
AM_MEDIA_TYPE mt;
|
||||||
HIC hvid;
|
HIC hvid;
|
||||||
BITMAPINFOHEADER* pBihIn;
|
BITMAPINFOHEADER* pBihIn;
|
||||||
BITMAPINFOHEADER* pBihOut;
|
BITMAPINFOHEADER* pBihOut;
|
||||||
REFERENCE_TIME late;
|
REFERENCE_TIME late;
|
||||||
} AVIDecImpl;
|
} AVIDecImpl;
|
||||||
|
|
||||||
static inline AVIDecImpl *impl_from_TransformFilter( TransformFilter *iface )
|
static AVIDecImpl *impl_from_strmbase_filter(struct strmbase_filter *iface)
|
||||||
{
|
{
|
||||||
return CONTAINING_RECORD(iface, AVIDecImpl, tf);
|
return CONTAINING_RECORD(iface, AVIDecImpl, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_StartStreaming(TransformFilter* pTransformFilter)
|
static HRESULT avi_decompressor_sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
||||||
{
|
{
|
||||||
AVIDecImpl* This = impl_from_TransformFilter(pTransformFilter);
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface->filter);
|
||||||
DWORD result;
|
|
||||||
|
|
||||||
TRACE("(%p)->()\n", This);
|
if (IsEqualGUID(iid, &IID_IMemInputPin))
|
||||||
This->late = -1;
|
*out = &filter->sink.IMemInputPin_iface;
|
||||||
|
|
||||||
result = ICDecompressBegin(This->hvid, This->pBihIn, This->pBihOut);
|
|
||||||
if (result != ICERR_OK)
|
|
||||||
{
|
|
||||||
ERR("Cannot start processing (%d)\n", result);
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_EndFlush(TransformFilter *pTransformFilter) {
|
|
||||||
AVIDecImpl* This = impl_from_TransformFilter(pTransformFilter);
|
|
||||||
This->late = -1;
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_NotifyDrop(TransformFilter *pTransformFilter, IBaseFilter *sender, Quality qm) {
|
|
||||||
AVIDecImpl *This = impl_from_TransformFilter(pTransformFilter);
|
|
||||||
|
|
||||||
EnterCriticalSection(&This->tf.filter.csFilter);
|
|
||||||
if (qm.Late > 0)
|
|
||||||
This->late = qm.Late + qm.TimeStamp;
|
|
||||||
else
|
else
|
||||||
This->late = -1;
|
return E_NOINTERFACE;
|
||||||
LeaveCriticalSection(&This->tf.filter.csFilter);
|
|
||||||
|
IUnknown_AddRef((IUnknown *)*out);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT avi_decompressor_sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT avi_decompressor_sink_end_flush(struct strmbase_sink *iface)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface->pin.filter);
|
||||||
|
filter->late = -1;
|
||||||
|
if (filter->source.pin.peer)
|
||||||
|
return IPin_EndFlush(filter->source.pin.peer);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ static int AVIDec_DropSample(AVIDecImpl *This, REFERENCE_TIME tStart) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
static HRESULT WINAPI avi_decompressor_sink_Receive(struct strmbase_sink *iface, IMediaSample *pSample)
|
||||||
{
|
{
|
||||||
AVIDecImpl* This = impl_from_TransformFilter(tf);
|
AVIDecImpl *This = impl_from_strmbase_filter(iface->pin.filter);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DWORD res;
|
DWORD res;
|
||||||
IMediaSample* pOutSample = NULL;
|
IMediaSample* pOutSample = NULL;
|
||||||
|
@ -111,10 +111,29 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
||||||
LONGLONG tStart, tStop;
|
LONGLONG tStart, tStop;
|
||||||
DWORD flags = 0;
|
DWORD flags = 0;
|
||||||
|
|
||||||
|
/* We do not expect pin connection state to change while the filter is
|
||||||
|
* running. This guarantee is necessary, since otherwise we would have to
|
||||||
|
* take the filter lock, and we can't take the filter lock from a streaming
|
||||||
|
* thread. */
|
||||||
|
if (!This->source.pMemInputPin)
|
||||||
|
{
|
||||||
|
WARN("Source is not connected, returning VFW_E_NOT_CONNECTED.\n");
|
||||||
|
return VFW_E_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (This->filter.state == State_Stopped)
|
||||||
|
return VFW_E_WRONG_STATE;
|
||||||
|
|
||||||
|
if (This->sink.flushing)
|
||||||
|
return S_FALSE;
|
||||||
|
|
||||||
|
EnterCriticalSection(&This->stream_cs);
|
||||||
|
|
||||||
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
|
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERR("Cannot get pointer to sample data (%x)\n", hr);
|
ERR("Cannot get pointer to sample data (%x)\n", hr);
|
||||||
|
LeaveCriticalSection(&This->stream_cs);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +144,10 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
||||||
/* Update input size to match sample size */
|
/* Update input size to match sample size */
|
||||||
This->pBihIn->biSizeImage = cbSrcStream;
|
This->pBihIn->biSizeImage = cbSrcStream;
|
||||||
|
|
||||||
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->tf.source, &pOutSample, NULL, NULL, 0);
|
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->source, &pOutSample, NULL, NULL, 0);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
ERR("Unable to get delivery buffer (%x)\n", hr);
|
ERR("Unable to get delivery buffer (%x)\n", hr);
|
||||||
|
LeaveCriticalSection(&This->stream_cs);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,12 +158,14 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
ERR("Unable to get pointer to buffer (%x)\n", hr);
|
ERR("Unable to get pointer to buffer (%x)\n", hr);
|
||||||
IMediaSample_Release(pOutSample);
|
IMediaSample_Release(pOutSample);
|
||||||
|
LeaveCriticalSection(&This->stream_cs);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
cbDstStream = IMediaSample_GetSize(pOutSample);
|
cbDstStream = IMediaSample_GetSize(pOutSample);
|
||||||
if (cbDstStream < This->pBihOut->biSizeImage) {
|
if (cbDstStream < This->pBihOut->biSizeImage) {
|
||||||
ERR("Sample size is too small %d < %d\n", cbDstStream, This->pBihOut->biSizeImage);
|
ERR("Sample size is too small %d < %d\n", cbDstStream, This->pBihOut->biSizeImage);
|
||||||
IMediaSample_Release(pOutSample);
|
IMediaSample_Release(pOutSample);
|
||||||
|
LeaveCriticalSection(&This->stream_cs);
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +184,7 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
||||||
/* Drop sample if it's intended to be dropped */
|
/* Drop sample if it's intended to be dropped */
|
||||||
if (flags & ICDECOMPRESS_HURRYUP) {
|
if (flags & ICDECOMPRESS_HURRYUP) {
|
||||||
IMediaSample_Release(pOutSample);
|
IMediaSample_Release(pOutSample);
|
||||||
|
LeaveCriticalSection(&This->stream_cs);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,36 +206,18 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
||||||
else
|
else
|
||||||
IMediaSample_SetMediaTime(pOutSample, NULL, NULL);
|
IMediaSample_SetMediaTime(pOutSample, NULL, NULL);
|
||||||
|
|
||||||
hr = IMemInputPin_Receive(This->tf.source.pMemInputPin, pOutSample);
|
hr = IMemInputPin_Receive(This->source.pMemInputPin, pOutSample);
|
||||||
if (hr != S_OK && hr != VFW_E_NOT_CONNECTED)
|
if (hr != S_OK && hr != VFW_E_NOT_CONNECTED)
|
||||||
ERR("Error sending sample (%x)\n", hr);
|
ERR("Error sending sample (%x)\n", hr);
|
||||||
|
|
||||||
IMediaSample_Release(pOutSample);
|
IMediaSample_Release(pOutSample);
|
||||||
|
LeaveCriticalSection(&This->stream_cs);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_StopStreaming(TransformFilter* pTransformFilter)
|
static HRESULT avi_decompressor_sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *pmt)
|
||||||
{
|
{
|
||||||
AVIDecImpl* This = impl_from_TransformFilter(pTransformFilter);
|
AVIDecImpl *This = impl_from_strmbase_filter(iface->pin.filter);
|
||||||
DWORD result;
|
|
||||||
|
|
||||||
TRACE("(%p)->()\n", This);
|
|
||||||
|
|
||||||
if (!This->hvid)
|
|
||||||
return S_OK;
|
|
||||||
|
|
||||||
result = ICDecompressEnd(This->hvid);
|
|
||||||
if (result != ICERR_OK)
|
|
||||||
{
|
|
||||||
ERR("Cannot stop processing (%d)\n", result);
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT avi_dec_connect_sink(TransformFilter *tf, const AM_MEDIA_TYPE *pmt)
|
|
||||||
{
|
|
||||||
AVIDecImpl* This = impl_from_TransformFilter(tf);
|
|
||||||
HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
|
HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
|
||||||
|
|
||||||
/* Check root (GUID w/o FOURCC) */
|
/* Check root (GUID w/o FOURCC) */
|
||||||
|
@ -233,12 +238,11 @@ static HRESULT avi_dec_connect_sink(TransformFilter *tf, const AM_MEDIA_TYPE *pm
|
||||||
This->hvid = ICLocate(pmt->majortype.Data1, pmt->subtype.Data1, bmi, NULL, ICMODE_DECOMPRESS);
|
This->hvid = ICLocate(pmt->majortype.Data1, pmt->subtype.Data1, bmi, NULL, ICMODE_DECOMPRESS);
|
||||||
if (This->hvid)
|
if (This->hvid)
|
||||||
{
|
{
|
||||||
AM_MEDIA_TYPE* outpmt = &This->tf.pmt;
|
|
||||||
const CLSID* outsubtype;
|
const CLSID* outsubtype;
|
||||||
DWORD bih_size;
|
DWORD bih_size;
|
||||||
DWORD output_depth = bmi->biBitCount;
|
DWORD output_depth = bmi->biBitCount;
|
||||||
DWORD result;
|
DWORD result;
|
||||||
FreeMediaType(outpmt);
|
FreeMediaType(&This->mt);
|
||||||
|
|
||||||
switch(bmi->biBitCount)
|
switch(bmi->biBitCount)
|
||||||
{
|
{
|
||||||
|
@ -283,13 +287,13 @@ static HRESULT avi_dec_connect_sink(TransformFilter *tf, const AM_MEDIA_TYPE *pm
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update output media type */
|
/* Update output media type */
|
||||||
CopyMediaType(outpmt, pmt);
|
CopyMediaType(&This->mt, pmt);
|
||||||
outpmt->subtype = *outsubtype;
|
This->mt.subtype = *outsubtype;
|
||||||
|
|
||||||
if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
|
if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
|
||||||
memcpy(&(((VIDEOINFOHEADER *)outpmt->pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize);
|
memcpy(&(((VIDEOINFOHEADER *)This->mt.pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize);
|
||||||
else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
|
else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
|
||||||
memcpy(&(((VIDEOINFOHEADER2 *)outpmt->pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize);
|
memcpy(&(((VIDEOINFOHEADER2 *)This->mt.pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize);
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
||||||
|
@ -305,29 +309,71 @@ failed:
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_BreakConnect(TransformFilter *tf, PIN_DIRECTION dir)
|
static void avi_decompressor_sink_disconnect(struct strmbase_sink *iface)
|
||||||
{
|
{
|
||||||
AVIDecImpl *This = impl_from_TransformFilter(tf);
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface->pin.filter);
|
||||||
|
|
||||||
TRACE("(%p)->()\n", This);
|
if (filter->hvid)
|
||||||
|
ICClose(filter->hvid);
|
||||||
|
CoTaskMemFree(filter->pBihIn);
|
||||||
|
CoTaskMemFree(filter->pBihOut);
|
||||||
|
filter->hvid = NULL;
|
||||||
|
filter->pBihIn = NULL;
|
||||||
|
filter->pBihOut = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (dir == PINDIR_INPUT)
|
static const struct strmbase_sink_ops sink_ops =
|
||||||
{
|
{
|
||||||
if (This->hvid)
|
.base.pin_query_interface = avi_decompressor_sink_query_interface,
|
||||||
ICClose(This->hvid);
|
.base.pin_query_accept = avi_decompressor_sink_query_accept,
|
||||||
CoTaskMemFree(This->pBihIn);
|
.base.pin_get_media_type = strmbase_pin_get_media_type,
|
||||||
CoTaskMemFree(This->pBihOut);
|
.pfnReceive = avi_decompressor_sink_Receive,
|
||||||
This->hvid = NULL;
|
.sink_connect = avi_decompressor_sink_connect,
|
||||||
This->pBihIn = NULL;
|
.sink_disconnect = avi_decompressor_sink_disconnect,
|
||||||
This->pBihOut = NULL;
|
.sink_end_flush = avi_decompressor_sink_end_flush,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
static HRESULT avi_decompressor_source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface->filter);
|
||||||
|
|
||||||
|
if (IsEqualGUID(iid, &IID_IQualityControl))
|
||||||
|
*out = &filter->source_IQualityControl_iface;
|
||||||
|
else if (IsEqualGUID(iid, &IID_IMediaSeeking))
|
||||||
|
return IUnknown_QueryInterface(filter->seeking, iid, out);
|
||||||
|
else
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
|
||||||
|
IUnknown_AddRef((IUnknown *)*out);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI AVIDec_DecideBufferSize(TransformFilter *tf, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
static HRESULT avi_decompressor_source_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
|
||||||
{
|
{
|
||||||
AVIDecImpl *pAVI = impl_from_TransformFilter(tf);
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface->filter);
|
||||||
|
|
||||||
|
if (IsEqualGUID(&mt->majortype, &filter->mt.majortype)
|
||||||
|
&& (IsEqualGUID(&mt->subtype, &filter->mt.subtype)
|
||||||
|
|| IsEqualGUID(&filter->mt.subtype, &GUID_NULL)))
|
||||||
|
return S_OK;
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT avi_decompressor_source_get_media_type(struct strmbase_pin *iface,
|
||||||
|
unsigned int index, AM_MEDIA_TYPE *mt)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface->filter);
|
||||||
|
|
||||||
|
if (index)
|
||||||
|
return VFW_S_NO_MORE_ITEMS;
|
||||||
|
CopyMediaType(mt, &filter->mt);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI avi_decompressor_source_DecideBufferSize(struct strmbase_source *iface,
|
||||||
|
IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
||||||
|
{
|
||||||
|
AVIDecImpl *pAVI = impl_from_strmbase_filter(iface->pin.filter);
|
||||||
ALLOCATOR_PROPERTIES actual;
|
ALLOCATOR_PROPERTIES actual;
|
||||||
|
|
||||||
if (!ppropInputRequest->cbAlign)
|
if (!ppropInputRequest->cbAlign)
|
||||||
|
@ -342,35 +388,185 @@ static HRESULT WINAPI AVIDec_DecideBufferSize(TransformFilter *tf, IMemAllocator
|
||||||
return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
|
return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TransformFilterFuncTable AVIDec_FuncsTable = {
|
static const struct strmbase_source_ops source_ops =
|
||||||
.pfnDecideBufferSize = AVIDec_DecideBufferSize,
|
{
|
||||||
.pfnStartStreaming = AVIDec_StartStreaming,
|
.base.pin_query_interface = avi_decompressor_source_query_interface,
|
||||||
.pfnReceive = AVIDec_Receive,
|
.base.pin_query_accept = avi_decompressor_source_query_accept,
|
||||||
.pfnStopStreaming = AVIDec_StopStreaming,
|
.base.pin_get_media_type = avi_decompressor_source_get_media_type,
|
||||||
.transform_connect_sink = avi_dec_connect_sink,
|
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
|
||||||
.pfnBreakConnect = AVIDec_BreakConnect,
|
.pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
|
||||||
.pfnEndFlush = AVIDec_EndFlush,
|
.pfnDecideBufferSize = avi_decompressor_source_DecideBufferSize,
|
||||||
.pfnNotify = AVIDec_NotifyDrop,
|
};
|
||||||
|
|
||||||
|
static AVIDecImpl *impl_from_source_IQualityControl(IQualityControl *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, AVIDecImpl, source_IQualityControl_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI acm_wrapper_source_qc_QueryInterface(IQualityControl *iface,
|
||||||
|
REFIID iid, void **out)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_source_IQualityControl(iface);
|
||||||
|
return IPin_QueryInterface(&filter->source.pin.IPin_iface, iid, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI acm_wrapper_source_qc_AddRef(IQualityControl *iface)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_source_IQualityControl(iface);
|
||||||
|
return IPin_AddRef(&filter->source.pin.IPin_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI acm_wrapper_source_qc_Release(IQualityControl *iface)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_source_IQualityControl(iface);
|
||||||
|
return IPin_Release(&filter->source.pin.IPin_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI acm_wrapper_source_qc_Notify(IQualityControl *iface,
|
||||||
|
IBaseFilter *sender, Quality q)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_source_IQualityControl(iface);
|
||||||
|
|
||||||
|
TRACE("filter %p, sender %p, type %#x, proportion %u, late %s, timestamp %s.\n",
|
||||||
|
filter, sender, q.Type, q.Proportion, debugstr_time(q.Late), debugstr_time(q.TimeStamp));
|
||||||
|
|
||||||
|
EnterCriticalSection(&filter->stream_cs);
|
||||||
|
if (q.Late > 0)
|
||||||
|
filter->late = q.Late + q.TimeStamp;
|
||||||
|
else
|
||||||
|
filter->late = -1;
|
||||||
|
LeaveCriticalSection(&filter->stream_cs);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI acm_wrapper_source_qc_SetSink(IQualityControl *iface, IQualityControl *sink)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_source_IQualityControl(iface);
|
||||||
|
|
||||||
|
TRACE("filter %p, sink %p.\n", filter, sink);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const IQualityControlVtbl source_qc_vtbl =
|
||||||
|
{
|
||||||
|
acm_wrapper_source_qc_QueryInterface,
|
||||||
|
acm_wrapper_source_qc_AddRef,
|
||||||
|
acm_wrapper_source_qc_Release,
|
||||||
|
acm_wrapper_source_qc_Notify,
|
||||||
|
acm_wrapper_source_qc_SetSink,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct strmbase_pin *avi_decompressor_get_pin(struct strmbase_filter *iface, unsigned int index)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface);
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
return &filter->sink.pin;
|
||||||
|
else if (index == 1)
|
||||||
|
return &filter->source.pin;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void avi_decompressor_destroy(struct strmbase_filter *iface)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface);
|
||||||
|
|
||||||
|
if (filter->sink.pin.peer)
|
||||||
|
IPin_Disconnect(filter->sink.pin.peer);
|
||||||
|
IPin_Disconnect(&filter->sink.pin.IPin_iface);
|
||||||
|
|
||||||
|
if (filter->source.pin.peer)
|
||||||
|
IPin_Disconnect(filter->source.pin.peer);
|
||||||
|
IPin_Disconnect(&filter->source.pin.IPin_iface);
|
||||||
|
|
||||||
|
strmbase_sink_cleanup(&filter->sink);
|
||||||
|
strmbase_source_cleanup(&filter->source);
|
||||||
|
|
||||||
|
filter->stream_cs.DebugInfo->Spare[0] = 0;
|
||||||
|
DeleteCriticalSection(&filter->stream_cs);
|
||||||
|
FreeMediaType(&filter->mt);
|
||||||
|
IUnknown_Release(filter->seeking);
|
||||||
|
strmbase_filter_cleanup(&filter->filter);
|
||||||
|
free(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT avi_decompressor_init_stream(struct strmbase_filter *iface)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface);
|
||||||
|
LRESULT res;
|
||||||
|
|
||||||
|
filter->late = -1;
|
||||||
|
|
||||||
|
if ((res = ICDecompressBegin(filter->hvid, filter->pBihIn, filter->pBihOut)))
|
||||||
|
{
|
||||||
|
ERR("ICDecompressBegin() failed, error %ld.\n", res);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseOutputPinImpl_Active(&filter->source);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT avi_decompressor_cleanup_stream(struct strmbase_filter *iface)
|
||||||
|
{
|
||||||
|
AVIDecImpl *filter = impl_from_strmbase_filter(iface);
|
||||||
|
LRESULT res;
|
||||||
|
|
||||||
|
if (filter->hvid && (res = ICDecompressEnd(filter->hvid)))
|
||||||
|
{
|
||||||
|
ERR("ICDecompressEnd() failed, error %ld.\n", res);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseOutputPinImpl_Inactive(&filter->source);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct strmbase_filter_ops filter_ops =
|
||||||
|
{
|
||||||
|
.filter_get_pin = avi_decompressor_get_pin,
|
||||||
|
.filter_destroy = avi_decompressor_destroy,
|
||||||
|
.filter_init_stream = avi_decompressor_init_stream,
|
||||||
|
.filter_cleanup_stream = avi_decompressor_cleanup_stream,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT AVIDec_create(IUnknown *outer, void **out)
|
HRESULT AVIDec_create(IUnknown *outer, void **out)
|
||||||
{
|
{
|
||||||
|
AVIDecImpl *object;
|
||||||
|
ISeekingPassThru *passthrough;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
AVIDecImpl * This;
|
|
||||||
|
|
||||||
*out = NULL;
|
if (!(object = calloc(1, sizeof(*object))))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
hr = strmbase_transform_create(sizeof(AVIDecImpl), outer, &CLSID_AVIDec,
|
strmbase_filter_init(&object->filter, outer, &CLSID_AVIDec, &filter_ops);
|
||||||
&AVIDec_FuncsTable, (IBaseFilter **)&This);
|
|
||||||
|
|
||||||
if (FAILED(hr))
|
InitializeCriticalSection(&object->stream_cs);
|
||||||
|
object->stream_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": avi_decompressor.stream_cs");
|
||||||
|
|
||||||
|
strmbase_sink_init(&object->sink, &object->filter, L"In", &sink_ops, NULL);
|
||||||
|
|
||||||
|
strmbase_source_init(&object->source, &object->filter, L"Out", &source_ops);
|
||||||
|
object->source_IQualityControl_iface.lpVtbl = &source_qc_vtbl;
|
||||||
|
|
||||||
|
if (FAILED(hr = CoCreateInstance(&CLSID_SeekingPassThru,
|
||||||
|
(IUnknown *)&object->source.pin.IPin_iface, CLSCTX_INPROC_SERVER,
|
||||||
|
&IID_IUnknown, (void **)&object->seeking)))
|
||||||
|
{
|
||||||
|
strmbase_sink_cleanup(&object->sink);
|
||||||
|
strmbase_source_cleanup(&object->source);
|
||||||
|
strmbase_filter_cleanup(&object->filter);
|
||||||
|
free(object);
|
||||||
return hr;
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
This->hvid = NULL;
|
IUnknown_QueryInterface(object->seeking, &IID_ISeekingPassThru, (void **)&passthrough);
|
||||||
This->pBihIn = NULL;
|
ISeekingPassThru_Init(passthrough, FALSE, &object->sink.pin.IPin_iface);
|
||||||
This->pBihOut = NULL;
|
ISeekingPassThru_Release(passthrough);
|
||||||
|
|
||||||
*out = &This->tf.filter.IUnknown_inner;
|
TRACE("Created AVI decompressor %p.\n", object);
|
||||||
|
*out = &object->filter.IUnknown_inner;
|
||||||
|
|
||||||
return hr;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,7 +644,7 @@ static void test_unconnected_filter_state(void)
|
||||||
todo_wine ok(state == State_Paused, "Got state %u.\n", state);
|
todo_wine ok(state == State_Paused, "Got state %u.\n", state);
|
||||||
|
|
||||||
hr = IBaseFilter_Stop(filter);
|
hr = IBaseFilter_Stop(filter);
|
||||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IBaseFilter_GetState(filter, 0, &state);
|
hr = IBaseFilter_GetState(filter, 0, &state);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
@ -658,7 +658,7 @@ static void test_unconnected_filter_state(void)
|
||||||
todo_wine ok(state == State_Running, "Got state %u.\n", state);
|
todo_wine ok(state == State_Running, "Got state %u.\n", state);
|
||||||
|
|
||||||
hr = IBaseFilter_Stop(filter);
|
hr = IBaseFilter_Stop(filter);
|
||||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IBaseFilter_GetState(filter, 0, &state);
|
hr = IBaseFilter_GetState(filter, 0, &state);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
Loading…
Reference in New Issue