[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 1300, Sat Dec 27 14:33:13 2003 UTC revision 1314, Wed Jan 21 04:26:21 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.7 2003-12-27 14:33:13 Isibaar Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.11 2004-01-21 04:26:21 syskin Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 201  Line 201 
201    
202  /* constructor */  /* constructor */
203    
204    #define XVID_DLL_NAME "xvidcore.dll"
205    
206  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :
207      CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID)      CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID)
208  {  {
# Line 209  Line 211 
211          xvid_gbl_init_t init;          xvid_gbl_init_t init;
212          memset(&init, 0, sizeof(init));          memset(&init, 0, sizeof(init));
213          init.version = XVID_VERSION;          init.version = XVID_VERSION;
214          if (xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0)  
215            ar_x = ar_y = 0;
216    
217            m_hdll = LoadLibrary(XVID_DLL_NAME);
218            if (m_hdll == NULL) {
219                    DPRINTF("dll load failed");
220                    MessageBox(0, XVID_DLL_NAME " not found","Error", 0);
221                    return;
222            }
223    
224            xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global");
225            if (xvid_global_func == NULL) {
226                    MessageBox(0, "xvid_global() not found", "Error", 0);
227                    return;
228            }
229    
230            xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore");
231            if (xvid_decore_func == NULL) {
232                    MessageBox(0, "xvid_decore() not found", "Error", 0);
233                    return;
234            }
235    
236            if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)
237          {          {
238                  MessageBox(0, "xvid_global() failed", "Error", 0);                  MessageBox(0, "xvid_global() failed", "Error", 0);
239                  return;                  return;
# Line 228  Line 252 
252    
253          // Set the default post-processing settings          // Set the default post-processing settings
254          REG_GET_N("Brightness", PPSettings.nBrightness, 25)          REG_GET_N("Brightness", PPSettings.nBrightness, 25)
255          REG_GET_N("Deblock_Y",  PPSettings.bDeblock_Y, 1)          REG_GET_N("Deblock_Y",  PPSettings.bDeblock_Y, 0)
256          REG_GET_N("Deblock_UV", PPSettings.bDeblock_UV, 1)          REG_GET_N("Deblock_UV", PPSettings.bDeblock_UV, 0)
257          REG_GET_N("Dering",  PPSettings.bDering, 1)          REG_GET_N("Dering",  PPSettings.bDering, 0)
258          REG_GET_N("FilmEffect", PPSettings.bFilmEffect, 1)          REG_GET_N("FilmEffect", PPSettings.bFilmEffect, 0)
259          REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)          REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0)
260    
261          RegCloseKey(hKey);          RegCloseKey(hKey);
# Line 285  Line 309 
309    
310          if (m_create.handle != NULL)          if (m_create.handle != NULL)
311          {          {
312                  xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0);                  xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0);
313                  m_create.handle = NULL;                  m_create.handle = NULL;
314          }          }
315    
316            if (m_hdll != NULL)
317            {
318                    FreeLibrary(m_hdll);
319                    m_hdll = NULL;
320            }
321  }  }
322    
323    
# Line 309  Line 339 
339          {          {
340                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();
341                  hdr = &vih->bmiHeader;                  hdr = &vih->bmiHeader;
342                    /* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter
343                       which is equal to ppm_Y:ppm_X */
344                    ar_x = vih->bmiHeader.biYPelsPerMeter*hdr->biWidth;
345                    ar_y = vih->bmiHeader.biXPelsPerMeter*hdr->biHeight;
346          }          }
347          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)
348          {          {
349                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();
350                  hdr = &vih2->bmiHeader;                  hdr = &vih2->bmiHeader;
351                    ar_x = vih2->dwPictAspectRatioX;
352                    ar_y = vih2->dwPictAspectRatioY;
353          }          }
354          else          else
355          {          {
# Line 362  Line 398 
398                  return E_UNEXPECTED;                  return E_UNEXPECTED;
399          }          }
400    
401          VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));          VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));
402          if (vih == NULL)          if (vih == NULL)
403          {          {
404                  return E_OUTOFMEMORY;                  return E_OUTOFMEMORY;
# Line 381  Line 417 
417    
418          switch(iPosition)          switch(iPosition)
419          {          {
420    
421          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:  
422  if ( USE_YUY2 )  if ( USE_YUY2 )
423  {  {
424                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;
# Line 405  Line 426 
426                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
427                  break;                  break;
428  }  }
429          case 3 :          case 1 :
430  if ( USE_YVYU )  if ( USE_YVYU )
431  {  {
432                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;
# Line 413  Line 434 
434                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
435                  break;                  break;
436  }  }
437          case 4 :          case 2 :
438  if ( USE_UYVY )  if ( USE_UYVY )
439  {  {
440                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;
# Line 421  Line 442 
442                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
443                  break;                  break;
444  }  }
445            case 3  :
446                    if ( USE_IYUV )
447    {
448                    vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
449                    vih->bmiHeader.biBitCount = 12;
450                    mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
451                    break;
452    }
453            case 4  :
454    if ( USE_YV12 )
455    {
456                    vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;
457                    vih->bmiHeader.biBitCount = 12;
458                    mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
459                    break;
460    }
461          case 5 :          case 5 :
462  if ( USE_RGB32 )  if ( USE_RGB32 )
463  {  {
# Line 459  Line 496 
496    
497          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);
498    
499            if (ar_x != 0 && ar_y != 0) {
500                    vih->dwPictAspectRatioX = ar_x;
501                    vih->dwPictAspectRatioY = ar_y;
502            } else { // just to be safe
503                    vih->dwPictAspectRatioX = m_create.width;
504                    vih->dwPictAspectRatioY = m_create.height;
505            }
506    
507          mtOut->SetType(&MEDIATYPE_Video);          mtOut->SetType(&MEDIATYPE_Video);
508          mtOut->SetFormatType(&FORMAT_VideoInfo);          mtOut->SetFormatType(&FORMAT_VideoInfo2);
509          mtOut->SetTemporalCompression(FALSE);          mtOut->SetTemporalCompression(FALSE);
510          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);
511    
# Line 620  Line 665 
665    
666          if (m_create.handle == NULL)          if (m_create.handle == NULL)
667          {          {
668                  if (xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0)                  if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0)
669                  {                  {
670              DPRINTF("*** XVID_DEC_CREATE error");              DPRINTF("*** XVID_DEC_CREATE error");
671                          return S_FALSE;                          return S_FALSE;
# Line 671  Line 716 
716          if (PPSettings.bFilmEffect)          if (PPSettings.bFilmEffect)
717                  m_frame.general |= XVID_FILMEFFECT;                  m_frame.general |= XVID_FILMEFFECT;
718    
         if (PPSettings.bFlipVideo) {  
                 if (rgb_flip)  
719                          m_frame.output.csp &= ~XVID_CSP_VFLIP;                          m_frame.output.csp &= ~XVID_CSP_VFLIP;
720                  else          m_frame.output.csp |= rgb_flip^(PPSettings.bFlipVideo ? XVID_CSP_VFLIP : 0);
                         m_frame.output.csp |= XVID_CSP_VFLIP;  
         }  
         else {  
                 if (rgb_flip)  
                         m_frame.output.csp |= XVID_CSP_VFLIP;  
                 else  
                         m_frame.output.csp &= ~XVID_CSP_VFLIP;  
         }  
721    
722  repeat :  repeat :
723    
724          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)
725          {          {
726                  length = xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
727    
728                  if (length < 0)                  if (length < 0)
729                  {                  {
# Line 709  Line 744 
744  /*              m_frame.general &= ~XVID_DERING; */  /*              m_frame.general &= ~XVID_DERING; */
745                  m_frame.general &= ~XVID_FILMEFFECT;                  m_frame.general &= ~XVID_FILMEFFECT;
746    
747                  length = xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
748                  if (length < 0)                  if (length < 0)
749                  {                  {
750              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");

Legend:
Removed from v.1300  
changed lines
  Added in v.1314

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