36 |
place these paths at the top of the Tools|Options|Directories list |
place these paths at the top of the Tools|Options|Directories list |
37 |
|
|
38 |
headers: |
headers: |
39 |
C:\DXVCSDK\include |
C:\DX90SDK\Include |
40 |
C:\DXVCSDK\samples\Multimedia\DirectShow\BaseClasses |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses |
41 |
|
|
42 |
libraries (optional): |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Release |
43 |
C:\DXVCSDK\samples\Multimedia\DirectShow\BaseClasses\Release |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
44 |
*/ |
*/ |
45 |
|
|
46 |
|
|
82 |
{ &MEDIATYPE_Video, &CLSID_DX50 }, |
{ &MEDIATYPE_Video, &CLSID_DX50 }, |
83 |
{ &MEDIATYPE_Video, &CLSID_DX50_UC }, |
{ &MEDIATYPE_Video, &CLSID_DX50_UC }, |
84 |
{ &MEDIATYPE_Video, &CLSID_MP4V }, |
{ &MEDIATYPE_Video, &CLSID_MP4V }, |
85 |
|
{ &MEDIATYPE_Video, &CLSID_MP4V_UC }, |
86 |
}; |
}; |
87 |
|
|
88 |
const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] = |
const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] = |
205 |
#define XVID_DLL_NAME "xvidcore.dll" |
#define XVID_DLL_NAME "xvidcore.dll" |
206 |
|
|
207 |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
208 |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID) |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL) |
209 |
{ |
{ |
210 |
DPRINTF("Constructor"); |
DPRINTF("Constructor"); |
211 |
|
|
212 |
|
xvid_decore_func = NULL; // Hmm, some strange errors appearing if I try to initialize... |
213 |
|
xvid_global_func = NULL; // ...this in constructor's init-list. So, they assigned here. |
214 |
|
|
215 |
|
LoadRegistryInfo(); |
216 |
|
|
217 |
|
*phr = OpenLib(); |
218 |
|
} |
219 |
|
|
220 |
|
HRESULT CXvidDecoder::OpenLib() |
221 |
|
{ |
222 |
|
DPRINTF("OpenLib"); |
223 |
|
|
224 |
|
if (m_hdll != NULL) |
225 |
|
return E_UNEXPECTED; // Seems, that library already opened. |
226 |
|
|
227 |
xvid_gbl_init_t init; |
xvid_gbl_init_t init; |
228 |
memset(&init, 0, sizeof(init)); |
memset(&init, 0, sizeof(init)); |
229 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
230 |
|
|
|
ar_x = ar_y = 0; |
|
|
|
|
231 |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
232 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
233 |
DPRINTF("dll load failed"); |
DPRINTF("dll load failed"); |
234 |
MessageBox(0, XVID_DLL_NAME " not found","Error", 0); |
MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST); |
235 |
return; |
return E_FAIL; |
236 |
} |
} |
237 |
|
|
238 |
xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global"); |
xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global"); |
239 |
if (xvid_global_func == NULL) { |
if (xvid_global_func == NULL) { |
240 |
MessageBox(0, "xvid_global() not found", "Error", 0); |
FreeLibrary(m_hdll); |
241 |
return; |
m_hdll = NULL; |
242 |
|
MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST); |
243 |
|
return E_FAIL; |
244 |
} |
} |
245 |
|
|
246 |
xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore"); |
xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore"); |
247 |
if (xvid_decore_func == NULL) { |
if (xvid_decore_func == NULL) { |
248 |
MessageBox(0, "xvid_decore() not found", "Error", 0); |
xvid_global_func = NULL; |
249 |
return; |
FreeLibrary(m_hdll); |
250 |
|
m_hdll = NULL; |
251 |
|
MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST); |
252 |
|
return E_FAIL; |
253 |
} |
} |
254 |
|
|
255 |
if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0) |
if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0) |
256 |
{ |
{ |
257 |
MessageBox(0, "xvid_global() failed", "Error", 0); |
xvid_global_func = NULL; |
258 |
return; |
xvid_decore_func = NULL; |
259 |
|
FreeLibrary(m_hdll); |
260 |
|
m_hdll = NULL; |
261 |
|
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
262 |
|
return E_FAIL; |
263 |
} |
} |
264 |
|
|
265 |
memset(&m_create, 0, sizeof(m_create)); |
memset(&m_create, 0, sizeof(m_create)); |
269 |
memset(&m_frame, 0, sizeof(m_frame)); |
memset(&m_frame, 0, sizeof(m_frame)); |
270 |
m_frame.version = XVID_VERSION; |
m_frame.version = XVID_VERSION; |
271 |
|
|
|
LoadRegistryInfo(); |
|
|
|
|
272 |
USE_IYUV = false; |
USE_IYUV = false; |
273 |
USE_YV12 = false; |
USE_YV12 = false; |
274 |
USE_YUY2 = false; |
USE_YUY2 = false; |
306 |
USE_RGB32 = true; |
USE_RGB32 = true; |
307 |
break; |
break; |
308 |
} |
} |
|
} |
|
|
|
|
309 |
|
|
310 |
|
switch (g_config.aspect_ratio) |
311 |
|
{ |
312 |
|
case 0: |
313 |
|
case 1: |
314 |
|
break; |
315 |
|
case 2: |
316 |
|
ar_x = 4; |
317 |
|
ar_y = 3; |
318 |
|
break; |
319 |
|
case 3: |
320 |
|
ar_x = 16; |
321 |
|
ar_y = 9; |
322 |
|
break; |
323 |
|
case 4: |
324 |
|
ar_x = 47; |
325 |
|
ar_y = 20; |
326 |
|
break; |
327 |
|
} |
328 |
|
|
329 |
/* destructor */ |
return S_OK; |
330 |
|
} |
331 |
|
|
332 |
CXvidDecoder::~CXvidDecoder() |
void CXvidDecoder::CloseLib() |
333 |
{ |
{ |
334 |
DPRINTF("Destructor"); |
DPRINTF("CloseLib"); |
335 |
|
|
336 |
if (m_create.handle != NULL) |
if ((m_create.handle != NULL) && (xvid_decore_func != NULL)) |
337 |
{ |
{ |
338 |
xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0); |
xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0); |
339 |
m_create.handle = NULL; |
m_create.handle = NULL; |
340 |
} |
} |
341 |
|
|
342 |
if (m_hdll != NULL) |
if (m_hdll != NULL) { |
|
{ |
|
343 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
344 |
m_hdll = NULL; |
m_hdll = NULL; |
345 |
} |
} |
346 |
|
xvid_decore_func = NULL; |
347 |
|
xvid_global_func = NULL; |
348 |
|
} |
349 |
|
|
350 |
|
/* destructor */ |
351 |
|
|
352 |
|
CXvidDecoder::~CXvidDecoder() |
353 |
|
{ |
354 |
|
DPRINTF("Destructor"); |
355 |
|
CloseLib(); |
356 |
} |
} |
357 |
|
|
358 |
|
|
364 |
DPRINTF("CheckInputType"); |
DPRINTF("CheckInputType"); |
365 |
BITMAPINFOHEADER * hdr; |
BITMAPINFOHEADER * hdr; |
366 |
|
|
367 |
|
ar_x = ar_y = 0; |
368 |
|
|
369 |
if (*mtIn->Type() != MEDIATYPE_Video) |
if (*mtIn->Type() != MEDIATYPE_Video) |
370 |
{ |
{ |
371 |
DPRINTF("Error: Unknown Type"); |
DPRINTF("Error: Unknown Type"); |
372 |
|
CloseLib(); |
373 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
374 |
|
} |
375 |
|
|
376 |
|
if (m_hdll == NULL) |
377 |
|
{ |
378 |
|
HRESULT hr = OpenLib(); |
379 |
|
|
380 |
|
if (FAILED(hr) || (m_hdll == NULL)) // Paranoid checks. |
381 |
return VFW_E_TYPE_NOT_ACCEPTED; |
return VFW_E_TYPE_NOT_ACCEPTED; |
382 |
} |
} |
383 |
|
|
385 |
{ |
{ |
386 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format(); |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format(); |
387 |
hdr = &vih->bmiHeader; |
hdr = &vih->bmiHeader; |
|
/* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter |
|
|
which is equal to ppm_Y:ppm_X */ |
|
|
ar_x = vih->bmiHeader.biYPelsPerMeter * abs(hdr->biWidth); |
|
|
ar_y = vih->bmiHeader.biXPelsPerMeter * abs(hdr->biHeight); |
|
|
DPRINTF("VIDEOINFOHEADER PAR: %d:%d -> AR %d:%d", |
|
|
vih->bmiHeader.biYPelsPerMeter,vih->bmiHeader.biXPelsPerMeter, ar_x, ar_y); |
|
388 |
} |
} |
389 |
else if (*mtIn->FormatType() == FORMAT_VideoInfo2) |
else if (*mtIn->FormatType() == FORMAT_VideoInfo2) |
390 |
{ |
{ |
391 |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format(); |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format(); |
392 |
hdr = &vih2->bmiHeader; |
hdr = &vih2->bmiHeader; |
393 |
|
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { |
394 |
|
ar_x = vih2->dwPictAspectRatioX; |
395 |
|
ar_y = vih2->dwPictAspectRatioY; |
396 |
|
} |
397 |
|
DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y); |
398 |
|
} |
399 |
|
else if (*mtIn->FormatType() == FORMAT_MPEG2Video) { |
400 |
|
MPEG2VIDEOINFO * mpgvi = (MPEG2VIDEOINFO*)mtIn->Format(); |
401 |
|
VIDEOINFOHEADER2 * vih2 = &mpgvi->hdr; |
402 |
|
hdr = &vih2->bmiHeader; |
403 |
|
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { |
404 |
ar_x = vih2->dwPictAspectRatioX; |
ar_x = vih2->dwPictAspectRatioX; |
405 |
ar_y = vih2->dwPictAspectRatioY; |
ar_y = vih2->dwPictAspectRatioY; |
406 |
|
} |
407 |
DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y); |
DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y); |
408 |
|
|
409 |
|
/* haali media splitter reports VOL information in the format header */ |
410 |
|
|
411 |
|
if (mpgvi->cbSequenceHeader>0) { |
412 |
|
|
413 |
|
xvid_dec_stats_t stats; |
414 |
|
memset(&stats, 0, sizeof(stats)); |
415 |
|
stats.version = XVID_VERSION; |
416 |
|
|
417 |
|
if (m_create.handle == NULL) { |
418 |
|
if (xvid_decore_func == NULL) |
419 |
|
return E_FAIL; |
420 |
|
if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0) { |
421 |
|
DPRINTF("*** XVID_DEC_CREATE error"); |
422 |
|
return S_FALSE; |
423 |
|
} |
424 |
|
} |
425 |
|
|
426 |
|
m_frame.general = 0; |
427 |
|
m_frame.bitstream = (void*)mpgvi->dwSequenceHeader; |
428 |
|
m_frame.length = mpgvi->cbSequenceHeader; |
429 |
|
m_frame.output.csp = XVID_CSP_NULL; |
430 |
|
|
431 |
|
if (xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats) >= 0) { |
432 |
|
/* honour video dimensions reported in VOL header */ |
433 |
|
if (stats.type == XVID_TYPE_VOL) { |
434 |
|
hdr->biWidth = stats.data.vol.width; |
435 |
|
hdr->biHeight = stats.data.vol.height; |
436 |
|
} |
437 |
|
} |
438 |
|
|
439 |
|
} |
440 |
} |
} |
441 |
else |
else |
442 |
{ |
{ |
443 |
DPRINTF("Error: Unknown FormatType"); |
DPRINTF("Error: Unknown FormatType"); |
444 |
|
CloseLib(); |
445 |
return VFW_E_TYPE_NOT_ACCEPTED; |
return VFW_E_TYPE_NOT_ACCEPTED; |
446 |
} |
} |
447 |
|
|
455 |
|
|
456 |
switch(hdr->biCompression) |
switch(hdr->biCompression) |
457 |
{ |
{ |
458 |
|
case FOURCC_mp4v: |
459 |
case FOURCC_MP4V: |
case FOURCC_MP4V: |
460 |
if (!(g_config.supported_4cc & SUPPORT_MP4V)) return VFW_E_TYPE_NOT_ACCEPTED; |
if (!(g_config.supported_4cc & SUPPORT_MP4V)) { |
461 |
|
CloseLib(); |
462 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
463 |
|
} |
464 |
break; |
break; |
465 |
case FOURCC_DIVX : |
case FOURCC_DIVX : |
466 |
if (!(g_config.supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED; |
if (!(g_config.supported_4cc & SUPPORT_DIVX)) { |
467 |
|
CloseLib(); |
468 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
469 |
|
} |
470 |
break; |
break; |
471 |
case FOURCC_DX50 : |
case FOURCC_DX50 : |
472 |
if (!(g_config.supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED; |
if (!(g_config.supported_4cc & SUPPORT_DX50)) { |
473 |
|
CloseLib(); |
474 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
475 |
|
} |
476 |
case FOURCC_XVID : |
case FOURCC_XVID : |
477 |
break; |
break; |
478 |
|
|
484 |
(hdr->biCompression>>8)&0xff, |
(hdr->biCompression>>8)&0xff, |
485 |
(hdr->biCompression>>16)&0xff, |
(hdr->biCompression>>16)&0xff, |
486 |
(hdr->biCompression>>24)&0xff); |
(hdr->biCompression>>24)&0xff); |
487 |
|
CloseLib(); |
488 |
return VFW_E_TYPE_NOT_ACCEPTED; |
return VFW_E_TYPE_NOT_ACCEPTED; |
489 |
} |
} |
490 |
return S_OK; |
return S_OK; |
515 |
if (ar_x != 0 && ar_y != 0) { |
if (ar_x != 0 && ar_y != 0) { |
516 |
vih->dwPictAspectRatioX = ar_x; |
vih->dwPictAspectRatioX = ar_x; |
517 |
vih->dwPictAspectRatioY = ar_y; |
vih->dwPictAspectRatioY = ar_y; |
518 |
|
forced_ar = true; |
519 |
} else { // just to be safe |
} else { // just to be safe |
520 |
vih->dwPictAspectRatioX = m_create.width; |
vih->dwPictAspectRatioX = m_create.width; |
521 |
vih->dwPictAspectRatioY = abs(m_create.height); |
vih->dwPictAspectRatioY = abs(m_create.height); |
522 |
|
forced_ar = false; |
523 |
} |
} |
|
|
|
524 |
} else { |
} else { |
525 |
|
|
526 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER)); |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER)); |
628 |
|
|
629 |
|
|
630 |
/* (internal function) change colorspace */ |
/* (internal function) change colorspace */ |
631 |
|
#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) |
632 |
|
|
633 |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
634 |
{ |
{ |
635 |
|
DWORD biWidth; |
636 |
|
|
637 |
if (formattype == FORMAT_VideoInfo) |
if (formattype == FORMAT_VideoInfo) |
638 |
{ |
{ |
639 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; |
640 |
m_frame.output.stride[0] = (((vih->bmiHeader.biWidth * vih->bmiHeader.biBitCount) + 31) & ~31) >> 3; |
biWidth = vih->bmiHeader.biWidth; |
641 |
|
m_frame.output.stride[0] = CALC_BI_STRIDE(vih->bmiHeader.biWidth, vih->bmiHeader.biBitCount); |
642 |
rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
643 |
} |
} |
644 |
else if (formattype == FORMAT_VideoInfo2) |
else if (formattype == FORMAT_VideoInfo2) |
645 |
{ |
{ |
646 |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; |
647 |
m_frame.output.stride[0] = (((vih2->bmiHeader.biWidth * vih2->bmiHeader.biBitCount) + 31) & ~31) >> 3; |
biWidth = vih2->bmiHeader.biWidth; |
648 |
|
m_frame.output.stride[0] = CALC_BI_STRIDE(vih2->bmiHeader.biWidth, vih2->bmiHeader.biBitCount); |
649 |
rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
650 |
} |
} |
651 |
else |
else |
658 |
DPRINTF("IYUV"); |
DPRINTF("IYUV"); |
659 |
rgb_flip = 0; |
rgb_flip = 0; |
660 |
m_frame.output.csp = XVID_CSP_I420; |
m_frame.output.csp = XVID_CSP_I420; |
661 |
m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3; /* planar format fix */ |
m_frame.output.stride[0] = CALC_BI_STRIDE(biWidth, 8); /* planar format fix */ |
662 |
} |
} |
663 |
else if (subtype == MEDIASUBTYPE_YV12) |
else if (subtype == MEDIASUBTYPE_YV12) |
664 |
{ |
{ |
665 |
DPRINTF("YV12"); |
DPRINTF("YV12"); |
666 |
rgb_flip = 0; |
rgb_flip = 0; |
667 |
m_frame.output.csp = XVID_CSP_YV12; |
m_frame.output.csp = XVID_CSP_YV12; |
668 |
m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3; /* planar format fix */ |
m_frame.output.stride[0] = CALC_BI_STRIDE(biWidth, 8); /* planar format fix */ |
669 |
} |
} |
670 |
else if (subtype == MEDIASUBTYPE_YUY2) |
else if (subtype == MEDIASUBTYPE_YUY2) |
671 |
{ |
{ |
789 |
|
|
790 |
if (m_create.handle == NULL) |
if (m_create.handle == NULL) |
791 |
{ |
{ |
792 |
|
if (xvid_decore_func == NULL) |
793 |
|
return E_FAIL; |
794 |
|
|
795 |
if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0) |
if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0) |
796 |
{ |
{ |
797 |
DPRINTF("*** XVID_DEC_CREATE error"); |
DPRINTF("*** XVID_DEC_CREATE error"); |
829 |
m_frame.general = XVID_LOWDELAY; |
m_frame.general = XVID_LOWDELAY; |
830 |
|
|
831 |
if (pIn->IsDiscontinuity() == S_OK) |
if (pIn->IsDiscontinuity() == S_OK) |
832 |
m_frame.general = XVID_DISCONTINUITY; |
m_frame.general |= XVID_DISCONTINUITY; |
833 |
|
|
834 |
if (g_config.nDeblock_Y) |
if (g_config.nDeblock_Y) |
835 |
m_frame.general |= XVID_DEBLOCKY; |
m_frame.general |= XVID_DEBLOCKY; |
836 |
|
|
837 |
if (g_config.nDeblock_UV) |
if (g_config.nDeblock_UV) |
838 |
m_frame.general |= XVID_DEBLOCKUV; |
m_frame.general |= XVID_DEBLOCKUV; |
839 |
/* |
|
840 |
if (g_config.nDering) |
if (g_config.nDering_Y) |
841 |
m_frame.general |= XVID_DERING; |
m_frame.general |= XVID_DERINGY; |
842 |
*/ |
|
843 |
|
if (g_config.nDering_UV) |
844 |
|
m_frame.general |= XVID_DERINGUV; |
845 |
|
|
846 |
if (g_config.nFilmEffect) |
if (g_config.nFilmEffect) |
847 |
m_frame.general |= XVID_FILMEFFECT; |
m_frame.general |= XVID_FILMEFFECT; |
848 |
|
|
851 |
m_frame.output.csp &= ~XVID_CSP_VFLIP; |
m_frame.output.csp &= ~XVID_CSP_VFLIP; |
852 |
m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0); |
m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0); |
853 |
|
|
854 |
|
// Paranoid check. |
855 |
|
if (xvid_decore_func == NULL) |
856 |
|
return E_FAIL; |
857 |
|
|
858 |
|
|
859 |
|
|
860 |
repeat : |
repeat : |
861 |
|
|
862 |
if (pIn->IsPreroll() != S_OK) |
if (pIn->IsPreroll() != S_OK) |
867 |
{ |
{ |
868 |
DPRINTF("*** XVID_DEC_DECODE"); |
DPRINTF("*** XVID_DEC_DECODE"); |
869 |
return S_FALSE; |
return S_FALSE; |
870 |
|
} else |
871 |
|
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1 && forced_ar == false) { |
872 |
|
|
873 |
|
if (stats.type != XVID_TYPE_NOTHING) { /* dont attempt to set vmr aspect ratio if no frame was returned by decoder */ |
874 |
|
// inspired by minolta! works for VMR 7 + 9 |
875 |
|
IMediaSample2 *pOut2 = NULL; |
876 |
|
AM_SAMPLE2_PROPERTIES outProp2; |
877 |
|
if (SUCCEEDED(pOut->QueryInterface(IID_IMediaSample2, (void **)&pOut2)) && |
878 |
|
SUCCEEDED(pOut2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&outProp2))) |
879 |
|
{ |
880 |
|
CMediaType mtOut2 = m_pOutput->CurrentMediaType(); |
881 |
|
VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format(); |
882 |
|
|
883 |
|
if (*mtOut2.FormatType() == FORMAT_VideoInfo2 && |
884 |
|
vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y) |
885 |
|
{ |
886 |
|
vihOut2->dwPictAspectRatioX = ar_x; |
887 |
|
vihOut2->dwPictAspectRatioY = ar_y; |
888 |
|
pOut2->SetMediaType(&mtOut2); |
889 |
|
m_pOutput->SetMediaType(&mtOut2); |
890 |
|
} |
891 |
|
pOut2->Release(); |
892 |
|
} |
893 |
|
} |
894 |
} |
} |
895 |
} |
} |
896 |
else |
else |
932 |
return S_FALSE; |
return S_FALSE; |
933 |
} |
} |
934 |
|
|
|
// pOut->SetDiscontinuity(TRUE); |
|
935 |
pOut->SetSyncPoint(TRUE); |
pOut->SetSyncPoint(TRUE); |
936 |
|
|
937 |
|
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { /* auto */ |
938 |
|
int par_x, par_y; |
939 |
|
if (stats.data.vol.par == XVID_PAR_EXT) { |
940 |
|
par_x = stats.data.vol.par_width; |
941 |
|
par_y = stats.data.vol.par_height; |
942 |
|
} else { |
943 |
|
par_x = PARS[stats.data.vol.par-1][0]; |
944 |
|
par_y = PARS[stats.data.vol.par-1][1]; |
945 |
|
} |
946 |
|
|
947 |
|
ar_x = par_x * stats.data.vol.width; |
948 |
|
ar_y = par_y * stats.data.vol.height; |
949 |
|
} |
950 |
|
|
951 |
m_frame.bitstream = (BYTE*)m_frame.bitstream + length; |
m_frame.bitstream = (BYTE*)m_frame.bitstream + length; |
952 |
m_frame.length -= length; |
m_frame.length -= length; |
953 |
goto repeat; |
goto repeat; |