--- trunk/xvidcore/dshow/src/CXvidDecoder.cpp 2004/07/16 15:38:01 1498 +++ trunk/xvidcore/dshow/src/CXvidDecoder.cpp 2004/10/25 10:29:10 1558 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $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 $ * ****************************************************************************/ @@ -36,11 +36,11 @@ place these paths at the top of the Tools|Options|Directories list headers: - C:\DXVCSDK\include - C:\DXVCSDK\samples\Multimedia\DirectShow\BaseClasses + C:\DX90SDK\Include + C:\DX90SDK\Samples\C++\DirectShow\BaseClasses - libraries (optional): - C:\DXVCSDK\samples\Multimedia\DirectShow\BaseClasses\Release + C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Release + C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug */ @@ -549,19 +549,24 @@ /* (internal function) change colorspace */ +#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) { + DWORD biWidth; + if (formattype == FORMAT_VideoInfo) { VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; - m_frame.output.stride[0] = (((vih->bmiHeader.biWidth * vih->bmiHeader.biBitCount) + 31) & ~31) >> 3; + biWidth = vih->bmiHeader.biWidth; + m_frame.output.stride[0] = CALC_BI_STRIDE(vih->bmiHeader.biWidth, vih->bmiHeader.biBitCount); rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); } else if (formattype == FORMAT_VideoInfo2) { VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; - m_frame.output.stride[0] = (((vih2->bmiHeader.biWidth * vih2->bmiHeader.biBitCount) + 31) & ~31) >> 3; + biWidth = vih2->bmiHeader.biWidth; + m_frame.output.stride[0] = CALC_BI_STRIDE(vih2->bmiHeader.biWidth, vih2->bmiHeader.biBitCount); rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); } else @@ -574,14 +579,14 @@ DPRINTF("IYUV"); rgb_flip = 0; m_frame.output.csp = XVID_CSP_I420; - 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 */ } else if (subtype == MEDIASUBTYPE_YV12) { DPRINTF("YV12"); rgb_flip = 0; m_frame.output.csp = XVID_CSP_YV12; - 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 */ } else if (subtype == MEDIASUBTYPE_YUY2) { @@ -788,7 +793,9 @@ { CMediaType mtOut2 = m_pOutput->CurrentMediaType(); VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format(); - if (vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y) + + if (*mtOut2.FormatType() == FORMAT_VideoInfo2 && + vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y) { vihOut2->dwPictAspectRatioX = ar_x; vihOut2->dwPictAspectRatioY = ar_y; @@ -846,8 +853,8 @@ par_x = stats.data.vol.par_width; par_y = stats.data.vol.par_height; } else { - par_x = PARS[stats.data.vol.par][0]; - par_y = PARS[stats.data.vol.par][1]; + par_x = PARS[stats.data.vol.par-1][0]; + par_y = PARS[stats.data.vol.par-1][1]; } ar_x = par_x * stats.data.vol.width;