[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 1558, Mon Oct 25 10:29:10 2004 UTC revision 1605, Mon Mar 14 01:18:20 2005 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.13 2004-10-25 10:29:10 suxen_drol Exp $   * $Id: CXvidDecoder.cpp,v 1.14 2005-03-14 01:18:20 Isibaar Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 204  Line 204 
204  #define XVID_DLL_NAME "xvidcore.dll"  #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), m_hdll (NULL)
208  {  {
209          DPRINTF("Constructor");          DPRINTF("Constructor");
210    
211        xvid_decore_func = NULL; // Hmm, some strange errors appearing if I try to initialize...
212        xvid_global_func = NULL; // ...this in constructor's init-list. So, they assigned here.
213    
214        LoadRegistryInfo();
215    
216        *phr = OpenLib();
217    }
218    
219    HRESULT CXvidDecoder::OpenLib()
220    {
221        DPRINTF("OpenLib");
222    
223        if (m_hdll != NULL)
224                    return E_UNEXPECTED; // Seems, that library already opened.
225    
226          xvid_gbl_init_t init;          xvid_gbl_init_t init;
227          memset(&init, 0, sizeof(init));          memset(&init, 0, sizeof(init));
228          init.version = XVID_VERSION;          init.version = XVID_VERSION;
# Line 216  Line 231 
231          if (m_hdll == NULL) {          if (m_hdll == NULL) {
232                  DPRINTF("dll load failed");                  DPRINTF("dll load failed");
233                  MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST);                  MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST);
234                  return;                  return E_FAIL;
235          }          }
236    
237          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");
238          if (xvid_global_func == NULL) {          if (xvid_global_func == NULL) {
239            FreeLibrary(m_hdll);
240            m_hdll = NULL;
241                  MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST);                  MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST);
242                  return;                  return E_FAIL;
243          }          }
244    
245          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");
246          if (xvid_decore_func == NULL) {          if (xvid_decore_func == NULL) {
247            xvid_global_func = NULL;
248            FreeLibrary(m_hdll);
249            m_hdll = NULL;
250                  MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST);                  MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST);
251                  return;                  return E_FAIL;
252          }          }
253    
254          if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)          if (xvid_global_func(0, XVID_GBL_INIT, &init, NULL) < 0)
255          {          {
256            xvid_global_func = NULL;
257            xvid_decore_func = NULL;
258            FreeLibrary(m_hdll);
259            m_hdll = NULL;
260                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);
261                  return;                  return E_FAIL;
262          }          }
263    
264          memset(&m_create, 0, sizeof(m_create));          memset(&m_create, 0, sizeof(m_create));
# Line 244  Line 268 
268          memset(&m_frame, 0, sizeof(m_frame));          memset(&m_frame, 0, sizeof(m_frame));
269          m_frame.version = XVID_VERSION;          m_frame.version = XVID_VERSION;
270    
         LoadRegistryInfo();  
   
271          USE_IYUV = false;          USE_IYUV = false;
272          USE_YV12 = false;          USE_YV12 = false;
273          USE_YUY2 = false;          USE_YUY2 = false;
# Line 302  Line 324 
324                  ar_y = 20;                  ar_y = 20;
325                  break;                  break;
326          }          }
327    
328            return S_OK;
329  }  }
330    
331  void CXvidDecoder::CloseLib()  void CXvidDecoder::CloseLib()
332  {  {
333          DPRINTF("Destructor");          DPRINTF("CloseLib");
334    
335          if (m_create.handle != NULL) {          if ((m_create.handle != NULL) && (xvid_decore_func != NULL))
336            {
337                  xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0);                  xvid_decore_func(m_create.handle, XVID_DEC_DESTROY, 0, 0);
338                  m_create.handle = NULL;                  m_create.handle = NULL;
339          }          }
# Line 317  Line 342 
342                  FreeLibrary(m_hdll);                  FreeLibrary(m_hdll);
343                  m_hdll = NULL;                  m_hdll = NULL;
344          }          }
345        xvid_decore_func = NULL;
346        xvid_global_func = NULL;
347  }  }
348    
349  /* destructor */  /* destructor */
350    
351  CXvidDecoder::~CXvidDecoder()  CXvidDecoder::~CXvidDecoder()
352  {  {
353        DPRINTF("Destructor");
354          CloseLib();          CloseLib();
355  }  }
356    
# Line 344  Line 372 
372                  return VFW_E_TYPE_NOT_ACCEPTED;                  return VFW_E_TYPE_NOT_ACCEPTED;
373          }          }
374    
375        if (m_hdll == NULL)
376        {
377                    HRESULT hr = OpenLib();
378    
379            if (FAILED(hr) || (m_hdll == NULL)) // Paranoid checks.
380                            return VFW_E_TYPE_NOT_ACCEPTED;
381        }
382    
383          if (*mtIn->FormatType() == FORMAT_VideoInfo)          if (*mtIn->FormatType() == FORMAT_VideoInfo)
384          {          {
385                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format();
# Line 710  Line 746 
746    
747          if (m_create.handle == NULL)          if (m_create.handle == NULL)
748          {          {
749                    if (xvid_decore_func == NULL)
750                            return E_FAIL;
751    
752                  if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0)                  if (xvid_decore_func(0, XVID_DEC_CREATE, &m_create, 0) < 0)
753                  {                  {
754              DPRINTF("*** XVID_DEC_CREATE error");              DPRINTF("*** XVID_DEC_CREATE error");
# Line 769  Line 808 
808          m_frame.output.csp &= ~XVID_CSP_VFLIP;          m_frame.output.csp &= ~XVID_CSP_VFLIP;
809          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);
810    
811        // Paranoid check.
812        if (xvid_decore_func == NULL)
813                    return E_FAIL;
814    
815    
816    

Legend:
Removed from v.1558  
changed lines
  Added in v.1605

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