--- CXvidDecoder.cpp 2005/03/14 01:18:20 1.14 +++ CXvidDecoder.cpp 2009/05/28 15:42:06 1.17 @@ -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.14 2005/03/14 01:18:20 Isibaar Exp $ + * $Id: CXvidDecoder.cpp,v 1.17 2009/05/28 15:42:06 Isibaar Exp $ * ****************************************************************************/ @@ -82,6 +82,7 @@ { &MEDIATYPE_Video, &CLSID_DX50 }, { &MEDIATYPE_Video, &CLSID_DX50_UC }, { &MEDIATYPE_Video, &CLSID_MP4V }, + { &MEDIATYPE_Video, &CLSID_MP4V_UC }, }; const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] = @@ -395,6 +396,49 @@ } DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y); } + else if (*mtIn->FormatType() == FORMAT_MPEG2Video) { + MPEG2VIDEOINFO * mpgvi = (MPEG2VIDEOINFO*)mtIn->Format(); + VIDEOINFOHEADER2 * vih2 = &mpgvi->hdr; + hdr = &vih2->bmiHeader; + if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { + ar_x = vih2->dwPictAspectRatioX; + ar_y = vih2->dwPictAspectRatioY; + } + DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y); + + /* haali media splitter reports VOL information in the format header */ + + if (mpgvi->cbSequenceHeader>0) { + + xvid_dec_stats_t stats; + memset(&stats, 0, sizeof(stats)); + stats.version = XVID_VERSION; + + if (m_create.handle == NULL) { + if (xvid_decore_func == NULL) + return E_FAIL; + if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0) { + DPRINTF("*** XVID_DEC_CREATE error"); + return E_FAIL; + } + } + + m_frame.general = 0; + m_frame.bitstream = (void*)mpgvi->dwSequenceHeader; + m_frame.length = mpgvi->cbSequenceHeader; + m_frame.output.csp = XVID_CSP_NULL; + + int ret = 0; + if ((ret=xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats)) >= 0) { + /* honour video dimensions reported in VOL header */ + if (stats.type == XVID_TYPE_VOL) { + hdr->biWidth = stats.data.vol.width; + hdr->biHeight = stats.data.vol.height; + } + } + if (ret == XVID_ERR_MEMORY) return E_FAIL; + } + } else { DPRINTF("Error: Unknown FormatType"); @@ -412,7 +456,7 @@ switch(hdr->biCompression) { - + case FOURCC_mp4v: case FOURCC_MP4V: if (!(g_config.supported_4cc & SUPPORT_MP4V)) { CloseLib(); @@ -752,7 +796,7 @@ if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0) { DPRINTF("*** XVID_DEC_CREATE error"); - return S_FALSE; + return E_FAIL; } } @@ -819,15 +863,18 @@ if (pIn->IsPreroll() != S_OK) { length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats); - - if (length < 0) + + if (length == XVID_ERR_MEMORY) + return E_FAIL; + else if (length < 0) { DPRINTF("*** XVID_DEC_DECODE"); return S_FALSE; } else if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1 && forced_ar == false) { + + if (stats.type != XVID_TYPE_NOTHING) { /* dont attempt to set vmr aspect ratio if no frame was returned by decoder */ // inspired by minolta! works for VMR 7 + 9 - IMediaSample2 *pOut2 = NULL; AM_SAMPLE2_PROPERTIES outProp2; if (SUCCEEDED(pOut->QueryInterface(IID_IMediaSample2, (void **)&pOut2)) && @@ -846,6 +893,7 @@ } pOut2->Release(); } + } } } else @@ -862,7 +910,9 @@ m_frame.general &= ~XVID_FILMEFFECT; length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats); - if (length < 0) + if (length == XVID_ERR_MEMORY) + return E_FAIL; + else if (length < 0) { DPRINTF("*** XVID_DEC_DECODE"); return S_FALSE;