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 |
|
|
215 |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
216 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
217 |
DPRINTF("dll load failed"); |
DPRINTF("dll load failed"); |
218 |
MessageBox(0, XVID_DLL_NAME " not found","Error", 0); |
MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST); |
219 |
return; |
return; |
220 |
} |
} |
221 |
|
|
222 |
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"); |
223 |
if (xvid_global_func == NULL) { |
if (xvid_global_func == NULL) { |
224 |
MessageBox(0, "xvid_global() not found", "Error", 0); |
MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST); |
225 |
return; |
return; |
226 |
} |
} |
227 |
|
|
228 |
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"); |
229 |
if (xvid_decore_func == NULL) { |
if (xvid_decore_func == NULL) { |
230 |
MessageBox(0, "xvid_decore() not found", "Error", 0); |
MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST); |
231 |
return; |
return; |
232 |
} |
} |
233 |
|
|
234 |
if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0) |
if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0) |
235 |
{ |
{ |
236 |
MessageBox(0, "xvid_global() failed", "Error", 0); |
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
237 |
return; |
return; |
238 |
} |
} |
239 |
|
|
286 |
|
|
287 |
switch (g_config.aspect_ratio) |
switch (g_config.aspect_ratio) |
288 |
{ |
{ |
289 |
case 0: // Auto mode |
case 0: |
|
ar_x = ar_y = 0; |
|
|
break; |
|
290 |
case 1: |
case 1: |
291 |
|
break; |
292 |
|
case 2: |
293 |
ar_x = 4; |
ar_x = 4; |
294 |
ar_y = 3; |
ar_y = 3; |
295 |
break; |
break; |
296 |
case 2: |
case 3: |
297 |
ar_x = 16; |
ar_x = 16; |
298 |
ar_y = 9; |
ar_y = 9; |
299 |
break; |
break; |
300 |
case 3: |
case 4: |
301 |
ar_x = 47; |
ar_x = 47; |
302 |
ar_y = 20; |
ar_y = 20; |
303 |
break; |
break; |
335 |
DPRINTF("CheckInputType"); |
DPRINTF("CheckInputType"); |
336 |
BITMAPINFOHEADER * hdr; |
BITMAPINFOHEADER * hdr; |
337 |
|
|
338 |
|
ar_x = ar_y = 0; |
339 |
|
|
340 |
if (*mtIn->Type() != MEDIATYPE_Video) |
if (*mtIn->Type() != MEDIATYPE_Video) |
341 |
{ |
{ |
342 |
DPRINTF("Error: Unknown Type"); |
DPRINTF("Error: Unknown Type"); |
348 |
{ |
{ |
349 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format(); |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format(); |
350 |
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 */ |
|
|
if ((ar_x == 0) && (ar_y == 0)) // selected Auto-mode |
|
|
{ |
|
|
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); |
|
351 |
} |
} |
352 |
else if (*mtIn->FormatType() == FORMAT_VideoInfo2) |
else if (*mtIn->FormatType() == FORMAT_VideoInfo2) |
353 |
{ |
{ |
354 |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format(); |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format(); |
355 |
hdr = &vih2->bmiHeader; |
hdr = &vih2->bmiHeader; |
356 |
if ((ar_x == 0) && (ar_y == 0)) // selected Auto-mode |
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { |
|
{ |
|
357 |
ar_x = vih2->dwPictAspectRatioX; |
ar_x = vih2->dwPictAspectRatioX; |
358 |
ar_y = vih2->dwPictAspectRatioY; |
ar_y = vih2->dwPictAspectRatioY; |
359 |
} |
} |
436 |
if (ar_x != 0 && ar_y != 0) { |
if (ar_x != 0 && ar_y != 0) { |
437 |
vih->dwPictAspectRatioX = ar_x; |
vih->dwPictAspectRatioX = ar_x; |
438 |
vih->dwPictAspectRatioY = ar_y; |
vih->dwPictAspectRatioY = ar_y; |
439 |
|
forced_ar = true; |
440 |
} else { // just to be safe |
} else { // just to be safe |
441 |
vih->dwPictAspectRatioX = m_create.width; |
vih->dwPictAspectRatioX = m_create.width; |
442 |
vih->dwPictAspectRatioY = abs(m_create.height); |
vih->dwPictAspectRatioY = abs(m_create.height); |
443 |
|
forced_ar = false; |
444 |
} |
} |
|
|
|
445 |
} else { |
} else { |
446 |
|
|
447 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER)); |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER)); |
764 |
m_frame.output.csp &= ~XVID_CSP_VFLIP; |
m_frame.output.csp &= ~XVID_CSP_VFLIP; |
765 |
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); |
766 |
|
|
767 |
|
|
768 |
|
|
769 |
|
|
770 |
repeat : |
repeat : |
771 |
|
|
772 |
if (pIn->IsPreroll() != S_OK) |
if (pIn->IsPreroll() != S_OK) |
777 |
{ |
{ |
778 |
DPRINTF("*** XVID_DEC_DECODE"); |
DPRINTF("*** XVID_DEC_DECODE"); |
779 |
return S_FALSE; |
return S_FALSE; |
780 |
|
} else |
781 |
|
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1 && forced_ar == false) { |
782 |
|
// inspired by minolta! works for VMR 7 + 9 |
783 |
|
|
784 |
|
IMediaSample2 *pOut2 = NULL; |
785 |
|
AM_SAMPLE2_PROPERTIES outProp2; |
786 |
|
if (SUCCEEDED(pOut->QueryInterface(IID_IMediaSample2, (void **)&pOut2)) && |
787 |
|
SUCCEEDED(pOut2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&outProp2))) |
788 |
|
{ |
789 |
|
CMediaType mtOut2 = m_pOutput->CurrentMediaType(); |
790 |
|
VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format(); |
791 |
|
|
792 |
|
if (*mtOut2.FormatType() == FORMAT_VideoInfo2 && |
793 |
|
vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y) |
794 |
|
{ |
795 |
|
vihOut2->dwPictAspectRatioX = ar_x; |
796 |
|
vihOut2->dwPictAspectRatioY = ar_y; |
797 |
|
pOut2->SetMediaType(&mtOut2); |
798 |
|
m_pOutput->SetMediaType(&mtOut2); |
799 |
|
} |
800 |
|
pOut2->Release(); |
801 |
|
} |
802 |
} |
} |
803 |
} |
} |
804 |
else |
else |
840 |
return S_FALSE; |
return S_FALSE; |
841 |
} |
} |
842 |
|
|
|
// pOut->SetDiscontinuity(TRUE); |
|
843 |
pOut->SetSyncPoint(TRUE); |
pOut->SetSyncPoint(TRUE); |
844 |
|
|
845 |
|
if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { /* auto */ |
846 |
|
int par_x, par_y; |
847 |
|
if (stats.data.vol.par == XVID_PAR_EXT) { |
848 |
|
par_x = stats.data.vol.par_width; |
849 |
|
par_y = stats.data.vol.par_height; |
850 |
|
} else { |
851 |
|
par_x = PARS[stats.data.vol.par-1][0]; |
852 |
|
par_y = PARS[stats.data.vol.par-1][1]; |
853 |
|
} |
854 |
|
|
855 |
|
ar_x = par_x * stats.data.vol.width; |
856 |
|
ar_y = par_y * stats.data.vol.height; |
857 |
|
} |
858 |
|
|
859 |
m_frame.bitstream = (BYTE*)m_frame.bitstream + length; |
m_frame.bitstream = (BYTE*)m_frame.bitstream + length; |
860 |
m_frame.length -= length; |
m_frame.length -= length; |
861 |
goto repeat; |
goto repeat; |