[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 1054, Mon Jun 9 13:55:56 2003 UTC revision 1343, Fri Jan 30 13:13:10 2004 UTC
# Line 19  Line 19 
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.1.2.2 2003-06-09 13:49:00 edgomez Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.15 2004-01-30 13:13:10 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    
# Line 53  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 62  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 131  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 179  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 208  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 235  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 247  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 277  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 299  Line 371 
371    
372          switch(hdr->biCompression)          switch(hdr->biCompression)
373          {          {
374    
375            case FOURCC_MP4V:
376                    if (!(supported_4cc & SUPPORT_MP4V)) return VFW_E_TYPE_NOT_ACCEPTED;
377                    break;
378            case FOURCC_DIVX :
379                    if (!(supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED;
380                    break;
381            case FOURCC_DX50 :
382                    if (!(supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED;
383          case FOURCC_XVID :          case FOURCC_XVID :
 //      case FOURCC_DIVX :  
 //      case FOURCC_DX50 :  
384                  break;                  break;
385    
386    
387          default :          default :
388                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",
389                          hdr->biCompression,                          hdr->biCompression,
# Line 313  Line 393 
393                          (hdr->biCompression>>24)&0xff);                          (hdr->biCompression>>24)&0xff);
394                  return VFW_E_TYPE_NOT_ACCEPTED;                  return VFW_E_TYPE_NOT_ACCEPTED;
395          }          }
   
396          return S_OK;          return S_OK;
397  }  }
398    
399    
 #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  
   
400  /* get list of supported output colorspaces */  /* get list of supported output colorspaces */
401    
402    
403  HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut)  HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut)
404  {  {
405          DPRINTF("GetMediaType");          DPRINTF("GetMediaType");
# Line 339  Line 409 
409                  return E_UNEXPECTED;                  return E_UNEXPECTED;
410          }          }
411    
412          VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));          VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));
413          if (vih == NULL)          if (vih == NULL)
414          {          {
415                  return E_OUTOFMEMORY;                  return E_OUTOFMEMORY;
# Line 358  Line 428 
428    
429          switch(iPosition)          switch(iPosition)
430          {          {
431    
432          case 0  :          case 0  :
433  #ifdef USE_IYUV  if ( USE_YUY2 )
434                  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  
435                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
436                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
437                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
438                  break;                  break;
439  #endif  }
440          case 3 :          case 1 :
441  #ifdef USE_YVYU  if ( USE_YVYU )
442    {
443                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
444                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
445                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
446                  break;                  break;
447  #endif  }
448          case 4 :          case 2 :
449  #ifdef USE_UYVY  if ( USE_UYVY )
450    {
451                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
452                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
453                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
454                  break;                  break;
455  #endif  }
456            case 3  :
457                    if ( USE_IYUV )
458    {
459                    vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
460                    vih->bmiHeader.biBitCount = 12;
461                    mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
462                    break;
463    }
464            case 4  :
465    if ( USE_YV12 )
466    {
467                    vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;
468                    vih->bmiHeader.biBitCount = 12;
469                    mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
470                    break;
471    }
472          case 5 :          case 5 :
473  #ifdef USE_RGB32  if ( USE_RGB32 )
474    {
475                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
476                  vih->bmiHeader.biBitCount = 32;                  vih->bmiHeader.biBitCount = 32;
477                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);
478                  break;                  break;
479  #endif  }
480          case 6 :          case 6 :
481  #ifdef USE_RGB24  if ( USE_RGB24 )
482    {
483                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
484                  vih->bmiHeader.biBitCount = 24;                  vih->bmiHeader.biBitCount = 24;
485                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);
486                  break;                  break;
487  #endif  }
488          case 7 :          case 7 :
489  #ifdef USE_RG555  if ( USE_RG555 )
490    {
491                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
492                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
493                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);
494                  break;                  break;
495  #endif  }
496          case 8 :          case 8 :
497  #ifdef USE_RG565  if ( USE_RG565 )
498    {
499                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
500                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
501                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);
502                  break;                  break;
503  #endif  }
504          default :          default :
505                  return VFW_S_NO_MORE_ITEMS;                  return VFW_S_NO_MORE_ITEMS;
506          }          }
507    
508          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);
509    
510            if (ar_x != 0 && ar_y != 0) {
511                    vih->dwPictAspectRatioX = ar_x;
512                    vih->dwPictAspectRatioY = ar_y;
513            } else { // just to be safe
514                    vih->dwPictAspectRatioX = m_create.width;
515                    vih->dwPictAspectRatioY = m_create.height;
516            }
517    
518          mtOut->SetType(&MEDIATYPE_Video);          mtOut->SetType(&MEDIATYPE_Video);
519          mtOut->SetFormatType(&FORMAT_VideoInfo);          mtOut->SetFormatType(&FORMAT_VideoInfo2);
520          mtOut->SetTemporalCompression(FALSE);          mtOut->SetTemporalCompression(FALSE);
521          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);
522    
# Line 440  Line 528 
528    
529  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)
530  {  {
         int rgb_flip;  
   
531          if (formattype == FORMAT_VideoInfo)          if (formattype == FORMAT_VideoInfo)
532          {          {
533                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;
# Line 459  Line 545 
545                  return S_FALSE;                  return S_FALSE;
546          }          }
547    
548          if (subtype == MEDIASUBTYPE_IYUV)          if (subtype == CLSID_MEDIASUBTYPE_IYUV)
549          {          {
550                  DPRINTF("IYUV");                  DPRINTF("IYUV");
551                    rgb_flip = 0;
552                  m_frame.output.csp = XVID_CSP_I420;                  m_frame.output.csp = XVID_CSP_I420;
553                  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 */
554          }          }
555          else if (subtype == MEDIASUBTYPE_YV12)          else if (subtype == MEDIASUBTYPE_YV12)
556          {          {
557                  DPRINTF("YV12");                  DPRINTF("YV12");
558                    rgb_flip = 0;
559                  m_frame.output.csp = XVID_CSP_YV12;                  m_frame.output.csp = XVID_CSP_YV12;
560                  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 */
561          }          }
562          else if (subtype == MEDIASUBTYPE_YUY2)          else if (subtype == MEDIASUBTYPE_YUY2)
563          {          {
564                  DPRINTF("YUY2");                  DPRINTF("YUY2");
565                    rgb_flip = 0;
566                  m_frame.output.csp = XVID_CSP_YUY2;                  m_frame.output.csp = XVID_CSP_YUY2;
567          }          }
568          else if (subtype == MEDIASUBTYPE_YVYU)          else if (subtype == MEDIASUBTYPE_YVYU)
569          {          {
570                  DPRINTF("YVYU");                  DPRINTF("YVYU");
571                    rgb_flip = 0;
572                  m_frame.output.csp = XVID_CSP_YVYU;                  m_frame.output.csp = XVID_CSP_YVYU;
573          }          }
574          else if (subtype == MEDIASUBTYPE_UYVY)          else if (subtype == MEDIASUBTYPE_UYVY)
575          {          {
576                  DPRINTF("UYVY");                  DPRINTF("UYVY");
577                    rgb_flip = 0;
578                  m_frame.output.csp = XVID_CSP_UYVY;                  m_frame.output.csp = XVID_CSP_UYVY;
579          }          }
580          else if (subtype == MEDIASUBTYPE_RGB32)          else if (subtype == MEDIASUBTYPE_RGB32)
# Line 590  Line 681 
681    
682          if (m_create.handle == NULL)          if (m_create.handle == NULL)
683          {          {
684                  if (m_xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0)                  if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0)
685                  {                  {
686              DPRINTF("*** XVID_DEC_CREATE error");              DPRINTF("*** XVID_DEC_CREATE error");
687                          return S_FALSE;                          return S_FALSE;
# Line 625  Line 716 
716          }          }
717    
718          m_frame.general = XVID_LOWDELAY;          m_frame.general = XVID_LOWDELAY;
719    
720          if (pIn->IsDiscontinuity() == S_OK)          if (pIn->IsDiscontinuity() == S_OK)
721                  m_frame.general = XVID_DISCONTINUITY;                  m_frame.general = XVID_DISCONTINUITY;
722    
723            if (PPSettings.nDeblock_Y)
724                    m_frame.general |= XVID_DEBLOCKY;
725    
726            if (PPSettings.nDeblock_UV)
727                    m_frame.general |= XVID_DEBLOCKUV;
728    /*
729            if (PPSettings.nDering)
730                    m_frame.general |= XVID_DERING;
731    */
732            if (PPSettings.nFilmEffect)
733                    m_frame.general |= XVID_FILMEFFECT;
734    
735            m_frame.output.csp &= ~XVID_CSP_VFLIP;
736            m_frame.output.csp |= rgb_flip^(PPSettings.nFlipVideo ? XVID_CSP_VFLIP : 0);
737    
738  repeat :  repeat :
739    
740          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)
741          {          {
742                  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);
743    
744                  if (length < 0)                  if (length < 0)
745                  {                  {
746              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 640  Line 748 
748                  }                  }
749          }          }
750          else          else
751          {          {       /* Preroll frame - won't be displayed */
752                  int tmp = m_frame.output.csp;                  int tmp = m_frame.output.csp;
753                    int tmp_gen = m_frame.general;
754    
755                  m_frame.output.csp = XVID_CSP_NULL;                  m_frame.output.csp = XVID_CSP_NULL;
756    
757                  length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  /* Disable postprocessing to speed-up seeking */
758                    m_frame.general &= ~XVID_DEBLOCKY;
759                    m_frame.general &= ~XVID_DEBLOCKUV;
760    /*              m_frame.general &= ~XVID_DERING; */
761                    m_frame.general &= ~XVID_FILMEFFECT;
762    
763                    length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
764                  if (length < 0)                  if (length < 0)
765                  {                  {
766              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 652  Line 768 
768                  }                  }
769    
770                  m_frame.output.csp = tmp;                  m_frame.output.csp = tmp;
771                    m_frame.general = tmp_gen;
772          }          }
773    
774            if (stats.type == XVID_TYPE_NOTHING && length > 0) {
775                    DPRINTF("B-Frame decoder lag");
776                    return S_FALSE;
777            }
778    
779    
780          if (stats.type == XVID_TYPE_VOL)          if (stats.type == XVID_TYPE_VOL)
781          {          {
782                  if (stats.data.vol.width != m_create.width ||                  if (stats.data.vol.width != m_create.width ||
# Line 663  Line 786 
786                          return S_FALSE;                          return S_FALSE;
787                  }                  }
788    
789                    pOut->SetDiscontinuity(TRUE);
790                    pOut->SetSyncPoint(TRUE);
791    
792                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
793                  m_frame.length -= length;                  m_frame.length -= length;
794                  goto repeat;                  goto repeat;
795          }          }
796    
797            if (pIn->IsPreroll() == S_OK) {
798                    return S_FALSE;
799            }
800    
801          return S_OK;          return S_OK;
802  }  }
803    

Legend:
Removed from v.1054  
changed lines
  Added in v.1343

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