[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 1259, Fri Dec 12 14:16:40 2003 UTC revision 1260, Fri Dec 12 15:09:01 2003 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.4 2003-12-09 14:32:52 syskin Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.5 2003-12-12 15:09:01 Isibaar 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    
67    int rgb_flip;
68    
69    bool USE_IYUV;
70    bool USE_YV12;
71    bool USE_YUY2;
72    bool USE_YVYU;
73    bool USE_UYVY;
74    bool USE_RGB32;
75    bool USE_RGB24;
76    bool USE_RG555;
77    bool USE_RG565;
78    
79  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =
80  {  {
# Line 132  Line 153 
153  int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);  int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);
154    
155    
   
   
156  STDAPI DllRegisterServer()  STDAPI DllRegisterServer()
157  {  {
158      return AMovieDllRegisterServer2( TRUE );      return AMovieDllRegisterServer2( TRUE );
# Line 180  Line 199 
199    
200    
201    
   
202  /* constructor */  /* constructor */
203    
204  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :
# Line 203  Line 221 
221    
222          memset(&m_frame, 0, sizeof(m_frame));          memset(&m_frame, 0, sizeof(m_frame));
223          m_frame.version = XVID_VERSION;          m_frame.version = XVID_VERSION;
224    
225            HKEY hKey;
226            DWORD size;
227            RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey);
228    
229            // Set the default post-processing settings
230            REG_GET_N("Brightness", PPSettings.nBrightness, 25)
231            REG_GET_N("Deblock_Y",  PPSettings.bDeblock_Y, 0)
232            REG_GET_N("Deblock_UV", PPSettings.bDeblock_UV, 0)
233            REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)
234    
235            RegCloseKey(hKey);
236    
237            USE_IYUV = false;
238            USE_YV12 = false;
239            USE_YUY2 = false;
240            USE_YVYU = false;
241            USE_UYVY = false;
242            USE_RGB32 = false;
243            USE_RGB24 = false;
244            USE_RG555 = false;
245            USE_RG565 = false;
246    
247            switch ( PPSettings.nForceColorspace )
248            {
249            case FORCE_NONE:
250                    USE_IYUV = true;
251                    USE_YV12 = true;
252                    USE_YUY2 = true;
253                    USE_YVYU = true;
254                    USE_UYVY = true;
255                    USE_RGB32 = true;
256                    USE_RGB24 = true;
257                    USE_RG555 = true;
258                    USE_RG565 = true;
259                    break;
260            case FORCE_YV12:
261                    USE_IYUV = true;
262                    USE_YV12 = true;
263                    break;
264            case FORCE_YUY2:
265                    USE_YUY2 = true;
266                    break;
267            case FORCE_RGB24:
268                    USE_RGB24 = true;
269                    break;
270            case FORCE_RGB32:
271                    USE_RGB32 = true;
272                    break;
273            }
274  }  }
275    
276    
# Line 280  Line 348 
348  }  }
349    
350    
 #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  
   
351  /* get list of supported output colorspaces */  /* get list of supported output colorspaces */
352    
353    
# Line 322  Line 380 
380          switch(iPosition)          switch(iPosition)
381          {          {
382          case 0  :          case 0  :
383  #ifdef USE_IYUV  if ( USE_IYUV )
384    {
385                  vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;                  vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
386                  vih->bmiHeader.biBitCount = 12;                  vih->bmiHeader.biBitCount = 12;
387                  mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);                  mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
388                  break;                  break;
389  #endif  }
390          case 1  :          case 1  :
391  #ifdef USE_YV12  if ( USE_YV12 )
392    {
393                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;
394                  vih->bmiHeader.biBitCount = 12;                  vih->bmiHeader.biBitCount = 12;
395                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
396                  break;                  break;
397  #endif  }
398          case 2:          case 2:
399  #ifdef USE_YUY2  if ( USE_YUY2 )
400    {
401                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
402                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
403                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
404                  break;                  break;
405  #endif  }
406          case 3 :          case 3 :
407  #ifdef USE_YVYU  if ( USE_YVYU )
408    {
409                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
410                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
411                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
412                  break;                  break;
413  #endif  }
414          case 4 :          case 4 :
415  #ifdef USE_UYVY  if ( USE_UYVY )
416    {
417                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
418                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
419                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
420                  break;                  break;
421  #endif  }
422          case 5 :          case 5 :
423  #ifdef USE_RGB32  if ( USE_RGB32 )
424    {
425                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
426                  vih->bmiHeader.biBitCount = 32;                  vih->bmiHeader.biBitCount = 32;
427                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);
428                  break;                  break;
429  #endif  }
430          case 6 :          case 6 :
431  #ifdef USE_RGB24  if ( USE_RGB24 )
432    {
433                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
434                  vih->bmiHeader.biBitCount = 24;                  vih->bmiHeader.biBitCount = 24;
435                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);
436                  break;                  break;
437  #endif  }
438          case 7 :          case 7 :
439  #ifdef USE_RG555  if ( USE_RG555 )
440    {
441                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
442                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
443                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);
444                  break;                  break;
445  #endif  }
446          case 8 :          case 8 :
447  #ifdef USE_RG565  if ( USE_RG565 )
448    {
449                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
450                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
451                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);
452                  break;                  break;
453  #endif  }
454          default :          default :
455                  return VFW_S_NO_MORE_ITEMS;                  return VFW_S_NO_MORE_ITEMS;
456          }          }
# Line 403  Line 470 
470    
471  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)
472  {  {
         int rgb_flip;  
   
473          if (formattype == FORMAT_VideoInfo)          if (formattype == FORMAT_VideoInfo)
474          {          {
475                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;
# Line 588  Line 653 
653          }          }
654    
655          m_frame.general = XVID_LOWDELAY;          m_frame.general = XVID_LOWDELAY;
656    
657          if (pIn->IsDiscontinuity() == S_OK)          if (pIn->IsDiscontinuity() == S_OK)
658                  m_frame.general = XVID_DISCONTINUITY;                  m_frame.general = XVID_DISCONTINUITY;
659    
660            if (PPSettings.bDeblock_Y)
661                    m_frame.general |= XVID_DEBLOCKY;
662    
663            if (PPSettings.bDeblock_UV)
664                    m_frame.general |= XVID_DEBLOCKUV;
665    
666            if (PPSettings.bFlipVideo) {
667                    if (rgb_flip)
668                            m_frame.output.csp &= ~XVID_CSP_VFLIP;
669                    else
670                            m_frame.output.csp |= XVID_CSP_VFLIP;
671            }
672            else {
673                    if (rgb_flip)
674                            m_frame.output.csp |= XVID_CSP_VFLIP;
675                    else
676                            m_frame.output.csp &= ~XVID_CSP_VFLIP;
677            }
678    
679  repeat :  repeat :
680    
681          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)

Legend:
Removed from v.1259  
changed lines
  Added in v.1260

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