annotate loader/dshow/DS_VideoDec.c @ 1863:bb7710b16dc2

reset module status after uninit
author arpi
date Thu, 06 Sep 2001 20:44:42 +0000
parents 9e23ceba3f65
children a5a4143d5599
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
1 #include "guids.h"
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
2 #include "interfaces.h"
1559
arpi
parents: 1555
diff changeset
3 #include "libwin32.h"
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
4
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
5 #include "DS_VideoDecoder.h"
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
6 #include <wine/winerror.h>
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
7 //#include <cpuinfo.h>
1063
269780d31b51 added missing 'using namespace std;' for gcc 3.0
arpi_esp
parents: 713
diff changeset
8
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
9 #include <unistd.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
10 #include <fcntl.h>
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
11 #include <errno.h>
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
12 #include <sys/types.h>
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
13 #include <sys/mman.h>
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
14 #include <cstdio>
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
15 #include <iostream>
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
16 #include <strstream>
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
17
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
18 #include <registry.h>
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
19 //#include <wine/winreg.h>
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
20
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
21 #include "DS_VideoDec.h"
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
22
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
23 static void* _handle; // will be parameter later...
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
24 static char** _d_ptr; // will be parameter later...
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
25
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
26 extern "C" void Setup_LDT_Keeper();
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
27 extern "C" void setup_FS_Segment();
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
28
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
29 extern "C" int DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER* format, int flip,char** d_ptr){
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
30
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
31 Setup_LDT_Keeper();
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
32
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
33 CodecInfo ci;
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
34 ci.dll=dllname;
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
35 ci.guid=*guid;
1559
arpi
parents: 1555
diff changeset
36
1560
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
37 try {
1559
arpi
parents: 1555
diff changeset
38 DS_VideoDecoder* dec=new DS_VideoDecoder(ci, *format, flip);
1560
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
39 _d_ptr=d_ptr;
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
40 _handle=(void*)dec;
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
41 return 0;
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
42 } catch (FatalError &e) { }
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
43
1560
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
44 _handle=NULL;
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
45 return -1;
a3d84360aa81 exception stuff fixed
arpi
parents: 1559
diff changeset
46
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
47 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
48
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
49 extern "C" void DS_VideoDecoder_Start(){
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
50 DS_VideoDecoder* dec=(DS_VideoDecoder*) _handle;
1555
076c27342828 Start/Stop state flag fixed - requires for brightness/contrast/etc stuff...
arpi
parents: 1545
diff changeset
51 dec->Start();
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
52 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
53
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
54 extern "C" void DS_VideoDecoder_Stop(){
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
55 DS_VideoDecoder* dec=(DS_VideoDecoder*) _handle;
1555
076c27342828 Start/Stop state flag fixed - requires for brightness/contrast/etc stuff...
arpi
parents: 1545
diff changeset
56 dec->Stop();
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
57 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
58
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
59 extern "C" void DS_VideoDecoder_Restart(){
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
60 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
61
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
62 extern "C" void DS_VideoDecoder_Close(){
1559
arpi
parents: 1555
diff changeset
63 DS_VideoDecoder* dec=(DS_VideoDecoder*) _handle;
1722
9e23ceba3f65 small fix
arpi
parents: 1592
diff changeset
64 _handle=NULL;
1559
arpi
parents: 1555
diff changeset
65 delete dec;
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
66 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
67
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
68 extern "C" int DS_VideoDecoder_DecodeFrame(char* src, int size, int is_keyframe, int render){
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
69 DS_VideoDecoder* dec=(DS_VideoDecoder*) _handle;
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
70 CImage image;
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
71 image.ptr=*_d_ptr;
1559
arpi
parents: 1555
diff changeset
72 return dec->Decode((void*)src,(size_t)size,is_keyframe,&image);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
73 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
74
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
75 extern "C" int DS_VideoDecoder_SetDestFmt(int bits, int csp){
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
76 DS_VideoDecoder* dec=(DS_VideoDecoder*) _handle;
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
77 return dec->SetDestFmt(bits,(fourcc_t)csp);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
78 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
79
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
80 extern "C" int DS_SetValue_DivX(char* name, int value){
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
81 DS_VideoDecoder* dec=(DS_VideoDecoder*) _handle;
1592
80cbe17e0f58 Commented out annoying printfs with -autoq.
atmos4
parents: 1560
diff changeset
82 /* This printf is annoying with autoquality, *
80cbe17e0f58 Commented out annoying printfs with -autoq.
atmos4
parents: 1560
diff changeset
83 * should be moved into players code - atmos */
80cbe17e0f58 Commented out annoying printfs with -autoq.
atmos4
parents: 1560
diff changeset
84 //printf("DS_SetValue_DivX(%s),%d)\n",name,value);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
85 return (int) dec->SetValue(name,value);
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
86 }
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
87
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
88 extern "C" int DS_SetAttr_DivX(char* attribute, int value){
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
89 int result, status, newkey, count;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
90 if(strcmp(attribute, "Quality")==0){
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
91 char* keyname="SOFTWARE\\Microsoft\\Scrunch";
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
92 result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
93 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
94 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
95 printf("VideoDecoder::SetExtAttr: registry failure\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
96 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
97 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
98 result=RegSetValueExA(newkey, "Current Post Process Mode", 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
99 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
100 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
101 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
102 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
103 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
104 value=-1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
105 result=RegSetValueExA(newkey, "Force Post Process Mode", 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
106 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
107 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
108 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
109 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
110 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
111 RegCloseKey(newkey);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
112 return 0;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
113 }
169
550ebe869cec Added C-C++ interface in DS_VideoDec.h
arpi_esp
parents:
diff changeset
114
173
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
115 if(
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
116 (strcmp(attribute, "Saturation")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
117 (strcmp(attribute, "Hue")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
118 (strcmp(attribute, "Contrast")==0) ||
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
119 (strcmp(attribute, "Brightness")==0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
120 )
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
121 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
122 char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video";
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
123 result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
124 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
125 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
126 printf("VideoDecoder::SetExtAttr: registry failure\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
127 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
128 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
129 result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
130 if(result!=0)
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
131 {
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
132 printf("VideoDecoder::SetExtAttr: error writing value\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
133 return -1;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
134 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
135 RegCloseKey(newkey);
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
136 return 0;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
137 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
138
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
139 printf("Unknown attribute!\n");
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
140 return -200;
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
141 }
fb67a2aa61fe fixed DivX Quality setting (using registry)
arpi_esp
parents: 169
diff changeset
142