[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 1301, Fri Jan 2 13:18:28 2004 UTC revision 1351, Tue Feb 3 06:57:24 2004 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - XviD Decoder part of the DShow Filter  -   *  - XviD Decoder part of the DShow Filter  -
5   *   *
6   *  Copyright(C) 2002-2003 Peter Ross <pross@xvid.org>   *  Copyright(C) 2002-2004 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 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.8 2004-01-02 13:18:28 syskin Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.17 2004-02-03 06:57:24 syskin Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 60  Line 60 
60  #include "IXvidDecoder.h"  #include "IXvidDecoder.h"
61  #include "CXvidDecoder.h"  #include "CXvidDecoder.h"
62  #include "CAbout.h"  #include "CAbout.h"
63    #include "config.h"
64    #include "debug.h"
65    
 // Externs defined here  
 PostProcessing_Settings PPSettings;  
66    
67  int rgb_flip;  static int rgb_flip;
68    static bool USE_IYUV;
69  bool USE_IYUV;  static bool USE_YV12;
70  bool USE_YV12;  static bool USE_YUY2;
71  bool USE_YUY2;  static bool USE_YVYU;
72  bool USE_YVYU;  static bool USE_UYVY;
73  bool USE_UYVY;  static bool USE_RGB32;
74  bool USE_RGB32;  static bool USE_RGB24;
75  bool USE_RGB24;  static bool USE_RG555;
76  bool USE_RG555;  static bool USE_RG565;
 bool USE_RG565;  
77    
78  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =
79  {  {
# Line 84  Line 83 
83          { &MEDIATYPE_Video, &CLSID_DIVX_UC },          { &MEDIATYPE_Video, &CLSID_DIVX_UC },
84          { &MEDIATYPE_Video, &CLSID_DX50 },          { &MEDIATYPE_Video, &CLSID_DX50 },
85          { &MEDIATYPE_Video, &CLSID_DX50_UC },          { &MEDIATYPE_Video, &CLSID_DX50_UC },
86            { &MEDIATYPE_Video, &CLSID_MP4V },
87  };  };
88    
89  const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] =
# Line 150  Line 150 
150    
151  };  };
152    
153    
154    /* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */
155  int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);  int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);
156    
157    
# Line 212  Line 214 
214          memset(&init, 0, sizeof(init));          memset(&init, 0, sizeof(init));
215          init.version = XVID_VERSION;          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) {
221                  DPRINTF("dll load failed");                  DPRINTF("dll load failed");
# Line 244  Line 248 
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;          LoadRegistryInfo();
         DWORD size;  
         RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey);  
   
         // Set the default post-processing settings  
         REG_GET_N("Brightness", PPSettings.nBrightness, 25)  
         REG_GET_N("Deblock_Y",  PPSettings.bDeblock_Y, 1)  
         REG_GET_N("Deblock_UV", PPSettings.bDeblock_UV, 1)  
         REG_GET_N("Dering",  PPSettings.bDering, 1)  
         REG_GET_N("FilmEffect", PPSettings.bFilmEffect, 1)  
         REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)  
   
         RegCloseKey(hKey);  
252    
253          USE_IYUV = false;          USE_IYUV = false;
254          USE_YV12 = false;          USE_YV12 = false;
# Line 268  Line 260 
260          USE_RG555 = false;          USE_RG555 = false;
261          USE_RG565 = false;          USE_RG565 = false;
262    
263          switch ( PPSettings.nForceColorspace )          switch ( g_config.nForceColorspace )
264          {          {
265          case FORCE_NONE:          case FORCE_NONE:
266                  USE_IYUV = true;                  USE_IYUV = true;
# Line 337  Line 329 
329          {          {
330                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();
331                  hdr = &vih->bmiHeader;                  hdr = &vih->bmiHeader;
332                    /* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter
333                       which is equal to ppm_Y:ppm_X */
334                    ar_x = vih->bmiHeader.biYPelsPerMeter*hdr->biWidth;
335                    ar_y = vih->bmiHeader.biXPelsPerMeter*hdr->biHeight;
336          }          }
337          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)
338          {          {
339                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();
340                  hdr = &vih2->bmiHeader;                  hdr = &vih2->bmiHeader;
341                    ar_x = vih2->dwPictAspectRatioX;
342                    ar_y = vih2->dwPictAspectRatioY;
343          }          }
344          else          else
345          {          {
# Line 359  Line 357 
357    
358          switch(hdr->biCompression)          switch(hdr->biCompression)
359          {          {
360    
361            case FOURCC_MP4V:
362                    if (!(g_config.supported_4cc & SUPPORT_MP4V)) return VFW_E_TYPE_NOT_ACCEPTED;
363                    break;
364            case FOURCC_DIVX :
365                    if (!(g_config.supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED;
366                    break;
367            case FOURCC_DX50 :
368                    if (!(g_config.supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED;
369          case FOURCC_XVID :          case FOURCC_XVID :
 //      case FOURCC_DIVX :  
 //      case FOURCC_DX50 :  
370                  break;                  break;
371    
372    
373          default :          default :
374                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",
375                          hdr->biCompression,                          hdr->biCompression,
# Line 373  Line 379 
379                          (hdr->biCompression>>24)&0xff);                          (hdr->biCompression>>24)&0xff);
380                  return VFW_E_TYPE_NOT_ACCEPTED;                  return VFW_E_TYPE_NOT_ACCEPTED;
381          }          }
   
382          return S_OK;          return S_OK;
383  }  }
384    
# Line 390  Line 395 
395                  return E_UNEXPECTED;                  return E_UNEXPECTED;
396          }          }
397    
398          VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));          VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));
399          if (vih == NULL)          if (vih == NULL)
400          {          {
401                  return E_OUTOFMEMORY;                  return E_OUTOFMEMORY;
402          }          }
403    
404          ZeroMemory(vih, sizeof (VIDEOINFOHEADER));          ZeroMemory(vih, sizeof (VIDEOINFOHEADER2));
405          vih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);          vih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
406          vih->bmiHeader.biWidth  = m_create.width;          vih->bmiHeader.biWidth  = m_create.width;
407          vih->bmiHeader.biHeight = m_create.height;          vih->bmiHeader.biHeight = m_create.height;
# Line 409  Line 414 
414    
415          switch(iPosition)          switch(iPosition)
416          {          {
417    
418          case 0  :          case 0  :
 if ( USE_IYUV )  
 {  
                 vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;  
                 vih->bmiHeader.biBitCount = 12;  
                 mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);  
                 break;  
 }  
         case 1  :  
 if ( USE_YV12 )  
 {  
                 vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;  
                 vih->bmiHeader.biBitCount = 12;  
                 mtOut->SetSubtype(&MEDIASUBTYPE_YV12);  
                 break;  
 }  
         case 2:  
419  if ( USE_YUY2 )  if ( USE_YUY2 )
420  {  {
421                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
# Line 433  Line 423 
423                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
424                  break;                  break;
425  }  }
426          case 3 :          case 1 :
427  if ( USE_YVYU )  if ( USE_YVYU )
428  {  {
429                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
# Line 441  Line 431 
431                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
432                  break;                  break;
433  }  }
434          case 4 :          case 2 :
435  if ( USE_UYVY )  if ( USE_UYVY )
436  {  {
437                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
# Line 449  Line 439 
439                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
440                  break;                  break;
441  }  }
442            case 3  :
443                    if ( USE_IYUV )
444    {
445                    vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
446                    vih->bmiHeader.biBitCount = 12;
447                    mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
448                    break;
449    }
450            case 4  :
451    if ( USE_YV12 )
452    {
453                    vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;
454                    vih->bmiHeader.biBitCount = 12;
455                    mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
456                    break;
457    }
458          case 5 :          case 5 :
459  if ( USE_RGB32 )  if ( USE_RGB32 )
460  {  {
# Line 487  Line 493 
493    
494          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);
495    
496            if (ar_x != 0 && ar_y != 0) {
497                    vih->dwPictAspectRatioX = ar_x;
498                    vih->dwPictAspectRatioY = ar_y;
499            } else { // just to be safe
500                    vih->dwPictAspectRatioX = m_create.width;
501                    vih->dwPictAspectRatioY = m_create.height;
502            }
503    
504          mtOut->SetType(&MEDIATYPE_Video);          mtOut->SetType(&MEDIATYPE_Video);
505          mtOut->SetFormatType(&FORMAT_VideoInfo);          mtOut->SetFormatType(&FORMAT_VideoInfo2);
506          mtOut->SetTemporalCompression(FALSE);          mtOut->SetTemporalCompression(FALSE);
507          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);
508    
# Line 520  Line 534 
534          if (subtype == CLSID_MEDIASUBTYPE_IYUV)          if (subtype == CLSID_MEDIASUBTYPE_IYUV)
535          {          {
536                  DPRINTF("IYUV");                  DPRINTF("IYUV");
537                    rgb_flip = 0;
538                  m_frame.output.csp = XVID_CSP_I420;                  m_frame.output.csp = XVID_CSP_I420;
539                  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 */
540          }          }
541          else if (subtype == MEDIASUBTYPE_YV12)          else if (subtype == MEDIASUBTYPE_YV12)
542          {          {
543                  DPRINTF("YV12");                  DPRINTF("YV12");
544                    rgb_flip = 0;
545                  m_frame.output.csp = XVID_CSP_YV12;                  m_frame.output.csp = XVID_CSP_YV12;
546                  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 */
547          }          }
548          else if (subtype == MEDIASUBTYPE_YUY2)          else if (subtype == MEDIASUBTYPE_YUY2)
549          {          {
550                  DPRINTF("YUY2");                  DPRINTF("YUY2");
551                    rgb_flip = 0;
552                  m_frame.output.csp = XVID_CSP_YUY2;                  m_frame.output.csp = XVID_CSP_YUY2;
553          }          }
554          else if (subtype == MEDIASUBTYPE_YVYU)          else if (subtype == MEDIASUBTYPE_YVYU)
555          {          {
556                  DPRINTF("YVYU");                  DPRINTF("YVYU");
557                    rgb_flip = 0;
558                  m_frame.output.csp = XVID_CSP_YVYU;                  m_frame.output.csp = XVID_CSP_YVYU;
559          }          }
560          else if (subtype == MEDIASUBTYPE_UYVY)          else if (subtype == MEDIASUBTYPE_UYVY)
561          {          {
562                  DPRINTF("UYVY");                  DPRINTF("UYVY");
563                    rgb_flip = 0;
564                  m_frame.output.csp = XVID_CSP_UYVY;                  m_frame.output.csp = XVID_CSP_UYVY;
565          }          }
566          else if (subtype == MEDIASUBTYPE_RGB32)          else if (subtype == MEDIASUBTYPE_RGB32)
# Line 687  Line 706 
706          if (pIn->IsDiscontinuity() == S_OK)          if (pIn->IsDiscontinuity() == S_OK)
707                  m_frame.general = XVID_DISCONTINUITY;                  m_frame.general = XVID_DISCONTINUITY;
708    
709          if (PPSettings.bDeblock_Y)          if (g_config.nDeblock_Y)
710                  m_frame.general |= XVID_DEBLOCKY;                  m_frame.general |= XVID_DEBLOCKY;
711    
712          if (PPSettings.bDeblock_UV)          if (g_config.nDeblock_UV)
713                  m_frame.general |= XVID_DEBLOCKUV;                  m_frame.general |= XVID_DEBLOCKUV;
714  /*  /*
715          if (PPSettings.bDering)          if (g_config.nDering)
716                  m_frame.general |= XVID_DERING;                  m_frame.general |= XVID_DERING;
717  */  */
718          if (PPSettings.bFilmEffect)          if (g_config.nFilmEffect)
719                  m_frame.general |= XVID_FILMEFFECT;                  m_frame.general |= XVID_FILMEFFECT;
720    
         if (PPSettings.bFlipVideo) {  
                 if (rgb_flip)  
                         m_frame.output.csp &= ~XVID_CSP_VFLIP;  
                 else  
                         m_frame.output.csp |= XVID_CSP_VFLIP;  
         }  
         else {  
                 if (rgb_flip)  
                         m_frame.output.csp |= XVID_CSP_VFLIP;  
                 else  
721                          m_frame.output.csp &= ~XVID_CSP_VFLIP;                          m_frame.output.csp &= ~XVID_CSP_VFLIP;
722          }          m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0);
723    
724  repeat :  repeat :
725    
# Line 748  Line 757 
757                  m_frame.general = tmp_gen;                  m_frame.general = tmp_gen;
758          }          }
759    
760          if (stats.type == XVID_TYPE_NOTHING) {          if (stats.type == XVID_TYPE_NOTHING && length > 0) {
761                  DPRINTF("B-Frame decoder lag");                  DPRINTF("B-Frame decoder lag");
762                  return S_FALSE;                  return S_FALSE;
763          }          }

Legend:
Removed from v.1301  
changed lines
  Added in v.1351

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