[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 1366, Sat Feb 28 07:15:39 2004 UTC revision 1367, Sat Feb 28 07:24:34 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.18 2004-02-07 03:57:39 syskin Exp $   * $Id: CXvidDecoder.cpp,v 1.1.2.19 2004-02-28 07:24:34 syskin Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 331  Line 331 
331                     which is equal to ppm_Y:ppm_X */                     which is equal to ppm_Y:ppm_X */
332                  ar_x = vih->bmiHeader.biYPelsPerMeter * abs(hdr->biWidth);                  ar_x = vih->bmiHeader.biYPelsPerMeter * abs(hdr->biWidth);
333                  ar_y = vih->bmiHeader.biXPelsPerMeter * abs(hdr->biHeight);                  ar_y = vih->bmiHeader.biXPelsPerMeter * abs(hdr->biHeight);
334                    DPRINTF("VIDEOINFOHEADER PAR: %d:%d -> AR %d:%d",
335                            vih->bmiHeader.biYPelsPerMeter,vih->bmiHeader.biXPelsPerMeter, ar_x, ar_y);
336          }          }
337          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)
338          {          {
# Line 338  Line 340 
340                  hdr = &vih2->bmiHeader;                  hdr = &vih2->bmiHeader;
341                  ar_x = vih2->dwPictAspectRatioX;                  ar_x = vih2->dwPictAspectRatioX;
342                  ar_y = vih2->dwPictAspectRatioY;                  ar_y = vih2->dwPictAspectRatioY;
343                    DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y);
344          }          }
345          else          else
346          {          {
# Line 386  Line 389 
389    
390  HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut)  HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut)
391  {  {
392            BITMAPINFOHEADER * bmih;
393          DPRINTF("GetMediaType");          DPRINTF("GetMediaType");
394    
395          if (m_pInput->IsConnected() == FALSE)          if (m_pInput->IsConnected() == FALSE)
# Line 393  Line 397 
397                  return E_UNEXPECTED;                  return E_UNEXPECTED;
398          }          }
399    
400            if (!g_config.videoinfo_compat) {
401          VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));          VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));
402          if (vih == NULL)                  if (vih == NULL) return E_OUTOFMEMORY;
         {  
                 return E_OUTOFMEMORY;  
         }  
403    
404          ZeroMemory(vih, sizeof (VIDEOINFOHEADER2));          ZeroMemory(vih, sizeof (VIDEOINFOHEADER2));
405          vih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);                  bmih = &(vih->bmiHeader);
406          vih->bmiHeader.biWidth  = m_create.width;                  mtOut->SetFormatType(&FORMAT_VideoInfo2);
         vih->bmiHeader.biHeight = m_create.height;  
         vih->bmiHeader.biPlanes = 1;  
407    
408          if (iPosition < 0)                  if (ar_x != 0 && ar_y != 0) {
409          {                          vih->dwPictAspectRatioX = ar_x;
410                  return E_INVALIDARG;                          vih->dwPictAspectRatioY = ar_y;
411                    } else { // just to be safe
412                            vih->dwPictAspectRatioX = m_create.width;
413                            vih->dwPictAspectRatioY = abs(m_create.height);
414          }          }
415    
416            } else {
417    
418                    VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));
419                    if (vih == NULL) return E_OUTOFMEMORY;
420    
421                    ZeroMemory(vih, sizeof (VIDEOINFOHEADER2));
422                    bmih = &(vih->bmiHeader);
423                    mtOut->SetFormatType(&FORMAT_VideoInfo);
424            }
425    
426            bmih->biSize = sizeof(BITMAPINFOHEADER);
427            bmih->biWidth   = m_create.width;
428            bmih->biHeight = m_create.height;
429            bmih->biPlanes = 1;
430    
431            if (iPosition < 0) return E_INVALIDARG;
432    
433          switch(iPosition)          switch(iPosition)
434          {          {
435    
436          case 0:          case 0:
437  if ( USE_YUY2 )  if ( USE_YUY2 )
438  {  {
439                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;                  bmih->biCompression = MEDIASUBTYPE_YUY2.Data1;
440                  vih->bmiHeader.biBitCount = 16;                  bmih->biBitCount = 16;
441                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
442                  break;                  break;
443  }  }
444          case 1 :          case 1 :
445  if ( USE_YVYU )  if ( USE_YVYU )
446  {  {
447                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;                  bmih->biCompression = MEDIASUBTYPE_YVYU.Data1;
448                  vih->bmiHeader.biBitCount = 16;                  bmih->biBitCount = 16;
449                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
450                  break;                  break;
451  }  }
452          case 2 :          case 2 :
453  if ( USE_UYVY )  if ( USE_UYVY )
454  {  {
455                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;                  bmih->biCompression = MEDIASUBTYPE_UYVY.Data1;
456                  vih->bmiHeader.biBitCount = 16;                  bmih->biBitCount = 16;
457                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
458                  break;                  break;
459  }  }
460          case 3  :          case 3  :
461                  if ( USE_IYUV )                  if ( USE_IYUV )
462  {  {
463                  vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;                  bmih->biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
464                  vih->bmiHeader.biBitCount = 12;                  bmih->biBitCount = 12;
465                  mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);                  mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
466                  break;                  break;
467  }  }
468          case 4  :          case 4  :
469  if ( USE_YV12 )  if ( USE_YV12 )
470  {  {
471                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;                  bmih->biCompression = MEDIASUBTYPE_YV12.Data1;
472                  vih->bmiHeader.biBitCount = 12;                  bmih->biBitCount = 12;
473                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
474                  break;                  break;
475  }  }
476          case 5 :          case 5 :
477  if ( USE_RGB32 )  if ( USE_RGB32 )
478  {  {
479                  vih->bmiHeader.biCompression = BI_RGB;                  bmih->biCompression = BI_RGB;
480                  vih->bmiHeader.biBitCount = 32;                  bmih->biBitCount = 32;
481                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);
482                  break;                  break;
483  }  }
484          case 6 :          case 6 :
485  if ( USE_RGB24 )  if ( USE_RGB24 )
486  {  {
487                  vih->bmiHeader.biCompression = BI_RGB;                  bmih->biCompression = BI_RGB;
488                  vih->bmiHeader.biBitCount = 24;                  bmih->biBitCount = 24;
489                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);
490                  break;                  break;
491  }  }
492          case 7 :          case 7 :
493  if ( USE_RG555 )  if ( USE_RG555 )
494  {  {
495                  vih->bmiHeader.biCompression = BI_RGB;                  bmih->biCompression = BI_RGB;
496                  vih->bmiHeader.biBitCount = 16;                  bmih->biBitCount = 16;
497                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);
498                  break;                  break;
499  }  }
500          case 8 :          case 8 :
501  if ( USE_RG565 )  if ( USE_RG565 )
502  {  {
503                  vih->bmiHeader.biCompression = BI_RGB;                  bmih->biCompression = BI_RGB;
504                  vih->bmiHeader.biBitCount = 16;                  bmih->biBitCount = 16;
505                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);
506                  break;                  break;
507  }  }
# Line 489  Line 509 
509                  return VFW_S_NO_MORE_ITEMS;                  return VFW_S_NO_MORE_ITEMS;
510          }          }
511    
512          vih->bmiHeader.biSizeImage = GetBitmapSize(&vih->bmiHeader);          bmih->biSizeImage = GetBitmapSize(bmih);
   
         if (ar_x != 0 && ar_y != 0) {  
                 vih->dwPictAspectRatioX = ar_x;  
                 vih->dwPictAspectRatioY = ar_y;  
         } else { // just to be safe  
                 vih->dwPictAspectRatioX = m_create.width;  
                 vih->dwPictAspectRatioY = abs(m_create.height);  
         }  
513    
514          mtOut->SetType(&MEDIATYPE_Video);          mtOut->SetType(&MEDIATYPE_Video);
         mtOut->SetFormatType(&FORMAT_VideoInfo2);  
515          mtOut->SetTemporalCompression(FALSE);          mtOut->SetTemporalCompression(FALSE);
516          mtOut->SetSampleSize(vih->bmiHeader.biSizeImage);          mtOut->SetSampleSize(bmih->biSizeImage);
517    
518          return S_OK;          return S_OK;
519  }  }
# Line 770  Line 781 
781                          return S_FALSE;                          return S_FALSE;
782                  }                  }
783    
784                  pOut->SetDiscontinuity(TRUE);  //              pOut->SetDiscontinuity(TRUE);
785                  pOut->SetSyncPoint(TRUE);                  pOut->SetSyncPoint(TRUE);
786    
787                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;

Legend:
Removed from v.1366  
changed lines
  Added in v.1367

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