[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 1341, Fri Jan 30 03:21:20 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.8 2004-01-02 13:18:28 syskin Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.14 2004-01-30 03:21:20 syskin Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 63  Line 63 
63    
64  // Externs defined here  // Externs defined here
65  PostProcessing_Settings PPSettings;  PostProcessing_Settings PPSettings;
66    unsigned int supported_4cc;
67  int rgb_flip;  int rgb_flip;
68    
69    
70  bool USE_IYUV;  bool USE_IYUV;
71  bool USE_YV12;  bool USE_YV12;
72  bool USE_YUY2;  bool USE_YUY2;
# Line 84  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 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 250  Line 254 
254    
255          // Set the default post-processing settings          // Set the default post-processing settings
256          REG_GET_N("Brightness", PPSettings.nBrightness, 25)          REG_GET_N("Brightness", PPSettings.nBrightness, 25)
257          REG_GET_N("Deblock_Y",  PPSettings.bDeblock_Y, 1)          REG_GET_N("Deblock_Y",  PPSettings.nDeblock_Y, 0)
258          REG_GET_N("Deblock_UV", PPSettings.bDeblock_UV, 1)          REG_GET_N("Deblock_UV", PPSettings.nDeblock_UV, 0)
259          REG_GET_N("Dering",  PPSettings.bDering, 1)          REG_GET_N("Dering",  PPSettings.nDering, 0)
260          REG_GET_N("FilmEffect", PPSettings.bFilmEffect, 1)          REG_GET_N("FilmEffect", PPSettings.nFilmEffect, 0)
261          REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)          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);          RegCloseKey(hKey);
266    
# Line 337  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 359  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 373  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    
# Line 390  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 409  Line 426 
426    
427          switch(iPosition)          switch(iPosition)
428          {          {
429    
430          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:  
431  if ( USE_YUY2 )  if ( USE_YUY2 )
432  {  {
433                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
# Line 433  Line 435 
435                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
436                  break;                  break;
437  }  }
438          case 3 :          case 1 :
439  if ( USE_YVYU )  if ( USE_YVYU )
440  {  {
441                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
# Line 441  Line 443 
443                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
444                  break;                  break;
445  }  }
446          case 4 :          case 2 :
447  if ( USE_UYVY )  if ( USE_UYVY )
448  {  {
449                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
# Line 449  Line 451 
451                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
452                  break;                  break;
453  }  }
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  if ( USE_RGB32 )  if ( USE_RGB32 )
472  {  {
# Line 487  Line 505 
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 520  Line 546 
546          if (subtype == CLSID_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 687  Line 718 
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.bDeblock_Y)          if (PPSettings.nDeblock_Y)
722                  m_frame.general |= XVID_DEBLOCKY;                  m_frame.general |= XVID_DEBLOCKY;
723    
724          if (PPSettings.bDeblock_UV)          if (PPSettings.nDeblock_UV)
725                  m_frame.general |= XVID_DEBLOCKUV;                  m_frame.general |= XVID_DEBLOCKUV;
726  /*  /*
727          if (PPSettings.bDering)          if (PPSettings.nDering)
728                  m_frame.general |= XVID_DERING;                  m_frame.general |= XVID_DERING;
729  */  */
730          if (PPSettings.bFilmEffect)          if (PPSettings.nFilmEffect)
731                  m_frame.general |= XVID_FILMEFFECT;                  m_frame.general |= XVID_FILMEFFECT;
732    
         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  
733                          m_frame.output.csp &= ~XVID_CSP_VFLIP;                          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    
# Line 748  Line 769 
769                  m_frame.general = tmp_gen;                  m_frame.general = tmp_gen;
770          }          }
771    
772          if (stats.type == XVID_TYPE_NOTHING) {          if (stats.type == XVID_TYPE_NOTHING && length > 0) {
773                  DPRINTF("B-Frame decoder lag");                  DPRINTF("B-Frame decoder lag");
774                  return S_FALSE;                  return S_FALSE;
775          }          }

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

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