[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 888, Sat Feb 22 08:22:03 2003 UTC revision 1367, Sat Feb 28 07:24:34 2004 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID DIRECTSHOW FRONTEND -- decoder fitler   *  XVID MPEG-4 VIDEO CODEC
4   *      Copyright (c) 2002 Peter Ross <pross@xvid.org>   *  - XviD Decoder part of the DShow Filter  -
5     *
6     *  Copyright(C) 2002-2004 Peter Ross <pross@xvid.org>
7   *   *
8   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
9   *      it under the terms of the GNU General Public License as published by   *      it under the terms of the GNU General Public License as published by
# Line 15  Line 17 
17   *   *
18   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
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., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21     *
22     * $Id: CXvidDecoder.cpp,v 1.1.2.19 2004-02-28 07:24:34 syskin 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    
34   /*   /*
35          this requires the directx sdk          this requires the directx sdk
# Line 48  Line 60 
60  #include "IXvidDecoder.h"  #include "IXvidDecoder.h"
61  #include "CXvidDecoder.h"  #include "CXvidDecoder.h"
62  #include "CAbout.h"  #include "CAbout.h"
63    #include "config.h"
64    #include "debug.h"
65    
66    static bool USE_IYUV;
67    static bool USE_YV12;
68    static bool USE_YUY2;
69    static bool USE_YVYU;
70    static bool USE_UYVY;
71    static bool USE_RGB32;
72    static bool USE_RGB24;
73    static bool USE_RG555;
74    static bool USE_RG565;
75    
76  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] =
77  {  {
# Line 58  Line 81 
81          { &MEDIATYPE_Video, &CLSID_DIVX_UC },          { &MEDIATYPE_Video, &CLSID_DIVX_UC },
82          { &MEDIATYPE_Video, &CLSID_DX50 },          { &MEDIATYPE_Video, &CLSID_DX50 },
83          { &MEDIATYPE_Video, &CLSID_DX50_UC },          { &MEDIATYPE_Video, &CLSID_DX50_UC },
84            { &MEDIATYPE_Video, &CLSID_MP4V },
85  };  };
86    
87  const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] =  const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] =
# Line 124  Line 148 
148    
149  };  };
150    
 int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);  
   
151    
152    /* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */
153    int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate);
154    
155    
156  STDAPI DllRegisterServer()  STDAPI DllRegisterServer()
# Line 175  Line 199 
199    
200    
201    
 /* dummy decore() */  
   
 static int dummy_xvid_decore(void * handle, int opt, void * param1, void * param2)  
 {  
         return XVID_ERR_FAIL;  
 }  
   
   
   
202  /* constructor */  /* constructor */
203    
204  #define XVID_DLL_NAME           "xvid.dll"  #define XVID_DLL_NAME "xvidcore.dll"
 #define XVID_GLOBAL_NAME        "xvid_global"  
 #define XVID_DECORE_NAME        "xvid_decore"  
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  {  {
209          DPRINTF("Constructor");          DPRINTF("Constructor");
210    
211          m_xvid_decore = dummy_xvid_decore;          xvid_gbl_init_t init;
212            memset(&init, 0, sizeof(init));
213            init.version = XVID_VERSION;
214    
215            ar_x = ar_y = 0;
216    
217          m_hdll = LoadLibrary(XVID_DLL_NAME);          m_hdll = LoadLibrary(XVID_DLL_NAME);
218          if (m_hdll == NULL) {          if (m_hdll == NULL) {
# Line 204  Line 221 
221                  return;                  return;
222          }          }
223    
224          m_xvid_global = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, XVID_GLOBAL_NAME);          xvid_global_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global");
225          if (m_xvid_global == NULL) {          if (xvid_global_func == NULL) {
226                  MessageBox(0, XVID_GLOBAL_NAME "() not found", "Error", 0);                  MessageBox(0, "xvid_global() not found", "Error", 0);
227                  return;                  return;
228          }          }
229    
230          m_xvid_decore = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, XVID_DECORE_NAME);          xvid_decore_func = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_decore");
231          if (m_xvid_decore == NULL) {          if (xvid_decore_func == NULL) {
232                  MessageBox(0, XVID_DECORE_NAME "() not found", "Error", 0);                  MessageBox(0, "xvid_decore() not found", "Error", 0);
233                  return;                  return;
234          }          }
235    
236          xvid_gbl_init_t init;          if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)
         memset(&init, 0, sizeof(init));  
         init.version = XVID_VERSION;  
         if (m_xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0)  
237          {          {
238                  MessageBox(0, XVID_GLOBAL_NAME "() failed", "Error", 0);                  MessageBox(0, "xvid_global() failed", "Error", 0);
239                  return;                  return;
240          }          }
241    
# Line 231  Line 245 
245    
246          memset(&m_frame, 0, sizeof(m_frame));          memset(&m_frame, 0, sizeof(m_frame));
247          m_frame.version = XVID_VERSION;          m_frame.version = XVID_VERSION;
248    
249            LoadRegistryInfo();
250    
251            USE_IYUV = false;
252            USE_YV12 = false;
253            USE_YUY2 = false;
254            USE_YVYU = false;
255            USE_UYVY = false;
256            USE_RGB32 = false;
257            USE_RGB24 = false;
258            USE_RG555 = false;
259            USE_RG565 = false;
260    
261            switch ( g_config.nForceColorspace )
262            {
263            case FORCE_NONE:
264                    USE_IYUV = true;
265                    USE_YV12 = true;
266                    USE_YUY2 = true;
267                    USE_YVYU = true;
268                    USE_UYVY = true;
269                    USE_RGB32 = true;
270                    USE_RGB24 = true;
271                    USE_RG555 = true;
272                    USE_RG565 = true;
273                    break;
274            case FORCE_YV12:
275                    USE_IYUV = true;
276                    USE_YV12 = true;
277                    break;
278            case FORCE_YUY2:
279                    USE_YUY2 = true;
280                    break;
281            case FORCE_RGB24:
282                    USE_RGB24 = true;
283                    break;
284            case FORCE_RGB32:
285                    USE_RGB32 = true;
286                    break;
287            }
288  }  }
289    
290    
# Line 243  Line 297 
297    
298          if (m_create.handle != NULL)          if (m_create.handle != NULL)
299          {          {
300                  m_xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0);                  xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0);
301                  m_create.handle = NULL;                  m_create.handle = NULL;
302          }          }
303    
# Line 273  Line 327 
327          {          {
328                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();
329                  hdr = &vih->bmiHeader;                  hdr = &vih->bmiHeader;
330                    /* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter
331                       which is equal to ppm_Y:ppm_X */
332                    ar_x = vih->bmiHeader.biYPelsPerMeter * abs(hdr->biWidth);
333                    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          {          {
339                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 *) mtIn->Format();
340                  hdr = &vih2->bmiHeader;                  hdr = &vih2->bmiHeader;
341                    ar_x = vih2->dwPictAspectRatioX;
342                    ar_y = vih2->dwPictAspectRatioY;
343                    DPRINTF("VIDEOINFOHEADER2 AR: %d:%d", ar_x, ar_y);
344          }          }
345          else          else
346          {          {
# Line 295  Line 358 
358    
359          switch(hdr->biCompression)          switch(hdr->biCompression)
360          {          {
361    
362            case FOURCC_MP4V:
363                    if (!(g_config.supported_4cc & SUPPORT_MP4V)) return VFW_E_TYPE_NOT_ACCEPTED;
364                    break;
365            case FOURCC_DIVX :
366                    if (!(g_config.supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED;
367                    break;
368            case FOURCC_DX50 :
369                    if (!(g_config.supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED;
370          case FOURCC_XVID :          case FOURCC_XVID :
 //      case FOURCC_DIVX :  
 //      case FOURCC_DX50 :  
371                  break;                  break;
372    
373    
374          default :          default :
375                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",                  DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)",
376                          hdr->biCompression,                          hdr->biCompression,
# Line 309  Line 380 
380                          (hdr->biCompression>>24)&0xff);                          (hdr->biCompression>>24)&0xff);
381                  return VFW_E_TYPE_NOT_ACCEPTED;                  return VFW_E_TYPE_NOT_ACCEPTED;
382          }          }
   
383          return S_OK;          return S_OK;
384  }  }
385    
386    
 #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  
   
387  /* get list of supported output colorspaces */  /* get list of supported output colorspaces */
388    
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 335  Line 397 
397                  return E_UNEXPECTED;                  return E_UNEXPECTED;
398          }          }
399    
400          VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));          if (!g_config.videoinfo_compat) {
401          if (vih == NULL)                  VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));
402          {                  if (vih == NULL) return E_OUTOFMEMORY;
403                  return E_OUTOFMEMORY;  
404                    ZeroMemory(vih, sizeof (VIDEOINFOHEADER2));
405                    bmih = &(vih->bmiHeader);
406                    mtOut->SetFormatType(&FORMAT_VideoInfo2);
407    
408                    if (ar_x != 0 && ar_y != 0) {
409                            vih->dwPictAspectRatioX = ar_x;
410                            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          ZeroMemory(vih, sizeof (VIDEOINFOHEADER));          } else {
         vih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);  
         vih->bmiHeader.biWidth  = m_create.width;  
         vih->bmiHeader.biHeight = m_create.height;  
         vih->bmiHeader.biPlanes = 1;  
417    
418          if (iPosition < 0)                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtOut->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));
419          {                  if (vih == NULL) return E_OUTOFMEMORY;
420                  return E_INVALIDARG;  
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  #ifdef USE_IYUV  if ( USE_YUY2 )
438                  vih->bmiHeader.biCompression = MEDIASUBTYPE_IYUV.Data1;  {
439                  vih->bmiHeader.biBitCount = 12;                  bmih->biCompression = MEDIASUBTYPE_YUY2.Data1;
440                  mtOut->SetSubtype(&MEDIASUBTYPE_IYUV);                  bmih->biBitCount = 16;
441                    mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);
442                  break;                  break;
443  #endif  }
444          case 1  :          case 1  :
445  #ifdef USE_YV12  if ( USE_YVYU )
446                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YV12.Data1;  {
447                  vih->bmiHeader.biBitCount = 12;                  bmih->biCompression = MEDIASUBTYPE_YVYU.Data1;
448                  mtOut->SetSubtype(&MEDIASUBTYPE_YV12);                  bmih->biBitCount = 16;
449                    mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);
450                  break;                  break;
451  #endif  }
452          case 2:          case 2:
453  #ifdef USE_YUY2  if ( USE_UYVY )
454                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YUY2.Data1;  {
455                  vih->bmiHeader.biBitCount = 16;                  bmih->biCompression = MEDIASUBTYPE_UYVY.Data1;
456                  mtOut->SetSubtype(&MEDIASUBTYPE_YUY2);                  bmih->biBitCount = 16;
457                    mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);
458                  break;                  break;
459  #endif  }
460          case 3 :          case 3 :
461  #ifdef USE_YVYU                  if ( USE_IYUV )
462                  vih->bmiHeader.biCompression = MEDIASUBTYPE_YVYU.Data1;  {
463                  vih->bmiHeader.biBitCount = 16;                  bmih->biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1;
464                  mtOut->SetSubtype(&MEDIASUBTYPE_YVYU);                  bmih->biBitCount = 12;
465                    mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV);
466                  break;                  break;
467  #endif  }
468          case 4 :          case 4 :
469  #ifdef USE_UYVY  if ( USE_YV12 )
470                  vih->bmiHeader.biCompression = MEDIASUBTYPE_UYVY.Data1;  {
471                  vih->bmiHeader.biBitCount = 16;                  bmih->biCompression = MEDIASUBTYPE_YV12.Data1;
472                  mtOut->SetSubtype(&MEDIASUBTYPE_UYVY);                  bmih->biBitCount = 12;
473                    mtOut->SetSubtype(&MEDIASUBTYPE_YV12);
474                  break;                  break;
475  #endif  }
476          case 5 :          case 5 :
477  #ifdef USE_RGB32  if ( USE_RGB32 )
478                  vih->bmiHeader.biCompression = BI_RGB;  {
479                  vih->bmiHeader.biBitCount = 32;                  bmih->biCompression = BI_RGB;
480                    bmih->biBitCount = 32;
481                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB32);
482                  break;                  break;
483  #endif  }
484          case 6 :          case 6 :
485  #ifdef USE_RGB24  if ( USE_RGB24 )
486                  vih->bmiHeader.biCompression = BI_RGB;  {
487                  vih->bmiHeader.biBitCount = 24;                  bmih->biCompression = BI_RGB;
488                    bmih->biBitCount = 24;
489                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB24);
490                  break;                  break;
491  #endif  }
492          case 7 :          case 7 :
493  #ifdef USE_RG555  if ( USE_RG555 )
494                  vih->bmiHeader.biCompression = BI_RGB;  {
495                  vih->bmiHeader.biBitCount = 16;                  bmih->biCompression = BI_RGB;
496                    bmih->biBitCount = 16;
497                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB555);
498                  break;                  break;
499  #endif  }
500          case 8 :          case 8 :
501  #ifdef USE_RG565  if ( USE_RG565 )
502                  vih->bmiHeader.biCompression = BI_RGB;  {
503                  vih->bmiHeader.biBitCount = 16;                  bmih->biCompression = BI_RGB;
504                    bmih->biBitCount = 16;
505                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);                  mtOut->SetSubtype(&MEDIASUBTYPE_RGB565);
506                  break;                  break;
507  #endif  }
508          default :          default :
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);
513    
514          mtOut->SetType(&MEDIATYPE_Video);          mtOut->SetType(&MEDIATYPE_Video);
         mtOut->SetFormatType(&FORMAT_VideoInfo);  
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 436  Line 523 
523    
524  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)
525  {  {
         int rgb_flip;  
   
526          if (formattype == FORMAT_VideoInfo)          if (formattype == FORMAT_VideoInfo)
527          {          {
528                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;
# Line 455  Line 540 
540                  return S_FALSE;                  return S_FALSE;
541          }          }
542    
543          if (subtype == MEDIASUBTYPE_IYUV)          if (subtype == CLSID_MEDIASUBTYPE_IYUV)
544          {          {
545                  DPRINTF("IYUV");                  DPRINTF("IYUV");
546                    rgb_flip = 0;
547                  m_frame.output.csp = XVID_CSP_I420;                  m_frame.output.csp = XVID_CSP_I420;
548                  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 */
549          }          }
550          else if (subtype == MEDIASUBTYPE_YV12)          else if (subtype == MEDIASUBTYPE_YV12)
551          {          {
552                  DPRINTF("YV12");                  DPRINTF("YV12");
553                    rgb_flip = 0;
554                  m_frame.output.csp = XVID_CSP_YV12;                  m_frame.output.csp = XVID_CSP_YV12;
555                  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 */
556          }          }
557          else if (subtype == MEDIASUBTYPE_YUY2)          else if (subtype == MEDIASUBTYPE_YUY2)
558          {          {
559                  DPRINTF("YUY2");                  DPRINTF("YUY2");
560                    rgb_flip = 0;
561                  m_frame.output.csp = XVID_CSP_YUY2;                  m_frame.output.csp = XVID_CSP_YUY2;
562          }          }
563          else if (subtype == MEDIASUBTYPE_YVYU)          else if (subtype == MEDIASUBTYPE_YVYU)
564          {          {
565                  DPRINTF("YVYU");                  DPRINTF("YVYU");
566                    rgb_flip = 0;
567                  m_frame.output.csp = XVID_CSP_YVYU;                  m_frame.output.csp = XVID_CSP_YVYU;
568          }          }
569          else if (subtype == MEDIASUBTYPE_UYVY)          else if (subtype == MEDIASUBTYPE_UYVY)
570          {          {
571                  DPRINTF("UYVY");                  DPRINTF("UYVY");
572                    rgb_flip = 0;
573                  m_frame.output.csp = XVID_CSP_UYVY;                  m_frame.output.csp = XVID_CSP_UYVY;
574          }          }
575          else if (subtype == MEDIASUBTYPE_RGB32)          else if (subtype == MEDIASUBTYPE_RGB32)
# Line 586  Line 676 
676    
677          if (m_create.handle == NULL)          if (m_create.handle == NULL)
678          {          {
679                  if (m_xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0)                  if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0)
680                  {                  {
681              DPRINTF("*** XVID_DEC_CREATE error");              DPRINTF("*** XVID_DEC_CREATE error");
682                          return S_FALSE;                          return S_FALSE;
# Line 621  Line 711 
711          }          }
712    
713          m_frame.general = XVID_LOWDELAY;          m_frame.general = XVID_LOWDELAY;
714    
715          if (pIn->IsDiscontinuity() == S_OK)          if (pIn->IsDiscontinuity() == S_OK)
716                  m_frame.general = XVID_DISCONTINUITY;                  m_frame.general = XVID_DISCONTINUITY;
717    
718            if (g_config.nDeblock_Y)
719                    m_frame.general |= XVID_DEBLOCKY;
720    
721            if (g_config.nDeblock_UV)
722                    m_frame.general |= XVID_DEBLOCKUV;
723    /*
724            if (g_config.nDering)
725                    m_frame.general |= XVID_DERING;
726    */
727            if (g_config.nFilmEffect)
728                    m_frame.general |= XVID_FILMEFFECT;
729    
730            m_frame.output.csp &= ~XVID_CSP_VFLIP;
731            m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0);
732    
733  repeat :  repeat :
734    
735          if (pIn->IsPreroll() != S_OK)          if (pIn->IsPreroll() != S_OK)
736          {          {
737                  length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
738    
739                  if (length < 0)                  if (length < 0)
740                  {                  {
741              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 636  Line 743 
743                  }                  }
744          }          }
745          else          else
746          {          {       /* Preroll frame - won't be displayed */
747                  int tmp = m_frame.output.csp;                  int tmp = m_frame.output.csp;
748                    int tmp_gen = m_frame.general;
749    
750                  m_frame.output.csp = XVID_CSP_NULL;                  m_frame.output.csp = XVID_CSP_NULL;
751    
752                  length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);                  /* Disable postprocessing to speed-up seeking */
753                    m_frame.general &= ~XVID_DEBLOCKY;
754                    m_frame.general &= ~XVID_DEBLOCKUV;
755    /*              m_frame.general &= ~XVID_DERING; */
756                    m_frame.general &= ~XVID_FILMEFFECT;
757    
758                    length = xvid_decore_func(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats);
759                  if (length < 0)                  if (length < 0)
760                  {                  {
761              DPRINTF("*** XVID_DEC_DECODE");              DPRINTF("*** XVID_DEC_DECODE");
# Line 648  Line 763 
763                  }                  }
764    
765                  m_frame.output.csp = tmp;                  m_frame.output.csp = tmp;
766                    m_frame.general = tmp_gen;
767            }
768    
769            if (stats.type == XVID_TYPE_NOTHING && length > 0) {
770                    DPRINTF("B-Frame decoder lag");
771                    return S_FALSE;
772          }          }
773    
774    
775          if (stats.type == XVID_TYPE_VOL)          if (stats.type == XVID_TYPE_VOL)
776          {          {
777                  if (stats.data.vol.width != m_create.width ||                  if (stats.data.vol.width != m_create.width ||
# Line 659  Line 781 
781                          return S_FALSE;                          return S_FALSE;
782                  }                  }
783    
784    //              pOut->SetDiscontinuity(TRUE);
785                    pOut->SetSyncPoint(TRUE);
786    
787                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
788                  m_frame.length -= length;                  m_frame.length -= length;
789                  goto repeat;                  goto repeat;
790          }          }
791    
792            if (pIn->IsPreroll() == S_OK) {
793                    return S_FALSE;
794            }
795    
796          return S_OK;          return S_OK;
797  }  }
798    

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

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