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