Mercurial > mplayer.hg
annotate loader/dmo/dmo.c @ 11522:09a2a6288744
wording
author | diego |
---|---|
date | Tue, 25 Nov 2003 10:34:29 +0000 |
parents | b0d1b415320c |
children | f5537cc95b02 |
rev | line source |
---|---|
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8294
diff
changeset
|
1 #include "config.h" |
8294 | 2 #include "DMO_Filter.h" |
3 #include "driver.h" | |
4 #include "com.h" | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <string.h> | |
8 #include "win32.h" // printf macro | |
9 | |
10 void trapbug(); | |
11 typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**); | |
12 | |
13 void DMO_Filter_Destroy(DMO_Filter* This) | |
14 { | |
15 if (This->m_pOptim) | |
16 This->m_pOptim->vt->Release((IUnknown*)This->m_pOptim); | |
17 if (This->m_pInPlace) | |
18 This->m_pInPlace->vt->Release((IUnknown*)This->m_pInPlace); | |
19 if (This->m_pMedia) | |
20 This->m_pMedia->vt->Release((IUnknown*)This->m_pMedia); | |
21 | |
22 free(This); | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8294
diff
changeset
|
23 #ifdef WIN32_LOADER |
8294 | 24 CodecRelease(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8294
diff
changeset
|
25 #endif |
8294 | 26 } |
27 | |
28 DMO_Filter* DMO_FilterCreate(const char* dllname, const GUID* id, | |
29 DMO_MEDIA_TYPE* in_fmt, | |
30 DMO_MEDIA_TYPE* out_fmt) | |
31 { | |
32 HRESULT hr = 0; | |
33 const char* em = NULL; | |
34 DMO_Filter* This = (DMO_Filter*) malloc(sizeof(DMO_Filter)); | |
35 if (!This) | |
36 return NULL; | |
37 | |
38 memset(This, 0, sizeof(DMO_Filter)); | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8294
diff
changeset
|
39 #ifdef WIN32_LOADER |
8294 | 40 CodecAlloc(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8294
diff
changeset
|
41 #endif |
8294 | 42 |
43 //This->Start = DS_Filter_Start; | |
44 //This->Stop = DS_Filter_Stop; | |
45 | |
46 for (;;) | |
47 { | |
48 GETCLASS func; | |
49 struct IClassFactory* factory = NULL; | |
50 struct IUnknown* object = NULL; | |
51 unsigned int i; | |
52 unsigned long inputs, outputs; | |
53 | |
54 This->m_iHandle = LoadLibraryA(dllname); | |
55 if (!This->m_iHandle) | |
56 { | |
57 em = "could not open DMO DLL"; | |
58 break; | |
59 } | |
60 func = (GETCLASS)GetProcAddress((unsigned)This->m_iHandle, "DllGetClassObject"); | |
61 if (!func) | |
62 { | |
63 em = "illegal or corrupt DMO DLL"; | |
64 break; | |
65 } | |
66 //trapbug(); | |
67 hr = func(id, &IID_IClassFactory, (void**)&factory); | |
68 if (hr || !factory) | |
69 { | |
70 em = "no such class object"; | |
71 break; | |
72 } | |
73 hr = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); | |
74 factory->vt->Release((IUnknown*)factory); | |
75 if (hr || !object) | |
76 { | |
77 em = "class factory failure"; | |
78 break; | |
79 } | |
80 hr = object->vt->QueryInterface(object, &IID_IMediaObject, (void**)&This->m_pMedia); | |
81 if (hr == 0) | |
82 { | |
83 /* query for some extra available interface */ | |
84 HRESULT r = object->vt->QueryInterface(object, &IID_IMediaObjectInPlace, (void**)&This->m_pInPlace); | |
85 if (r == 0 && This->m_pInPlace) | |
86 printf("DMO dll supports InPlace - PLEASE REPORT to developer\n"); | |
87 r = object->vt->QueryInterface(object, &IID_IDMOVideoOutputOptimizations, (void**)&This->m_pOptim); | |
88 if (r == 0 && This->m_pOptim) | |
89 { | |
90 unsigned long flags; | |
91 r = This->m_pOptim->vt->QueryOperationModePreferences(This->m_pOptim, 0, &flags); | |
92 printf("DMO dll supports VO Optimizations %ld %lx\n", r, flags); | |
93 if (flags & DMO_VOSF_NEEDS_PREVIOUS_SAMPLE) | |
94 printf("DMO dll might use previous sample when requested\n"); | |
95 } | |
96 } | |
97 object->vt->Release((IUnknown*)object); | |
98 if (hr || !This->m_pMedia) | |
99 { | |
100 em = "object does not provide IMediaObject interface"; | |
101 break; | |
102 } | |
103 hr = This->m_pMedia->vt->SetInputType(This->m_pMedia, 0, in_fmt, 0); | |
104 if (hr) | |
105 { | |
106 em = "input format not accepted"; | |
107 break; | |
108 } | |
109 | |
110 if (0) { | |
111 DMO_MEDIA_TYPE dmo; | |
112 VIDEOINFOHEADER* vi; | |
113 memset(&dmo, 0, sizeof(dmo)); | |
114 i = This->m_pMedia->vt->GetOutputType(This->m_pMedia, 0, 2, &dmo); | |
115 printf("GetOutputType %x \n", i); | |
116 printf("DMO 0x%x (%.4s) 0x%x (%.4s)\n" | |
117 //printf("DMO 0x%x 0x%x\n" | |
118 ":: fixszsamp:%d tempcomp:%d sampsz:%ld\n" | |
119 ":: formtype: 0x%x\n" | |
120 ":: unk %p cbform: %ld pbform:%p\n", | |
121 dmo.majortype.f1, | |
122 (const char*)&dmo.majortype.f1, | |
123 dmo.subtype.f1, | |
124 (const char*)&dmo.subtype.f1, | |
125 dmo.bFixedSizeSamples, dmo.bTemporalCompression, | |
126 dmo.lSampleSize, | |
127 dmo.formattype.f1, | |
128 dmo.pUnk, dmo.cbFormat, dmo.pbFormat | |
129 ); | |
130 /* vi = (VIDEOINFOHEADER*) dmo.pbFormat; | |
131 vi = (VIDEOINFOHEADER*) out_fmt->pbFormat; | |
132 for (i = 0; i < out_fmt->cbFormat; i++) | |
133 printf("BYTE %d %02x %02x\n", i, ((uint8_t*)dmo.pbFormat)[i], ((uint8_t*)out_fmt->pbFormat)[i]); | |
134 */ | |
135 } | |
136 | |
137 hr = This->m_pMedia->vt->SetOutputType(This->m_pMedia, 0, out_fmt, 0); | |
138 if (hr) | |
139 { | |
140 em = "output format no accepted"; | |
141 break; | |
142 } | |
143 | |
144 inputs = outputs = 0; | |
145 hr = This->m_pMedia->vt->GetOutputSizeInfo(This->m_pMedia, 0, &inputs, &outputs); | |
146 printf("GetOutput r=0x%lx size:%ld align:%ld\n", hr, inputs, outputs); | |
147 | |
148 // This->m_pMedia->vt->AllocateStreamingResources(This->m_pMedia); | |
149 hr = This->m_pMedia->vt->GetStreamCount(This->m_pMedia, &inputs, &outputs); | |
150 printf("StreamCount r=0x%lx %ld %ld\n", hr, inputs, outputs); | |
151 | |
152 break; | |
153 } | |
154 if (em) | |
155 { | |
156 DMO_Filter_Destroy(This); | |
157 printf("IMediaObject ERROR: %p %s (0x%lx : %ld)\n", em, em ? em : "", hr, hr); | |
158 This = 0; | |
159 } | |
160 return This; | |
161 } |