ReactOS 0.4.17-dev-934-g091855f
avidec.c File Reference
#include "quartz_private.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"
#include "dvdmedia.h"
#include <assert.h>
#include "wine/debug.h"
Include dependency graph for avidec.c:

Go to the source code of this file.

Classes

struct  avi_decompressor
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (quartz)
 
static struct avi_decompressor * impl_from_strmbase_filter (struct strmbase_filter *iface)
 
static HRESULT avi_decompressor_sink_query_interface (struct strmbase_pin *iface, REFIID iid, void **out)
 
static HRESULT avi_decompressor_sink_query_accept (struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
 
static HRESULT avi_decompressor_sink_end_flush (struct strmbase_sink *iface)
 
static int AVIDec_DropSample (struct avi_decompressor *This, REFERENCE_TIME tStart)
 
static HRESULT WINAPI avi_decompressor_sink_Receive (struct strmbase_sink *iface, IMediaSample *pSample)
 
static HRESULT avi_decompressor_sink_connect (struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *pmt)
 
static void avi_decompressor_sink_disconnect (struct strmbase_sink *iface)
 
static HRESULT avi_decompressor_source_query_interface (struct strmbase_pin *iface, REFIID iid, void **out)
 
static HRESULT avi_decompressor_source_query_accept (struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
 
static HRESULT avi_decompressor_source_get_media_type (struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
 
static HRESULT WINAPI avi_decompressor_source_DecideBufferSize (struct strmbase_source *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
 
static struct avi_decompressor * impl_from_source_IQualityControl (IQualityControl *iface)
 
static HRESULT WINAPI avi_decompressor_source_qc_QueryInterface (IQualityControl *iface, REFIID iid, void **out)
 
static ULONG WINAPI avi_decompressor_source_qc_AddRef (IQualityControl *iface)
 
static ULONG WINAPI avi_decompressor_source_qc_Release (IQualityControl *iface)
 
static HRESULT WINAPI avi_decompressor_source_qc_Notify (IQualityControl *iface, IBaseFilter *sender, Quality q)
 
static HRESULT WINAPI avi_decompressor_source_qc_SetSink (IQualityControl *iface, IQualityControl *sink)
 
static struct strmbase_pin * avi_decompressor_get_pin (struct strmbase_filter *iface, unsigned int index)
 
static void avi_decompressor_destroy (struct strmbase_filter *iface)
 
static HRESULT avi_decompressor_init_stream (struct strmbase_filter *iface)
 
static HRESULT avi_decompressor_cleanup_stream (struct strmbase_filter *iface)
 
HRESULT avi_dec_create (IUnknown *outer, IUnknown **out)
 

Variables

static const struct strmbase_sink_ops sink_ops
 
static const struct strmbase_source_ops source_ops
 
static const IQualityControlVtbl source_qc_vtbl
 
static const struct strmbase_filter_ops filter_ops
 

Function Documentation

◆ avi_dec_create()

HRESULT avi_dec_create ( IUnknown *  outer,
IUnknown **  out 
)

Definition at line 613 of file avidec.c.

614{
615 struct avi_decompressor *object;
616
617 if (!(object = calloc(1, sizeof(*object))))
618 return E_OUTOFMEMORY;
619
620 strmbase_filter_init(&object->filter, outer, &CLSID_AVIDec, &filter_ops);
621
622 strmbase_sink_init(&object->sink, &object->filter, L"In", &sink_ops, NULL);
623 wcscpy(object->sink.pin.name, L"XForm In");
624
625 strmbase_source_init(&object->source, &object->filter, L"Out", &source_ops);
626 wcscpy(object->source.pin.name, L"XForm Out");
627
628 object->source_IQualityControl_iface.lpVtbl = &source_qc_vtbl;
629 strmbase_passthrough_init(&object->passthrough, (IUnknown *)&object->source.pin.IPin_iface);
630 ISeekingPassThru_Init(&object->passthrough.ISeekingPassThru_iface, FALSE,
631 &object->sink.pin.IPin_iface);
632
634 object->late_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": object.late_cs");
635
636 TRACE("Created AVI decompressor %p.\n", object);
637 *out = &object->filter.IUnknown_inner;
638
639 return S_OK;
640}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static const IQualityControlVtbl source_qc_vtbl
Definition: avidec.c:510
static const struct strmbase_source_ops source_ops
Definition: avidec.c:449
static const struct strmbase_sink_ops sink_ops
Definition: avidec.c:275
static const struct strmbase_filter_ops filter_ops
Definition: avidec.c:605
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
static IUnknown * outer
Definition: compobj.c:82
#define calloc
Definition: rosglue.h:14
wcscpy
#define TRACE(s)
Definition: solgame.cpp:4
void strmbase_source_init(struct strmbase_source *pin, struct strmbase_filter *filter, const WCHAR *name, const struct strmbase_source_ops *func_table)
Definition: pin.c:765
void strmbase_sink_init(struct strmbase_sink *pin, struct strmbase_filter *filter, const WCHAR *name, const struct strmbase_sink_ops *ops, IMemAllocator *allocator)
Definition: pin.c:1168
void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer)
Definition: pospass.c:725
void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer, const CLSID *clsid, const struct strmbase_filter_ops *func_table)
Definition: filter.c:517
#define DWORD_PTR
Definition: treelist.c:76
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1156

◆ avi_decompressor_cleanup_stream()

static HRESULT avi_decompressor_cleanup_stream ( struct strmbase_filter *  iface)
static

Definition at line 580 of file avidec.c.

581{
583 LRESULT res;
584
585 if (!filter->source.pin.peer)
586 return S_OK;
587
588 if (filter->hvid)
589 {
591 res = ICDecompressEnd(filter->hvid);
593 if (res)
594 {
595 ERR("ICDecompressEnd() failed, error %Id.\n", res);
596 return E_FAIL;
597 }
598 }
599
600 IMemAllocator_Decommit(filter->source.pAllocator);
601
602 return S_OK;
603}
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_FAIL
Definition: ddrawi.h:102
static struct avi_decompressor * impl_from_strmbase_filter(struct strmbase_filter *iface)
Definition: avidec.c:56
GLuint res
Definition: glext.h:9613
LONG_PTR LRESULT
Definition: minwindef.h:176
Definition: filter.c:165
IBaseFilter * filter
Definition: filtergraph.c:75
#define ICDecompressEnd(hic)
Definition: vfw.h:404
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ avi_decompressor_destroy()

static void avi_decompressor_destroy ( struct strmbase_filter *  iface)
static

Definition at line 530 of file avidec.c.

531{
533
534 if (filter->sink.pin.peer)
535 IPin_Disconnect(filter->sink.pin.peer);
536 IPin_Disconnect(&filter->sink.pin.IPin_iface);
537
538 if (filter->source.pin.peer)
539 IPin_Disconnect(filter->source.pin.peer);
540 IPin_Disconnect(&filter->source.pin.IPin_iface);
541
542 filter->late_cs.DebugInfo->Spare[0] = 0;
543 DeleteCriticalSection(&filter->late_cs);
544
548
550 free(filter);
551}
#define free
Definition: debug_ros.c:5
void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough)
Definition: pospass.c:738
void strmbase_sink_cleanup(struct strmbase_sink *pin)
Definition: pin.c:1185
void strmbase_filter_cleanup(struct strmbase_filter *filter)
Definition: filter.c:540
void strmbase_source_cleanup(struct strmbase_source *pin)
Definition: pin.c:778
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ avi_decompressor_get_pin()

static struct strmbase_pin * avi_decompressor_get_pin ( struct strmbase_filter *  iface,
unsigned int  index 
)
static

Definition at line 519 of file avidec.c.

520{
522
523 if (index == 0)
524 return &filter->sink.pin;
525 else if (index == 1)
526 return &filter->source.pin;
527 return NULL;
528}
GLuint index
Definition: glext.h:6031

◆ avi_decompressor_init_stream()

static HRESULT avi_decompressor_init_stream ( struct strmbase_filter *  iface)
static

Definition at line 553 of file avidec.c.

554{
556 VIDEOINFOHEADER *source_format;
557 LRESULT res;
558 HRESULT hr;
559
560 if (!filter->source.pin.peer)
561 return S_OK;
562
563 EnterCriticalSection(&filter->late_cs);
564 filter->late = -1;
565 LeaveCriticalSection(&filter->late_cs);
566
567 source_format = (VIDEOINFOHEADER *)filter->source.pin.mt.pbFormat;
568 if ((res = ICDecompressBegin(filter->hvid, filter->pBihIn, &source_format->bmiHeader)))
569 {
570 ERR("ICDecompressBegin() failed, error %Id.\n", res);
571 return E_FAIL;
572 }
573
574 if (FAILED(hr = IMemAllocator_Commit(filter->source.pAllocator)))
575 ERR("Failed to commit allocator, hr %#lx.\n", hr);
576
577 return S_OK;
578}
HRESULT hr
Definition: delayimp.cpp:582
#define FAILED(hr)
Definition: intsafe.h:51
if(dx< 0)
Definition: linetemp.h:194
BITMAPINFOHEADER bmiHeader
Definition: amvideo.idl:189
#define ICDecompressBegin(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:371

◆ avi_decompressor_sink_connect()

static HRESULT avi_decompressor_sink_connect ( struct strmbase_sink *  iface,
IPin *  peer,
const AM_MEDIA_TYPE *  pmt 
)
static

Definition at line 210 of file avidec.c.

211{
212 struct avi_decompressor *This = impl_from_strmbase_filter(iface->pin.filter);
214
215 /* Check root (GUID w/o FOURCC) */
216 if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) &&
217 (!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4)))
218 {
219 VIDEOINFOHEADER *format1 = (VIDEOINFOHEADER *)pmt->pbFormat;
220 VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat;
221 BITMAPINFOHEADER *bmi;
222
223 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
224 bmi = &format1->bmiHeader;
225 else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
226 bmi = &format2->bmiHeader;
227 else
228 goto failed;
229
230 This->hvid = ICLocate(pmt->majortype.Data1, pmt->subtype.Data1, bmi, NULL, ICMODE_DECOMPRESS);
231 if (This->hvid)
232 {
233 DWORD bih_size;
235
236 /* Copy bitmap header from media type to 1 for input and 1 for output */
237 bih_size = bmi->biSize + bmi->biClrUsed * 4;
238 This->pBihIn = CoTaskMemAlloc(bih_size);
239 if (!This->pBihIn)
240 {
242 goto failed;
243 }
244 memcpy(This->pBihIn, bmi, bih_size);
245
246 if ((result = ICDecompressQuery(This->hvid, This->pBihIn, NULL)))
247 {
248 WARN("No decompressor found, error %Id.\n", result);
250 }
251
252 TRACE("Connection accepted\n");
253 return S_OK;
254 }
255 TRACE("Unable to find a suitable VFW decompressor\n");
256 }
257
258failed:
259
260 TRACE("Connection refused\n");
261 return hr;
262}
#define WARN(fmt,...)
Definition: precomp.h:61
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint64EXT * result
Definition: glext.h:11304
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
HIC VFWAPI ICLocate(DWORD type, DWORD handler, BITMAPINFOHEADER *in, BITMAPINFOHEADER *out, WORD mode)
Definition: msvideo_main.c:620
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
struct strmbase_pin pin
Definition: strmbase.h:106
#define ICMODE_DECOMPRESS
Definition: vfw.h:269
#define ICDecompressQuery(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:377
#define VFW_E_TYPE_NOT_ACCEPTED
Definition: vfwmsgs.h:81

◆ avi_decompressor_sink_disconnect()

static void avi_decompressor_sink_disconnect ( struct strmbase_sink *  iface)
static

Definition at line 264 of file avidec.c.

265{
266 struct avi_decompressor *filter = impl_from_strmbase_filter(iface->pin.filter);
267
268 if (filter->hvid)
269 ICClose(filter->hvid);
270 CoTaskMemFree(filter->pBihIn);
271 filter->hvid = NULL;
272 filter->pBihIn = NULL;
273}
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
LRESULT WINAPI ICClose(HIC hic)

◆ avi_decompressor_sink_end_flush()

static HRESULT avi_decompressor_sink_end_flush ( struct strmbase_sink *  iface)
static

Definition at line 79 of file avidec.c.

80{
83 filter->late = -1;
85 if (filter->source.pin.peer)
86 return IPin_EndFlush(filter->source.pin.peer);
87 return S_OK;
88}

◆ avi_decompressor_sink_query_accept()

static HRESULT avi_decompressor_sink_query_accept ( struct strmbase_pin *  iface,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 74 of file avidec.c.

75{
76 return S_OK;
77}

◆ avi_decompressor_sink_query_interface()

static HRESULT avi_decompressor_sink_query_interface ( struct strmbase_pin *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 61 of file avidec.c.

62{
64
65 if (IsEqualGUID(iid, &IID_IMemInputPin))
66 *out = &filter->sink.IMemInputPin_iface;
67 else
68 return E_NOINTERFACE;
69
70 IUnknown_AddRef((IUnknown *)*out);
71 return S_OK;
72}
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
struct strmbase_filter * filter
Definition: strmbase.h:58
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ avi_decompressor_sink_Receive()

static HRESULT WINAPI avi_decompressor_sink_Receive ( struct strmbase_sink *  iface,
IMediaSample *  pSample 
)
static

Definition at line 103 of file avidec.c.

104{
105 struct avi_decompressor *This = impl_from_strmbase_filter(iface->pin.filter);
106 VIDEOINFOHEADER *source_format;
107 HRESULT hr;
108 IMediaSample* pOutSample = NULL;
109 LONG cbDstStream, cbSrcStream;
110 LPBYTE pbDstStream;
111 LPBYTE pbSrcStream;
112 LONGLONG tStart, tStop;
113 DWORD flags = 0;
114 LRESULT res;
115
116 /* We do not expect pin connection state to change while the filter is
117 * running. This guarantee is necessary, since otherwise we would have to
118 * take the filter lock, and we can't take the filter lock from a streaming
119 * thread. */
120 if (!This->source.pMemInputPin)
121 {
122 WARN("Source is not connected, returning VFW_E_NOT_CONNECTED.\n");
123 return VFW_E_NOT_CONNECTED;
124 }
125
126 source_format = (VIDEOINFOHEADER *)This->source.pin.mt.pbFormat;
127
128 if (This->filter.state == State_Stopped)
129 return VFW_E_WRONG_STATE;
130
131 if (This->sink.flushing)
132 return S_FALSE;
133
134 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
135 if (FAILED(hr))
136 {
137 ERR("Failed to get input buffer pointer, hr %#lx.\n", hr);
138 return hr;
139 }
140
141 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
142
143 /* Update input size to match sample size */
144 This->pBihIn->biSizeImage = cbSrcStream;
145
146 if (FAILED(hr = IMemAllocator_GetBuffer(This->source.pAllocator, &pOutSample, NULL, NULL, 0)))
147 {
148 ERR("Failed to get sample, hr %#lx.\n", hr);
149 return hr;
150 }
151
152 hr = IMediaSample_SetActualDataLength(pOutSample, 0);
153 assert(hr == S_OK);
154
155 hr = IMediaSample_GetPointer(pOutSample, &pbDstStream);
156 if (FAILED(hr)) {
157 ERR("Failed to get output buffer pointer, hr %#lx.\n", hr);
158 IMediaSample_Release(pOutSample);
159 return hr;
160 }
161 cbDstStream = IMediaSample_GetSize(pOutSample);
162 if (cbDstStream < source_format->bmiHeader.biSizeImage)
163 {
164 ERR("Sample size is too small (%ld < %lu).\n", cbDstStream, source_format->bmiHeader.biSizeImage);
165 IMediaSample_Release(pOutSample);
166 return E_FAIL;
167 }
168
169 if (IMediaSample_IsPreroll(pSample) == S_OK)
171 if (IMediaSample_IsSyncPoint(pSample) != S_OK)
173 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
174 EnterCriticalSection(&This->late_cs);
175 if (hr == S_OK && AVIDec_DropSample(This, tStart))
177 LeaveCriticalSection(&This->late_cs);
178
179 res = ICDecompress(This->hvid, flags, This->pBihIn, pbSrcStream, &source_format->bmiHeader, pbDstStream);
180 if (res != ICERR_OK)
181 ERR("Failed to decompress, error %Id.\n", res);
182
183 /* Drop sample if it's intended to be dropped */
185 IMediaSample_Release(pOutSample);
186 return S_OK;
187 }
188
189 IMediaSample_SetActualDataLength(pOutSample, source_format->bmiHeader.biSizeImage);
190
191 IMediaSample_SetPreroll(pOutSample, (IMediaSample_IsPreroll(pSample) == S_OK));
192 IMediaSample_SetDiscontinuity(pOutSample, (IMediaSample_IsDiscontinuity(pSample) == S_OK));
193 IMediaSample_SetSyncPoint(pOutSample, (IMediaSample_IsSyncPoint(pSample) == S_OK));
194
195 if (hr == S_OK)
196 IMediaSample_SetTime(pOutSample, &tStart, &tStop);
197 else if (hr == VFW_S_NO_STOP_TIME)
198 IMediaSample_SetTime(pOutSample, &tStart, NULL);
199 else
200 IMediaSample_SetTime(pOutSample, NULL, NULL);
201
202 hr = IMemInputPin_Receive(This->source.pMemInputPin, pOutSample);
203 if (hr != S_OK && hr != VFW_E_NOT_CONNECTED)
204 ERR("Failed to send sample, hr %#lx.\n", hr);
205
206 IMediaSample_Release(pOutSample);
207 return hr;
208}
static int AVIDec_DropSample(struct avi_decompressor *This, REFERENCE_TIME tStart)
Definition: avidec.c:90
#define assert(_expr)
Definition: assert.h:32
GLbitfield flags
Definition: glext.h:7161
DWORD VFWAPIV ICDecompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits)
Definition: msvideo_main.c:814
long LONG
Definition: pedump.c:60
DWORD biSizeImage
Definition: amvideo.idl:36
unsigned char * LPBYTE
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
#define ICERR_OK
Definition: vfw.h:50
#define ICDECOMPRESS_NOTKEYFRAME
Definition: vfw.h:331
#define ICDECOMPRESS_PREROLL
Definition: vfw.h:329
#define ICDECOMPRESS_HURRYUP
Definition: vfw.h:327
#define VFW_S_NO_STOP_TIME
Definition: vfwmsgs.h:34
#define VFW_E_WRONG_STATE
Definition: vfwmsgs.h:78
#define VFW_E_NOT_CONNECTED
Definition: vfwmsgs.h:48
#define S_FALSE
Definition: winerror.h:3451

◆ avi_decompressor_source_DecideBufferSize()

static HRESULT WINAPI avi_decompressor_source_DecideBufferSize ( struct strmbase_source *  iface,
IMemAllocator *  pAlloc,
ALLOCATOR_PROPERTIES *  ppropInputRequest 
)
static

Definition at line 431 of file avidec.c.

433{
434 const VIDEOINFOHEADER *source_format = (VIDEOINFOHEADER *)iface->pin.mt.pbFormat;
436
437 if (!ppropInputRequest->cbAlign)
438 ppropInputRequest->cbAlign = 1;
439
440 if (ppropInputRequest->cbBuffer < source_format->bmiHeader.biSizeImage)
441 ppropInputRequest->cbBuffer = source_format->bmiHeader.biSizeImage;
442
443 if (!ppropInputRequest->cBuffers)
444 ppropInputRequest->cBuffers = 1;
445
446 return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
447}
struct strmbase_pin pin
Definition: strmbase.h:79

◆ avi_decompressor_source_get_media_type()

static HRESULT avi_decompressor_source_get_media_type ( struct strmbase_pin *  iface,
unsigned int  index,
AM_MEDIA_TYPE *  mt 
)
static

Definition at line 317 of file avidec.c.

319{
320 static const struct
321 {
322 const GUID *subtype;
324 WORD bpp;
325 }
326 formats[] =
327 {
328 {&MEDIASUBTYPE_CLJR, mmioFOURCC('C','L','J','R'), 8},
329 {&MEDIASUBTYPE_UYVY, mmioFOURCC('U','Y','V','Y'), 16},
330 {&MEDIASUBTYPE_YUY2, mmioFOURCC('Y','U','Y','2'), 16},
331 {&MEDIASUBTYPE_RGB32, BI_RGB, 32},
332 {&MEDIASUBTYPE_RGB24, BI_RGB, 24},
333 {&MEDIASUBTYPE_RGB565, BI_BITFIELDS, 16},
334 {&MEDIASUBTYPE_RGB555, BI_RGB, 16},
335 {&MEDIASUBTYPE_RGB8, BI_RGB, 8},
336 };
337
339 const VIDEOINFOHEADER *sink_format;
341
342 if (!filter->sink.pin.peer)
343 return VFW_S_NO_MORE_ITEMS;
344
345 sink_format = (VIDEOINFOHEADER *)filter->sink.pin.mt.pbFormat;
346
347 memset(mt, 0, sizeof(AM_MEDIA_TYPE));
348
349 if (index < ARRAY_SIZE(formats))
350 {
351 /* In theory we could allocate less than this, but gcc generates
352 * -Warray-bounds warnings if we access the structure through a
353 * VIDEOINFO pointer, even if we only access valid fields. */
354 if (!(format = CoTaskMemAlloc(sizeof(*format))))
355 return E_OUTOFMEMORY;
356 memset(format, 0, sizeof(*format));
357
358 format->rcSource = sink_format->rcSource;
359 format->rcTarget = sink_format->rcTarget;
360 format->dwBitRate = sink_format->dwBitRate;
361 format->dwBitErrorRate = sink_format->dwBitErrorRate;
362 format->AvgTimePerFrame = sink_format->AvgTimePerFrame;
363
364 format->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
365 format->bmiHeader.biWidth = sink_format->bmiHeader.biWidth;
366 format->bmiHeader.biHeight = sink_format->bmiHeader.biHeight;
367 format->bmiHeader.biPlanes = sink_format->bmiHeader.biPlanes;
368 format->bmiHeader.biBitCount = formats[index].bpp;
369 format->bmiHeader.biCompression = formats[index].compression;
370 format->bmiHeader.biSizeImage = format->bmiHeader.biHeight * (((format->bmiHeader.biWidth
371 * formats[index].bpp + 31) / 8) & ~3);
372
373 if (IsEqualGUID(formats[index].subtype, &MEDIASUBTYPE_RGB565))
374 {
375 format->dwBitMasks[iRED] = 0xf800;
376 format->dwBitMasks[iGREEN] = 0x07e0;
377 format->dwBitMasks[iBLUE] = 0x001f;
378 mt->cbFormat = offsetof(VIDEOINFO, dwBitMasks[3]);
379 }
380 else
381 mt->cbFormat = sizeof(VIDEOINFOHEADER);
382
383 mt->majortype = MEDIATYPE_Video;
384 mt->subtype = *formats[index].subtype;
385 mt->bFixedSizeSamples = TRUE;
386 mt->lSampleSize = format->bmiHeader.biSizeImage;
387 mt->formattype = FORMAT_VideoInfo;
388 mt->pbFormat = (BYTE *)format;
389
390 return S_OK;
391 }
392
393 if (index == ARRAY_SIZE(formats))
394 {
395 size_t size = ICDecompressGetFormatSize(filter->hvid, &sink_format->bmiHeader);
396
397 if (!size)
398 return VFW_S_NO_MORE_ITEMS;
399
400 mt->cbFormat = offsetof(VIDEOINFOHEADER, bmiHeader) + size;
401 if (!(format = CoTaskMemAlloc(mt->cbFormat)))
402 return E_OUTOFMEMORY;
403 memset(format, 0, mt->cbFormat);
404
405 format->rcSource = sink_format->rcSource;
406 format->rcTarget = sink_format->rcTarget;
407 format->dwBitRate = sink_format->dwBitRate;
408 format->dwBitErrorRate = sink_format->dwBitErrorRate;
409 format->AvgTimePerFrame = sink_format->AvgTimePerFrame;
410
411 if (ICDecompressGetFormat(filter->hvid, &sink_format->bmiHeader, &format->bmiHeader))
412 {
414 return VFW_S_NO_MORE_ITEMS;
415 }
416
417 mt->majortype = MEDIATYPE_Video;
418 mt->subtype = MEDIATYPE_Video;
419 mt->subtype.Data1 = format->bmiHeader.biCompression;
420 mt->bFixedSizeSamples = TRUE;
421 mt->lSampleSize = format->bmiHeader.biSizeImage;
422 mt->formattype = FORMAT_VideoInfo;
423 mt->pbFormat = (BYTE *)format;
424
425 return S_OK;
426 }
427
428 return VFW_S_NO_MORE_ITEMS;
429}
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
Definition: btrfs_drv.h:1365
#define TRUE
Definition: types.h:120
static const struct pixel_format_desc formats[]
Definition: util.c:31
struct tagVIDEOINFOHEADER VIDEOINFOHEADER
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
#define BI_BITFIELDS
Definition: mmreg.h:507
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
const GUID * subtype
Definition: mpegvideo.c:120
#define offsetof(TYPE, MEMBER)
#define memset(x, y, z)
Definition: compat.h:39
REFERENCE_TIME AvgTimePerFrame
Definition: amvideo.idl:187
#define BI_RGB
Definition: uefivid.c:46
#define ICDecompressGetFormatSize(hic, lpbi)
Definition: vfw.h:389
#define ICDecompressGetFormat(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:383
#define VFW_S_NO_MORE_ITEMS
Definition: vfwmsgs.h:19
ULONG bpp[]
Definition: xlate.c:19
unsigned char BYTE
Definition: xxhash.c:193

◆ avi_decompressor_source_qc_AddRef()

static ULONG WINAPI avi_decompressor_source_qc_AddRef ( IQualityControl *  iface)
static

Definition at line 471 of file avidec.c.

472{
474 return IPin_AddRef(&filter->source.pin.IPin_iface);
475}
static struct avi_decompressor * impl_from_source_IQualityControl(IQualityControl *iface)
Definition: avidec.c:459

◆ avi_decompressor_source_qc_Notify()

static HRESULT WINAPI avi_decompressor_source_qc_Notify ( IQualityControl *  iface,
IBaseFilter *  sender,
Quality  q 
)
static

Definition at line 483 of file avidec.c.

485{
487
488 TRACE("filter %p, sender %p, type %#x, proportion %ld, late %s, timestamp %s.\n",
489 filter, sender, q.Type, q.Proportion, debugstr_time(q.Late), debugstr_time(q.TimeStamp));
490
491 /* can't take the stream CS here, Submarine Titans calls this function from a foreign thread while inside sink_Receive */
492 EnterCriticalSection(&filter->late_cs);
493 if (q.Late > 0)
494 filter->late = q.Late + q.TimeStamp;
495 else
496 filter->late = -1;
497 LeaveCriticalSection(&filter->late_cs);
498 return S_OK;
499}
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
static const char * debugstr_time(REFERENCE_TIME time)
Definition: strmbase.h:32

◆ avi_decompressor_source_qc_QueryInterface()

static HRESULT WINAPI avi_decompressor_source_qc_QueryInterface ( IQualityControl *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 464 of file avidec.c.

466{
468 return IPin_QueryInterface(&filter->source.pin.IPin_iface, iid, out);
469}

◆ avi_decompressor_source_qc_Release()

static ULONG WINAPI avi_decompressor_source_qc_Release ( IQualityControl *  iface)
static

Definition at line 477 of file avidec.c.

478{
480 return IPin_Release(&filter->source.pin.IPin_iface);
481}

◆ avi_decompressor_source_qc_SetSink()

static HRESULT WINAPI avi_decompressor_source_qc_SetSink ( IQualityControl *  iface,
IQualityControl *  sink 
)
static

Definition at line 501 of file avidec.c.

502{
504
505 TRACE("filter %p, sink %p.\n", filter, sink);
506
507 return S_OK;
508}
GLsizei GLenum GLboolean sink
Definition: glext.h:5672

◆ avi_decompressor_source_query_accept()

static HRESULT avi_decompressor_source_query_accept ( struct strmbase_pin *  iface,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 300 of file avidec.c.

301{
303 VIDEOINFOHEADER *sink_format, *format;
304
305 if (!filter->sink.pin.peer || !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
306 return S_FALSE;
307
308 sink_format = (VIDEOINFOHEADER *)filter->sink.pin.mt.pbFormat;
309 format = (VIDEOINFOHEADER *)mt->pbFormat;
310
311 if (ICDecompressQuery(filter->hvid, &sink_format->bmiHeader, &format->bmiHeader))
312 return S_FALSE;
313
314 return S_OK;
315}

◆ avi_decompressor_source_query_interface()

static HRESULT avi_decompressor_source_query_interface ( struct strmbase_pin *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 285 of file avidec.c.

286{
288
289 if (IsEqualGUID(iid, &IID_IQualityControl))
290 *out = &filter->source_IQualityControl_iface;
291 else if (IsEqualGUID(iid, &IID_IMediaSeeking))
292 *out = &filter->passthrough.IMediaSeeking_iface;
293 else
294 return E_NOINTERFACE;
295
296 IUnknown_AddRef((IUnknown *)*out);
297 return S_OK;
298}
IMediaSeeking IMediaSeeking_iface
Definition: filter.c:167

◆ AVIDec_DropSample()

static int AVIDec_DropSample ( struct avi_decompressor *  This,
REFERENCE_TIME  tStart 
)
static

Definition at line 90 of file avidec.c.

91{
92 if (This->late < 0)
93 return 0;
94
95 if (tStart < This->late) {
96 TRACE("Dropping sample\n");
97 return 1;
98 }
99 This->late = -1;
100 return 0;
101}

Referenced by avi_decompressor_sink_Receive().

◆ impl_from_source_IQualityControl()

static struct avi_decompressor * impl_from_source_IQualityControl ( IQualityControl *  iface)
static

Definition at line 459 of file avidec.c.

460{
461 return CONTAINING_RECORD(iface, struct avi_decompressor, source_IQualityControl_iface);
462}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by avi_decompressor_source_qc_AddRef(), avi_decompressor_source_qc_Notify(), avi_decompressor_source_qc_QueryInterface(), avi_decompressor_source_qc_Release(), and avi_decompressor_source_qc_SetSink().

◆ impl_from_strmbase_filter()

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( quartz  )

Variable Documentation

◆ filter_ops

const struct strmbase_filter_ops filter_ops
static
Initial value:
=
{
.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,
}
static void avi_decompressor_destroy(struct strmbase_filter *iface)
Definition: avidec.c:530
static struct strmbase_pin * avi_decompressor_get_pin(struct strmbase_filter *iface, unsigned int index)
Definition: avidec.c:519
static HRESULT avi_decompressor_init_stream(struct strmbase_filter *iface)
Definition: avidec.c:553
static HRESULT avi_decompressor_cleanup_stream(struct strmbase_filter *iface)
Definition: avidec.c:580

Definition at line 605 of file avidec.c.

Referenced by avi_dec_create().

◆ sink_ops

const struct strmbase_sink_ops sink_ops
static
Initial value:
=
{
.base.pin_query_interface = avi_decompressor_sink_query_interface,
.base.pin_query_accept = avi_decompressor_sink_query_accept,
}
static HRESULT avi_decompressor_sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *pmt)
Definition: avidec.c:210
static HRESULT avi_decompressor_sink_end_flush(struct strmbase_sink *iface)
Definition: avidec.c:79
static void avi_decompressor_sink_disconnect(struct strmbase_sink *iface)
Definition: avidec.c:264
static HRESULT avi_decompressor_sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
Definition: avidec.c:74
static HRESULT WINAPI avi_decompressor_sink_Receive(struct strmbase_sink *iface, IMediaSample *pSample)
Definition: avidec.c:103
static HRESULT avi_decompressor_sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
Definition: avidec.c:61

Definition at line 275 of file avidec.c.

Referenced by avi_dec_create().

◆ source_ops

const struct strmbase_source_ops source_ops
static
Initial value:
=
{
.base.pin_query_interface = avi_decompressor_source_query_interface,
.base.pin_query_accept = avi_decompressor_source_query_accept,
.base.pin_get_media_type = avi_decompressor_source_get_media_type,
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
.pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
}
static HRESULT avi_decompressor_source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
Definition: avidec.c:285
static HRESULT avi_decompressor_source_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
Definition: avidec.c:317
static HRESULT avi_decompressor_source_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
Definition: avidec.c:300
static HRESULT WINAPI avi_decompressor_source_DecideBufferSize(struct strmbase_source *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
Definition: avidec.c:431
HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(struct strmbase_source *pin, IMemInputPin *peer, IMemAllocator **allocator)
Definition: pin.c:680
HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *pin, IPin *peer, const AM_MEDIA_TYPE *mt)
Definition: pin.c:710

Definition at line 449 of file avidec.c.

Referenced by avi_dec_create().

◆ source_qc_vtbl

const IQualityControlVtbl source_qc_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI avi_decompressor_source_qc_Notify(IQualityControl *iface, IBaseFilter *sender, Quality q)
Definition: avidec.c:483
static HRESULT WINAPI avi_decompressor_source_qc_QueryInterface(IQualityControl *iface, REFIID iid, void **out)
Definition: avidec.c:464
static HRESULT WINAPI avi_decompressor_source_qc_SetSink(IQualityControl *iface, IQualityControl *sink)
Definition: avidec.c:501
static ULONG WINAPI avi_decompressor_source_qc_AddRef(IQualityControl *iface)
Definition: avidec.c:471
static ULONG WINAPI avi_decompressor_source_qc_Release(IQualityControl *iface)
Definition: avidec.c:477

Definition at line 510 of file avidec.c.

Referenced by avi_dec_create().