[svn] / branches / dev-api-4 / xvidcore / dshow / src / CXvidDecoder.cpp Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/dshow/src/CXvidDecoder.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 888, Sat Feb 22 08:22:03 2003 UTC revision 1341, Fri Jan 30 03:21:20 2004 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID DIRECTSHOW FRONTEND -- decoder fitler   *  XVID MPEG-4 VIDEO CODEC
4   *      Copyright (c) 2002 Peter Ross <pross@xvid.org>   *  - XviD Decoder part of the DShow Filter  -
5     *
6     *  Copyright(C) 2002-2003 Peter Ross <pross@xvid.org>
7   *   *
8   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
9   *      it under the terms of the GNU General Public License as published by   *      it under the terms of the GNU General Public License as published by
# Line 15  Line 17 
17   *   *
18   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
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., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21     *
22     * $Id: CXvidDecoder.cpp,v 1.1.2.14 2004-01-30 03:21:20 syskin Exp $
23   *   *
24   *************************************************************************/   ****************************************************************************/
25    
26    /****************************************************************************
27     *
28     * 2003/12/11 - added some additional options, mainly to make the deblocking
29     *              code from xvidcore available. Most of the new code is taken
30     *              from Nic's dshow filter, (C) Nic, http://nic.dnsalias.com
31     *
32     ****************************************************************************/
33    
34   /*   /*
35          this requires the directx sdk          this requires the directx sdk
# Line 49  Line 61 
61  #include "CXvidDecoder.h"  #include "CXvidDecoder.h"
62  #include "CAbout.h"  #include "CAbout.h"
63    
64    // Externs defined here
65    PostProcessing_Settings PPSettings;
66    unsigned int supported_4cc;
67    int rgb_flip;
68    
69    
70    bool USE_IYUV;
71    bool USE_YV12;
72    bool USE_YUY2;
73    bool USE_YVYU;
74    bool USE_UYVY;
75    bool USE_RGB32;
76    bool USE_RGB24;
77    bool USE_RG555;
78    bool USE_RG565;
79    
80  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =
81  {  {
# Line 58  Line 85 
85          { &MEDIATYPE_Video, &CLSID_DIVX_UC },          { &MEDIATYPE_Video, &CLSID_DIVX_UC },
86          { &MEDIATYPE_Video, &CLSID_DX50 },          { &MEDIATYPE_Video, &CLSID_DX50 },
87          { &MEDIATYPE_Video, &CLSID_DX50_UC },          { &MEDIATYPE_Video, &CLSID_DX50_UC },
88            { &MEDIATYPE_Video, &CLSID_MP4V },
89  };  };
90    
91  const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] =
# Line 127  Line 155 
155  int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);  int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);
156    
157    
   
   
158  STDAPI DllRegisterServer()  STDAPI DllRegisterServer()
159  {  {
160      return AMovieDllRegisterServer2( TRUE );      return AMovieDllRegisterServer2( TRUE );
# Line 175  Line 201 
201    
202    
203    
 /* dummy decore() */  
   
 static int dummy_xvid_decore(void * handle, int opt, void * param1, void * param2)  
 {  
         return XVID_ERR_FAIL;  
 }  
   
   
   
204  /* constructor */  /* constructor */
205    
206  #define XVID_DLL_NAME           "xvid.dll"  #define XVID_DLL_NAME "xvidcore.dll"
 #define XVID_GLOBAL_NAME        "xvid_global"  
 #define XVID_DECORE_NAME        "xvid_decore"  
207    
208  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :
209      CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID)      CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID)
210  {  {
211          DPRINTF("Constructor");          DPRINTF("Constructor");
212    
213          m_xvid_decore = dummy_xvid_decore;          xvid_gbl_init_t init;
214            memset(&init, 0, sizeof(init));
215            init.version = XVID_VERSION;
216    
217            ar_x = ar_y = 0;
218    
219          m_hdll = LoadLibrary(XVID_DLL_NAME);          m_hdll = LoadLibrary(XVID_DLL_NAME);
220          if (m_hdll == NULL) {          if (m_hdll == NULL) {
# Line 204  Line 223 
223                  return;                  return;
224          }          }
225    
226          m_xvid_global = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, XVID_GLOBAL_NAME);          xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global");
227          if (m_xvid_global == NULL) {          if (xvid_global_func == NULL) {
228                  MessageBox(0, XVID_GLOBAL_NAME "() not found", "Error", 0);                  MessageBox(0, "xvid_global() not found", "Error", 0);
229                  return;                  return;
230          }          }
231    
232          m_xvid_decore = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, XVID_DECORE_NAME);          xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore");
233          if (m_xvid_decore == NULL) {          if (xvid_decore_func == NULL) {
234                  MessageBox(0, XVID_DECORE_NAME "() not found", "Error", 0);                  MessageBox(0, "xvid_decore() not found", "Error", 0);
235                  return;                  return;
236          }          }
237    
238          xvid_gbl_init_t init;          if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)
         memset(&init, 0, sizeof(init));  
         init.version = XVID_VERSION;  
         if (m_xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0)  
239          {          {
240                  MessageBox(0, XVID_GLOBAL_NAME "() failed", "Error", 0);                  MessageBox(0, "xvid_global() failed", "Error", 0);
241                  return;                  return;
242          }          }
243    
# Line 231  Line 247 
247    
248          memset(&m_frame, 0, sizeof(m_frame));          memset(&m_frame, 0, sizeof(m_frame));
249          m_frame.version = XVID_VERSION;          m_frame.version = XVID_VERSION;
250    
251            HKEY hKey;
252            DWORD size;
253            RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey);
254    
255            // Set the default post-processing settings
256            REG_GET_N("Brightness", PPSettings.nBrightness, 25)
257            REG_GET_N("Deblock_Y",  PPSettings.nDeblock_Y, 0)
258            REG_GET_N("Deblock_UV", PPSettings.nDeblock_UV, 0)
259            REG_GET_N("Dering",  PPSettings.nDering, 0)
260            REG_GET_N("FilmEffect", PPSettings.nFilmEffect, 0)
261            REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)
262            REG_GET_N("FlipVideo",  PPSettings.nFlipVideo, 0)
263            REG_GET_N("Supported_4CC",  supported_4cc, 0)
264    
265            RegCloseKey(hKey);
266    
267            USE_IYUV = false;
268            USE_YV12 = false;
269            USE_YUY2 = false;
270            USE_YVYU = false;
271            USE_UYVY = false;
272            USE_RGB32 = false;
273            USE_RGB24 = false;
274            USE_RG555 = false;
275            USE_RG565 = false;
276    
277            switch ( PPSettings.nForceColorspace )
278            {
279            case FORCE_NONE:
280                    USE_IYUV = true;
281                    USE_YV12 = true;
282                    USE_YUY2 = true;
283                    USE_YVYU = true;
284                    USE_UYVY = true;
285                    USE_RGB32 = true;
286                    USE_RGB24 = true;
287                    USE_RG555 = true;
288                    USE_RG565 = true;
289                    break;
290            case FORCE_YV12:
291                    USE_IYUV = true;
292                    USE_YV12 = true;
293                    break;
294            case FORCE_YUY2:
295                    USE_YUY2 = true;
296                    break;
297            case FORCE_RGB24:
298                    USE_RGB24 = true;
299                    break;
300            case FORCE_RGB32:
301                    USE_RGB32 = true;
302                    break;
303            }
304  }  }
305    
306    
# Line 243  Line 313 
313    
314          if (m_create.handle != NULL)          if (m_create.handle != NULL)
315          {          {
316                  m_xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0);                  xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0);
317                  m_create.handle = NULL;                  m_create.handle = NULL;
318          }          }
319    
# Line 273  Line 343 
343          {          {
344                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();
345                  hdr = &vih->bmiHeader;                  hdr = &vih->bmiHeader;
346                    /* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter
347                       which is equal to ppm_Y:ppm_X */
348                    ar_x = vih->bmiHeader.biYPelsPerMeter*hdr->biWidth;
349                    ar_y = vih->bmiHeader.biXPelsPerMeter*hdr->biHeight;
350          }          }
351          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)
352          {          {
353                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();
354                  hdr = &vih2->bmiHeader;                  hdr = &vih2->bmiHeader;
355                    ar_x = vih2->dwPictAspectRatioX;
356                    ar_y = vih2->dwPictAspectRatioY;
357          }          }
358          else          else
359          {          {
# Line 295  Line 371 
371    
372          switch(hdr->biCompression)          switch(hdr->biCompression)
373          {          {
374    
375    
376            case FOURCC_DIVX :
377                    if (!(supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED;
378                    else break;
379            case FOURCC_DX50 :
380                    if (!(supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED;
381          case FOURCC_XVID :          case FOURCC_XVID :
 //      case FOURCC_DIVX :  
 //      case FOURCC_DX50 :  
382                  break;                  break;
383    
384    
385          default :          default :
386                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",
387                          hdr->biCompression,                          hdr->biCompression,
# Line 309  Line 391 
391                          (hdr->biCompression>>24)&0xff);                          (hdr->biCompression>>24)&0xff);
392                  return VFW_E_TYPE_NOT_ACCEPTED;                  return VFW_E_TYPE_NOT_ACCEPTED;
393          }          }
   
394          return S_OK;          return S_OK;
395  }  }
396    
397    
 #define USE_IYUV  
 #define USE_YV12  
 #define USE_YUY2  
 #define USE_YVYU  
 #define USE_UYVY  
 #define USE_RGB32  
 #define USE_RGB24  
 #define USE_RG555  
 #define USE_RG565  
   
398  /* get list of supported output colorspaces */  /* get list of supported output colorspaces */
399    
400    
401  HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut)  HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut)
402  {  {
403          DPRINTF("GetMediaType");          DPRINTF("GetMediaType");
# Line 335  Line 407 
407                  return E_UNEXPECTED;                  return E_UNEXPECTED;
408          }          }
409    
410          VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));          VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));
411          if (vih == NULL)          if (vih == NULL)
412          {          {
413                  return E_OUTOFMEMORY;                  return E_OUTOFMEMORY;
# Line 354  Line 426 
426    
427          switch(iPosition)          switch(iPosition)
428          {          {
429    
430          case 0  :          case 0  :
431  #ifdef USE_IYUV  if ( USE_YUY2 )
432                  vih->bmiHeader.biCompression = MEDIASUBTYPE_IYUV.Data1;  {
                 vih->bmiHeader.biBitCount = 12;  
                 mtOut->SetSubtype(&MEDIASUBTYPE_IYUV);  
                 break;  
 #endif  
         case 1  :  
 #ifdef USE_YV12  
                 vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;  
                 vih->bmiHeader.biBitCount = 12;  
                 mtOut->SetSubtype(&MEDIASUBTYPE_YV12);  
                 break;  
 #endif  
         case 2:  
 #ifdef USE_YUY2  
433                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
434                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
435                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
436                  break;                  break;
437  #endif  }
438          case 3 :          case 1 :
439  #ifdef USE_YVYU  if ( USE_YVYU )
440    {
441                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
442                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
443                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
444                  break;                  break;
445  #endif  }
446          case 4 :          case 2 :
447  #ifdef USE_UYVY  if ( USE_UYVY )
448    {
449                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
450                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
451                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
452                  break;                  break;
453  #endif  }
454            case 3  :
455                    if ( USE_IYUV )
456    {
457                    vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
458                    vih->bmiHeader.biBitCount = 12;
459                    mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
460                    break;
461    }
462            case 4  :
463    if ( USE_YV12 )
464    {
465                    vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;
466                    vih->bmiHeader.biBitCount = 12;
467                    mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
468                    break;
469    }
470          case 5 :          case 5 :
471  #ifdef USE_RGB32  if ( USE_RGB32 )
472    {
473                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
474                  vih->bmiHeader.biBitCount = 32;                  vih->bmiHeader.biBitCount = 32;
475                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);
476                  break;                  break;
477  #endif  }
478          case 6 :          case 6 :
479  #ifdef USE_RGB24  if ( USE_RGB24 )
480    {
481                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
482                  vih->bmiHeader.biBitCount = 24;                  vih->bmiHeader.biBitCount = 24;
483                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);
484                  break;                  break;
485  #endif  }
486          case 7 :          case 7 :
487  #ifdef USE_RG555  if ( USE_RG555 )
488    {
489                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
490                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
491                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);
492                  break;                  break;
493  #endif  }
494          case 8 :          case 8 :
495  #ifdef USE_RG565  if ( USE_RG565 )
496    {
497                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
498                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
499                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);
500                  break;                  break;
501  #endif  }
502          default :          default :
503                  return VFW_S_NO_MORE_ITEMS;                  return VFW_S_NO_MORE_ITEMS;
504          }          }
505    
506          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);
507    
508            if (ar_x != 0 && ar_y != 0) {
509                    vih->dwPictAspectRatioX = ar_x;
510                    vih->dwPictAspectRatioY = ar_y;
511            } else { // just to be safe
512                    vih->dwPictAspectRatioX = m_create.width;
513                    vih->dwPictAspectRatioY = m_create.height;
514            }
515    
516          mtOut->SetType(&MEDIATYPE_Video);          mtOut->SetType(&MEDIATYPE_Video);
517          mtOut->SetFormatType(&FORMAT_VideoInfo);          mtOut->SetFormatType(&FORMAT_VideoInfo2);
518          mtOut->SetTemporalCompression(FALSE);          mtOut->SetTemporalCompression(FALSE);
519          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);
520    
# Line 436  Line 526 
526    
527  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)
528  {  {
         int rgb_flip;  
   
529          if (formattype == FORMAT_VideoInfo)          if (formattype == FORMAT_VideoInfo)
530          {          {
531                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;
# Line 455  Line 543 
543                  return S_FALSE;                  return S_FALSE;
544          }          }
545    
546          if (subtype == MEDIASUBTYPE_IYUV)          if (subtype == CLSID_MEDIASUBTYPE_IYUV)
547          {          {
548                  DPRINTF("IYUV");                  DPRINTF("IYUV");
549                    rgb_flip = 0;
550                  m_frame.output.csp = XVID_CSP_I420;                  m_frame.output.csp = XVID_CSP_I420;
551                  m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3;  /* planar format fix */                  m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3;  /* planar format fix */
552          }          }
553          else if (subtype == MEDIASUBTYPE_YV12)          else if (subtype == MEDIASUBTYPE_YV12)
554          {          {
555                  DPRINTF("YV12");                  DPRINTF("YV12");
556                    rgb_flip = 0;
557                  m_frame.output.csp = XVID_CSP_YV12;                  m_frame.output.csp = XVID_CSP_YV12;
558                  m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3;  /* planar format fix */                  m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3;  /* planar format fix */
559          }          }
560          else if (subtype == MEDIASUBTYPE_YUY2)          else if (subtype == MEDIASUBTYPE_YUY2)
561          {          {
562                  DPRINTF("YUY2");                  DPRINTF("YUY2");
563                    rgb_flip = 0;
564                  m_frame.output.csp = XVID_CSP_YUY2;                  m_frame.output.csp = XVID_CSP_YUY2;
565          }          }
566          else if (subtype == MEDIASUBTYPE_YVYU)          else if (subtype == MEDIASUBTYPE_YVYU)
567          {          {
568                  DPRINTF("YVYU");                  DPRINTF("YVYU");
569                    rgb_flip = 0;
570                  m_frame.output.csp = XVID_CSP_YVYU;                  m_frame.output.csp = XVID_CSP_YVYU;
571          }          }
572          else if (subtype == MEDIASUBTYPE_UYVY)          else if (subtype == MEDIASUBTYPE_UYVY)
573          {          {
574                  DPRINTF("UYVY");                  DPRINTF("UYVY");
575                    rgb_flip = 0;
576                  m_frame.output.csp = XVID_CSP_UYVY;                  m_frame.output.csp = XVID_CSP_UYVY;
577          }          }
578          else if (subtype == MEDIASUBTYPE_RGB32)          else if (subtype == MEDIASUBTYPE_RGB32)
# Line 586  Line 679 
679    
680          if (m_create.handle == NULL)          if (m_create.handle == NULL)
681          {          {
682                  if (m_xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0)                  if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0)
683                  {                  {
684              DPRINTF("*** XVID_DEC_CREATE error");              DPRINTF("*** XVID_DEC_CREATE error");
685                          return S_FALSE;                          return S_FALSE;
# Line 621  Line 714 
714          }          }
715    
716          m_frame.general = XVID_LOWDELAY;          m_frame.general = XVID_LOWDELAY;
717    
718          if (pIn->IsDiscontinuity() == S_OK)          if (pIn->IsDiscontinuity() == S_OK)
719                  m_frame.general = XVID_DISCONTINUITY;                  m_frame.general = XVID_DISCONTINUITY;
720    
721            if (PPSettings.nDeblock_Y)
722                    m_frame.general |= XVID_DEBLOCKY;
723    
724            if (PPSettings.nDeblock_UV)
725                    m_frame.general |= XVID_DEBLOCKUV;
726    /*
727            if (PPSettings.nDering)
728                    m_frame.general |= XVID_DERING;
729    */
730            if (PPSettings.nFilmEffect)
731                    m_frame.general |= XVID_FILMEFFECT;
732    
733            m_frame.output.csp &= ~XVID_CSP_VFLIP;
734            m_frame.output.csp |= rgb_flip^(PPSettings.nFlipVideo ? XVID_CSP_VFLIP : 0);
735    
736  repeat :  repeat :
737    
738          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)
739          {          {
740                  length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
741    
742                  if (length < 0)                  if (length < 0)
743                  {                  {
744              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 636  Line 746 
746                  }                  }
747          }          }
748          else          else
749          {          {       /* Preroll frame - won't be displayed */
750                  int tmp = m_frame.output.csp;                  int tmp = m_frame.output.csp;
751                    int tmp_gen = m_frame.general;
752    
753                  m_frame.output.csp = XVID_CSP_NULL;                  m_frame.output.csp = XVID_CSP_NULL;
754    
755                  length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  /* Disable postprocessing to speed-up seeking */
756                    m_frame.general &= ~XVID_DEBLOCKY;
757                    m_frame.general &= ~XVID_DEBLOCKUV;
758    /*              m_frame.general &= ~XVID_DERING; */
759                    m_frame.general &= ~XVID_FILMEFFECT;
760    
761                    length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
762                  if (length < 0)                  if (length < 0)
763                  {                  {
764              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 648  Line 766 
766                  }                  }
767    
768                  m_frame.output.csp = tmp;                  m_frame.output.csp = tmp;
769                    m_frame.general = tmp_gen;
770          }          }
771    
772            if (stats.type == XVID_TYPE_NOTHING && length > 0) {
773                    DPRINTF("B-Frame decoder lag");
774                    return S_FALSE;
775            }
776    
777    
778          if (stats.type == XVID_TYPE_VOL)          if (stats.type == XVID_TYPE_VOL)
779          {          {
780                  if (stats.data.vol.width != m_create.width ||                  if (stats.data.vol.width != m_create.width ||
# Line 659  Line 784 
784                          return S_FALSE;                          return S_FALSE;
785                  }                  }
786    
787                    pOut->SetDiscontinuity(TRUE);
788                    pOut->SetSyncPoint(TRUE);
789    
790                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
791                  m_frame.length -= length;                  m_frame.length -= length;
792                  goto repeat;                  goto repeat;
793          }          }
794    
795            if (pIn->IsPreroll() == S_OK) {
796                    return S_FALSE;
797            }
798    
799          return S_OK;          return S_OK;
800  }  }
801    

Legend:
Removed from v.888  
changed lines
  Added in v.1341

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4