19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: CXvidDecoder.cpp,v 1.9 2004-07-16 15:38:01 syskin Exp $ |
* $Id: CXvidDecoder.cpp,v 1.13 2004-10-25 10:29:10 suxen_drol Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
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 |
|
|
549 |
|
|
550 |
|
|
551 |
/* (internal function) change colorspace */ |
/* (internal function) change colorspace */ |
552 |
|
#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) |
553 |
|
|
554 |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
555 |
{ |
{ |
556 |
|
DWORD biWidth; |
557 |
|
|
558 |
if (formattype == FORMAT_VideoInfo) |
if (formattype == FORMAT_VideoInfo) |
559 |
{ |
{ |
560 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; |
561 |
m_frame.output.stride[0] = (((vih->bmiHeader.biWidth * vih->bmiHeader.biBitCount) + 31) & ~31) >> 3; |
biWidth = vih->bmiHeader.biWidth; |
562 |
|
m_frame.output.stride[0] = CALC_BI_STRIDE(vih->bmiHeader.biWidth, vih->bmiHeader.biBitCount); |
563 |
rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
564 |
} |
} |
565 |
else if (formattype == FORMAT_VideoInfo2) |
else if (formattype == FORMAT_VideoInfo2) |
566 |
{ |
{ |
567 |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; |
568 |
m_frame.output.stride[0] = (((vih2->bmiHeader.biWidth * vih2->bmiHeader.biBitCount) + 31) & ~31) >> 3; |
biWidth = vih2->bmiHeader.biWidth; |
569 |
|
m_frame.output.stride[0] = CALC_BI_STRIDE(vih2->bmiHeader.biWidth, vih2->bmiHeader.biBitCount); |
570 |
rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
571 |
} |
} |
572 |
else |
else |
579 |
DPRINTF("IYUV"); |
DPRINTF("IYUV"); |
580 |
rgb_flip = 0; |
rgb_flip = 0; |
581 |
m_frame.output.csp = XVID_CSP_I420; |
m_frame.output.csp = XVID_CSP_I420; |
582 |
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 */ |
583 |
} |
} |
584 |
else if (subtype == MEDIASUBTYPE_YV12) |
else if (subtype == MEDIASUBTYPE_YV12) |
585 |
{ |
{ |
586 |
DPRINTF("YV12"); |
DPRINTF("YV12"); |
587 |
rgb_flip = 0; |
rgb_flip = 0; |
588 |
m_frame.output.csp = XVID_CSP_YV12; |
m_frame.output.csp = XVID_CSP_YV12; |
589 |
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 */ |
590 |
} |
} |
591 |
else if (subtype == MEDIASUBTYPE_YUY2) |
else if (subtype == MEDIASUBTYPE_YUY2) |
592 |
{ |
{ |
793 |
{ |
{ |
794 |
CMediaType mtOut2 = m_pOutput->CurrentMediaType(); |
CMediaType mtOut2 = m_pOutput->CurrentMediaType(); |
795 |
VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format(); |
VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format(); |
796 |
if (vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y) |
|
797 |
|
if (*mtOut2.FormatType() == FORMAT_VideoInfo2 && |
798 |
|
vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y) |
799 |
{ |
{ |
800 |
vihOut2->dwPictAspectRatioX = ar_x; |
vihOut2->dwPictAspectRatioX = ar_x; |
801 |
vihOut2->dwPictAspectRatioY = ar_y; |
vihOut2->dwPictAspectRatioY = ar_y; |
853 |
par_x = stats.data.vol.par_width; |
par_x = stats.data.vol.par_width; |
854 |
par_y = stats.data.vol.par_height; |
par_y = stats.data.vol.par_height; |
855 |
} else { |
} else { |
856 |
par_x = PARS[stats.data.vol.par][0]; |
par_x = PARS[stats.data.vol.par-1][0]; |
857 |
par_y = PARS[stats.data.vol.par][1]; |
par_y = PARS[stats.data.vol.par-1][1]; |
858 |
} |
} |
859 |
|
|
860 |
ar_x = par_x * stats.data.vol.width; |
ar_x = par_x * stats.data.vol.width; |