2004-08-24 04:28:35 +02:00
|
|
|
/*
|
|
|
|
* AVI Decompressor (VFW decompressors wrapper)
|
|
|
|
*
|
2005-01-31 17:24:00 +01:00
|
|
|
* Copyright 2004-2005 Christian Costa
|
2004-08-24 04:28:35 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-08-24 04:28:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "pin.h"
|
|
|
|
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "amvideo.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "dshow.h"
|
|
|
|
#include "strmif.h"
|
|
|
|
#include "vfwmsgs.h"
|
|
|
|
#include "vfw.h"
|
2008-06-20 06:17:08 +02:00
|
|
|
#include "dvdmedia.h"
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
typedef struct AVIDecImpl
|
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter tf;
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
HIC hvid;
|
2004-11-29 18:50:23 +01:00
|
|
|
BITMAPINFOHEADER* pBihIn;
|
|
|
|
BITMAPINFOHEADER* pBihOut;
|
2010-11-09 23:42:42 +01:00
|
|
|
REFERENCE_TIME late;
|
2004-08-24 04:28:35 +02:00
|
|
|
} AVIDecImpl;
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static const IBaseFilterVtbl AVIDec_Vtbl;
|
|
|
|
|
2012-03-31 03:10:15 +02:00
|
|
|
static inline AVIDecImpl *impl_from_TransformFilter( TransformFilter *iface )
|
|
|
|
{
|
2016-03-28 07:27:49 +02:00
|
|
|
return CONTAINING_RECORD(iface, AVIDecImpl, tf);
|
2012-03-31 03:10:15 +02:00
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static HRESULT WINAPI AVIDec_StartStreaming(TransformFilter* pTransformFilter)
|
2005-02-21 21:37:45 +01:00
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl* This = impl_from_TransformFilter(pTransformFilter);
|
2005-02-21 21:37:45 +01:00
|
|
|
DWORD result;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
2010-11-09 23:42:42 +01:00
|
|
|
This->late = -1;
|
2005-02-21 21:37:45 +01:00
|
|
|
|
|
|
|
result = ICDecompressBegin(This->hvid, This->pBihIn, This->pBihOut);
|
|
|
|
if (result != ICERR_OK)
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Cannot start processing (%d)\n", result);
|
2005-02-21 21:37:45 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-09 23:42:42 +01:00
|
|
|
static HRESULT WINAPI AVIDec_EndFlush(TransformFilter *pTransformFilter) {
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl* This = impl_from_TransformFilter(pTransformFilter);
|
2010-11-09 23:42:42 +01:00
|
|
|
This->late = -1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AVIDec_NotifyDrop(TransformFilter *pTransformFilter, IBaseFilter *sender, Quality qm) {
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl *This = impl_from_TransformFilter(pTransformFilter);
|
2010-11-09 23:42:42 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&This->tf.filter.csFilter);
|
|
|
|
if (qm.Late > 0)
|
|
|
|
This->late = qm.Late + qm.TimeStamp;
|
|
|
|
else
|
|
|
|
This->late = -1;
|
|
|
|
LeaveCriticalSection(&This->tf.filter.csFilter);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int AVIDec_DropSample(AVIDecImpl *This, REFERENCE_TIME tStart) {
|
|
|
|
if (This->late < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (tStart < This->late) {
|
|
|
|
TRACE("Dropping sample\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
This->late = -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl* This = impl_from_TransformFilter(tf);
|
2004-08-24 04:28:35 +02:00
|
|
|
AM_MEDIA_TYPE amt;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD res;
|
2007-04-07 11:32:45 +02:00
|
|
|
IMediaSample* pOutSample = NULL;
|
2004-08-24 04:28:35 +02:00
|
|
|
DWORD cbDstStream;
|
|
|
|
LPBYTE pbDstStream;
|
2007-04-07 11:32:45 +02:00
|
|
|
DWORD cbSrcStream;
|
|
|
|
LPBYTE pbSrcStream;
|
2008-05-21 23:33:47 +02:00
|
|
|
LONGLONG tStart, tStop;
|
2010-11-09 23:42:42 +01:00
|
|
|
DWORD flags = 0;
|
2008-07-05 01:59:22 +02:00
|
|
|
|
2012-01-23 15:33:22 +01:00
|
|
|
EnterCriticalSection(&This->tf.csReceive);
|
2007-04-07 11:32:45 +02:00
|
|
|
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Cannot get pointer to sample data (%x)\n", hr);
|
2008-07-05 01:59:22 +02:00
|
|
|
goto error;
|
2007-04-07 11:32:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cbSrcStream = IMediaSample_GetActualDataLength(pSample);
|
|
|
|
|
2010-05-20 01:14:09 +02:00
|
|
|
TRACE("Sample data ptr = %p, size = %d\n", pbSrcStream, cbSrcStream);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
hr = IPin_ConnectionMediaType(This->tf.ppPins[0], &amt);
|
2004-08-24 04:28:35 +02:00
|
|
|
if (FAILED(hr)) {
|
2008-05-21 23:33:47 +02:00
|
|
|
ERR("Unable to retrieve media type\n");
|
|
|
|
goto error;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
2004-11-29 18:50:23 +01:00
|
|
|
/* Update input size to match sample size */
|
2007-04-07 11:32:45 +02:00
|
|
|
This->pBihIn->biSizeImage = cbSrcStream;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2010-10-05 21:37:56 +02:00
|
|
|
hr = BaseOutputPinImpl_GetDeliveryBuffer((BaseOutputPin*)This->tf.ppPins[1], &pOutSample, NULL, NULL, 0);
|
2004-08-24 04:28:35 +02:00
|
|
|
if (FAILED(hr)) {
|
2008-07-05 01:59:22 +02:00
|
|
|
ERR("Unable to get delivery buffer (%x)\n", hr);
|
|
|
|
goto error;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2007-04-07 11:32:45 +02:00
|
|
|
hr = IMediaSample_SetActualDataLength(pOutSample, 0);
|
2004-08-24 04:28:35 +02:00
|
|
|
assert(hr == S_OK);
|
|
|
|
|
2007-04-07 11:32:45 +02:00
|
|
|
hr = IMediaSample_GetPointer(pOutSample, &pbDstStream);
|
2004-08-24 04:28:35 +02:00
|
|
|
if (FAILED(hr)) {
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Unable to get pointer to buffer (%x)\n", hr);
|
2004-08-24 04:28:35 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2007-04-07 11:32:45 +02:00
|
|
|
cbDstStream = IMediaSample_GetSize(pOutSample);
|
2004-11-29 18:50:23 +01:00
|
|
|
if (cbDstStream < This->pBihOut->biSizeImage) {
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Sample size is too small %d < %d\n", cbDstStream, This->pBihOut->biSizeImage);
|
2008-06-10 16:53:28 +02:00
|
|
|
hr = E_FAIL;
|
|
|
|
goto error;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
2010-11-09 23:42:42 +01:00
|
|
|
if (IMediaSample_IsPreroll(pSample) == S_OK)
|
|
|
|
flags |= ICDECOMPRESS_PREROLL;
|
|
|
|
if (IMediaSample_IsSyncPoint(pSample) != S_OK)
|
|
|
|
flags |= ICDECOMPRESS_NOTKEYFRAME;
|
2010-11-29 10:44:17 +01:00
|
|
|
hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
|
|
|
|
if (hr == S_OK && AVIDec_DropSample(This, tStart))
|
2010-11-09 23:42:42 +01:00
|
|
|
flags |= ICDECOMPRESS_HURRYUP;
|
|
|
|
|
|
|
|
res = ICDecompress(This->hvid, flags, This->pBihIn, pbSrcStream, This->pBihOut, pbDstStream);
|
2004-08-24 04:28:35 +02:00
|
|
|
if (res != ICERR_OK)
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Error occurred during the decompression (%x)\n", res);
|
2004-11-29 18:50:23 +01:00
|
|
|
|
2010-11-09 23:42:42 +01:00
|
|
|
/* Drop sample if its intended to be dropped */
|
2010-11-29 10:44:17 +01:00
|
|
|
if (flags & ICDECOMPRESS_HURRYUP) {
|
|
|
|
hr = S_OK;
|
2010-11-09 23:42:42 +01:00
|
|
|
goto error;
|
2010-11-29 10:44:17 +01:00
|
|
|
}
|
2010-11-09 23:42:42 +01:00
|
|
|
|
2008-06-10 16:53:28 +02:00
|
|
|
IMediaSample_SetActualDataLength(pOutSample, This->pBihOut->biSizeImage);
|
2008-05-21 23:33:47 +02:00
|
|
|
|
|
|
|
IMediaSample_SetPreroll(pOutSample, (IMediaSample_IsPreroll(pSample) == S_OK));
|
|
|
|
IMediaSample_SetDiscontinuity(pOutSample, (IMediaSample_IsDiscontinuity(pSample) == S_OK));
|
|
|
|
IMediaSample_SetSyncPoint(pOutSample, (IMediaSample_IsSyncPoint(pSample) == S_OK));
|
|
|
|
|
2010-11-29 10:44:17 +01:00
|
|
|
if (hr == S_OK)
|
2008-05-21 23:33:47 +02:00
|
|
|
IMediaSample_SetTime(pOutSample, &tStart, &tStop);
|
2010-11-29 10:44:17 +01:00
|
|
|
else if (hr == VFW_S_NO_STOP_TIME)
|
|
|
|
IMediaSample_SetTime(pOutSample, &tStart, NULL);
|
2008-05-21 23:33:47 +02:00
|
|
|
else
|
|
|
|
IMediaSample_SetTime(pOutSample, NULL, NULL);
|
|
|
|
|
2010-11-07 15:02:46 +01:00
|
|
|
if (IMediaSample_GetMediaTime(pSample, &tStart, &tStop) == S_OK)
|
|
|
|
IMediaSample_SetMediaTime(pOutSample, &tStart, &tStop);
|
|
|
|
else
|
|
|
|
IMediaSample_SetMediaTime(pOutSample, NULL, NULL);
|
|
|
|
|
2012-01-23 15:33:22 +01:00
|
|
|
LeaveCriticalSection(&This->tf.csReceive);
|
2010-10-05 21:37:56 +02:00
|
|
|
hr = BaseOutputPinImpl_Deliver((BaseOutputPin*)This->tf.ppPins[1], pOutSample);
|
2012-01-23 15:33:22 +01:00
|
|
|
EnterCriticalSection(&This->tf.csReceive);
|
2008-07-05 01:59:22 +02:00
|
|
|
if (hr != S_OK && hr != VFW_E_NOT_CONNECTED)
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Error sending sample (%x)\n", hr);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
error:
|
2007-04-07 11:32:45 +02:00
|
|
|
if (pOutSample)
|
|
|
|
IMediaSample_Release(pOutSample);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2012-01-23 15:33:22 +01:00
|
|
|
LeaveCriticalSection(&This->tf.csReceive);
|
2004-08-24 04:28:35 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static HRESULT WINAPI AVIDec_StopStreaming(TransformFilter* pTransformFilter)
|
2005-02-21 21:37:45 +01:00
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl* This = impl_from_TransformFilter(pTransformFilter);
|
2005-02-21 21:37:45 +01:00
|
|
|
DWORD result;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
2008-04-13 08:04:49 +02:00
|
|
|
if (!This->hvid)
|
|
|
|
return S_OK;
|
|
|
|
|
2005-02-21 21:37:45 +01:00
|
|
|
result = ICDecompressEnd(This->hvid);
|
|
|
|
if (result != ICERR_OK)
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Cannot stop processing (%d)\n", result);
|
2008-04-13 08:04:49 +02:00
|
|
|
return E_FAIL;
|
2005-02-21 21:37:45 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static HRESULT WINAPI AVIDec_SetMediaType(TransformFilter *tf, PIN_DIRECTION dir, const AM_MEDIA_TYPE * pmt)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl* This = impl_from_TransformFilter(tf);
|
2007-06-05 05:11:25 +02:00
|
|
|
HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
|
2005-02-01 15:22:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pmt);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
if (dir != PINDIR_INPUT)
|
|
|
|
return S_OK;
|
|
|
|
|
2006-09-22 19:50:12 +02:00
|
|
|
/* Check root (GUID w/o FOURCC) */
|
2004-08-24 04:28:35 +02:00
|
|
|
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) &&
|
2008-06-20 06:17:08 +02:00
|
|
|
(!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4)))
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2008-06-20 06:17:08 +02:00
|
|
|
VIDEOINFOHEADER *format1 = (VIDEOINFOHEADER *)pmt->pbFormat;
|
|
|
|
VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat;
|
|
|
|
BITMAPINFOHEADER *bmi;
|
|
|
|
|
|
|
|
if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
|
|
|
|
bmi = &format1->bmiHeader;
|
|
|
|
else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
|
|
|
|
bmi = &format2->bmiHeader;
|
|
|
|
else
|
|
|
|
goto failed;
|
2010-03-26 21:53:36 +01:00
|
|
|
TRACE("Fourcc: %s\n", debugstr_an((const char *)&pmt->subtype.Data1, 4));
|
2008-06-20 06:17:08 +02:00
|
|
|
|
|
|
|
This->hvid = ICLocate(pmt->majortype.Data1, pmt->subtype.Data1, bmi, NULL, ICMODE_DECOMPRESS);
|
2005-02-21 21:37:45 +01:00
|
|
|
if (This->hvid)
|
2004-11-29 18:50:23 +01:00
|
|
|
{
|
2008-07-11 06:41:35 +02:00
|
|
|
AM_MEDIA_TYPE* outpmt = &This->tf.pmt;
|
2004-11-29 18:50:23 +01:00
|
|
|
const CLSID* outsubtype;
|
|
|
|
DWORD bih_size;
|
2008-06-20 06:17:08 +02:00
|
|
|
DWORD output_depth = bmi->biBitCount;
|
2005-02-21 21:37:45 +01:00
|
|
|
DWORD result;
|
2008-07-11 06:41:35 +02:00
|
|
|
FreeMediaType(outpmt);
|
2004-11-29 18:50:23 +01:00
|
|
|
|
2008-06-20 06:17:08 +02:00
|
|
|
switch(bmi->biBitCount)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2004-11-29 18:50:23 +01:00
|
|
|
case 32: outsubtype = &MEDIASUBTYPE_RGB32; break;
|
2004-08-24 04:28:35 +02:00
|
|
|
case 24: outsubtype = &MEDIASUBTYPE_RGB24; break;
|
|
|
|
case 16: outsubtype = &MEDIASUBTYPE_RGB565; break;
|
|
|
|
case 8: outsubtype = &MEDIASUBTYPE_RGB8; break;
|
|
|
|
default:
|
2008-06-20 06:17:08 +02:00
|
|
|
WARN("Non standard input depth %d, forced output depth to 32\n", bmi->biBitCount);
|
2005-02-21 21:37:45 +01:00
|
|
|
outsubtype = &MEDIASUBTYPE_RGB32;
|
|
|
|
output_depth = 32;
|
|
|
|
break;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
2004-11-29 18:50:23 +01:00
|
|
|
|
|
|
|
/* Copy bitmap header from media type to 1 for input and 1 for output */
|
2008-06-20 06:17:08 +02:00
|
|
|
bih_size = bmi->biSize + bmi->biClrUsed * 4;
|
2007-06-27 00:12:07 +02:00
|
|
|
This->pBihIn = CoTaskMemAlloc(bih_size);
|
2005-02-01 15:22:00 +01:00
|
|
|
if (!This->pBihIn)
|
2004-11-29 18:50:23 +01:00
|
|
|
{
|
2005-02-21 21:37:45 +01:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto failed;
|
2004-11-29 18:50:23 +01:00
|
|
|
}
|
2007-06-27 00:12:07 +02:00
|
|
|
This->pBihOut = CoTaskMemAlloc(bih_size);
|
2005-02-01 15:22:00 +01:00
|
|
|
if (!This->pBihOut)
|
2004-11-29 18:50:23 +01:00
|
|
|
{
|
2005-02-21 21:37:45 +01:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto failed;
|
2004-11-29 18:50:23 +01:00
|
|
|
}
|
2008-06-20 06:17:08 +02:00
|
|
|
memcpy(This->pBihIn, bmi, bih_size);
|
|
|
|
memcpy(This->pBihOut, bmi, bih_size);
|
2004-11-29 18:50:23 +01:00
|
|
|
|
|
|
|
/* Update output format as non compressed bitmap */
|
2005-02-01 15:22:00 +01:00
|
|
|
This->pBihOut->biCompression = 0;
|
2005-02-21 21:37:45 +01:00
|
|
|
This->pBihOut->biBitCount = output_depth;
|
2005-02-01 15:22:00 +01:00
|
|
|
This->pBihOut->biSizeImage = This->pBihOut->biWidth * This->pBihOut->biHeight * This->pBihOut->biBitCount / 8;
|
2008-06-20 06:17:08 +02:00
|
|
|
TRACE("Size: %u\n", This->pBihIn->biSize);
|
2005-02-21 21:37:45 +01:00
|
|
|
result = ICDecompressQuery(This->hvid, This->pBihIn, This->pBihOut);
|
|
|
|
if (result != ICERR_OK)
|
|
|
|
{
|
2008-06-20 06:17:08 +02:00
|
|
|
ERR("Unable to found a suitable output format (%d)\n", result);
|
2005-02-21 21:37:45 +01:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update output media type */
|
|
|
|
CopyMediaType(outpmt, pmt);
|
|
|
|
outpmt->subtype = *outsubtype;
|
2008-06-20 06:17:08 +02:00
|
|
|
|
|
|
|
if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
|
|
|
|
memcpy(&(((VIDEOINFOHEADER *)outpmt->pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize);
|
|
|
|
else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
|
|
|
|
memcpy(&(((VIDEOINFOHEADER2 *)outpmt->pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize);
|
|
|
|
else
|
|
|
|
assert(0);
|
2005-02-21 21:37:45 +01:00
|
|
|
|
2004-11-29 18:50:23 +01:00
|
|
|
TRACE("Connection accepted\n");
|
2004-08-24 04:28:35 +02:00
|
|
|
return S_OK;
|
2004-11-29 18:50:23 +01:00
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
TRACE("Unable to find a suitable VFW decompressor\n");
|
|
|
|
}
|
|
|
|
|
2005-02-21 21:37:45 +01:00
|
|
|
failed:
|
2008-06-20 06:17:08 +02:00
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("Connection refused\n");
|
2005-02-21 21:37:45 +01:00
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static HRESULT WINAPI AVIDec_CompleteConnect(TransformFilter *tf, PIN_DIRECTION dir, IPin *pin)
|
2004-08-24 04:28:35 +02:00
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl* This = impl_from_TransformFilter(tf);
|
2010-10-07 21:48:19 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AVIDec_BreakConnect(TransformFilter *tf, PIN_DIRECTION dir)
|
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl *This = impl_from_TransformFilter(tf);
|
2005-02-01 15:22:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
if (dir == PINDIR_INPUT)
|
|
|
|
{
|
|
|
|
if (This->hvid)
|
|
|
|
ICClose(This->hvid);
|
2016-07-08 10:10:14 +02:00
|
|
|
CoTaskMemFree(This->pBihIn);
|
|
|
|
CoTaskMemFree(This->pBihOut);
|
2010-10-07 21:48:19 +02:00
|
|
|
This->hvid = NULL;
|
|
|
|
This->pBihIn = NULL;
|
|
|
|
This->pBihOut = NULL;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
return S_OK;
|
2004-08-24 04:28:35 +02:00
|
|
|
}
|
|
|
|
|
2010-10-13 17:46:27 +02:00
|
|
|
static HRESULT WINAPI AVIDec_DecideBufferSize(TransformFilter *tf, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
|
|
|
{
|
2012-03-31 03:10:15 +02:00
|
|
|
AVIDecImpl *pAVI = impl_from_TransformFilter(tf);
|
2010-10-13 17:46:27 +02:00
|
|
|
ALLOCATOR_PROPERTIES actual;
|
|
|
|
|
|
|
|
if (!ppropInputRequest->cbAlign)
|
|
|
|
ppropInputRequest->cbAlign = 1;
|
|
|
|
|
|
|
|
if (ppropInputRequest->cbBuffer < pAVI->pBihOut->biSizeImage)
|
|
|
|
ppropInputRequest->cbBuffer = pAVI->pBihOut->biSizeImage;
|
|
|
|
|
|
|
|
if (!ppropInputRequest->cBuffers)
|
|
|
|
ppropInputRequest->cBuffers = 1;
|
|
|
|
|
|
|
|
return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static const TransformFilterFuncTable AVIDec_FuncsTable = {
|
2010-10-13 17:46:27 +02:00
|
|
|
AVIDec_DecideBufferSize,
|
2010-10-07 21:48:19 +02:00
|
|
|
AVIDec_StartStreaming,
|
|
|
|
AVIDec_Receive,
|
|
|
|
AVIDec_StopStreaming,
|
|
|
|
NULL,
|
|
|
|
AVIDec_SetMediaType,
|
|
|
|
AVIDec_CompleteConnect,
|
|
|
|
AVIDec_BreakConnect,
|
2007-04-03 09:06:16 +02:00
|
|
|
NULL,
|
2010-10-07 21:48:19 +02:00
|
|
|
NULL,
|
2010-11-09 23:42:42 +01:00
|
|
|
AVIDec_EndFlush,
|
2010-10-07 21:48:19 +02:00
|
|
|
NULL,
|
2010-11-09 23:42:42 +01:00
|
|
|
AVIDec_NotifyDrop
|
2005-02-21 21:37:45 +01:00
|
|
|
};
|
|
|
|
|
2004-08-24 04:28:35 +02:00
|
|
|
HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
2005-02-01 15:22:00 +01:00
|
|
|
AVIDecImpl * This;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pUnkOuter, ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
hr = TransformFilter_Construct(&AVIDec_Vtbl, sizeof(AVIDecImpl), &CLSID_AVIDec, &AVIDec_FuncsTable, (IBaseFilter**)&This);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2005-02-01 15:22:00 +01:00
|
|
|
This->hvid = NULL;
|
|
|
|
This->pBihIn = NULL;
|
2005-02-21 21:37:45 +01:00
|
|
|
This->pBihOut = NULL;
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2015-06-26 05:52:42 +02:00
|
|
|
*ppv = &This->tf.filter.IBaseFilter_iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
2004-08-24 04:28:35 +02:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static const IBaseFilterVtbl AVIDec_Vtbl =
|
|
|
|
{
|
2013-03-04 12:21:19 +01:00
|
|
|
TransformFilterImpl_QueryInterface,
|
2010-10-07 21:48:19 +02:00
|
|
|
BaseFilterImpl_AddRef,
|
|
|
|
TransformFilterImpl_Release,
|
|
|
|
BaseFilterImpl_GetClassID,
|
|
|
|
TransformFilterImpl_Stop,
|
|
|
|
TransformFilterImpl_Pause,
|
|
|
|
TransformFilterImpl_Run,
|
|
|
|
BaseFilterImpl_GetState,
|
|
|
|
BaseFilterImpl_SetSyncSource,
|
|
|
|
BaseFilterImpl_GetSyncSource,
|
|
|
|
BaseFilterImpl_EnumPins,
|
|
|
|
TransformFilterImpl_FindPin,
|
|
|
|
BaseFilterImpl_QueryFilterInfo,
|
|
|
|
BaseFilterImpl_JoinFilterGraph,
|
|
|
|
BaseFilterImpl_QueryVendorInfo
|
|
|
|
};
|