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.2 2004-03-22 23:35:11 edgomez Exp $ |
* $Id: CXvidDecoder.cpp,v 1.2.2.3 2004-11-24 22:14:11 edgomez Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
287 |
} |
} |
288 |
} |
} |
289 |
|
|
290 |
|
void CXvidDecoder::CloseLib() |
|
|
|
|
/* destructor */ |
|
|
|
|
|
CXvidDecoder::~CXvidDecoder() |
|
291 |
{ |
{ |
292 |
DPRINTF("Destructor"); |
DPRINTF("Destructor"); |
293 |
|
|
294 |
if (m_create.handle != NULL) |
if (m_create.handle != NULL) { |
|
{ |
|
295 |
xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0); |
xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0); |
296 |
m_create.handle = NULL; |
m_create.handle = NULL; |
297 |
} |
} |
298 |
|
|
299 |
if (m_hdll != NULL) |
if (m_hdll != NULL) { |
|
{ |
|
300 |
FreeLibrary(m_hdll); |
FreeLibrary(m_hdll); |
301 |
m_hdll = NULL; |
m_hdll = NULL; |
302 |
} |
} |
303 |
} |
} |
304 |
|
|
305 |
|
/* destructor */ |
306 |
|
|
307 |
|
CXvidDecoder::~CXvidDecoder() |
308 |
|
{ |
309 |
|
CloseLib(); |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
/* check input type */ |
/* check input type */ |
321 |
if (*mtIn->Type() != MEDIATYPE_Video) |
if (*mtIn->Type() != MEDIATYPE_Video) |
322 |
{ |
{ |
323 |
DPRINTF("Error: Unknown Type"); |
DPRINTF("Error: Unknown Type"); |
324 |
|
CloseLib(); |
325 |
return VFW_E_TYPE_NOT_ACCEPTED; |
return VFW_E_TYPE_NOT_ACCEPTED; |
326 |
} |
} |
327 |
|
|
347 |
else |
else |
348 |
{ |
{ |
349 |
DPRINTF("Error: Unknown FormatType"); |
DPRINTF("Error: Unknown FormatType"); |
350 |
|
CloseLib(); |
351 |
return VFW_E_TYPE_NOT_ACCEPTED; |
return VFW_E_TYPE_NOT_ACCEPTED; |
352 |
} |
} |
353 |
|
|
363 |
{ |
{ |
364 |
|
|
365 |
case FOURCC_MP4V: |
case FOURCC_MP4V: |
366 |
if (!(g_config.supported_4cc & SUPPORT_MP4V)) return VFW_E_TYPE_NOT_ACCEPTED; |
if (!(g_config.supported_4cc & SUPPORT_MP4V)) { |
367 |
|
CloseLib(); |
368 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
369 |
|
} |
370 |
break; |
break; |
371 |
case FOURCC_DIVX : |
case FOURCC_DIVX : |
372 |
if (!(g_config.supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED; |
if (!(g_config.supported_4cc & SUPPORT_DIVX)) { |
373 |
|
CloseLib(); |
374 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
375 |
|
} |
376 |
break; |
break; |
377 |
case FOURCC_DX50 : |
case FOURCC_DX50 : |
378 |
if (!(g_config.supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED; |
if (!(g_config.supported_4cc & SUPPORT_DX50)) { |
379 |
|
CloseLib(); |
380 |
|
return VFW_E_TYPE_NOT_ACCEPTED; |
381 |
|
} |
382 |
case FOURCC_XVID : |
case FOURCC_XVID : |
383 |
break; |
break; |
384 |
|
|
390 |
(hdr->biCompression>>8)&0xff, |
(hdr->biCompression>>8)&0xff, |
391 |
(hdr->biCompression>>16)&0xff, |
(hdr->biCompression>>16)&0xff, |
392 |
(hdr->biCompression>>24)&0xff); |
(hdr->biCompression>>24)&0xff); |
393 |
|
CloseLib(); |
394 |
return VFW_E_TYPE_NOT_ACCEPTED; |
return VFW_E_TYPE_NOT_ACCEPTED; |
395 |
} |
} |
396 |
return S_OK; |
return S_OK; |
533 |
|
|
534 |
|
|
535 |
/* (internal function) change colorspace */ |
/* (internal function) change colorspace */ |
536 |
|
#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) |
537 |
|
|
538 |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
539 |
{ |
{ |
540 |
|
DWORD biWidth; |
541 |
|
|
542 |
if (formattype == FORMAT_VideoInfo) |
if (formattype == FORMAT_VideoInfo) |
543 |
{ |
{ |
544 |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; |
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format; |
545 |
m_frame.output.stride[0] = (((vih->bmiHeader.biWidth * vih->bmiHeader.biBitCount) + 31) & ~31) >> 3; |
biWidth = vih->bmiHeader.biWidth; |
546 |
|
m_frame.output.stride[0] = CALC_BI_STRIDE(vih->bmiHeader.biWidth, vih->bmiHeader.biBitCount); |
547 |
rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
548 |
} |
} |
549 |
else if (formattype == FORMAT_VideoInfo2) |
else if (formattype == FORMAT_VideoInfo2) |
550 |
{ |
{ |
551 |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; |
VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format; |
552 |
m_frame.output.stride[0] = (((vih2->bmiHeader.biWidth * vih2->bmiHeader.biBitCount) + 31) & ~31) >> 3; |
biWidth = vih2->bmiHeader.biWidth; |
553 |
|
m_frame.output.stride[0] = CALC_BI_STRIDE(vih2->bmiHeader.biWidth, vih2->bmiHeader.biBitCount); |
554 |
rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP); |
555 |
} |
} |
556 |
else |
else |
563 |
DPRINTF("IYUV"); |
DPRINTF("IYUV"); |
564 |
rgb_flip = 0; |
rgb_flip = 0; |
565 |
m_frame.output.csp = XVID_CSP_I420; |
m_frame.output.csp = XVID_CSP_I420; |
566 |
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 */ |
567 |
} |
} |
568 |
else if (subtype == MEDIASUBTYPE_YV12) |
else if (subtype == MEDIASUBTYPE_YV12) |
569 |
{ |
{ |
570 |
DPRINTF("YV12"); |
DPRINTF("YV12"); |
571 |
rgb_flip = 0; |
rgb_flip = 0; |
572 |
m_frame.output.csp = XVID_CSP_YV12; |
m_frame.output.csp = XVID_CSP_YV12; |
573 |
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 */ |
574 |
} |
} |
575 |
else if (subtype == MEDIASUBTYPE_YUY2) |
else if (subtype == MEDIASUBTYPE_YUY2) |
576 |
{ |
{ |
731 |
m_frame.general = XVID_LOWDELAY; |
m_frame.general = XVID_LOWDELAY; |
732 |
|
|
733 |
if (pIn->IsDiscontinuity() == S_OK) |
if (pIn->IsDiscontinuity() == S_OK) |
734 |
m_frame.general = XVID_DISCONTINUITY; |
m_frame.general |= XVID_DISCONTINUITY; |
735 |
|
|
736 |
if (g_config.nDeblock_Y) |
if (g_config.nDeblock_Y) |
737 |
m_frame.general |= XVID_DEBLOCKY; |
m_frame.general |= XVID_DEBLOCKY; |