[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 1208, Sat Nov 15 02:51:41 2003 UTC revision 1271, Wed Dec 17 17:08:29 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.3 2003-11-15 02:51:41 suxen_drol Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.6 2003-12-17 17:08:29 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("Dering",  PPSettings.bDering, 0)
234            REG_GET_N("FilmEffect", PPSettings.bFilmEffect, 0)
235            REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)
236    
237            RegCloseKey(hKey);
238    
239            USE_IYUV = false;
240            USE_YV12 = false;
241            USE_YUY2 = false;
242            USE_YVYU = false;
243            USE_UYVY = false;
244            USE_RGB32 = false;
245            USE_RGB24 = false;
246            USE_RG555 = false;
247            USE_RG565 = false;
248    
249            switch ( PPSettings.nForceColorspace )
250            {
251            case FORCE_NONE:
252                    USE_IYUV = true;
253                    USE_YV12 = true;
254                    USE_YUY2 = true;
255                    USE_YVYU = true;
256                    USE_UYVY = true;
257                    USE_RGB32 = true;
258                    USE_RGB24 = true;
259                    USE_RG555 = true;
260                    USE_RG565 = true;
261                    break;
262            case FORCE_YV12:
263                    USE_IYUV = true;
264                    USE_YV12 = true;
265                    break;
266            case FORCE_YUY2:
267                    USE_YUY2 = true;
268                    break;
269            case FORCE_RGB24:
270                    USE_RGB24 = true;
271                    break;
272            case FORCE_RGB32:
273                    USE_RGB32 = true;
274                    break;
275            }
276  }  }
277    
278    
# Line 280  Line 350 
350  }  }
351    
352    
 #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  
   
353  /* get list of supported output colorspaces */  /* get list of supported output colorspaces */
354    
355    
# Line 322  Line 382 
382          switch(iPosition)          switch(iPosition)
383          {          {
384          case 0  :          case 0  :
385  #ifdef USE_IYUV  if ( USE_IYUV )
386    {
387                  vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;                  vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
388                  vih->bmiHeader.biBitCount = 12;                  vih->bmiHeader.biBitCount = 12;
389                  mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);                  mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
390                  break;                  break;
391  #endif  }
392          case 1  :          case 1  :
393  #ifdef USE_YV12  if ( USE_YV12 )
394    {
395                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;
396                  vih->bmiHeader.biBitCount = 12;                  vih->bmiHeader.biBitCount = 12;
397                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
398                  break;                  break;
399  #endif  }
400          case 2:          case 2:
401  #ifdef USE_YUY2  if ( USE_YUY2 )
402    {
403                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
404                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
405                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
406                  break;                  break;
407  #endif  }
408          case 3 :          case 3 :
409  #ifdef USE_YVYU  if ( USE_YVYU )
410    {
411                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
412                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
413                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
414                  break;                  break;
415  #endif  }
416          case 4 :          case 4 :
417  #ifdef USE_UYVY  if ( USE_UYVY )
418    {
419                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
420                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
421                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
422                  break;                  break;
423  #endif  }
424          case 5 :          case 5 :
425  #ifdef USE_RGB32  if ( USE_RGB32 )
426    {
427                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
428                  vih->bmiHeader.biBitCount = 32;                  vih->bmiHeader.biBitCount = 32;
429                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);
430                  break;                  break;
431  #endif  }
432          case 6 :          case 6 :
433  #ifdef USE_RGB24  if ( USE_RGB24 )
434    {
435                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
436                  vih->bmiHeader.biBitCount = 24;                  vih->bmiHeader.biBitCount = 24;
437                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);
438                  break;                  break;
439  #endif  }
440          case 7 :          case 7 :
441  #ifdef USE_RG555  if ( USE_RG555 )
442    {
443                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
444                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
445                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);
446                  break;                  break;
447  #endif  }
448          case 8 :          case 8 :
449  #ifdef USE_RG565  if ( USE_RG565 )
450    {
451                  vih->bmiHeader.biCompression = BI_RGB;                  vih->bmiHeader.biCompression = BI_RGB;
452                  vih->bmiHeader.biBitCount = 16;                  vih->bmiHeader.biBitCount = 16;
453                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);
454                  break;                  break;
455  #endif  }
456          default :          default :
457                  return VFW_S_NO_MORE_ITEMS;                  return VFW_S_NO_MORE_ITEMS;
458          }          }
# Line 403  Line 472 
472    
473  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)
474  {  {
         int rgb_flip;  
   
475          if (formattype == FORMAT_VideoInfo)          if (formattype == FORMAT_VideoInfo)
476          {          {
477                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;
# Line 588  Line 655 
655          }          }
656    
657          m_frame.general = XVID_LOWDELAY;          m_frame.general = XVID_LOWDELAY;
658    
659          if (pIn->IsDiscontinuity() == S_OK)          if (pIn->IsDiscontinuity() == S_OK)
660                  m_frame.general = XVID_DISCONTINUITY;                  m_frame.general = XVID_DISCONTINUITY;
661    
662            if (PPSettings.bDeblock_Y)
663                    m_frame.general |= XVID_DEBLOCKY;
664    
665            if (PPSettings.bDeblock_UV)
666                    m_frame.general |= XVID_DEBLOCKUV;
667    /*
668            if (PPSettings.bDering)
669                    m_frame.general |= XVID_DERING;
670    */
671            if (PPSettings.bFilmEffect)
672                    m_frame.general |= XVID_FILMEFFECT;
673    
674            if (PPSettings.bFlipVideo) {
675                    if (rgb_flip)
676                            m_frame.output.csp &= ~XVID_CSP_VFLIP;
677                    else
678                            m_frame.output.csp |= XVID_CSP_VFLIP;
679            }
680            else {
681                    if (rgb_flip)
682                            m_frame.output.csp |= XVID_CSP_VFLIP;
683                    else
684                            m_frame.output.csp &= ~XVID_CSP_VFLIP;
685            }
686    
687  repeat :  repeat :
688    
689          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)
690          {          {
691                  length = xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  length = xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
692    
693                  if (length < 0)                  if (length < 0)
694                  {                  {
695              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 617  Line 711 
711                  m_frame.output.csp = tmp;                  m_frame.output.csp = tmp;
712          }          }
713    
714            if (stats.type == XVID_TYPE_NOTHING) {
715                    DPRINTF("B-Frame decoder lag");
716                    return S_FALSE;
717            }
718    
719    
720          if (stats.type == XVID_TYPE_VOL)          if (stats.type == XVID_TYPE_VOL)
721          {          {
722                  if (stats.data.vol.width != m_create.width ||                  if (stats.data.vol.width != m_create.width ||

Legend:
Removed from v.1208  
changed lines
  Added in v.1271

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