video.c 20.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Generic Implementation of strmbase video classes
 *
 * Copyright 2012 Aric Stewart, CodeWeavers
 *
 * 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
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

21
#include "strmbase_private.h"
22 23 24 25 26 27 28 29

WINE_DEFAULT_DEBUG_CHANNEL(strmbase);

static inline BaseControlVideo *impl_from_IBasicVideo(IBasicVideo *iface)
{
    return CONTAINING_RECORD(iface, BaseControlVideo, IBasicVideo_iface);
}

30
HRESULT WINAPI BaseControlVideo_Destroy(BaseControlVideo *pControlVideo)
31
{
32
    return S_OK;
33
}
34

35 36 37 38 39 40 41 42
static HRESULT BaseControlVideoImpl_CheckSourceRect(BaseControlVideo *This, RECT *pSourceRect)
{
    LONG VideoWidth, VideoHeight;
    HRESULT hr;

    if (IsRectEmpty(pSourceRect))
        return E_INVALIDARG;

43
    hr = IBasicVideo_GetVideoSize(&This->IBasicVideo_iface, &VideoWidth, &VideoHeight);
44 45 46 47 48 49 50 51 52 53
    if (FAILED(hr))
        return hr;

    if (pSourceRect->top < 0 || pSourceRect->left < 0 ||
        pSourceRect->bottom > VideoHeight || pSourceRect->right > VideoWidth)
        return E_INVALIDARG;

    return S_OK;
}

54 55 56 57 58 59 60 61
static HRESULT BaseControlVideoImpl_CheckTargetRect(BaseControlVideo *This, RECT *pTargetRect)
{
    if (IsRectEmpty(pTargetRect))
        return E_INVALIDARG;

    return S_OK;
}

62
static HRESULT WINAPI basic_video_QueryInterface(IBasicVideo *iface, REFIID iid, void **out)
63 64 65 66 67
{
    BaseControlVideo *video = impl_from_IBasicVideo(iface);
    return IUnknown_QueryInterface(video->pFilter->outer_unk, iid, out);
}

68
static ULONG WINAPI basic_video_AddRef(IBasicVideo *iface)
69 70 71 72 73
{
    BaseControlVideo *video = impl_from_IBasicVideo(iface);
    return IUnknown_AddRef(video->pFilter->outer_unk);
}

74
static ULONG WINAPI basic_video_Release(IBasicVideo *iface)
75 76 77 78 79
{
    BaseControlVideo *video = impl_from_IBasicVideo(iface);
    return IUnknown_Release(video->pFilter->outer_unk);
}

80
static HRESULT WINAPI basic_video_GetTypeInfoCount(IBasicVideo *iface, UINT *count)
81
{
82 83 84
    TRACE("iface %p, count %p.\n", iface, count);
    *count = 1;
    return S_OK;
85 86
}

87
static HRESULT WINAPI basic_video_GetTypeInfo(IBasicVideo *iface, UINT index,
88
        LCID lcid, ITypeInfo **typeinfo)
89
{
90 91
    TRACE("iface %p, index %u, lcid %#x, typeinfo %p.\n", iface, index, lcid, typeinfo);
    return strmbase_get_typeinfo(IBasicVideo_tid, typeinfo);
92 93
}

94
static HRESULT WINAPI basic_video_GetIDsOfNames(IBasicVideo *iface, REFIID iid,
95
        LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
96
{
97 98 99 100 101
    ITypeInfo *typeinfo;
    HRESULT hr;

    TRACE("iface %p, iid %s, names %p, count %u, lcid %#x, ids %p.\n",
            iface, debugstr_guid(iid), names, count, lcid, ids);
102

103 104 105 106 107 108
    if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo)))
    {
        hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, ids);
        ITypeInfo_Release(typeinfo);
    }
    return hr;
109 110
}

111
static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID iid, LCID lcid,
112
        WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *error_arg)
113
{
114
    ITypeInfo *typeinfo;
115
    HRESULT hr;
116

117 118 119 120
    TRACE("iface %p, id %d, iid %s, lcid %#x, flags %#x, params %p, result %p, excepinfo %p, error_arg %p.\n",
            iface, id, debugstr_guid(iid), lcid, flags, params, result, excepinfo, error_arg);

    if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo)))
121
    {
122 123
        hr = ITypeInfo_Invoke(typeinfo, iface, id, flags, params, result, excepinfo, error_arg);
        ITypeInfo_Release(typeinfo);
124 125
    }
    return hr;
126 127
}

128
static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame)
129 130 131 132
{
    VIDEOINFOHEADER *vih;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

133 134
    if (!pAvgTimePerFrame)
        return E_POINTER;
135 136 137 138 139 140 141 142 143 144
    if (!This->pPin->pConnectedTo)
        return VFW_E_NOT_CONNECTED;

    TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);

    vih = This->pFuncsTable->pfnGetVideoFormat(This);
    *pAvgTimePerFrame = vih->AvgTimePerFrame;
    return S_OK;
}

145
static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate)
146 147 148 149 150 151
{
    VIDEOINFOHEADER *vih;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);

152 153
    if (!pBitRate)
        return E_POINTER;
154 155 156 157 158 159 160 161
    if (!This->pPin->pConnectedTo)
        return VFW_E_NOT_CONNECTED;

    vih = This->pFuncsTable->pfnGetVideoFormat(This);
    *pBitRate = vih->dwBitRate;
    return S_OK;
}

162
static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate)
163 164 165 166 167 168
{
    VIDEOINFOHEADER *vih;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);

169 170
    if (!pBitErrorRate)
        return E_POINTER;
171 172 173 174 175 176 177 178
    if (!This->pPin->pConnectedTo)
        return VFW_E_NOT_CONNECTED;

    vih = This->pFuncsTable->pfnGetVideoFormat(This);
    *pBitErrorRate = vih->dwBitErrorRate;
    return S_OK;
}

179
static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth)
180 181 182 183 184
{
    VIDEOINFOHEADER *vih;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
185 186
    if (!pVideoWidth)
        return E_POINTER;
187 188 189 190 191 192 193

    vih = This->pFuncsTable->pfnGetVideoFormat(This);
    *pVideoWidth = vih->bmiHeader.biWidth;

    return S_OK;
}

194
static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight)
195 196 197 198 199
{
    VIDEOINFOHEADER *vih;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
200 201
    if (!pVideoHeight)
        return E_POINTER;
202 203

    vih = This->pFuncsTable->pfnGetVideoFormat(This);
204
    *pVideoHeight = abs(vih->bmiHeader.biHeight);
205 206 207 208

    return S_OK;
}

209
static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG SourceLeft)
210 211 212
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
213
    HRESULT hr;
214 215

    TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft);
216 217 218 219 220 221 222 223 224
    hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    if (SUCCEEDED(hr))
    {
        SourceRect.right = (SourceRect.right - SourceRect.left) + SourceLeft;
        SourceRect.left = SourceLeft;
        hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
225

226
    return hr;
227 228
}

229
static HRESULT WINAPI basic_video_get_SourceLeft(IBasicVideo *iface, LONG *pSourceLeft)
230 231 232 233 234
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
235 236
    if (!pSourceLeft)
        return E_POINTER;
237 238 239 240 241 242
    This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    *pSourceLeft = SourceRect.left;

    return S_OK;
}

243
static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG SourceWidth)
244 245 246
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
247
    HRESULT hr;
248 249

    TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth);
250 251 252 253 254 255 256 257
    hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    if (SUCCEEDED(hr))
    {
        SourceRect.right = SourceRect.left + SourceWidth;
        hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
258

259
    return hr;
260 261
}

262
static HRESULT WINAPI basic_video_get_SourceWidth(IBasicVideo *iface, LONG *pSourceWidth)
263 264 265 266 267
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
268 269
    if (!pSourceWidth)
        return E_POINTER;
270 271 272 273 274 275
    This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    *pSourceWidth = SourceRect.right - SourceRect.left;

    return S_OK;
}

276
static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG SourceTop)
277 278 279
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
280
    HRESULT hr;
281 282

    TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop);
283 284 285 286 287 288 289 290 291
    hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    if (SUCCEEDED(hr))
    {
        SourceRect.bottom = (SourceRect.bottom - SourceRect.top) + SourceTop;
        SourceRect.top = SourceTop;
        hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
292

293
    return hr;
294 295
}

296
static HRESULT WINAPI basic_video_get_SourceTop(IBasicVideo *iface, LONG *pSourceTop)
297 298 299 300 301
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
302 303
    if (!pSourceTop)
        return E_POINTER;
304 305 306 307 308 309
    This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    *pSourceTop = SourceRect.top;

    return S_OK;
}

310
static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG SourceHeight)
311 312 313
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
314
    HRESULT hr;
315 316

    TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight);
317 318 319 320 321 322 323 324
    hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
    if (SUCCEEDED(hr))
    {
        SourceRect.bottom = SourceRect.top + SourceHeight;
        hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
325

326
    return hr;
327 328
}

329
static HRESULT WINAPI basic_video_get_SourceHeight(IBasicVideo *iface, LONG *pSourceHeight)
330 331 332 333 334
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
335 336
    if (!pSourceHeight)
        return E_POINTER;
337 338 339 340 341 342 343
    This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);

    *pSourceHeight = SourceRect.bottom - SourceRect.top;

    return S_OK;
}

344
static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG DestinationLeft)
345 346 347
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
348
    HRESULT hr;
349 350

    TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
351 352 353 354 355 356 357 358 359
    hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    if (SUCCEEDED(hr))
    {
        DestRect.right = (DestRect.right - DestRect.left) + DestinationLeft;
        DestRect.left = DestinationLeft;
        hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
360

361
    return hr;
362 363
}

364
static HRESULT WINAPI basic_video_get_DestinationLeft(IBasicVideo *iface, LONG *pDestinationLeft)
365 366 367 368 369
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
370 371
    if (!pDestinationLeft)
        return E_POINTER;
372 373 374 375 376 377
    This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    *pDestinationLeft = DestRect.left;

    return S_OK;
}

378
static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG DestinationWidth)
379 380 381
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
382
    HRESULT hr;
383 384

    TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
385 386 387 388 389 390 391 392
    hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    if (SUCCEEDED(hr))
    {
        DestRect.right = DestRect.left + DestinationWidth;
        hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
393

394
    return hr;
395 396
}

397
static HRESULT WINAPI basic_video_get_DestinationWidth(IBasicVideo *iface, LONG *pDestinationWidth)
398 399 400 401 402
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
403 404
    if (!pDestinationWidth)
        return E_POINTER;
405 406 407 408 409 410
    This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    *pDestinationWidth = DestRect.right - DestRect.left;

    return S_OK;
}

411
static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG DestinationTop)
412 413 414
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
415
    HRESULT hr;
416 417

    TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
418 419 420 421 422 423 424 425 426
    hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    if (SUCCEEDED(hr))
    {
        DestRect.bottom = (DestRect.bottom - DestRect.top) + DestinationTop;
        DestRect.top = DestinationTop;
        hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
427

428
    return hr;
429 430
}

431
static HRESULT WINAPI basic_video_get_DestinationTop(IBasicVideo *iface, LONG *pDestinationTop)
432 433 434 435 436
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
437 438
    if (!pDestinationTop)
        return E_POINTER;
439 440 441 442 443 444
    This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    *pDestinationTop = DestRect.top;

    return S_OK;
}

445
static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG DestinationHeight)
446 447 448
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
449
    HRESULT hr;
450 451

    TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
452 453 454 455 456 457 458 459
    hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
    if (SUCCEEDED(hr))
    {
        DestRect.bottom = DestRect.top + DestinationHeight;
        hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect);
    }
    if (SUCCEEDED(hr))
        hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
460

461
    return hr;
462 463
}

464
static HRESULT WINAPI basic_video_get_DestinationHeight(IBasicVideo *iface, LONG *pDestinationHeight)
465 466 467 468 469
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
470 471
    if (!pDestinationHeight)
        return E_POINTER;
472
    This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
473
    *pDestinationHeight = DestRect.bottom - DestRect.top;
474 475 476 477

    return S_OK;
}

478
static HRESULT WINAPI basic_video_SetSourcePosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height)
479 480 481 482 483
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
484 485

    SetRect(&SourceRect, Left, Top, Left + Width, Top + Height);
486 487 488
    if (FAILED(BaseControlVideoImpl_CheckSourceRect(This, &SourceRect)))
        return E_INVALIDARG;
    return This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
489 490
}

491
static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
492 493 494 495 496
{
    RECT SourceRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
497 498
    if (!pLeft || !pTop || !pWidth || !pHeight)
        return E_POINTER;
499 500 501 502 503 504 505 506 507 508
    This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);

    *pLeft = SourceRect.left;
    *pTop = SourceRect.top;
    *pWidth = SourceRect.right - SourceRect.left;
    *pHeight = SourceRect.bottom - SourceRect.top;

    return S_OK;
}

509
static HRESULT WINAPI basic_video_SetDefaultSourcePosition(IBasicVideo *iface)
510 511 512 513 514 515 516
{
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->()\n", This, iface);
    return This->pFuncsTable->pfnSetDefaultSourceRect(This);
}

517
static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height)
518 519 520 521 522 523
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);

524
    SetRect(&DestRect, Left, Top, Left + Width, Top + Height);
525 526 527
    if (FAILED(BaseControlVideoImpl_CheckTargetRect(This, &DestRect)))
        return E_INVALIDARG;
    return This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
528 529
}

530
static HRESULT WINAPI basic_video_GetDestinationPosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
531 532 533 534 535
{
    RECT DestRect;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
536 537
    if (!pLeft || !pTop || !pWidth || !pHeight)
        return E_POINTER;
538 539 540 541 542 543 544 545 546 547
    This->pFuncsTable->pfnGetTargetRect(This, &DestRect);

    *pLeft = DestRect.left;
    *pTop = DestRect.top;
    *pWidth = DestRect.right - DestRect.left;
    *pHeight = DestRect.bottom - DestRect.top;

    return S_OK;
}

548
static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *iface)
549 550 551 552 553 554 555
{
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->()\n", This, iface);
    return This->pFuncsTable->pfnSetDefaultTargetRect(This);
}

556
static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight)
557 558 559 560 561
{
    VIDEOINFOHEADER *vih;
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
562 563
    if (!pWidth || !pHeight)
        return E_POINTER;
564 565 566 567 568 569 570 571

    vih = This->pFuncsTable->pfnGetVideoFormat(This);
    *pHeight = vih->bmiHeader.biHeight;
    *pWidth = vih->bmiHeader.biWidth;

    return S_OK;
}

572
static HRESULT WINAPI basic_video_GetVideoPaletteEntries(IBasicVideo *iface, LONG StartIndex, LONG Entries, LONG *pRetrieved, LONG *pPalette)
573 574 575 576
{
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
577 578
    if (!pRetrieved || !pPalette)
        return E_POINTER;
579

580
    *pRetrieved = 0;
581 582 583
    return VFW_E_NO_PALETTE_AVAILABLE;
}

584
static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *pBufferSize, LONG *pDIBImage)
585 586
{
    BaseControlVideo *This = impl_from_IBasicVideo(iface);
587 588
    if (!pBufferSize || !pDIBImage)
        return E_POINTER;
589 590 591 592

    return This->pFuncsTable->pfnGetStaticImage(This, pBufferSize, pDIBImage);
}

593
static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface)
594 595 596 597 598 599
{
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    return This->pFuncsTable->pfnIsDefaultSourceRect(This);
}

600
static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface)
601 602 603 604 605
{
    BaseControlVideo *This = impl_from_IBasicVideo(iface);

    return This->pFuncsTable->pfnIsDefaultTargetRect(This);
}
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660

static const IBasicVideoVtbl basic_video_vtbl =
{
    basic_video_QueryInterface,
    basic_video_AddRef,
    basic_video_Release,
    basic_video_GetTypeInfoCount,
    basic_video_GetTypeInfo,
    basic_video_GetIDsOfNames,
    basic_video_Invoke,
    basic_video_get_AvgTimePerFrame,
    basic_video_get_BitRate,
    basic_video_get_BitErrorRate,
    basic_video_get_VideoWidth,
    basic_video_get_VideoHeight,
    basic_video_put_SourceLeft,
    basic_video_get_SourceLeft,
    basic_video_put_SourceWidth,
    basic_video_get_SourceWidth,
    basic_video_put_SourceTop,
    basic_video_get_SourceTop,
    basic_video_put_SourceHeight,
    basic_video_get_SourceHeight,
    basic_video_put_DestinationLeft,
    basic_video_get_DestinationLeft,
    basic_video_put_DestinationWidth,
    basic_video_get_DestinationWidth,
    basic_video_put_DestinationTop,
    basic_video_get_DestinationTop,
    basic_video_put_DestinationHeight,
    basic_video_get_DestinationHeight,
    basic_video_SetSourcePosition,
    basic_video_GetSourcePosition,
    basic_video_SetDefaultSourcePosition,
    basic_video_SetDestinationPosition,
    basic_video_GetDestinationPosition,
    basic_video_SetDefaultDestinationPosition,
    basic_video_GetVideoSize,
    basic_video_GetVideoPaletteEntries,
    basic_video_GetCurrentImage,
    basic_video_IsUsingDefaultSource,
    basic_video_IsUsingDefaultDestination
};

HRESULT WINAPI strmbase_video_init(BaseControlVideo *video, BaseFilter *filter,
        CRITICAL_SECTION *cs, BasePin *pin, const BaseControlVideoFuncTable *func_table)
{
    video->IBasicVideo_iface.lpVtbl = &basic_video_vtbl;
    video->pFilter = filter;
    video->pInterfaceLock = cs;
    video->pPin = pin;
    video->pFuncsTable = func_table;

    return S_OK;
}