[svn] / trunk / xvidcore / dshow / src / CXvidDecoder.cpp Repository:
ViewVC logotype

Diff of /trunk/xvidcore/dshow/src/CXvidDecoder.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1488, Sun Jul 11 10:22:47 2004 UTC revision 1498, Fri Jul 16 15:38:01 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.8 2004-07-11 10:22:47 syskin Exp $   * $Id: CXvidDecoder.cpp,v 1.9 2004-07-16 15:38:01 syskin Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 215  Line 215 
215          m_hdll = LoadLibrary(XVID_DLL_NAME);          m_hdll = LoadLibrary(XVID_DLL_NAME);
216          if (m_hdll == NULL) {          if (m_hdll == NULL) {
217                  DPRINTF("dll load failed");                  DPRINTF("dll load failed");
218                  MessageBox(0, XVID_DLL_NAME " not found","Error", 0);                  MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST);
219                  return;                  return;
220          }          }
221    
222          xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global");          xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global");
223          if (xvid_global_func == NULL) {          if (xvid_global_func == NULL) {
224                  MessageBox(0, "xvid_global() not found", "Error", 0);                  MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST);
225                  return;                  return;
226          }          }
227    
228          xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore");          xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore");
229          if (xvid_decore_func == NULL) {          if (xvid_decore_func == NULL) {
230                  MessageBox(0, "xvid_decore() not found", "Error", 0);                  MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST);
231                  return;                  return;
232          }          }
233    
234          if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)          if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)
235          {          {
236                  MessageBox(0, "xvid_global() failed", "Error", 0);                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);
237                  return;                  return;
238          }          }
239    
# Line 286  Line 286 
286    
287          switch (g_config.aspect_ratio)          switch (g_config.aspect_ratio)
288          {          {
289          case 0: // Auto mode          case 0:
                 ar_x = ar_y = 0;  
                 break;  
290          case 1:          case 1:
291                    break;
292            case 2:
293                  ar_x = 4;                  ar_x = 4;
294                  ar_y = 3;                  ar_y = 3;
295                  break;                  break;
296          case 2:          case 3:
297                  ar_x = 16;                  ar_x = 16;
298                  ar_y = 9;                  ar_y = 9;
299                  break;                  break;
300          case 3:          case 4:
301                  ar_x = 47;                  ar_x = 47;
302                  ar_y = 20;                  ar_y = 20;
303                  break;                  break;
# Line 335  Line 335 
335          DPRINTF("CheckInputType");          DPRINTF("CheckInputType");
336          BITMAPINFOHEADER * hdr;          BITMAPINFOHEADER * hdr;
337    
338            ar_x = ar_y = 0;
339    
340          if (*mtIn->Type() != MEDIATYPE_Video)          if (*mtIn->Type() != MEDIATYPE_Video)
341          {          {
342                  DPRINTF("Error: Unknown Type");                  DPRINTF("Error: Unknown Type");
# Line 346  Line 348 
348          {          {
349                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();
350                  hdr = &vih->bmiHeader;                  hdr = &vih->bmiHeader;
                 /* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter  
                    which is equal to ppm_Y:ppm_X */  
                 if ((ar_x == 0) && (ar_y == 0)) // selected Auto-mode  
                 {  
                         ar_x = vih->bmiHeader.biYPelsPerMeter * abs(hdr->biWidth);  
                         ar_y = vih->bmiHeader.biXPelsPerMeter * abs(hdr->biHeight);  
                 }  
                 DPRINTF("VIDEOINFOHEADER PAR: %d:%d -> AR %d:%d",  
                         vih->bmiHeader.biYPelsPerMeter,vih->bmiHeader.biXPelsPerMeter, ar_x, ar_y);  
351          }          }
352          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)          else if (*mtIn->FormatType() == FORMAT_VideoInfo2)
353          {          {
354                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();
355                  hdr = &vih2->bmiHeader;                  hdr = &vih2->bmiHeader;
356                  if ((ar_x == 0) && (ar_y == 0)) // selected Auto-mode                  if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) {
                 {  
357                          ar_x = vih2->dwPictAspectRatioX;                          ar_x = vih2->dwPictAspectRatioX;
358                          ar_y = vih2->dwPictAspectRatioY;                          ar_y = vih2->dwPictAspectRatioY;
359                  }                  }
# Line 444  Line 436 
436                  if (ar_x != 0 && ar_y != 0) {                  if (ar_x != 0 && ar_y != 0) {
437                          vih->dwPictAspectRatioX = ar_x;                          vih->dwPictAspectRatioX = ar_x;
438                          vih->dwPictAspectRatioY = ar_y;                          vih->dwPictAspectRatioY = ar_y;
439                            forced_ar = true;
440                  } else { // just to be safe                  } else { // just to be safe
441                          vih->dwPictAspectRatioX = m_create.width;                          vih->dwPictAspectRatioX = m_create.width;
442                          vih->dwPictAspectRatioY = abs(m_create.height);                          vih->dwPictAspectRatioY = abs(m_create.height);
443                            forced_ar = false;
444                  }                  }
   
445          } else {          } else {
446    
447                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));
# Line 771  Line 764 
764          m_frame.output.csp &= ~XVID_CSP_VFLIP;          m_frame.output.csp &= ~XVID_CSP_VFLIP;
765          m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0);          m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0);
766    
767    
768    
769    
770  repeat :  repeat :
771    
772          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)
# Line 781  Line 777 
777                  {                  {
778              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
779                          return S_FALSE;                          return S_FALSE;
780                    } else
781                            if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1 && forced_ar == false) {
782                            // inspired by minolta! works for VMR 7 + 9
783    
784                            IMediaSample2 *pOut2 = NULL;
785                            AM_SAMPLE2_PROPERTIES outProp2;
786                            if (SUCCEEDED(pOut->QueryInterface(IID_IMediaSample2, (void **)&pOut2)) &&
787                                    SUCCEEDED(pOut2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&outProp2)))
788                            {
789                                    CMediaType mtOut2 = m_pOutput->CurrentMediaType();
790                                    VIDEOINFOHEADER2* vihOut2 = (VIDEOINFOHEADER2*)mtOut2.Format();
791                                    if (vihOut2->dwPictAspectRatioX != ar_x && vihOut2->dwPictAspectRatioY != ar_y)
792                                    {
793                                            vihOut2->dwPictAspectRatioX = ar_x;
794                                            vihOut2->dwPictAspectRatioY = ar_y;
795                                            pOut2->SetMediaType(&mtOut2);
796                                            m_pOutput->SetMediaType(&mtOut2);
797                                    }
798                                    pOut2->Release();
799                            }
800                  }                  }
801          }          }
802          else          else
# Line 822  Line 838 
838                          return S_FALSE;                          return S_FALSE;
839                  }                  }
840    
 //              pOut->SetDiscontinuity(TRUE);  
841                  pOut->SetSyncPoint(TRUE);                  pOut->SetSyncPoint(TRUE);
842    
843                    if (g_config.aspect_ratio == 0 || g_config.aspect_ratio == 1) { /* auto */
844                            int par_x, par_y;
845                            if (stats.data.vol.par == XVID_PAR_EXT) {
846                                    par_x = stats.data.vol.par_width;
847                                    par_y = stats.data.vol.par_height;
848                            } else {
849                                    par_x = PARS[stats.data.vol.par][0];
850                                    par_y = PARS[stats.data.vol.par][1];
851                            }
852    
853                            ar_x = par_x * stats.data.vol.width;
854                            ar_y = par_y * stats.data.vol.height;
855                    }
856    
857                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
858                  m_frame.length -= length;                  m_frame.length -= length;
859                  goto repeat;                  goto repeat;

Legend:
Removed from v.1488  
changed lines
  Added in v.1498

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